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;
}