Thread: Anti Train Code
View Single Post
  #7  
Old 07-22-2009, 01:20 PM
KingMort
Banned
 
Join Date: Sep 2006
Posts: 841
Default

You could also Leash the mobs that you want to not be trained..

Here is the code for that ..

Forgot who originally wrote this for my server but it works great! Thank you to whoever that was (Striat I think).. And i apologize that I forgot who you were.

Alright so this would go at the TOP of the script

Code:
##This is npc's spawned x, y location and leash length
$leashlength = 100;


sub EVENT_COMBAT
{
	if($combat_state == 1)
	{
	quest::settimer("checkleash",5);
	}
}

NOTE: You can change that 5 to whatever number you like..

Then you can place this down near the bottom (actually doesn't matter but that is how I do it)

Code:
sub EVENT_TIMER
{
$currentx = $npc->GetX();
$currenty = $npc->GetY() ;
$currentz = $npc->GetZ();
 
	if($timer eq "checkleash") 
	{
		###This is just the equation for a sphere
		###(x - x_0 )^2 + (y - y_0 )^2 + ( z - z_0 )^2 = r^2. 
		###
 
		$leftside = ((($currentx - $startingx)*($currentx-$startingx)) + (($currenty - $startingy)*($currenty - $startingy)) + (($currentz - $startingz)*($currentz - $startingz)));
		$rightside = ($leashlength * $leashlength);
		if($leftside > $rightside)
		{
		$currentx = undef;
		$currenty = undef;
		$currentz = undef;
		$npc->WipeHateList();
		$npc->GMMove($startingx, $startingy, $startingz, $startingh);
		quest::stoptimer("checkleash");
		quest::settimer("checkleash",5);
		}
	}

Anyway hope it works for you

King
www.raidaddicts.org
Reply With Quote