The logic of this program is:
- Found MVPs!
Run to opposite direction from where the monsters are
If the monster is closing in (chasing us), disconnect immediately.
Code: Select all
############### Advanced Avoid ##############
# The way to avoid monster without relog.
#
# Use by changing <teleport> parameter in
# mon_control.txt to 4 (Run before relog)
package runAway;
use Plugins;
use Globals;
use Log qw(warning);
use Network::Send;
use Utils;
Plugins::register('runAway', 'run from dangerous monsters', \&unload);
my $hook = Plugins::addHook('AI_pre', \&avoidMonster);
sub unload {
Plugins::delHook('AI_pre', $hook);
}
my $dist_x;
my $dist_y;
sub avoidMonster {
foreach (@monstersID) {
next unless $_;
if (Misc::mon_control($monsters{$_}{name},$monsters{$_}{nameID})->{teleport_auto} == 4) {
AI::clear(qw/move route mapRoute/);
$dist_x = $char->{pos_to}{x} - $monsters{$_}{pos_to}{x};
$dist_y = $char->{pos_to}{y} - $monsters{$_}{pos_to}{y};
if ($dist_x < 8 && $dist_x > -8 && $dist_y < 8 && $dist_y > -8) {
warning "runAway - Monster too close!\n","plugins";
warning "Disconnecting for $timeout{ai_mon_control}{'timeout'} secs to avoid $monsters{$_}{name}\n";
Misc::relog($timeout{ai_mon_control}{'timeout'});
} else {
warning "runAway - Run from monster $monsters{$_}{name}! ($monsters{$_}{pos_to}{x},$monsters{$_}{pos_to}{y})\n","plugins";
Misc::manualMove($dist_x,$dist_y);
}
}
}
}
1;
Regards!