Page 1 of 1

NEED HELP: runFromMVP Plugins

Posted: 10 May 2008, 12:00
by Chontrad
What i think when i made this plugins was to be able to avoid MVPs without disconnecting.

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;
But i can't make this work. Can anyone submit a fix to this plugins? Your help is much appreciated.

Regards!

Re: NEED HELP: runFromMVP Plugins

Posted: 13 May 2008, 22:36
by ezza
For the range code ... how about you shorten the code like this?

Code: Select all

if (inRange(distance($char->{pos_to}, $monsters{$_}{pos_to}), "1..8"))


p.s: Just suggesting ^^