coz i think its easier for me to use this format. [edit: Please note, use this when u like the format only]
The fix is more compact and efficient also, as the duplicating code for entering a portal is removed.
[edit: for the duplicating code, a dev should make a change of it in SVN]
Code: Select all
sub cmdMove {
my (undef, $args) = @_;
my ($map, $x, $y) = ($args =~ /^(\D\w+)? ?(\d*) ?(\d*)$/);
if ($args =~ /^(\d+)$/) {
if ($portalsID[$1]) {
message TF("Move into portal number %d (%s,%s)\n",
$1, $portals{$portalsID[$1]}{'pos'}{'x'}, $portals{$portalsID[$1]}{'pos'}{'y'});
main::ai_route($field{name}, $portals{$portalsID[$1]}{'pos'}{'x'}, $portals{$portalsID[$1]}{'pos'}{'y'}, attackOnRoute => 1, noSitAuto => 1);
} else {
error "Portal $1 not exist.\n";
}
} elsif ($args eq "stop") {
AI::clear(qw/move route mapRoute/);
message T("Stopped all movement\n"), "success";
} elsif ((!$x || !$y) && !$map) {
error T("Syntax Error in function 'move' (Move Player)\n" .
"Usage: move <map> &| <x> <y>\n");
} else {
AI::clear(qw/move route mapRoute/);
$map = $field{name} if ($map eq "");
if ($maps_lut{$map.'.rsw'}) {
if ($x && $y) {
message TF("Calculating route to: %s(%s): %s, %s\n",
$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);
} else {
error TF("Map '%s' does not exist\n", $map);
}
}
}