Log in

View Full Version : respawn?


Neiv
07-18-2008, 03:12 PM
What exactly does the quest:respawn function do? Is it used for npcs already spawned in the zone and need to be moved elsewhere? If not, how exactly would I accomplish that. I have an npc that spawns at a certain location after a turn-in, and (after a series of exchanges with him) I need him to move to a different location and stay there. What is the function to accomplish this? Thanks!

Striat
07-20-2008, 11:55 PM
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).

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

Neiv
07-22-2008, 07:27 AM
Thanks, Striat, I will give this a try.