Commands.pm
上传用户:market2
上传日期:2018-11-18
资源大小:18786k
文件大小:160k
- $message .= shift(@tmp) . "n";
- foreach (@tmp) {
- $length = length($_->[0]) if length($_->[0]) > $length;
- }
- my $pattern = "$cmd %-${length}s %sn";
- my $padsize = length($cmd) + $length + 5;
- my $pad = sprintf("%-${padsize}s", '');
- foreach (@tmp) {
- if ($padsize + length($_->[1]) > 79) {
- @words = split(/ /, $_->[1]);
- $message .= sprintf("$cmd %-${length}s ", $_->[0]);
- $messageTmp = '';
- foreach my $word (@words) {
- if ($padsize + length($messageTmp) + length($word) + 1 > 79) {
- $message .= $messageTmp . "n$pad";
- $messageTmp = '';
- } else {
- $messageTmp .= "$word ";
- }
- }
- $message .= $messageTmp."n";
- }
- else {
- $message .= sprintf($pattern, $_->[0], $_->[1]);
- }
- }
- $message .= "--------------------------------------------------n";
- message $message, "list";
- }
- sub cmdIdentify {
- if (!$net || $net->getState() != Network::IN_GAME) {
- error TF("You must be logged in the game to use this command (%s)n", shift);
- return;
- }
- my (undef, $arg1) = @_;
- if ($arg1 eq "" && defined @identifyID) {
- message T("---------Identify List--------n"), "list";
- for (my $i = 0; $i < @identifyID; $i++) {
- next if ($identifyID[$i] eq "");
- message(swrite(
- "@<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<",
- [$i, $char->inventory->get($identifyID[$i])->{name}]),
- "list");
- }
- message("------------------------------n", "list");
- } elsif (!defined @identifyID) {
- error TF("The identify list is empty, please use the identify skill or a magnifier first.n");
- } elsif ($arg1 =~ /^d+$/) {
- if ($identifyID[$arg1] eq "") {
- error TF("Error in function 'identify' (Identify Item)n" .
- "Identify Item %s does not existn", $arg1);
- } else {
- $messageSender->sendIdentify($char->inventory->get($identifyID[$arg1])->{index});
- }
- } else {
- error TF("Syntax Error in function 'identify' (Identify Item)n" .
- "Usage: identify [<identify #>]n");
- }
- }
- sub cmdIgnore {
- if (!$net || $net->getState() != Network::IN_GAME) {
- error TF("You must be logged in the game to use this command (%s)n", shift);
- return;
- }
- my (undef, $args) = @_;
- my ($arg1, $arg2) = $args =~ /^(d+) ([sS]*)/;
- if ($arg1 eq "" || $arg2 eq "" || ($arg1 ne "0" && $arg1 ne "1")) {
- error T("Syntax Error in function 'ignore' (Ignore Player/Everyone)n" .
- "Usage: ignore <flag> <name | all>n");
- } else {
- if ($arg2 eq "all") {
- $messageSender->sendIgnoreAll(!$arg1);
- } else {
- $messageSender->sendIgnore($arg2, !$arg1);
- }
- }
- }
- sub cmdIhist {
- # Display item history
- my (undef, $args) = @_;
- $args = 5 if ($args eq "");
- if (!($args =~ /^d+$/)) {
- error T("Syntax Error in function 'ihist' (Show Item History)n" .
- "Usage: ihist [<number of entries #>]n");
- } elsif (open(ITEM, "<", $Settings::item_log_file)) {
- my @item = <ITEM>;
- close(ITEM);
- message T("------ Item History --------------------n"), "list";
- my $i = @item - $args;
- $i = 0 if ($i < 0);
- for (; $i < @item; $i++) {
- message($item[$i], "list");
- }
- message("----------------------------------------n", "list");
- } else {
- error TF("Unable to open %sn", $Settings::item_log_file);
- }
- }
- sub cmdInventory {
- # Display inventory items
- my (undef, $args) = @_;
- my ($arg1) = $args =~ /^(w+)/;
- my ($arg2) = $args =~ /^w+ (.+)/;
- if (!$char || $char->inventory->size() == 0) {
- error T("Inventory is emptyn");
- return;
- }
- if ($arg1 eq "" || $arg1 eq "eq" || $arg1 eq "neq" || $arg1 eq "u" || $arg1 eq "nu") {
- my @useable;
- my @equipment;
- my @uequipment;
- my @non_useable;
- my ($i, $display, $index, $sell);
- foreach my $item (@{$char->inventory->getItems()}) {
- if (($item->{type} == 3 ||
- $item->{type} == 6 ||
- $item->{type} == 10 ||
- $item->{type} == 16 ||
- $item->{type} == 17) && !$item->{equipped}) {
- push @non_useable, $item->{invIndex};
- } elsif ($item->{type} <= 2) {
- push @useable, $item->{invIndex};
- } else {
- my %eqp;
- $eqp{index} = $item->{index};
- $eqp{binID} = $item->{invIndex};
- $eqp{name} = $item->{name};
- $eqp{type} = $itemTypes_lut{$item->{type}};
- $eqp{equipped} = ($item->{type} == 10 || $item->{type} == 16 || $item->{type} == 17) ? $item->{amount} . " left" : $equipTypes_lut{$item->{equipped}};
- $eqp{equipped} .= " ($item->{equipped})";
- # Translation Comment: Mark to tell item not identified
- $eqp{identified} = " -- " . T("Not Identified") if !$item->{identified};
- if ($item->{equipped}) {
- push @equipment, %eqp;
- } else {
- push @uequipment, %eqp;
- }
- }
- }
- my $msg = T("-----------Inventory-----------n");
- if ($arg1 eq "" || $arg1 eq "eq") {
- # Translation Comment: List of usable equipments
- $msg .= T("-- Equipment (Equipped) --n");
- foreach my $item (@equipment) {
- $sell = defined(findIndex(@sellList, "invIndex", $item->{binID})) ? T("Will be sold") : "";
- $display = sprintf("%-3d %s -- %s", $item->{binID}, $item->{name}, $item->{equipped});
- $msg .= sprintf("%-57s %sn", $display, $sell);
- }
- }
- if ($arg1 eq "" || $arg1 eq "neq") {
- # Translation Comment: List of equipments
- $msg .= T("-- Equipment (Not Equipped) --n");
- foreach my $item (@uequipment) {
- $sell = defined(findIndex(@sellList, "invIndex", $item->{binID})) ? T("Will be sold") : "";
- $display = sprintf("%-3d %s (%s) %s", $item->{binID}, $item->{name}, $item->{type}, $item->{identified});
- $msg .= sprintf("%-57s %sn", $display, $sell);
- }
- }
- if ($arg1 eq "" || $arg1 eq "nu") {
- # Translation Comment: List of non-usable items
- $msg .= T("-- Non-Usable --n");
- for ($i = 0; $i < @non_useable; $i++) {
- $index = $non_useable[$i];
- my $item = $char->inventory->get($index);
- $display = $item->{name};
- $display .= " x $item->{amount}";
- # Translation Comment: Tell if the item is marked to be sold
- $sell = defined(findIndex(@sellList, "invIndex", $index)) ? T("Will be sold") : "";
- $msg .= swrite(
- "@<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<",
- [$index, $display, $sell]);
- }
- }
- if ($arg1 eq "" || $arg1 eq "u") {
- # Translation Comment: List of usable items
- $msg .= T("-- Usable --n");
- for ($i = 0; $i < @useable; $i++) {
- $index = $useable[$i];
- my $item = $char->inventory->get($index);
- $display = $item->{name};
- $display .= " x $item->{amount}";
- $sell = defined(findIndex(@sellList, "invIndex", $index)) ? T("Will be sold") : "";
- $msg .= swrite(
- "@<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<",
- [$index, $display, $sell]);
- }
- }
- $msg .= "-------------------------------n";
- message($msg, "list");
- } elsif ($arg1 eq "desc" && $arg2 ne "") {
- cmdInventory_desc($arg2);
- } else {
- error T("Syntax Error in function 'i' (Inventory List)n" .
- "Usage: i [<u|eq|neq|nu|desc>] [<inventory item>]n");
- }
- }
- sub cmdInventory_desc {
- my ($name) = @_;
- my $item = Match::inventoryItem($name);
- if (!$item) {
- error TF("Error in function 'i' (Inventory Item Description)n" .
- "Inventory Item %s does not existn", $name);
- return;
- }
- printItemDesc($item->{nameID});
- }
- sub cmdItemList {
- message T("-----------Item List-----------n" .
- " # Name Coordn"), "list";
- for (my $i = 0; $i < @itemsID; $i++) {
- next if ($itemsID[$i] eq "");
- my $item = $items{$itemsID[$i]};
- my $display = "$item->{name} x $item->{amount}";
- message(sprintf("%4d %-30s (%3d, %3d)n",
- $i, $display, $item->{pos}{x}, $item->{pos}{y}),
- "list");
- }
- message("-------------------------------n", "list");
- }
- sub cmdItemLogClear {
- itemLog_clear();
- message T("Item log cleared.n"), "success";
- }
- #sub cmdJudge {
- # my (undef, $args) = @_;
- # my ($arg1) = $args =~ /^(d+)/;
- # my ($arg2) = $args =~ /^d+ (d+)/;
- # if ($arg1 eq "" || $arg2 eq "") {
- # error "Syntax Error in function 'judge' (Give an alignment point to Player)n" .
- # "Usage: judge <player #> <0 (good) | 1 (bad)>n";
- # } elsif ($playersID[$arg1] eq "") {
- # error "Error in function 'judge' (Give an alignment point to Player)n" .
- # "Player $arg1 does not exist.n";
- # } else {
- # $arg2 = ($arg2 >= 1);
- # $messageSender->sendAlignment($playersID[$arg1], $arg2);
- # }
- #}
- sub cmdKill {
- my (undef, $ID) = @_;
- my $target = $playersID[$ID];
- unless ($target) {
- error TF("Player %s does not exist.n", $ID);
- return;
- }
- attack($target);
- }
- sub cmdLook {
- my (undef, $args) = @_;
- my ($arg1) = $args =~ /^(d+)/;
- my ($arg2) = $args =~ /^d+ (d+)$/;
- if ($arg1 eq "") {
- error T("Syntax Error in function 'look' (Look a Direction)n" .
- "Usage: look <body dir> [<head dir>]n");
- } else {
- look($arg1, $arg2);
- }
- }
- sub cmdLookPlayer {
- my (undef, $arg1) = @_;
- if ($arg1 eq "") {
- error T("Syntax Error in function 'lookp' (Look at Player)n" .
- "Usage: lookp <player #>n");
- } elsif (!$playersID[$arg1]) {
- error TF("Error in function 'lookp' (Look at Player)n" .
- "'%s' is not a valid player number.n", $arg1);
- } else {
- lookAtPosition($players{$playersID[$arg1]}{pos_to});
- }
- }
- sub cmdManualMove {
- if (!$net || $net->getState() != Network::IN_GAME) {
- error TF("You must be logged in the game to use this command (%s)n", shift);
- return;
- }
- my ($switch, $steps) = @_;
- if (!$steps) {
- $steps = 5;
- } elsif ($steps !~ /^d+$/) {
- error TF("Error in function '%s' (Manual Move)n" .
- "Usage: %s [distance]n", $switch, $switch);
- return;
- }
- if ($switch eq "east") {
- manualMove($steps, 0);
- } elsif ($switch eq "west") {
- manualMove(-$steps, 0);
- } elsif ($switch eq "north") {
- manualMove(0, $steps);
- } elsif ($switch eq "south") {
- manualMove(0, -$steps);
- } elsif ($switch eq "northeast") {
- manualMove($steps, $steps);
- } elsif ($switch eq "southwest") {
- manualMove(-$steps, -$steps);
- } elsif ($switch eq "northwest") {
- manualMove(-$steps, $steps);
- } elsif ($switch eq "southeast") {
- manualMove($steps, -$steps);
- }
- }
- sub cmdMemo {
- if (!$net || $net->getState() != Network::IN_GAME) {
- error TF("You must be logged in the game to use this command (%s)n", shift);
- return;
- }
- $messageSender->sendMemo();
- }
- sub cmdMonsterList {
- my ($dmgTo, $dmgFrom, $dist, $pos, $name, $monsters);
- message TF("-----------Monster List-----------n" .
- "# Name ID DmgTo DmgFrom Distance Coordinatesn"), "list";
- $monsters = $monstersList->getItems() if ($monstersList);
- foreach my $monster (@{$monsters}) {
- $dmgTo = ($monster->{dmgTo} ne "")
- ? $monster->{dmgTo}
- : 0;
- $dmgFrom = ($monster->{dmgFrom} ne "")
- ? $monster->{dmgFrom}
- : 0;
- $dist = distance($char->{pos_to}, $monster->{pos_to});
- $dist = sprintf("%.1f", $dist) if (index($dist, '.') > -1);
- $pos = '(' . $monster->{pos_to}{x} . ', ' . $monster->{pos_to}{y} . ')';
- $name = $monster->name;
- if ($name ne $monster->{name_given}) {
- $name .= '[' . $monster->{name_given} . ']';
- }
- message(swrite(
- "@<< @<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<< @<<<< @<<<< @<<<<< @<<<<<<<<<<",
- [$monster->{binID}, $name, $monster->{binType}, $dmgTo, $dmgFrom, $dist, $pos]),
- "list");
- }
- message("----------------------------------n", "list");
- }
- sub cmdMove {
- if (!$net || $net->getState() != Network::IN_GAME) {
- error TF("You must be logged in the game to use this command (%s)n", shift);
- return;
- }
- my (undef, $args) = @_;
- my ($arg1, $arg2, $arg3) = $args =~ /^(.+?) (.+?)(?: (.*))?$/;
- my ($map, $x, $y);
- if ($arg1 eq "") {
- # map name or portal number
- $map = $args;
- } elsif ($arg3 eq "") {
- # coordinates
- $x = $arg1;
- $y = $arg2;
- $map = $field{name};
- } elsif ($arg1 =~ /^d+$/) {
- # coordinates and map
- $x = $arg1;
- $y = $arg2;
- $map = $arg3;
- } else {
- # map and coordinates
- $x = $arg2;
- $y = $arg3;
- $map = $arg1;
- }
-
- if ((($x !~ /^d+$/ || $y !~ /^d+$/) && $arg1 ne "") || ($args eq "")) {
- error T("Syntax Error in function 'move' (Move Player)n" .
- "Usage: move <x> <y> [<map>]n" .
- " move <map> [<x> <y>]n" .
- " move <portal#>n");
- } elsif ($map eq "stop") {
- AI::clear(qw/move route mapRoute/);
- message T("Stopped all movementn"), "success";
- } else {
- AI::clear(qw/move route mapRoute/);
- if ($maps_lut{"${map}.rsw"}) {
- if ($x ne "") {
- message TF("Calculating route to: %s(%s): %s, %sn",
- $maps_lut{$map.'.rsw'}, $map, $x, $y), "route";
- } else {
- message TF("Calculating route to: %s(%s)n",
- $maps_lut{$map.'.rsw'}, $map), "route";
- }
- main::ai_route($map, $x, $y,
- attackOnRoute => 1,
- noSitAuto => 1,
- notifyUponArrival => 1);
- } elsif ($map =~ /^d+$/) {
- if ($portalsID[$map]) {
- message TF("Move into portal number %s (%s,%s)n",
- $map, $portals{$portalsID[$map]}{'pos'}{'x'}, $portals{$portalsID[$map]}{'pos'}{'y'});
- main::ai_route($field{name}, $portals{$portalsID[$map]}{'pos'}{'x'}, $portals{$portalsID[$map]}{'pos'}{'y'}, attackOnRoute => 1, noSitAuto => 1);
- } else {
- error T("No portals exist.n");
- }
- } else {
- error TF("Map %s does not existn", $map);
- }
- }
- }
- sub cmdNPCList {
- my (undef, $args) = @_;
- my @arg = parseArgs($args);
- my $msg = T("-----------NPC List-----------n" .
- "# Name Coordinates IDn");
- if ($npcsList) {
- if ($arg[0] =~ /^d+$/) {
- my $i = $arg[0];
- if (my $npc = $npcsList->get($i)) {
- my $pos = "($npc->{pos_to}{x}, $npc->{pos_to}{y})";
- $msg .= swrite(
- "@<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<",
- [$i, $npc->name, $pos, $npc->{nameID}]);
- $msg .= "---------------------------------n";
- message $msg, "info";
- } else {
- error T("Syntax Error in function 'nl' (List NPCs)n" .
- "Usage: nl [<npc #>]n");
- }
- return;
- }
- my $npcs = $npcsList->getItems();
- foreach my $npc (@{$npcs}) {
- my $pos = "($npc->{pos}{x}, $npc->{pos}{y})";
- $msg .= swrite(
- "@<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<",
- [$npc->{binID}, $npc->name, $pos, $npc->{nameID}]);
- }
- }
- $msg .= "---------------------------------n";
- message $msg, "list";
- }
- sub cmdOpenShop {
- if (!$net || $net->getState() != Network::IN_GAME) {
- error TF("You must be logged in the game to use this command (%s)n", shift);
- return;
- }
- main::openShop();
- }
- sub cmdParty {
- my (undef, $args) = @_;
- my ($arg1) = $args =~ /^(w*)/;
- my ($arg2) = $args =~ /^w* (d+)b/;
- if ($arg1 eq "" && (!$char || !$char->{'party'} || !%{$char->{'party'}} )) {
- error T("Error in function 'party' (Party Functions)n" .
- "Can't list party - you're not in a party.n");
- } elsif ($arg1 eq "") {
- message TF("----------Party-----------n" .
- "%sn" .
- "# Name Map Online HPn",
- $char->{'party'}{'name'}), "list";
- for (my $i = 0; $i < @partyUsersID; $i++) {
- next if ($partyUsersID[$i] eq "");
- my $coord_string = "";
- my $hp_string = "";
- my $name_string = $char->{'party'}{'users'}{$partyUsersID[$i]}{'name'};
- my $admin_string = ($char->{'party'}{'users'}{$partyUsersID[$i]}{'admin'}) ? "(A)" : "";
- my $online_string;
- my $map_string;
- if ($partyUsersID[$i] eq $accountID) {
- # Translation Comment: Is the party user on list online?
- $online_string = T("Yes");
- ($map_string) = $field{name};
- $coord_string = $char->{'pos'}{'x'}. ", ".$char->{'pos'}{'y'};
- $hp_string = $char->{'hp'}."/".$char->{'hp_max'}
- ." (".int($char->{'hp'}/$char->{'hp_max'} * 100)
- ."%)";
- } else {
- $online_string = ($char->{'party'}{'users'}{$partyUsersID[$i]}{'online'}) ? T("Yes") : T("No");
- ($map_string) = $char->{'party'}{'users'}{$partyUsersID[$i]}{'map'} =~ /([sS]*).gat/;
- $coord_string = $char->{'party'}{'users'}{$partyUsersID[$i]}{'pos'}{'x'}
- . ", ".$char->{'party'}{'users'}{$partyUsersID[$i]}{'pos'}{'y'}
- if ($char->{'party'}{'users'}{$partyUsersID[$i]}{'pos'}{'x'} ne ""
- && $char->{'party'}{'users'}{$partyUsersID[$i]}{'online'});
- $hp_string = $char->{'party'}{'users'}{$partyUsersID[$i]}{'hp'}."/".$char->{'party'}{'users'}{$partyUsersID[$i]}{'hp_max'}
- ." (".int($char->{'party'}{'users'}{$partyUsersID[$i]}{'hp'}/$char->{'party'}{'users'}{$partyUsersID[$i]}{'hp_max'} * 100)
- ."%)" if ($char->{'party'}{'users'}{$partyUsersID[$i]}{'hp_max'} && $char->{'party'}{'users'}{$partyUsersID[$i]}{'online'});
- }
- message(swrite(
- "@< @<< @<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<< @<<<<<<< @<< @<<<<<<<<<<<<<<<<<<",
- [$i, $admin_string, $name_string, $map_string, $coord_string, $online_string, $hp_string]),
- "list");
- }
- message("--------------------------n", "list");
- } elsif (!$net || $net->getState() != Network::IN_GAME) {
- error TF("You must be logged in the game to use this command (%s)n", 'party ' . $arg1);
- return;
- } elsif ($arg1 eq "create") {
- my ($arg2) = $args =~ /^w* ([sS]*)/;
- if ($arg2 eq "") {
- error T("Syntax Error in function 'party create' (Organize Party)n" .
- "Usage: party create <party name>n");
- } else {
- $messageSender->sendPartyOrganize($arg2);
- }
- } elsif ($arg1 eq "join" && $arg2 ne "1" && $arg2 ne "0") {
- error T("Syntax Error in function 'party join' (Accept/Deny Party Join Request)n" .
- "Usage: party join <flag>n");
- } elsif ($arg1 eq "join" && $incomingParty{'ID'} eq "") {
- error T("Error in function 'party join' (Join/Request to Join Party)n" .
- "Can't accept/deny party request - no incoming request.n");
- } elsif ($arg1 eq "join") {
- $messageSender->sendPartyJoin($incomingParty{'ID'}, $arg2);
- undef %incomingParty;
- } elsif ($arg1 eq "request" && ( !$char->{'party'} || !%{$char->{'party'}} )) {
- error T("Error in function 'party request' (Request to Join Party)n" .
- "Can't request a join - you're not in a party.n");
- } elsif ($arg1 eq "request" && $playersID[$arg2] eq "") {
- error TF("Error in function 'party request' (Request to Join Party)n" .
- "Can't request to join party - player %s does not exist.n", $arg2);
- } elsif ($arg1 eq "request") {
- $messageSender->sendPartyJoinRequest($playersID[$arg2]);
- } elsif ($arg1 eq "leave" && (!$char->{'party'} || !%{$char->{'party'}} ) ) {
- error T("Error in function 'party leave' (Leave Party)n" .
- "Can't leave party - you're not in a party.n");
- } elsif ($arg1 eq "leave") {
- $messageSender->sendPartyLeave();
- } elsif ($arg1 eq "share" && ( !$char->{'party'} || !%{$char->{'party'}} )) {
- error T("Error in function 'party share' (Set Party Share EXP)n" .
- "Can't set share - you're not in a party.n");
- } elsif ($arg1 eq "share" && $arg2 ne "1" && $arg2 ne "0") {
- error T("Syntax Error in function 'party share' (Set Party Share EXP)n" .
- "Usage: party share <flag>n");
- } elsif ($arg1 eq "share") {
- $messageSender->sendPartyShareEXP($arg2);
- } elsif ($arg1 eq "kick" && ( !$char->{'party'} || !%{$char->{'party'}} )) {
- error T("Error in function 'party kick' (Kick Party Member)n" .
- "Can't kick member - you're not in a party.n");
- } elsif ($arg1 eq "kick" && $arg2 eq "") {
- error T("Syntax Error in function 'party kick' (Kick Party Member)n" .
- "Usage: party kick <party member #>n");
- } elsif ($arg1 eq "kick" && $partyUsersID[$arg2] eq "") {
- error TF("Error in function 'party kick' (Kick Party Member)n" .
- "Can't kick member - member %s doesn't exist.n", $arg2);
- } elsif ($arg1 eq "kick") {
- $messageSender->sendPartyKick($partyUsersID[$arg2]
- ,$char->{'party'}{'users'}{$partyUsersID[$arg2]}{'name'});
- } else {
- error T("Syntax Error in function 'party' (Party Management)n" .
- "Usage: party [<create|join|request|leave|share|kick>]n");
- }
- }
- sub cmdPartyChat {
- if (!$net || $net->getState() != Network::IN_GAME) {
- error TF("You must be logged in the game to use this command (%s)n", shift);
- return;
- }
- my (undef, $arg1) = @_;
- if ($arg1 eq "") {
- error T("Syntax Error in function 'p' (Party Chat)n" .
- "Usage: p <message>n");
- } else {
- sendMessage($messageSender, "p", $arg1);
- }
- }
- sub cmdPecopeco {
- my (undef, $arg1) = @_;
- my $hasPecopeco;
- if ($char) {
- foreach my $ID (keys %{$char->{statuses}}) {
- if ($ID eq "Pecopeco") {
- $hasPecopeco = 1;
- last;
- }
- }
- }
- if ($arg1 eq "") {
- if ($hasPecopeco) {
- message T("Your Pecopeco is activen");
- } else {
- message T("Your Pecopeco is inactiven");
- }
- } elsif ($arg1 eq "release") {
- if (!$net || $net->getState() != Network::IN_GAME) {
- error TF("You must be logged in the game to use this command (%s)n", 'pecopeco release');
- return;
- }
- if (!$hasPecopeco) {
- error T("Error in function 'pecopeco release' (Remove Pecopeco Status)n" .
- "You don't possess a Pecopeco.n");
- } else {
- $messageSender->sendCompanionRelease();
- }
- }
- }
- sub cmdPet {
- my (undef, $subcmd) = @_;
- if (!%pet) {
- error T("Error in function 'pet' (Pet Management)n" .
- "You don't have a pet.n");
- } elsif ($subcmd eq "s" || $subcmd eq "status") {
- message TF("-----------Pet Status-----------nName: %-23s Accessory: %s", $pet{name}, itemNameSimple($pet{accessory})), "list";
- } elsif (!$net || $net->getState() != Network::IN_GAME) {
- error TF("You must be logged in the game to use this command (%s)n", 'pet ' . $subcmd);
- return;
- } elsif ($subcmd eq "p" || $subcmd eq "performance") {
- $messageSender->sendPetPerformance();
- } elsif ($subcmd eq "r" || $subcmd eq "return") {
- $messageSender->sendPetReturnToEgg();
- } elsif ($subcmd eq "u" || $subcmd eq "unequip") {
- $messageSender->sendPetUnequipItem();
- }
- }
- sub cmdPetList {
- message T("-----------Pet List-----------n" .
- "# Type Namen"), "list";
- for (my $i = 0; $i < @petsID; $i++) {
- next if ($petsID[$i] eq "");
- message(swrite(
- "@<<< @<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<",
- [$i, $pets{$petsID[$i]}{'name'}, $pets{$petsID[$i]}{'name_given'}]),
- "list");
- }
- message("----------------------------------n", "list");
- }
- sub cmdPlayerList {
- my (undef, $args) = @_;
- my $msg;
- if ($args eq "g") {
- my $maxpl;
- my $maxplg=0;
- $msg = T("-----------Player List-----------n" .
- "# Name Sex Lv Job Dist Coordn");
- if ($playersList) {
- foreach my $player (@{$playersList->getItems()}) {
- my ($name, $dist, $pos);
- $name = $player->name;
- if ($char->{guild}{name} eq ($player->{guild}{name})) {
- if ($player->{guild} && %{$player->{guild}}) {
- $name .= " [$player->{guild}{name}]";
- }
- $dist = distance($char->{pos_to}, $player->{pos_to});
- $dist = sprintf("%.1f", $dist) if (index ($dist, '.') > -1);
- $pos = '(' . $player->{pos_to}{x} . ', ' . $player->{pos_to}{y} . ')';
-
- $maxplg = $maxplg+1;
- $msg .= swrite(
- "@<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<< @<< @<<<<<<<<<< @<<<< @<<<<<<<<<<",
- [$player->{binID}, $name, $sex_lut{$player->{sex}}, $player->{lv}, $player->job, $dist, $pos]);
- }
- $maxpl = @{$playersList->getItems()};
- }
- }
- $msg .= "Total guild players: $maxplg n";
- if ($maxpl ne "") {
- $msg .= "Total players: $maxpl n";
- } else {
- $msg .= "There are no players near you.n";
- }
- $msg .= "---------------------------------n";
- message($msg, "list");
- return;
- }
- if ($args eq "p") {
- my $maxpl;
- my $maxplp=0;
- $msg = T("-----------Player List-----------n" .
- "# Name Sex Lv Job Dist Coordn");
- if ($playersList) {
- foreach my $player (@{$playersList->getItems()}) {
- my ($name, $dist, $pos);
- $name = $player->name;
- if ($char->{party}{name} eq ($player->{party}{name})) {
- if ($player->{guild} && %{$player->{guild}}) {
- $name .= " [$player->{guild}{name}]";
- }
- $dist = distance($char->{pos_to}, $player->{pos_to});
- $dist = sprintf("%.1f", $dist) if (index ($dist, '.') > -1);
- $pos = '(' . $player->{pos_to}{x} . ', ' . $player->{pos_to}{y} . ')';
-
- $maxplp = $maxplp+1;
- $msg .= swrite(
- "@<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<< @<< @<<<<<<<<<< @<<<< @<<<<<<<<<<",
- [$player->{binID}, $name, $sex_lut{$player->{sex}}, $player->{lv}, $player->job, $dist, $pos]);
- }
- $maxpl = @{$playersList->getItems()};
- }
- }
- $msg .= "Total party players: $maxplp n";
- if ($maxpl ne "") {
- $msg .= "Total players: $maxpl n";
- } else {
- $msg .= "There are no players near you.n";
- }
- $msg .= "---------------------------------n";
- message($msg, "list");
- return;
- }
- if ($args ne "") {
- my Actor::Player $player = Match::player($args) if ($playersList);
- if (!$player) {
- error TF("Player "%s" does not exist.n", $args);
- return;
- }
- my $ID = $player->{ID};
- my $body = $player->{look}{body} % 8;
- my $head = $player->{look}{head};
- if ($head == 0) {
- $head = $body;
- } elsif ($head == 1) {
- $head = $body - 1;
- } else {
- $head = $body + 1;
- }
- my $pos = calcPosition($player);
- my $mypos = calcPosition($char);
- my $dist = sprintf("%.1f", distance($pos, $mypos));
- $dist =~ s/.0$//;
- my %vecPlayerToYou;
- my %vecYouToPlayer;
- getVector(%vecPlayerToYou, $mypos, $pos);
- getVector(%vecYouToPlayer, $pos, $mypos);
- my $degPlayerToYou = vectorToDegree(%vecPlayerToYou);
- my $degYouToPlayer = vectorToDegree(%vecYouToPlayer);
- my $hex = getHex($ID);
- my $playerToYou = int(sprintf("%.0f", (360 - $degPlayerToYou) / 45)) % 8;
- my $youToPlayer = int(sprintf("%.0f", (360 - $degYouToPlayer) / 45)) % 8;
- my $headTop = headgearName($player->{headgear}{top});
- my $headMid = headgearName($player->{headgear}{mid});
- my $headLow = headgearName($player->{headgear}{low});
-
- $msg = TF("------------------Player Info ------------------n" .
- "%s (%d)n" .
- "Account ID: %s (Hex: %s)n" .
- "Party: %sn" .
- "Guild: %sn" .
- "Guild title: %sn" .
- "Position: %s, %s (%s of you: %s degrees)n" .
- "Level: %-7d Distance: %-17sn" .
- "Sex: %-6s Class: %sn" .
- "-------------------------------------------------n" .
- "Body direction: %-19s Head direction: %-19sn" .
- "Weapon: %sn" .
- "Shield: %sn" .
- "Shoes : %sn" .
- "Upper headgear: %-19s Middle headgear: %-19sn" .
- "Lower headgear: %-19s Hair color: %-19sn" .
- "Walk speed: %s secs per blockn",
- $player->name, $player->{binID}, $player->{nameID}, $hex,
- ($player->{party} && $player->{party}{name} ne '') ? $player->{party}{name} : '',
- ($player->{guild}) ? $player->{guild}{name} : '',
- ($player->{guild}) ? $player->{guild}{title} : '',
- $pos->{x}, $pos->{y}, $directions_lut{$youToPlayer}, int($degYouToPlayer),
- $player->{lv}, $dist, $sex_lut{$player->{sex}}, $jobs_lut{$player->{jobID}},
- "$directions_lut{$body} ($body)", "$directions_lut{$head} ($head)",
- itemName({nameID => $player->{weapon}}),
- itemName({nameID => $player->{shield}}),
- itemName({nameID => $player->{shoes}}), $headTop, $headMid,
- $headLow, "$haircolors{$player->{hair_color}} ($player->{hair_color})",
- $player->{walk_speed});
- if ($player->{dead}) {
- $msg .= T("Player is dead.n");
- } elsif ($player->{sitting}) {
- $msg .= T("Player is sitting.n");
- }
- if ($degPlayerToYou >= $head * 45 - 29 && $degPlayerToYou <= $head * 45 + 29) {
- $msg .= T("Player is facing towards you.n");
- }
- $msg .= "------------------- Statuses -------------------n";
- #############################################################
- #Statuses
- #############################################################
- my $statuses = 'none';
- if (defined $player->{statuses} && %{$player->{statuses}}) {
- $statuses = join(", ", keys %{$player->{statuses}});
- }
- $msg .= TF("Statuses: %s n", $statuses);
- $msg .= "-------------------------------------------------n";
- message $msg, "info";
- return;
- }
- {
- my $maxpl;
- $msg = T("-----------Player List-----------n" .
- "# Name Sex Lv Job Dist Coordn");
- if ($playersList) {
- foreach my $player (@{$playersList->getItems()}) {
- my ($name, $dist, $pos);
- $name = $player->name;
- if ($player->{guild} && %{$player->{guild}}) {
- $name .= " [$player->{guild}{name}]";
- }
- $dist = distance($char->{pos_to}, $player->{pos_to});
- $dist = sprintf("%.1f", $dist) if (index ($dist, '.') > -1);
- $pos = '(' . $player->{pos_to}{x} . ', ' . $player->{pos_to}{y} . ')';
- $maxpl = @{$playersList->getItems()};
- $msg .= swrite(
- "@<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<< @<< @<<<<<<<<<< @<<<< @<<<<<<<<<<",
- [$player->{binID}, $name, $sex_lut{$player->{sex}}, $player->{lv}, $player->job, $dist, $pos]);
- }
- }
- if ($maxpl ne "") {
- $msg .= "Total players: $maxpl n";
- } else {$msg .= "There are no players near you.n";}
- $msg .= "---------------------------------n";
- message($msg, "list");
- }
- }
- sub cmdPlugin {
- return if ($Settings::lockdown);
- my (undef, $input) = @_;
- my @args = split(/ +/, $input, 2);
- if (@args == 0) {
- message T("--------- Currently loaded plugins ---------n" .
- "# Name Descriptionn"), "list";
- my $i = 0;
- foreach my $plugin (@Plugins::plugins) {
- next unless $plugin;
- message(swrite(
- "@<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<",
- [$i, $plugin->{name}, $plugin->{description}]
- ), "list");
- $i++;
- }
- message("--------------------------------------------n", "list");
- } elsif ($args[0] eq 'reload') {
- my @names;
- if ($args[1] =~ /^d+$/) {
- push @names, $Plugins::plugins[$args[1]]{name};
- } elsif ($args[1] eq '') {
- error T("Syntax Error in function 'plugin reload' (Reload Plugin)n" .
- "Usage: plugin reload <plugin name|plugin number#|"all">n");
- return;
- } elsif ($args[1] eq 'all') {
- foreach my $plugin (@Plugins::plugins) {
- push @names, $plugin->{name};
- }
- } else {
- foreach my $plugin (@Plugins::plugins) {
- if ($plugin->{name} =~ /$args[1]/i) {
- push @names, $plugin->{name};
- }
- }
- if (!@names) {
- error T("Error in function 'plugin reload' (Reload Plugin)n" .
- "The specified plugin names do not exist.n");
- return;
- }
- }
- foreach (my $i = 0; $i < @names; $i++) {
- Plugins::reload($names[$i]);
- }
- } elsif ($args[0] eq 'load') {
- if ($args[1] eq '') {
- error T("Syntax Error in function 'plugin load' (Load Plugin)n" .
- "Usage: plugin load <filename|"all">n");
- return;
- } elsif ($args[1] eq 'all') {
- Plugins::loadAll();
- } else {
- Plugins::load($args[1]);
- }
- } elsif ($args[0] eq 'unload') {
- if ($args[1] =~ /^d+$/) {
- if ($Plugins::plugins[$args[1]]) {
- my $name = $Plugins::plugins[$args[1]]{name};
- Plugins::unload($name);
- message TF("Plugin %s unloaded.n", $name), "system";
- } else {
- error TF("'%s' is not a valid plugin number.n", $args[1]);
- }
- } elsif ($args[1] eq '') {
- error T("Syntax Error in function 'plugin unload' (Unload Plugin)n" .
- "Usage: plugin unload <plugin name|plugin number#|"all">n");
- return;
- } elsif ($args[1] eq 'all') {
- Plugins::unloadAll();
- } else {
- foreach my $plugin (@Plugins::plugins) {
- if ($plugin->{name} =~ /$args[1]/i) {
- my $name = $plugin->{name};
- Plugins::unload($name);
- message TF("Plugin %s unloaded.n", $name), "system";
- }
- }
- }
- } else {
- my $msg;
- $msg = T("--------------- Plugin command syntax ---------------n" .
- "Command: Description:n" .
- " plugin List loaded pluginsn" .
- " plugin load <filename> Load a pluginn" .
- " plugin unload <plugin name|plugin number#|"all"> Unload a loaded pluginn" .
- " plugin reload <plugin name|plugin number#|"all"> Reload a loaded pluginn" .
- "-----------------------------------------------------n");
- if ($args[0] eq 'help') {
- message($msg, "info");
- } else {
- error T("Syntax Error in function 'plugin' (Control Plugins)n");
- error($msg);
- }
- }
- }
- sub cmdPMList {
- message T("-----------PM List-----------n"), "list";
- for (my $i = 1; $i <= @privMsgUsers; $i++) {
- message(swrite(
- "@<<< @<<<<<<<<<<<<<<<<<<<<<<<",
- [$i, $privMsgUsers[$i - 1]]),
- "list");
- }
- message("-----------------------------n", "list");
- }
- sub cmdPortalList {
- my (undef, $args) = @_;
- my ($arg) = parseArgs($args,1);
- if ($arg eq '') {
- message T("-----------Portal List-----------n" .
- "# Name Coordinatesn"), "list";
- for (my $i = 0; $i < @portalsID; $i++) {
- next if $portalsID[$i] eq "";
- my $portal = $portals{$portalsID[$i]};
- my $coords = "($portal->{pos}{x}, $portal->{pos}{y})";
- message(swrite(
- "@<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<",
- [$i, $portal->{name}, $coords]),
- "list");
- }
- message("---------------------------------n", "list");
- } elsif ($arg eq 'recompile') {
- Settings::loadByRegexp(qr/portals/);
- Misc::compilePortals() if Misc::compilePortals_check();
- }
- }
- sub cmdPrivateMessage {
- if (!$net || $net->getState() != Network::IN_GAME) {
- error TF("You must be logged in the game to use this command (%s)n", shift);
- return;
- }
- my ($switch, $args) = @_;
- my ($user, $msg) = parseArgs($args, 2);
- if ($user eq "" || $msg eq "") {
- error T("Syntax Error in function 'pm' (Private Message)n" .
- "Usage: pm (username) (message)n pm (<#>) (message)n");
- return;
- } elsif ($user =~ /^d+$/) {
- if ($user - 1 >= @privMsgUsers) {
- error TF("Error in function 'pm' (Private Message)n" .
- "Quick look-up %s does not existn", $user);
- } elsif (!@privMsgUsers) {
- error T("Error in function 'pm' (Private Message)n" .
- "You have not pm-ed anyone beforen");
- } else {
- sendMessage($messageSender, "pm", $msg, $privMsgUsers[$user - 1]);
- $lastpm{msg} = $msg;
- $lastpm{user} = $privMsgUsers[$user - 1];
- }
- } else {
- if (!defined binFind(@privMsgUsers, $user)) {
- push @privMsgUsers, $user;
- }
- sendMessage($messageSender, "pm", $msg, $user);
- $lastpm{msg} = $msg;
- $lastpm{user} = $user;
- }
- }
- sub cmdQuit {
- quit();
- }
- sub cmdReload {
- my (undef, $args) = @_;
- if ($args eq '') {
- error T("Syntax Error in function 'reload' (Reload Configuration Files)n" .
- "Usage: reload <name|"all">n");
- } else {
- parseReload($args);
- }
- }
- sub cmdReloadCode {
- my (undef, $args) = @_;
- if ($args ne "") {
- Modules::addToReloadQueue(parseArgs($args));
- } else {
- Modules::reloadFile("$FindBin::RealBin/src/functions.pl");
- }
- }
- sub cmdRelog {
- my (undef, $arg) = @_;
- if (!$arg || $arg =~ /^d+$/) {
- @cmdQueueList = ();
- $cmdQueue = 0;
- relog($arg);
- } else {
- error T("Syntax Error in function 'relog' (Log out then log in.)n" .
- "Usage: relog [delay]n");
- }
- }
- sub cmdRepair {
- if (!$net || $net->getState() != Network::IN_GAME) {
- error TF("You must be logged in the game to use this command (%s)n", shift);
- return;
- }
- my (undef, $listID) = @_;
- if ($listID =~ /^d+$/) {
- if ($repairList{$listID}) {
- $messageSender->sendRepairItem($repairList{$listID});
- my $name = itemNameSimple($repairList{$listID}{nameID});
- message TF("Sending repair item: %sn", $name);
- } elsif (!defined $repairList{$listID}) {
- error TF("Item with index: %s does either not exist in the repair list or the list is empty.n", $listID);
- }
- } else {
- error T("Syntax Error in function 'repair' (Repair player's items.)n" .
- "Usage: repair [item index]n");
- }
- }
- sub cmdRespawn {
- if (!$net || $net->getState() != Network::IN_GAME) {
- error TF("You must be logged in the game to use this command (%s)n", shift);
- return;
- }
- if ($char->{dead}) {
- $messageSender->sendRespawn();
- } else {
- main::useTeleport(2);
- }
- }
- sub cmdSell {
- if (!$net || $net->getState() != Network::IN_GAME) {
- error TF("You must be logged in the game to use this command (%s)n", shift);
- return;
- }
- my @args = parseArgs($_[1]);
- if ($args[0] eq "" && $talk{buyOrSell}) {
- $messageSender->sendGetSellList($talk{ID});
- } elsif ($args[0] eq "list") {
- if (@sellList == 0) {
- message T("Your sell list is empty.n"), "info";
- } else {
- my $text = '';
- $text .= T("------------- Sell list -------------n" .
- "# Item Amountn");
- foreach my $item (@sellList) {
- $text .= sprintf("%-3d %-30s %dn", $item->{invIndex}, $item->{name}, $item->{amount});
- }
- $text .= "-------------------------------------n";
- message($text, "list");
- }
- } elsif ($args[0] eq "done") {
- $messageSender->sendSellBulk(@sellList);
- message TF("Sold %s items.n", @sellList.""), "success";
- @sellList = ();
- } elsif ($args[0] eq "cancel") {
- @sellList = ();
- message T("Sell list has been cleared.n"), "info";
- } elsif ($args[0] eq "" || ($args[0] !~ /^d+$/ && $args[0] !~ /[,-]/)) {
- error T("Syntax Error in function 'sell' (Sell Inventory Item)n" .
- "Usage: sell <inventory item index #> [<amount>]n" .
- " sell listn" .
- " sell donen" .
- " sell canceln");
- } else {
- my @items = Actor::Item::getMultiple($args[0]);
- if (@items > 0) {
- foreach my $item (@items) {
- my %obj;
- if (defined(findIndex(@sellList, "invIndex", $item->{invIndex}))) {
- error TF("%s (%s) is already in the sell list.n", $item->nameString, $item->{invIndex});
- next;
- }
- $obj{name} = $item->nameString();
- $obj{index} = $item->{index};
- $obj{invIndex} = $item->{invIndex};
- if (!$args[1] || $args[1] > $item->{amount}) {
- $obj{amount} = $item->{amount};
- } else {
- $obj{amount} = $args[1];
- }
- push @sellList, %obj;
- message TF("Added to sell list: %s (%s) x %sn", $obj{name}, $obj{invIndex}, $obj{amount}), "info";
- }
- message T("Type 'sell done' to sell everything in your sell list.n"), "info";
- } else {
- error TF("Error in function 'sell' (Sell Inventory Item)n" .
- "'%s' is not a valid item index #; no item has been added to the sell list.n",
- $args[0]);
- }
- }
- }
- sub cmdSendRaw {
- if (!$net || $net->getState() == Network::NOT_CONNECTED) {
- error TF("You must be connected to the server to use this command (%s)n", shift);
- return;
- }
- my (undef, $args) = @_;
- $messageSender->sendRaw($args);
- }
- sub cmdShopInfoSelf {
- if (!$shopstarted) {
- error T("You do not have a shop open.n");
- return;
- }
- # FIXME: Read the packet the server sends us to determine
- # the shop title instead of using $shop{title}.
- message TF("%sn" .
- "# Name Type Qty Price Soldn",
- center(" $shop{title} ", 79, '-')), "list";
- my $priceAfterSale=0;
- my $i = 1;
- for my $item (@articles) {
- next unless $item;
- message(swrite(
- "@< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<< @>>> @>>>>>>>>>z @>>>>>",
- [$i++, $item->{name}, $itemTypes_lut{$item->{type}}, $item->{quantity}, formatNumber($item->{price}), $item->{sold}]),
- "list");
- $priceAfterSale += ($item->{quantity} * $item->{price});
- }
- message TF("%sn" .
- "You have earned: %sz.n" .
- "Current zeny: %sz.n" .
- "Maximum earned: %sz.n" .
- "Maximum zeny: %sz.n",
- ('-'x79), formatNumber($shopEarned), formatNumber($char->{zenny}),
- formatNumber($priceAfterSale), formatNumber($priceAfterSale + $char->{zenny})), "list";
- }
- sub cmdSit {
- if (!$net || $net->getState() != Network::IN_GAME) {
- error TF("You must be logged in the game to use this command (%s)n", shift);
- return;
- }
- $ai_v{sitAuto_forcedBySitCommand} = 1;
- AI::clear("move", "route", "mapRoute");
- AI::clear("attack") unless ai_getAggressives();
- require Task::SitStand;
- my $task = new Task::ErrorReport(
- task => new Task::SitStand(
- mode => 'sit',
- priority => Task::USER_PRIORITY
- )
- );
- $taskManager->add($task);
- $ai_v{sitAuto_forceStop} = 0;
- }
- sub cmdSkills {
- my (undef, $args) = @_;
- my ($arg1) = $args =~ /^(w+)/;
- my ($arg2) = $args =~ /^w+ (d+)/;
- if ($arg1 eq "") {
- my $msg = T("----------Skill List-----------n" .
- " # Skill Name Lv SPn");
- for my $handle (@skillsID) {
- my $skill = new Skill(handle => $handle);
- my $sp = $char->{skills}{$handle}{sp} || '';
- $msg .= swrite(
- "@>>> @<<<<<<<<<<<<<<<<<<<<<<<<<<<< @>> @>>>",
- [$skill->getIDN(), $skill->getName(), $char->getSkillLevel($skill), $sp]);
- }
- $msg .= TF("nSkill Points: %dn", $char->{points_skill});
- $msg .= "-------------------------------n";
- message($msg, "list");
- } elsif ($arg1 eq "add" && $arg2 =~ /d+/) {
- if (!$net || $net->getState() != Network::IN_GAME) {
- error TF("You must be logged in the game to use this command (%s)n", 'skills add');
- return;
- }
- my $skill = new Skill(idn => $arg2);
- if (!$skill->getIDN() || !$char->{skills}{$skill->getHandle()}) {
- error TF("Error in function 'skills add' (Add Skill Point)n" .
- "Skill %s does not exist.n", $arg2);
- } elsif ($char->{points_skill} < 1) {
- error TF("Error in function 'skills add' (Add Skill Point)n" .
- "Not enough skill points to increase %sn", $skill->getName());
- } else {
- $messageSender->sendAddSkillPoint($skill->getIDN());
- }
- } elsif ($arg1 eq "desc" && $arg2 =~ /d+/) {
- my $skill = new Skill(idn => $arg2);
- if (!$skill->getIDN()) {
- error TF("Error in function 'skills desc' (Skill Description)n" .
- "Skill %s does not exist.n", $arg2);
- } else {
- my $description = $skillsDesc_lut{$skill->getHandle()} || T("Error: No description available.n");
- message TF("===============Skill Description===============n" .
- "Skill: %snn", $skill->getName()), "info";
- message $description, "info";
- message "==============================================n", "info";
- }
- } else {
- error T("Syntax Error in function 'skills' (Skills Functions)n" .
- "Usage: skills [<add | desc>] [<skill #>]n");
- }
- }
- sub cmdSlaveList {
- my ($dist, $pos, $name, $slaves);
- message TF("-----------Slave List-----------n" .
- "# Name Type Distance Coordinatesn"), "list";
- $slaves = $slavesList->getItems() if ($slavesList);
- foreach my $slave (@{$slaves}) {
- $dist = distance($char->{pos_to}, $slave->{pos_to});
- $dist = sprintf("%.1f", $dist) if (index($dist, '.') > -1);
- $pos = '(' . $slave->{pos_to}{x} . ', ' . $slave->{pos_to}{y} . ')';
- $name = $slave->name;
- if ($name ne $slave->{name_given}) {
- $name .= '[' . $slave->{name_given} . ']';
- }
- message(swrite(
- "@<< @<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<< @<<<<<<<<<<",
- [$slave->{binID}, $name, $slave->{actorType}, $dist, $pos]),
- "list");
- }
- message("----------------------------------n", "list");
- }
- sub cmdSpells {
- message T("-----------Area Effects List-----------n" .
- " # Type Source X Yn"), "list";
- for my $ID (@spellsID) {
- my $spell = $spells{$ID};
- next unless $spell;
- message sprintf("%3d %-20s %-20s %3d %3dn", $spell->{binID}, getSpellName($spell->{type}), main::getActorName($spell->{sourceID}), $spell->{pos}{x}, $spell->{pos}{y}), "list";
- }
- message "---------------------------------------n", "list";
- }
- sub cmdStand {
- if (!$net || $net->getState() != Network::IN_GAME) {
- error TF("You must be logged in the game to use this command (%s)n", shift);
- return;
- }
- delete $ai_v{sitAuto_forcedBySitCommand};
- $ai_v{sitAuto_forceStop} = 1;
- require Task::SitStand;
- my $task = new Task::ErrorReport(
- task => new Task::SitStand(
- mode => 'stand',
- priority => Task::USER_PRIORITY
- )
- );
- $taskManager->add($task);
- }
- sub cmdStatAdd {
- # Add status point
- if (!$net || $net->getState() != Network::IN_GAME) {
- error TF("You must be logged in the game to use this command (%s)n", shift);
- return;
- }
- my (undef, $arg) = @_;
- if ($arg ne "str" && $arg ne "agi" && $arg ne "vit" && $arg ne "int"
- && $arg ne "dex" && $arg ne "luk") {
- error T("Syntax Error in function 'stat_add' (Add Status Point)n" .
- "Usage: stat_add <str | agi | vit | int | dex | luk>n");
- } elsif ($char->{'$arg'} >= 99 && !$config{statsAdd_over_99}) {
- error T("Error in function 'stat_add' (Add Status Point)n" .
- "You cannot add more stat points than 99n");
- } elsif ($char->{"points_$arg"} > $char->{'points_free'}) {
- error TF("Error in function 'stat_add' (Add Status Point)n" .
- "Not enough status points to increase %sn", $arg);
- } else {
- my $ID;
- if ($arg eq "str") {
- $ID = 0x0D;
- } elsif ($arg eq "agi") {
- $ID = 0x0E;
- } elsif ($arg eq "vit") {
- $ID = 0x0F;
- } elsif ($arg eq "int") {
- $ID = 0x10;
- } elsif ($arg eq "dex") {
- $ID = 0x11;
- } elsif ($arg eq "luk") {
- $ID = 0x12;
- }
- $char->{$arg} += 1;
- $messageSender->sendAddStatusPoint($ID);
- }
- }
- sub cmdStats {
- if (!$char) {
- error T("Character stats information not yet available.n");
- return;
- }
- my $guildName = $char->{guild} ? $char->{guild}{name} : T("None");
- my $msg = swrite(TF(
- "---------- Char Stats ----------n" .
- "Str: @<<+@<< #@< Atk: @<<+@<< Def: @<<+@<<n" .
- "Agi: @<<+@<< #@< Matk: @<<@@<< Mdef: @<<+@<<n" .
- "Vit: @<<+@<< #@< Hit: @<< Flee: @<<+@<<n" .
- "Int: @<<+@<< #@< Critical: @<< Aspd: @<<n" .
- "Dex: @<<+@<< #@< Status Points: @<<<n" .
- "Luk: @<<+@<< #@< Guild: @<<<<<<<<<<<<<<<<<<<<<n" .
- "--------------------------------n" .
- "Hair color: @<<<<<<<<<<<<<<<<<n" .
- "Walk speed: %.2f secs per blockn" .
- "--------------------------------", $char->{walk_speed}),
- [$char->{'str'}, $char->{'str_bonus'}, $char->{'points_str'}, $char->{'attack'}, $char->{'attack_bonus'}, $char->{'def'}, $char->{'def_bonus'},
- $char->{'agi'}, $char->{'agi_bonus'}, $char->{'points_agi'}, $char->{'attack_magic_min'}, '~', $char->{'attack_magic_max'}, $char->{'def_magic'}, $char->{'def_magic_bonus'},
- $char->{'vit'}, $char->{'vit_bonus'}, $char->{'points_vit'}, $char->{'hit'}, $char->{'flee'}, $char->{'flee_bonus'},
- $char->{'int'}, $char->{'int_bonus'}, $char->{'points_int'}, $char->{'critical'}, $char->{'attack_speed'},
- $char->{'dex'}, $char->{'dex_bonus'}, $char->{'points_dex'}, $char->{'points_free'},
- $char->{'luk'}, $char->{'luk_bonus'}, $char->{'points_luk'}, $guildName,
- "$haircolors{$char->{hair_color}} ($char->{hair_color})"]);
-
- $msg .= T("You are sitting.n") if ($char->{sitting});
- message $msg, "info";
- }
- sub cmdStatus {
- # Display character status
- my $msg;
- my ($baseEXPKill, $jobEXPKill);
- if (!$char) {
- error T("Character status information not yet available.n");
- return;
- }
- if ($char->{'exp_last'} > $char->{'exp'}) {
- $baseEXPKill = $char->{'exp_max_last'} - $char->{'exp_last'} + $char->{'exp'};
- } elsif ($char->{'exp_last'} == 0 && $char->{'exp_max_last'} == 0) {
- $baseEXPKill = 0;
- } else {
- $baseEXPKill = $char->{'exp'} - $char->{'exp_last'};
- }
- if ($char->{'exp_job_last'} > $char->{'exp_job'}) {
- $jobEXPKill = $char->{'exp_job_max_last'} - $char->{'exp_job_last'} + $char->{'exp_job'};
- } elsif ($char->{'exp_job_last'} == 0 && $char->{'exp_job_max_last'} == 0) {
- $jobEXPKill = 0;
- } else {
- $jobEXPKill = $char->{'exp_job'} - $char->{'exp_job_last'};
- }
- my ($hp_string, $sp_string, $base_string, $job_string, $weight_string, $job_name_string, $zeny_string);
- $hp_string = $char->{'hp'}."/".$char->{'hp_max'}." ("
- .int($char->{'hp'}/$char->{'hp_max'} * 100)
- ."%)" if $char->{'hp_max'};
- $sp_string = $char->{'sp'}."/".$char->{'sp_max'}." ("
- .int($char->{'sp'}/$char->{'sp_max'} * 100)
- ."%)" if $char->{'sp_max'};
- $base_string = formatNumber($char->{'exp'})."/".formatNumber($char->{'exp_max'})." /$baseEXPKill ("
- .sprintf("%.2f",$char->{'exp'}/$char->{'exp_max'} * 100)
- ."%)"
- if $char->{'exp_max'};
- $job_string = formatNumber($char->{'exp_job'})."/".formatNumber($char->{'exp_job_max'})." /$jobEXPKill ("
- .sprintf("%.2f",$char->{'exp_job'}/$char->{'exp_job_max'} * 100)
- ."%)"
- if $char->{'exp_job_max'};
- $weight_string = $char->{'weight'}."/".$char->{'weight_max'} .
- " (" . sprintf("%.1f", $char->{'weight'}/$char->{'weight_max'} * 100)
- . "%)"
- if $char->{'weight_max'};
- $job_name_string = "$jobs_lut{$char->{'jobID'}} $sex_lut{$char->{'sex'}}";
- $zeny_string = formatNumber($char->{'zenny'}) if (defined($char->{'zenny'}));
- # Translation Comment: No status effect on player
- my $statuses = 'none';
- if (defined $char->{statuses} && %{$char->{statuses}}) {
- $statuses = join(", ", keys %{$char->{statuses}});
- }
- my $dmgpsec_string = sprintf("%.2f", $dmgpsec);
- my $totalelasped_string = sprintf("%.2f", $totalelasped);
- my $elasped_string = sprintf("%.2f", $elasped);
- $msg = swrite(
- TF("----------------------- Status -------------------------n" .
- "@<<<<<<<<<<<<<<<<<<<<<<< HP: @>>>>>>>>>>>>>>>>>>n" .
- "@<<<<<<<<<<<<<<<<<<<<<<< SP: @>>>>>>>>>>>>>>>>>>n" .
- "Base: @<< @>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>n" .
- "Job : @<< @>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>n" .
- "Zeny: @<<<<<<<<<<<<<<<<< Weight: @>>>>>>>>>>>>>>>>>>n" .
- "Statuses: %sn" .
- "Spirits/Coins: %sn" .
- "--------------------------------------------------------n" .
- "Total Damage: @>>>>>>>>>>>>> Dmg/sec: @<<<<<<<<<<<<<<n" .
- "Total Time spent (sec): @>>>>>>>>n" .
- "Last Monster took (sec): @>>>>>>>n" .
- "--------------------------------------------------------",
- $statuses, (exists $char->{spirits} ? $char->{spirits} : 0)),
- [$char->{'name'}, $hp_string, $job_name_string, $sp_string,
- $char->{'lv'}, $base_string, $char->{'lv_job'}, $job_string, $zeny_string, $weight_string,
- $totaldmg, $dmgpsec_string, $totalelasped_string, $elasped_string]);
-
- message($msg, "info");
- }
- sub cmdStorage {
- if ($storage{opened} || $storage{openedThisSession}) {
- my (undef, $args) = @_;
- my ($switch, $items) = split(' ', $args, 2);
- if (!$switch || $switch eq 'eq' || $switch eq 'u' || $switch eq 'nu') {
- cmdStorage_list($switch);
- } elsif ($switch eq 'add' && $storage{opened}) {
- cmdStorage_add($items);
- } elsif ($switch eq 'addfromcart' && $storage{opened}) {
- cmdStorage_addfromcart($items);
- } elsif ($switch eq 'get' && $storage{opened}) {
- cmdStorage_get($items);
- } elsif ($switch eq 'gettocart' && $storage{opened}) {
- cmdStorage_gettocart($items);
- } elsif ($switch eq 'close' && $storage{opened}) {
- cmdStorage_close();
- } elsif ($switch eq 'log') {
- cmdStorage_log();
- } elsif ($switch eq 'desc') {
- cmdStorage_desc($items);
- } else {
- error T("Syntax Error in function 'storage' (Storage Functions)n" .
- "Usage: storage [<eq|u|nu>]n" .
- " storage closen" .
- " storage add <inventory_item> [<amount>]n" .
- " storage addfromcart <cart_item> [<amount>]n" .
- " storage get <storage_item> [<amount>]n" .
- " storage gettocart <storage_item> [<amount>]n" .
- " storage desc <storage_item_#>n".
- " storage log");
- }
- } else {
- error T("No information about storage; it has not been opened before in this sessionn");
- }
- }
- sub cmdStorage_list {
- my $type = shift;
- message "$typen";
-
- my @useable;
- my @equipment;
- my @non_useable;
-
- for (my $i = 0; $i < @storageID; $i++) {
- next if ($storageID[$i] eq "");
- my $item = $storage{$storageID[$i]};
- if ($item->{type} == 3 ||
- $item->{type} == 6 ||
- $item->{type} == 10 ||
- $item->{type} == 16 ||
- $item->{type} == 17) {
- push @non_useable, $item;
- } elsif ($item->{type} <= 2) {
- push @useable, $item;
- } else {
- my %eqp;
- $eqp{binID} = $i;
- $eqp{name} = $item->{name};
- $eqp{type} = $itemTypes_lut{$item->{type}};
- $eqp{identified} = " -- " . T("Not Identified") if !$item->{identified};
- push @equipment, %eqp;
- }
- }
-
- my $msg = T("-----------Storage-------------n");
-
- if (!$type || $type eq 'eq') {
- $msg .= T("-- Equipment --n");
- foreach my $item (@equipment) {
- $msg .= sprintf("%-3d %s (%s) %sn", $item->{binID}, $item->{name}, $item->{type}, $item->{identified});
- }
- }
-
- if (!$type || $type eq 'nu') {
- $msg .= T("-- Non-Usable --n");
- for (my $i = 0; $i < @non_useable; $i++) {
- my $item = $non_useable[$i];
- my $binID = $item->{binID};
- my $display = $item->{name};
- $display .= " x $item->{amount}";
- $msg .= swrite(
- "@<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<",
- [$binID, $display]);
- }
- }
-
- if (!$type || $type eq 'u') {
- $msg .= T("-- Usable --n");
- for (my $i = 0; $i < @useable; $i++) {
- my $item = $useable[$i];
- my $binID = $item->{binID};
- my $display = $item->{name};
- $display .= " x $item->{amount}";
- $msg .= swrite(
- "@<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<",
- [$binID, $display]);
- }
- }
-
- $msg .= "-------------------------------n";
- $msg .= TF("Capacity: %d/%dn", $storage{items}, $storage{items_max});
- $msg .= "-------------------------------n";
- message($msg, "list");
- }
- sub cmdStorage_add {
- my $items = shift;
- my ($name, $amount) = $items =~ /^(.*?)(?: (d+))?$/;
- my $item = Match::inventoryItem($name);
- if (!$item) {
- error TF("Inventory Item '%s' does not exist.n", $name);
- return;
- }
- if ($item->{equipped}) {
- error TF("Inventory Item '%s' is equipped.n", $name);
- return;
- }
- if (!defined($amount) || $amount > $item->{amount}) {
- $amount = $item->{amount};
- }
- $messageSender->sendStorageAdd($item->{index}, $amount);
- }
- sub cmdStorage_addfromcart {
- my $items = shift;
- my ($name, $amount) = $items =~ /^(.*?)(?: (d+))?$/;
- my $item = Match::cartItem($name);
- if (!$item) {
- error TF("Cart Item '%s' does not exist.n", $name);
- return;
- }
- if (!defined($amount) || $amount > $item->{amount}) {
- $amount = $item->{amount};
- }
- $messageSender->sendStorageAddFromCart($item->{index}, $amount);
- }
- sub cmdStorage_get {
- my $items = shift;
- my ($names, $amount) = $items =~ /^(.*?)(?: (d+))?$/;
- my @names = split(',', $names);
- my @items;
- for my $name (@names) {
- if ($name =~ /^(d+)-(d+)$/) {
- for my $i ($1..$2) {
- push @items, $storage{$storageID[$i]} if ($storage{$storageID[$i]});
- }
- } else {
- my $item = Match::storageItem($name);
- if (!$item) {
- error TF("Storage Item '%s' does not exist.n", $name);
- next;
- }
- push @items, $item;
- }
- }
- storageGet(@items, $amount) if @items;
- }
- sub cmdStorage_gettocart {
- my $items = shift;
- my ($name, $amount) = $items =~ /^(.*?)(?: (d+))?$/;
- my $item = Match::storageItem($name);
- if (!$item) {
- error TF("Storage Item '%s' does not exist.n", $name);
- return;
- }
- if (!defined($amount) || $amount > $item->{amount}) {
- $amount = $item->{amount};
- }
- $messageSender->sendStorageGetToCart($item->{index}, $amount);
- }
- sub cmdStorage_close {
- $messageSender->sendStorageClose();
- }
- sub cmdStorage_log {
- writeStorageLog(1);
- }
- sub cmdStorage_desc {
- my $items = shift;
- my $item = Match::storageItem($items);
- if (!$item) {
- error TF("Error in function 'storage desc' (Show Storage Item Description)n" .
- "Storage Item %s does not exist.n", $items);
- } else {
- printItemDesc($item->{nameID});
- }
- }
- sub cmdStore {
- my (undef, $args) = @_;
- my ($arg1) = $args =~ /^(w+)/;
- my ($arg2) = $args =~ /^w+ (d+)/;
- if ($arg1 eq "" && !$talk{'buyOrSell'}) {
- message T("----------Store List-----------n" .
- "# Name Type Pricen"), "list";
- my $display;
- for (my $i = 0; $i < @storeList; $i++) {
- $display = $storeList[$i]{'name'};
- message(swrite(
- "@< @<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<< @>>>>>>>z",
- [$i, $display, $itemTypes_lut{$storeList[$i]{'type'}}, $storeList[$i]{'price'}]),
- "list");
- }
- message("-------------------------------n", "list");
- } elsif ($arg1 eq "" && $talk{'buyOrSell'}
- && ($net && $net->getState() == Network::IN_GAME)) {
- $messageSender->sendGetStoreList($talk{'ID'});
- } elsif ($arg1 eq "desc" && $arg2 =~ /d+/ && !$storeList[$arg2]) {
- error TF("Error in function 'store desc' (Store Item Description)n" .
- "Store item %s does not existn", $arg2);
- } elsif ($arg1 eq "desc" && $arg2 =~ /d+/) {
- printItemDesc($storeList[$arg2]{nameID});
- } else {
- error T("Syntax Error in function 'store' (Store Functions)n" .
- "Usage: store [<desc>] [<store item #>]n");
- }
- }
- sub cmdSwitchConf {
- my (undef, $filename) = @_;
- if (!defined $filename) {
- error T("Syntax Error in function 'switchconf' (Switch Configuration File)n" .
- "Usage: switchconf <filename>n");
- } elsif (! -f $filename) {
- error TF("Syntax Error in function 'switchconf' (Switch Configuration File)n" .
- "File %s does not exist.n", $filename);
- } else {
- switchConfigFile($filename);
- message TF("Switched config file to "%s".n", $filename), "system";
- }
- }
- sub cmdTake {
- my (undef, $arg1) = @_;
- if ($arg1 eq "") {
- error T("Syntax Error in function 'take' (Take Item)n" .
- "Usage: take <item #>n");
- } elsif ($arg1 eq "first" && scalar(keys(%items)) == 0) {
- error T("Error in function 'take first' (Take Item)n" .
- "There are no items near.n");
- } elsif ($arg1 eq "first") {
- my @keys = keys %items;
- AI::take($keys[0]);
- } elsif (!$itemsID[$arg1]) {
- error TF("Error in function 'take' (Take Item)n" .
- "Item %s does not exist.n", $arg1);
- } else {
- main::take($itemsID[$arg1]);
- }
- }
- sub cmdTalk {
- if (!$net || $net->getState() != Network::IN_GAME) {
- error TF("You must be logged in the game to use this command (%s)n", shift);
- return;
- }
- my (undef, $args) = @_;
- my ($arg1) = $args =~ /^(w+)/;
- my ($arg2) = $args =~ /^w+ (d+)/;
- if ($arg1 =~ /^d+$/ && $npcsID[$arg1] eq "") {
- error TF("Error in function 'talk' (Talk to NPC)n" .
- "NPC %s does not existn", $arg1);
- } elsif ($arg1 =~ /^d+$/) {
- $messageSender->sendTalk($npcsID[$arg1]);
- } elsif (($arg1 eq "resp" || $arg1 eq "num" || $arg1 eq "text") && !%talk) {
- error TF("Error in function 'talk %s' (Respond to NPC)n" .
- "You are not talking to any NPC.n", $arg1);
- } elsif ($arg1 eq "resp" && $arg2 eq "") {
- if (!$talk{'responses'}) {
- error T("Error in function 'talk resp' (Respond to NPC)n" .
- "No NPC response list available.n");
- return;
- }
- my $display = $talk{name};
- message TF("----------Responses-----------n" .
- "NPC: %sn" .
- "# Responsen", $display),"list";
- for (my $i = 0; $i < @{$talk{'responses'}}; $i++) {
- message(sprintf(
- "%2s %sn",
- $i, $talk{'responses'}[$i]),
- "list");
- }
- message("-------------------------------n", "list");
- } elsif ($arg1 eq "resp" && $arg2 ne "" && $talk{'responses'}[$arg2] eq "") {
- error TF("Error in function 'talk resp' (Respond to NPC)n" .
- "Response %s does not exist.n", $arg2);
- } elsif ($arg1 eq "resp" && $arg2 ne "") {
- if ($talk{'responses'}[$arg2] eq "Cancel Chat") {
- $arg2 = 255;
- } else {
- $arg2 += 1;
- }
- $messageSender->sendTalkResponse($talk{'ID'}, $arg2);
- } elsif ($arg1 eq "num" && $arg2 eq "") {
- error T("Error in function 'talk num' (Respond to NPC)n" .
- "You must specify a number.n");
- } elsif ($arg1 eq "num" && !($arg2 =~ /^d+$/)) {
- error TF("Error in function 'talk num' (Respond to NPC)n" .
- "%s is not a valid number.n", $arg2);
- } elsif ($arg1 eq "num" && $arg2 =~ /^d+$/) {
- $messageSender->sendTalkNumber($talk{'ID'}, $arg2);
- } elsif ($arg1 eq "text") {
- my ($arg2) = $args =~ /^w+ (.*)/;
- if ($arg2 eq "") {
- error T("Error in function 'talk text' (Respond to NPC)n" .
- "You must specify a string.n");
- } else {
- $messageSender->sendTalkText($talk{'ID'}, $arg2);
- }
- } elsif ($arg1 eq "cont" && !%talk) {
- error T("Error in function 'talk cont' (Continue Talking to NPC)n" .
- "You are not talking to any NPC.n");
- } elsif ($arg1 eq "cont") {
- $messageSender->sendTalkContinue($talk{'ID'});
- } elsif ($arg1 eq "no") {
- if (!%talk) {
- error T("You are not talking to any NPC.n");
- } elsif ($ai_v{npc_talk}{talk} eq 'select') {
- $messageSender->sendTalkResponse($talk{ID}, 255);
- } elsif (!$talk{canceled}) {
- $messageSender->sendTalkCancel($talk{ID});
- $talk{canceled} = 1;
- }
- } else {
- error T("Syntax Error in function 'talk' (Talk to NPC)n" .
- "Usage: talk <NPC # | cont | resp | num> [<response #>|<number #>]n");
- }
- }
- sub cmdTalkNPC {
- my (undef, $args) = @_;
- my ($x, $y, $sequence) = $args =~ /^(d+) (d+) (.+)$/;
- unless (defined $x) {
- error T("Syntax Error in function 'talknpc' (Talk to an NPC)n" .
- "Usage: talknpc <x> <y> <sequence>n");
- return;
- }
- message TF("Talking to NPC at (%d, %d) using sequence: %sn", $x, $y, $sequence);
- main::ai_talkNPC($x, $y, $sequence);
- }
- sub cmdTank {
- my (undef, $arg) = @_;
- $arg =~ s/ .*//;
- if ($arg eq "") {
- error T("Syntax Error in function 'tank' (Tank for a Player)n" .
- "Usage: tank <player #|player name>n");
- } elsif ($arg eq "stop") {
- configModify("tankMode", 0);
- } elsif ($arg =~ /^d+$/) {
- if (!$playersID[$arg]) {
- error TF("Error in function 'tank' (Tank for a Player)n" .
- "Player %s does not exist.n", $arg);
- } else {
- configModify("tankMode", 1);
- configModify("tankModeTarget", $players{$playersID[$arg]}{name});
- }
- } else {
- my $found;
- foreach my $ID (@playersID) {
- next if !$ID;
- if (lc $players{$ID}{name} eq lc $arg) {
- $found = $ID;
- last;
- }
- }
- if ($found) {
- configModify("tankMode", 1);
- configModify("tankModeTarget", $players{$found}{name});
- } else {
- error TF("Error in function 'tank' (Tank for a Player)n" .
- "Player %s does not exist.n", $arg);
- }
- }
- }
- sub cmdTeleport {
- if (!$net || $net->getState() != Network::IN_GAME) {
- error TF("You must be logged in the game to use this command (%s)n", shift);
- return;
- }
- my (undef, $args) = @_;
- my ($arg1) = $args =~ /^(d)/;
- $arg1 = 1 unless $arg1;
- main::useTeleport($arg1);
- }
- sub cmdTestShop {
- my @items = main::makeShop();
- return unless @items;
- message TF("%sn" .
- "Name Amount Pricen",
- center(" $shop{title} ", 79, '-')), "list";
- for my $item (@items) {
- message(sprintf("%-40s %7d %10s zn", $item->{name},
- $item->{amount}, main::formatNumber($item->{price})), "list");
- }
- message("-------------------------------------------------------------------------------n", "list");
- message TF("Total of %d items to sell.n", binSize(@items)), "list";
- }
- sub cmdTimeout {
- my (undef, $args) = @_;
- my ($arg1) = $args =~ /^(w+)/;
- my ($arg2) = $args =~ /^w+s+([sS]+)s*$/;
- if ($arg1 eq "") {
- error T("Syntax Error in function 'timeout' (set a timeout)n" .
- "Usage: timeout <type> [<seconds>]n");
- } elsif ($timeout{$arg1} eq "") {
- error TF("Error in function 'timeout' (set a timeout)n" .
- "Timeout %s doesn't existn", $arg1);
- } elsif ($arg2 eq "") {
- message TF("Timeout '%s' is %sn",
- $arg1, $timeout{$arg1}{timeout}), "info";
- } else {
- setTimeout($arg1, $arg2);
- }
- }
- sub cmdTop10 {
- if (!$net || $net->getState() != Network::IN_GAME) {
- error TF("You must be logged in the game to use this command (%s)n", shift);
- return;
- }
- my (undef, $args) = @_;
- my ($arg1) = $args;
-
- if ($arg1 eq "") {
- message T("Function 'top10' (Show Top 10 Lists)n" .
- "Usage: top10 <b|a|t|p> | <black|alche|tk|pk> | <blacksmith|alchemist|taekwon|pvp>n");
- } elsif ($arg1 eq "a" || $arg1 eq "alche" || $arg1 eq "alchemist") {
- $messageSender->sendTop10Alchemist();
- } elsif ($arg1 eq "b" || $arg1 eq "black" || $arg1 eq "blacksmith") {
- $messageSender->sendTop10Blacksmith();
- } elsif ($arg1 eq "p" || $arg1 eq "pk" || $arg1 eq "pvp") {
- $messageSender->sendTop10PK();
- } elsif ($arg1 eq "t" || $arg1 eq "tk" || $arg1 eq "taekwon") {
- $messageSender->sendTop10Taekwon();
- } else {
- error T("Syntax Error in function 'top10' (Show Top 10 Lists)n" .
- "Usage: top10 <b|a|t|p> |n" .
- " <black|alche|tk|pk> |n".
- " <blacksmith|alchemist|taekwon|pvp>n");
- }
- }
- sub cmdUnequip {
- # unequip an item
- my (undef, $args) = @_;
- my ($arg1,$arg2) = $args =~ /^(S+)s*(.*)/;
- my $slot;
- my $item;
- if ($arg1 eq "") {
- cmdEquip_list();
- return;
- }
- if ($arg1 eq "slots") {
- # Translation Comment: List of equiped items on each slot
- message T("Slots:n") . join("n", @Actor::Item::slots). "n", "list";
- return;
- }
- if (!$net || $net->getState() != Network::IN_GAME) {
- error TF("You must be logged in the game to use this command (%s)n", 'eq ' . $args);
- return;
- }
- if ($equipSlot_rlut{$arg1}) {
- $slot = $arg1;
- } else {
- $arg1 .= " $arg2" if $arg2;
- }
- $item = Actor::Item::get(defined $slot ? $arg2 : $arg1, undef, 0);
- if (!$item) {
- $args =~ s/^($slot)s//g if ($slot);
- $slot = "undefined" unless ($slot);
- error TF("No such equipped Inventory Item: %s in slot: %sn", $args, $slot);
- return;
- }
- if (!$item->{type_equip} && $item->{type} != 10 && $item->{type} != 16 && $item->{type} != 17) {
- error TF("Inventory Item %s (%s) can't be unequipped.n",
- $item->{name}, $item->{invIndex});
- return;
- }
- if ($slot) {
- $item->unequipFromSlot($slot);
- } else {
- $item->unequip();
- }
- }
- sub cmdUseItemOnMonster {
- if (!$net || $net->getState() != Network::IN_GAME) {
- error TF("You must be logged in the game to use this command (%s)n", shift);
- return;
- }
- my (undef, $args) = @_;
- my ($arg1) = $args =~ /^(d+)/;
- my ($arg2) = $args =~ /^d+ (d+)/;
- if ($arg1 eq "" || $arg2 eq "") {
- error T("Syntax Error in function 'im' (Use Item on Monster)n" .
- "Usage: im <item #> <monster #>n");
- } elsif (!$char->inventory->get($arg1)) {
- error TF("Error in function 'im' (Use Item on Monster)n" .
- "Inventory Item %s does not exist.n", $arg1);
- } elsif ($char->inventory->get($arg1)->{type} > 2) {
- error TF("Error in function 'im' (Use Item on Monster)n" .
- "Inventory Item %s is not of type Usable.n", $arg1);
- } elsif ($monstersID[$arg2] eq "") {
- error TF("Error in function 'im' (Use Item on Monster)n" .
- "Monster %s does not exist.n", $arg2);
- } else {
- $char->inventory->get($arg1)->use($monstersID[$arg2]);
- }
- }
- sub cmdUseItemOnPlayer {
- if (!$net || $net->getState() != Network::IN_GAME) {
- error TF("You must be logged in the game to use this command (%s)n", shift);
- return;
- }
- my (undef, $args) = @_;
- my ($arg1) = $args =~ /^(d+)/;
- my ($arg2) = $args =~ /^d+ (d+)/;
- if ($arg1 eq "" || $arg2 eq "") {
- error T("Syntax Error in function 'ip' (Use Item on Player)n" .
- "Usage: ip <item #> <player #>n");
- } elsif (!$char->inventory->get($arg1)) {
- error TF("Error in function 'ip' (Use Item on Player)n" .
- "Inventory Item %s does not exist.n", $arg1);
- } elsif ($char->inventory->get($arg1)->{type} > 2) {
- error TF("Error in function 'ip' (Use Item on Player)n" .
- "Inventory Item %s is not of type Usable.n", $arg1);
- } elsif ($playersID[$arg2] eq "") {
- error TF("Error in function 'ip' (Use Item on Player)n" .
- "Player %s does not exist.n", $arg2);
- } else {
- $char->inventory->get($arg1)->use($playersID[$arg2]);
- }
- }
- sub cmdUseItemOnSelf {
- if (!$net || $net->getState() != Network::IN_GAME) {
- error TF("You must be logged in the game to use this command (%s)n", shift);
- return;
- }
- my (undef, $args) = @_;
- if ($args eq "") {
- error T("Syntax Error in function 'is' (Use Item on Yourself)n" .
- "Usage: is <item>n");
- return;
- }
- my $item = Actor::Item::get($args);
- if (!$item) {
- error TF("Error in function 'is' (Use Item on Yourself)n" .
- "Inventory Item %s does not exist.n", $args);
- return;
- }
- if ($item->{type} > 2) {
- error TF("Error in function 'is' (Use Item on Yourself)n" .
- "Inventory Item %s is not of type Usable.n", $item);
- return;
- }
- $item->use;
- }
- sub cmdUseSkill {
- if (!$net || $net->getState() != Network::IN_GAME) {
- error TF("You must be logged in the game to use this command (%s)n", shift);
- return;
- }
- my ($cmd, $args_string) = @_;
- my ($target, $actorList, $skill, $level) = @_;
- my @args = parseArgs($args_string);
- if ($cmd eq 'sl') {
- my $x = $args[1];
- my $y = $args[2];
- if (@args < 3 || @args > 4) {
- error T("Syntax error in function 'sl' (Use Skill on Location)n" .
- "Usage: sl <skill #> <x> <y> [level]n");
- return;
- } elsif ($x !~ /^d+$/ || $y !~ /^d+/) {
- error T("Error in function 'sl' (Use Skill on Location)n" .
- "Invalid coordinates given.n");
- return;
- } else {
- $target = { x => $x, y => $y };
- $level = $args[3];
- }
- # This was the code for choosing a random location when x and y are not given:
- # my $pos = calcPosition($char);
- # my @positions = calcRectArea($pos->{x}, $pos->{y}, int(rand 2) + 2);
- # $pos = $positions[rand(@positions)];
- # ($x, $y) = ($pos->{x}, $pos->{y});
- } elsif ($cmd eq 'ss') {
- if (@args < 1 || @args > 2) {
- error T("Syntax error in function 'ss' (Use Skill on Self)n" .
- "Usage: ss <skill #> [level]n");
- return;
- } else {
- $target = $char;
- $level = $args[1];
- }
- } elsif ($cmd eq 'sp') {
- if (@args < 2 || @args > 3) {
- error T("Syntax error in function 'sp' (Use Skill on Player)n" .
- "Usage: sp <skill #> <player #> [level]n");
- return;
- } else {
- $target = Match::player($args[1], 1);
- if (!$target) {
- error TF("Error in function 'sp' (Use Skill on Player)n" .
- "Player '%s' does not exist.n", $args[1]);
- return;
- }
- $actorList = $playersList;
- $level = $args[2];
- }
- } elsif ($cmd eq 'sm') {
- if (@args < 2 || @args > 3) {
- error T("Syntax error in function 'sm' (Use Skill on Monster)n" .
- "Usage: sm <skill #> <monster #> [level]n");
- return;
- } else {
- $target = $monstersList->get($args[1]);
- if (!$target) {
- error TF("Error in function 'sm' (Use Skill on Monster)n" .
- "Monster %d does not exist.n", $args[1]);
- return;
- }
- $actorList = $monstersList;
- $level = $args[2];
- }
- } elsif ($cmd eq 'ssp') {
- if (@args < 2 || @args > 3) {
- error T("Syntax error in function 'ssp' (Use Skill on Area Spell Location)n" .
- "Usage: ssp <skill #> <spell #> [level]n");
- return;
- }
- my $targetID = $spellsID[$args[1]];
- if (!$targetID) {
- error TF("Spell %d does not exist.n", $args[1]);
- return;
- }
- my $pos = $spells{$targetID}{pos_to};
- $target = { %{$pos} };
- }
- $skill = new Skill(auto => $args[0], level => $level);
- require Task::UseSkill;
- my $skillTask = new Task::UseSkill(
- target => $target,
- actorList => $actorList,
- skill => $skill,
- priority => Task::USER_PRIORITY
- );
- my $task = new Task::ErrorReport(task => $skillTask);
- $taskManager->add($task);
- }
- sub cmdVender {
- if (!$net || $net->getState() != Network::IN_GAME) {
- error TF("You must be logged in the game to use this command (%s)n", shift);
- return;
- }
- my (undef, $args) = @_;
- my ($arg1) = $args =~ /^([dw]+)/;
- my ($arg2) = $args =~ /^[dw]+ (d+)/;
- my ($arg3) = $args =~ /^[dw]+ d+ (d+)/;
- if ($arg1 eq "") {
- error T("Syntax error in function 'vender' (Vender Shop)n" .
- "Usage: vender <vender # | end> [<item #> <amount>]n");
- } elsif ($arg1 eq "end") {
- undef @venderItemList;
- undef $venderID;
- } elsif ($venderListsID[$arg1] eq "") {
- error TF("Error in function 'vender' (Vender Shop)n" .
- "Vender %s does not exist.n", $arg1);
- } elsif ($arg2 eq "") {
- $messageSender->sendEnteringVender($venderListsID[$arg1]);
- } elsif ($venderListsID[$arg1] ne $venderID) {
- error T("Error in function 'vender' (Vender Shop)n" .
- "Vender ID is wrong.n");
- } else {
- if ($arg3 <= 0) {
- $arg3 = 1;
- }
- $messageSender->sendBuyVender($venderID, $arg2, $arg3);
- }
- }
- sub cmdVenderList {
- message T("-----------Vender List-----------n" .
- "# Title Coords Ownern"), "list";
- for (my $i = 0; $i < @venderListsID; $i++) {
- next if ($venderListsID[$i] eq "");
- my $player = Actor::get($venderListsID[$i]);
- # autovivifies $obj->{pos_to} but it doesnt matter
- message(sprintf(
- "%3d %-36s (%3s, %3s) %-20sn",
- $i, $venderLists{$venderListsID[$i]}{'title'},
- $player->{pos_to}{x} || '?', $player->{pos_to}{y} || '?', $player->name),
- "list");
- }
- message("----------------------------------n", "list");
- }
- sub cmdVerbose {
- if ($config{'verbose'}) {
- configModify("verbose", 0);
- } else {
- configModify("verbose", 1);
- }
- }
- sub cmdVersion {
- message "$Settings::versionText";
- }
- sub cmdWarp {
- if (!$net || $net->getState() != Network::IN_GAME) {
- error TF("You must be logged in the game to use this command (%s)n", shift);
- return;
- }
- my (undef, $map) = @_;
- if ($map eq '') {
- error T("Error in function 'warp' (Open/List Warp Portal)n" .
- "Usage: warp <map name | map number# | list>n");
- } elsif ($map =~ /^d+$/) {
- if (!$char->{warp}{memo} || !@{$char->{warp}{memo}}) {
- error T("You didn't cast warp portal.n");
- return;
- }
- if ($map < 0 || $map > @{$char->{warp}{memo}}) {
- error TF("Invalid map number %s.n", $map);
- } else {
- my $name = $char->{warp}{memo}[$map];
- my $rsw = "$name.rsw";
- message TF("Attempting to open a warp portal to %s (%s)n",
- $maps_lut{$rsw}, $name), "info";
- $messageSender->sendOpenWarp("$name.gat");
- }
- } elsif ($map eq 'list') {
- if (!$char->{warp}{memo} || !@{$char->{warp}{memo}}) {
- error T("You didn't cast warp portal.n");
- return;
- }
- message T("----------------- Warp Portal --------------------n" .
- "# Place Mapn", "list");
- for (my $i = 0; $i < @{$char->{warp}{memo}}; $i++) {
- message(swrite(
- "@< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<",
- [$i, $maps_lut{$char->{warp}{memo}[$i].'.rsw'},
- $char->{warp}{memo}[$i]]),
- "list");
- }
- message("--------------------------------------------------n", "list");
- } elsif (!defined $maps_lut{$map.'.rsw'}) {
- error TF("Map '%s' does not exist.n", $map);
- } else {
- my $rsw = "$map.rsw";
- message TF("Attempting to open a warp portal to %s (%s)n",
- $maps_lut{$rsw}, $map), "info";
- $messageSender->sendOpenWarp("$map.gat");
- }
- }
- sub cmdWeight {
- if (!$char) {
- error T("Character weight information not yet available.n");
- return;
- }
- my (undef, $itemWeight) = @_;
- $itemWeight ||= 1;
- if ($itemWeight !~ /^d+(.d+)?$/) {
- error T("Syntax error in function 'weight' (Inventory Weight Info)n" .
- "Usage: weight [item weight]n");
- return;
- }
- my $itemString = $itemWeight == 1 ? '' : "*$itemWeight";
- message TF("Weight: %s/%s (%s%)n", $char->{weight}, $char->{weight_max}, sprintf("%.02f", $char->weight_percent)), "list";
- if ($char->weight_percent < 90) {
- if ($char->weight_percent < 50) {
- my $weight_50 = int((int($char->{weight_max}*0.5) - $char->{weight}) / $itemWeight);
- message TF("You can carry %s%s before %s overweight.n",
- $weight_50, $itemString, '50%'), "list";
- } else {
- message TF("You are %s overweight.n", '50%'), "list";
- }
- my $weight_90 = int((int($char->{weight_max}*0.9) - $char->{weight}) / $itemWeight);
- message TF("You can carry %s%s before %s overweight.n",
- $weight_90, $itemString, '90%'), "list";
- } else {
- message TF("You are %s overweight.n", '90%');
- }
- }
- sub cmdWhere {
- if (!$char) {
- error T("Location not yet available.n");
- return;
- }
- my $pos = calcPosition($char);
- message TF("Location %s (%s) : %d, %dn", $maps_lut{$field{name}.'.rsw'},
- $field{name}, $pos->{x}, $pos->{y}), "info";
- }
- sub cmdWho {
- if (!$net || $net->getState() != Network::IN_GAME) {
- error TF("You must be logged in the game to use this command (%s)n", shift);
- return;
- }
- $messageSender->sendWho();
- }
- sub cmdWhoAmI {
- if (!$char) {
- error T("Character information not yet available.n");
- return;
- }
- my $GID = unpack("L1", $charID);
- my $AID = unpack("L1", $accountID);
- message TF("Name: %s (Level %s %s %s)n" .
- "Char ID: %sn" .
- "Acct ID: %sn",
- $char->{name}, $char->{lv}, $sex_lut{$char->{sex}}, $jobs_lut{$char->{jobID}},
- $GID, $AID), "list";
- }
- sub cmdMail {
- if (!$net || $net->getState() != Network::IN_GAME) {
- error TF("You must be logged in the game to use this command (%s)n", shift);
- return;
- }
- my ($cmd, $args_string) = @_;
- my @args = parseArgs($args_string, 4);
- # mail send
- if ($cmd eq 'ms') {
- unless ($args[0] && $args[1] && $args[2]) {
- message T("Usage: ms <receiver> <title> <message>n"), "info";
- } else {
- my ($receiver, $title, $msg) = ($args[0], $args[1], $args[2]);
- $messageSender->sendMailSend((70+length($msg)), $receiver, $title, length($msg), $msg);
- }
- # mail open
- } elsif ($cmd eq 'mo') {
-
- unless ($args[0] =~ /^d+$/) {
- message T("Usage: mo <mail #>n"), "info";
- } elsif (!$mailList->[$args[0]]) {
- if (@{$mailList}) {
- message TF("No mail found with index: %s. (might need to re-open mailbox)n", $args[0]), "info";
- } else {
- message T("Mailbox has not been opened or is empty.n"), "info";
- }
- } else {
- $messageSender->sendMailRead($mailList->[$args[0]]->{mailID});
- }
- # mail inbox => set on begin as standard?
- } elsif ($cmd eq 'mi') {
- # if mail not already opened needed?
- $messageSender->sendMailboxOpen();
- # mail window (almost useless?)
- } elsif ($cmd eq 'mw') {
- unless (defined $args[0]) {
- message T("Usage: mw [0|1|2] (0:write, 1:take item back, 2:zenny input ok)n"), "info";
- } elsif ($args[0] =~ /^[0-2]$/) {
- $messageSender->sendMailOperateWindow($args[0]);
- } else {
- error T("Syntax error in function 'mw' (mailbox window)n" .
- "Usage: mw [0|1|2] (0:write, 1:take item back, 2:zenny input ok)n");
- }
- # mail attachment control
- } elsif ($cmd eq 'ma') {
- if ($args[0] eq "get" && $args[1] =~ /^d+$/) {
- unless ($mailList->[$args[1]]->{mailID}) {
- if (@{$mailList}) {
- message TF("No mail found with index: %s. (might need to re-open mailbox)n", $args[1]), "info";
- } else {
- message T("Mailbox has not been opened or is empty.n"), "info";
- }
- } else {
- $messageSender->sendMailGetAttach($mailList->[$args[1]]->{mailID});
- }
- } elsif ($args[0] eq "add") {
- unless ($args[2] =~ /^d+$/) {
- message T("Usage: ma add [zeny <amount>]|[item <amount> (<item #>|<item name>)]n"), "info";
- } elsif ($args[1] eq "zeny") {
- $messageSender->sendMailSetAttach($args[2], undef);
- } elsif ($args[1] eq "item" && defined $args[3]) {
- my $item = Actor::Item::get($args[3]);
- if ($item) {
- my $serverIndex = $item->{index};
- $messageSender->sendMailSetAttach($args[2], $serverIndex);
- } else {
- message TF("Item with index or name: %s does not exist in inventory.n", $args[3]), "info";
- }
- } else {
- error T("Syntax error in function 'ma' (mail attachment control)n" .
- "Usage: ma add [zeny <amount>]|[item <amount> (<item #>|<item name>)]n");
- }
- } else {
- message T("Usage: ma (get <mail #>)|(add [zeny <amount>]|[item <amount> (<item #>|<item name>)])n"), "info";
- }
- # mail delete (can't delete mail without removing attachment/zeny first)
- } elsif ($cmd eq 'md') {
- unless ($args[0] =~ /^d+$/) {
- message T("Usage: md <mail #>n"), "info";
- } elsif (!$mailList->[$args[0]]) {
- if (@{$mailList}) {
- message TF("No mail found with index: %s. (might need to re-open mailbox)n", $args[0]), "info";
- } else {
- message T("Mailbox has not been opened or is empty.n"), "info";
- }
- } else {
- $messageSender->sendMailDelete($mailList->[$args[0]]->{mailID});
- }
- # mail return
- } elsif ($cmd eq 'mr') {
- unless ($args[0] =~ /^d+$/) {
- message T("Usage: mr <mail #>n"), "info";
- } elsif (!$mailList->[$args[0]]) {
- if (@{$mailList}) {
- message TF("No mail found with index: %s. (might need to re-open mailbox)n", $args[1]), "info";
- } else {
- message T("Mailbox has not been opened or is empty.n"), "info";
- }
- } else {
- $messageSender->sendMailReturn($mailList->[$args[0]]->{mailID}, $mailList->[$args[0]]->{sender});
- }
- # with command mail, list of possebilities: $cmd eq 'm'
- } else {
- message T("Mail commands: ms, mi, mo, md, mw, mr, man"), "info";
- }
- }
- sub cmdAuction {
- if (!$net || $net->getState() != Network::IN_GAME) {
- error TF("You must be logged in the game to use this command (%s)n", shift);
- return;
- }
- my ($cmd, $args_string) = @_;
- my @args = parseArgs($args_string, 4);
- # auction add item
- # TODO: it doesn't seem possible to add more than 1 item?
- if ($cmd eq 'aua') {
- unless (defined $args[0] && $args[1] =~ /^d+$/) {
- message T("Usage: aua (<item #>|<item name>) <amount>n"), "info";
- } elsif (my $item = Actor::Item::get($args[0])) {
- my $serverIndex = $item->{index};
- $messageSender->sendAuctionAddItem($serverIndex, $args[1]);
- }
- # auction remove item
- } elsif ($cmd eq 'aur') {
- $messageSender->sendAuctionAddItemCancel();
- # auction create (add item first)
- } elsif ($cmd eq 'auc') {
- unless ($args[0] && $args[1] && $args[2]) {
- message T("Usage: auc <current price> <instant buy price> <hours>n"), "info";
- } else {
- my ($price, $buynow, $hours) = ($args[0], $args[1], $args[2]);
- $messageSender->sendAuctionCreate($price, $buynow, $hours);
- }
- # auction create (add item first)
- } elsif ($cmd eq 'aub') {
- unless (defined $args[0] && $args[1] =~ /^d+$/) {
- message T("Usage: aub <id> <price>n"), "info";
- } else {
- unless ($auctionList->[$args[0]]->{ID}) {
- if (@{$auctionList}) {
- message TF("No auction item found with index: %s. (might need to re-open auction window)n", $args[0]), "info";
- } else {
- message T("Auction window has not been opened or is empty.n"), "info";
- }
- } else {
- $messageSender->sendAuctionBuy($auctionList->[$args[0]]->{ID}, $args[1]);
- }
- }
- # auction info (my)
- } elsif ($cmd eq 'aui') {
- # funny thing is, we can access this info trough 'aus' aswell
- unless ($args[0] eq "selling" || $args[0] eq "buying") {
- message T("Usage: aui (selling|buying)n"), "info";
- } else {
- $args[0] = ($args[0] eq "selling") ? 0 : 1;
- $messageSender->sendAuctionReqMyInfo($args[0]);
- }
- # auction delete
- } elsif ($cmd eq 'aud') {
- unless ($args[0] =~ /^d+$/) {
- message T("Usage: aud <index>n"), "info";
- } else {
- unless ($auctionList->[$args[0]]->{ID}) {
- if (@{$auctionList}) {
- message TF("No auction item found with index: %s. (might need to re-open auction window)n", $args[0]), "info";
- } else {
- message T("Auction window has not been opened or is empty.n"), "info";
- }
- } else {
- $messageSender->sendAuctionCancel($auctionList->[$args[0]]->{ID});
- }
- }
- # auction end (item gets sold to highest bidder?)
- } elsif ($cmd eq 'aue') {
- unless ($args[0] =~ /^d+$/) {
- message T("Usage: aue <index>n"), "info";
- } else {
- unless ($auctionList->[$args[0]]->{ID}) {
- if (@{$auctionList}) {
- message TF("No auction item found with index: %s. (might need to re-open auction window)n", $args[0]), "info";
- } else {
- message T("Auction window has not been opened or is empty.n"), "info";
- }
- } else {
- $messageSender->sendAuctionMySellStop($auctionList->[$args[0]]->{ID});
- }
- }
- # auction search
- } elsif ($cmd eq 'aus') {
- # TODO: can you in official servers do a query on both a category AND price/text? (eA doesn't allow you to)
- unless (defined $args[0]) {
- message T("Usage: aus <type> [<price>|<text>]n" .
- " types (0:Armor 1:Weapon 2:Card 3:Misc 4:By Text 5:By Price 6:Sell 7:Buy)n"), "info";
- # armor, weapon, card, misc, sell, buy
- } elsif ($args[0] =~ /^[0-3]$/ || $args[0] =~ /^[6-7]$/) {
- $messageSender->sendAuctionItemSearch($args[0]);
- # by text
- } elsif ($args[0] == 5) {
- unless (defined $args[1]) {
- message T("Usage: aus 5 <text>n"), "info";
- } else {
- $messageSender->sendAuctionItemSearch($args[0], undef, $args[1]);
- }
- # by price
- } elsif ($args[0] == 6) {
- unless ($args[1] =~ /^d+$/) {
- message T("Usage: aus 6 <price>n"), "info";
- } else {
- $messageSender->sendAuctionItemSearch($args[0], $args[1]);
- }
- } else {
- error T("Possible value's for the <type> parameter are:n" .
- "(0:Armor 1:Weapon 2:Card 3:Misc 4:By Text 5:By Price 6:Sell 7:Buy)n");
- }
- # with command auction, list of possebilities: $cmd eq 'au'
- } else {
- message T("Auction commands: aua, aur, auc, aub, aui, aud, aue, ausn"), "info";
- }
- }
- return 1;