Warp Portal ultimate macro! REVISED
Posted: 27 Mar 2009, 11:56
EDITED: I've tweaed the macro adding the latest features, like subroutines, and I've reduced the code a lot. This set of macros is meant to allow you to command your slave Priest to cast the skill Warp Portal, no matter where you are or what warps does it have.
First the chunk of subroutine:
If you wanna know what does this do, it just checks for all the possible spots around the bot to cast the skill, and looks for obstacles and objects so it can put the warp portal in a good spot. Currently, it tries to cast the skill in the direction the bot is looking for, but in the future I'll try to make it start checking in the same direction the master is, that way it will look more natural.
Next, the macros:
these set of macros are what really do the work. The process is simple: to begin the action, you gotta tell the slave, by PM, "open warp". Your bot will stop all AI process and block other macros, so this doesn't get interrupted by anything else. Then it will check a good spot to cast the skill, and if found, it will use it. Then it will PM you the list of warps it has.
After this, you have 10 seconds to tell your bot the destination by PM'ing "1st warp", "2nd warp", "3rd warp" or "4th warp", depending on your option. If 10 secs pass, or you say "close warp", the macro will stop, warp will be closed. In case you choose a proper destination, the bot will open the warp. After any of those cases, the bot will be put back to normal, and if it was following you, it will do so even if you warp away.
This macro will tell you if the bot is out of gemstones, or doesn't have space or the warp couldn't be opened. There are some options I'd like to add but for now it has served me well. Enjoy!
First the chunk of subroutine:
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";
}
Next, the macros:
Code: Select all
automacro warpPortal {
console /^\(From: ####name of your master####\) : open warp$/i
overrideAI 1
exclusive 0
call {
if (@invamount (Blue Gemstone) > 0) goto blue
do pm " ####name of your master####" 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 " ####name of your master####" Those are my current saved maps:
$i = 0
while ($i <= 3) as warpLoop
do pm " ####name of your master####" @eval ($i + 1) : @eval ($::char->{warp}{memo}[$i])
$i++
end warpLoop
do pm " ####name of your master####" where to?
pause 10
do pm " ####name of your master####" I guess you changed your mind...
do warp cancel
goto ending
:fail
do pm " ####name of your master####" Sorry, I couldn't cast the skill.
:ending
set exclusive 1; release all; lock useWarp; do ai on
stop
:noSkill
do pm " ####name of your master####" I don't have place for the skill.
do ai on
}
}
automacro useWarp {
console /^\(From: ####name of your master####\) : (1st|2nd|3rd|4th|close) warp$/i
overrideAI 1
exclusive 1
call {
if ($.lastMatch1 == "close") goto cancel
do eval my %_warp = ("1st", "0", "2nd", "1", "3rd", "2", "4th", "3");$::Macro::Data::varStack{dest} = $_warp{$::Macro::Data::varStack{".lastMatch1"}}
do warp $dest
do pm " ####name of your master####" Warp opened! Destination: @eval ($::maps_lut{$::char->{warp}{memo}[$dest].'.rsw'})!
goto ending
:cancel
do pm " ####name of your master####" I guess you changed your mind...
do warp cancel
:ending
release all;lock useWarp; do ai on
}
}
After this, you have 10 seconds to tell your bot the destination by PM'ing "1st warp", "2nd warp", "3rd warp" or "4th warp", depending on your option. If 10 secs pass, or you say "close warp", the macro will stop, warp will be closed. In case you choose a proper destination, the bot will open the warp. After any of those cases, the bot will be put back to normal, and if it was following you, it will do so even if you warp away.
This macro will tell you if the bot is out of gemstones, or doesn't have space or the warp couldn't be opened. There are some options I'd like to add but for now it has served me well. Enjoy!