Thread: Q&A Thread
View Single Post
  #19  
Old 09-09-2018, 03:47 PM
Almusious
Fire Beetle
 
Join Date: Sep 2012
Posts: 25
Default

Quote:
Originally Posted by Huppy View Post
I almost forgot about another question I had regarding this follow thing and wondering if an idea I had was possible.

For example, NPC starts following player, but then the player is moving too fast, creating a big distance between them.

Is there a way to set an "sfollow" when a certain distance happens ? Like if the player gets too far away, the NPC quits ?
You could set a timer when you initiate the follow, then use an event timer like:

Code:
sub EVENT_TIMER
{
	if ($npc->CalculateDistance($entity_list->GetClientByCharID($npc->GetEntityVariable("master"))->GetX(),
								$entity_list->GetClientByCharID($npc->GetEntityVariable("master"))->GetY(),
								$entity_list->GetClientByCharID($npc->GetEntityVariable("master"))->GetZ()) > 20)
	{
		quest::sfollow();
	}
}
This assumes you replaced $entity in the code earlier posted with $npc.
Reply With Quote