Code: Select all
sub WarpTo {
require Task::Chained;
require Task::Function;
require Task::UseSkill;
my $portal = shift;
if (defined Misc::inInventory('Blue Gemstone') && defined $portal) {
my $block = GetNearestWalkable(2, $::config{'followMaxDistance'});
if (defined $block) {
my $task = new Task::Chained(
'name' => 'Warp Portal',
'priority' => Task::USER_PRIORITY,
'tasks' => [
new Task::Function(
'function' => sub {
shift->setDone if !AI::inQueue('macro');
}
),
new Task::UseSkill(
'skill' => new Skill('idn' => 27),
'target' => $block,
'stopWhenHit' => 1
),
new Task::Function(
'function' => sub {
return if !Utils::timeOut($char->{'skills'}{'AL_WARP'}{'time_used'}, 1);
$::config{'warpList'} = join(',', @{$::char->{'warp'}{'memo'}});
my $map = $portal =~ /^[0123]$/?
$::char->{'warp'}{'memo'}->[$portal]:
$::config{'warpList'} =~ /$portal\s?,|,\s?$portal/? $portal: '';
if ($map ne '') {
Log::message("[Warp] Creating portal to $map\n");
} else {
Log::message("[Warp] $portal not in warp memo\n");
}
$::messageSender->sendWarpTele(27, $map.'.gat');
shift->setDone;
}
)
]
);
$::taskManager->add($task);
}
return $block;
}
}
