Thread: respawn?
View Single Post
  #2  
Old 07-20-2008, 11:55 PM
Striat
Sarnak
 
Join Date: Aug 2006
Posts: 60
Default

To my knowledge, respawn is just for respawning a certain npc id. Not exactly sure what you mean about moving the npc. If you mean moving an npc from one location to the next, I made a little example in which a signal triggers a guard to move via quest::signal(targetnpcid, waittime).

Code:
#look for EVENTA for the sequence of moving the npc.

my $location = 0;

sub EVENT_SPAWN {
	$location = 0;	#resets location variable
	}


sub EVENT_WAYPOINT {	#this event is triggered everytime npc moves
  $npc->SaveGuardSpot(0);	#This prevents the npc from running back to his original spot

	if ($location == 2) {	#EVENTD - NPC makes it to location and triggers this
	quest::settimer("adjustheading",1);
	}
}

sub EVENT_SIGNAL {
	if ($location == 0) {	$EVENTA - NPC is triggered
	quest::settimer("move",1);
	$location = 1;
	}
}


sub EVENT_TIMER {
	if ($timer eq "move") {
	quest::stoptimer("move");
	if ($location == 1) {
	quest::moveto(-832,-1345,87);	#EVENTB - NPC moves to this xyz
	$location = 2;	#EVENT C - Changes variable.
	}
	}
	if ($timer eq "adjustheading") {	#EVENTE - The npc is in the appropriate location.  Sets Heading
	quest::stoptimer("adjustheading");
	if ($location == 2) {
	$npc->SetHeading(123);	#What heading does npc face?
	$npc->SendPosition();	#Now, send this heading change to client
	}
	}
}
Reply With Quote