Hi, Edited your code so that users won't have to edit the macro itself.
It will only accept commands from it's master (what ever value found in followTarget)
open warp --> bot will cast warp portal and give you the list of available warps
Code: Select all
sub warpPosition {
my ($_px, $_py) = @_;
my $_l = $::char->{look}{body};
if (!defined $_l || $_l > 7) {$_l = int(rand(8))};
my @_areas = (
[[0,4], [0,3],[-1,3],[1,3],[-1,4],[1,4],[-1,5],[1,5],[0,5],[0,2],[-1,2],[1,2],[-2,2],[2,2],[-2,3],[2,3],[-2,4],[2,4],[-2,5],[2,5],[-2,6],[2,6],[-1,6],[1,6],[0,6]] ,
[[-3,3], [-3,2],[-2,3],[-4,3],[-3,4],[-2,2],[-3,1],[-1,3],[-4,2],[-2,4],[-5,3],[-3,5],[-4,4],[-2,1],[-1,2],[-3,0],[0,3],[-4,1],[-1,4],[-5,2],[-2,5],[-6,3],[-3,6],[-5,4],[-4,5]] ,
[[-4,0], [-3,0],[-3,-1],[-3,1],[-4,-1],[-4,1],[-5,-1],[-5,1],[-5,0],[-2,0],[-2,-1],[-2,1],[-2,-2],[-2,2],[-3,-2],[-3,2],[-4,-2],[-4,2],[-5,-2],[-5,2],[-6,-2],[-6,2],[-6,-1],[-6,1],[-6,0]] ,
[[-3,-3], [-2,-3],[-3,-2],[-3,-4],[-4,-3],[-2,-2],[-1,-3],[-3,-1],[-2,-4],[-4,-2],[-3,-5],[-5,-3],[-4,-4],[-1,-2],[-2,-1],[0,-3],[-3,0],[-1,-4],[-4,-1],[-2,-5],[-5,-2],[-3,-6],[-6,-3],[-4,-5],[-5,-4]] ,
[[0,-4], [0,-3],[1,-3],[-1,-3],[1,-4],[-1,-4],[1,-5],[-1,-5],[0,-5],[0,-2],[1,-2],[-1,-2],[2,-2],[-2,-2],[2,-3],[-2,-3],[2,-4],[-2,-4],[2,-5],[-2,-5],[2,-6],[-2,-6],[1,-6],[-1,-6],[0,-6]] ,
[[3,-3], [3,-2],[2,-3],[4,-3],[3,-4],[2,-2],[3,-1],[1,-3],[4,-2],[2,-4],[5,-3],[3,-5],[4,-4],[2,-1],[1,-2],[3,0],[0,-3],[4,-1],[1,-4],[5,-2],[2,-5],[6,-3],[3,-6],[5,-4],[4,-5]] ,
[[4,0], [3,0],[3,1],[3,-1],[4,1],[4,-1],[5,1],[5,-1],[5,0],[2,0],[2,1],[2,-1],[2,2],[2,-2],[3,2],[3,-2],[4,2],[4,-2],[5,2],[5,-2],[6,2],[6,-2],[6,1],[6,-1],[6,0]] ,
[[3,3],[2,3],[3,2],[3,4],[4,3],[2,2],[1,3],[3,1],[2,4],[4,2],[3,5],[5,3],[4,4],[1,2],[2,1],[0,3],[3,0],[1,4],[4,1],[2,5],[5,2],[3,6],[6,3],[4,5],[5,4]]
);
my @_area = @{@_areas[$_l]};
my $_skip;
foreach my $_z (@_area) {
my ($_x, $_y) = ($_px + $_z->[0], $_py + $_z->[1]);
next if (!$::field->isWalkable($_x, $_y));
next if (!Misc::checkLineWalkable({x => $_px, y => $_py},{x => $_x, y => $_y}, 0));
$_skip = 0;
foreach my $_npc (@{$::npcsList->getItems()}) {
next if ($_npc->{pos_to}{x} != $_x || $_npc->{pos_to}{y} != $_y);
$_skip = 1;
last;
}
next if ($_skip == 1);
foreach my $_pl (@{$::playersList->getItems()}) {
next if ($_pl->{pos_to}{x} != $_x || $_pl->{pos_to}{y} != $_y);
$_skip = 1;
last;
}
next if ($_skip == 1);
foreach my $_mon (@{$::monstersList->getItems()}) {
next if ($_mon->{pos_to}{x} != $_x || $_mon->{pos_to}{y} != $_y);
$_skip = 1;
last;
}
next if ($_skip == 1);
return $_x." ".$_y;
}
return "none";
}
automacro warpPortal {
pm "open warp"
overrideAI 1
exclusive 0
call {
$masterName = @eval($::config{followTarget})
if ($masterName == $.lastpm) goto Checkblue
goto ending
:Checkblue
if (@invamount (Blue Gemstone) > 0) goto blue
do pm "$.lastpm" I need a Blue Gemstone.
stop
:blue
do ai manual
$px = @arg("$.pos", 1)
$py = @arg("$.pos", 2)
$loc = warpPosition($px, $py)
if ("$loc" == "none") goto noSkill
do sl 27 $loc
lock all; pause 2
if (@eval (if (!$::char->{warp}{memo}[0]) {return 0}) == 0) goto fail
release useWarp
do pm "$.lastpm" Those are my current saved maps:
$i = 0
while ($i <= 3) as warpLoop
do pm "$.lastpm" @eval ($i + 1) : @eval ($::char->{warp}{memo}[$i])
$i++
end warpLoop
do pm "$.lastpm" where to?
pause 10
do pm "$.lastpm" I guess you changed your mind...
do warp cancel
goto ending
:fail
do pm "$.lastpm" Sorry, I couldn't cast the skill.
:ending
log ending
set exclusive 1; release all; lock useWarp; do ai on
stop
:noSkill
do pm "$.lastpm" I don't have place for the skill.
do ai on
}
}
automacro useWarp {
pm /warp (1|2|3|4|close)/
overrideAI 1
exclusive 1
call {
$masterName = @eval($::config{followTarget})
if (($masterName == $.lastpm) && (($.lastMatch1 == "1") || ($.lastMatch1 == "2") || ($.lastMatch1 == "3") || ($.lastMatch1 == "4"))) goto continue
do warp cancel
goto ending
:continue
if ($.lastMatch1 == "close") goto cancel
do eval my %_warp = ("1", "0", "2", "1", "3", "2", "4", "3");$::Macro::Data::varStack{dest} = $_warp{$::Macro::Data::varStack{".lastMatch1"}}
do warp $dest
do pm "$.lastpm" Warp opened! Destination: @eval ($::maps_lut{$::char->{warp}{memo}[$dest].'.rsw'})!
goto ending
:cancel
do pm "$.lastpm" I guess you changed your mind...
do warp cancel
:ending
release all;lock useWarp; do ai on
}
}