NEED HELP: runFromMVP Plugins

Forum closed. All further discussion to be discussed at https://github.com/OpenKore/

Moderator: Moderators

Locked
Message
Author
Chontrad
Human
Human
Posts: 30
Joined: 23 Apr 2008, 10:11
Noob?: No
Location: Indonesia TANAH AIRKU
Contact:

NEED HELP: runFromMVP Plugins

#1 Post 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!

ezza
Developers
Developers
Posts: 109
Joined: 04 Apr 2008, 09:50

Re: NEED HELP: runFromMVP Plugins

#2 Post 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 ^^

Locked