View Single Post
  #2  
Old 12-07-2010, 04:41 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

You have been submitting plugins like crazy, lol! Gotta love plugins

BTW, you should be able to use guard points for leashing, so you don't need the SetLeashMob plugin at all and can just handle leashing by checking dist from the guardpoints. Also, an IsEngaged check probably wouldn't hurt either.


Here is a simple rewrite (untested!):
Code:
#Usage: plugin::Leash(LeashDist, NoEngageCheck=0);
#Example: plugin::Leash(100);
# This script will check the distance from the NPC's current guard point (spawn or waypoints).
# If they are further away from that point than the specified distance, it returns them to their guard point.
# LeashDist is the max distance an NPC can be before they get leashed back by this plugin
# NoEngageCheck is an optional field which disables the IsEngaged() check as a requirement before leashing (set to 1 to enable)
# The Plugin also returns 1 if the NPC gets leashed and 0 if not.

sub Leash{
	my $npc = plugin::val('$npc');
	my $LeashDist = $_[0];
	my $NoEngageCheck = $_[1];
	# Don't bother further checks if NPC isn't engaged unless the check is disabled
	if ($npc->IsEngaged() == 1 || $NoEngageCheck)
	{
		my $GuardX = $npc->GetGuardPointX();
		my $GuardY = $npc->GetGuardPointY();
		my $GuardZ = $npc->GetGuardPointZ();
		my $CurDist = $npc->CalculateDistance($GuardX, $GuardY, $GuardZ);
		if ($CurDist > $LeashDist)
		{
			# Get their current heading, since there is currently no way to get Guard Heading (yet)
			my $CurH = $npc->GetHeading();
			# Return them to their Guard Point
			$npc->GMMove($GuardX, $GuardY, $GuardZ, $CurH);
			# Wipe the NPC's hate list as well
			$npc->WipeHateList();
			return 1;
		}
	}
	return 0;
}
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!

Last edited by trevius; 12-07-2010 at 04:48 AM..
Reply With Quote