How can I make an NPC move to a location and vanish gracefully?
Original thread (
http://www.lucasforums.com/showthread.php?s=&threadid=143254)
void main () {
// goodbye.nss
// This script will make any NPC
// move to a desired location and vanish.
object oNPC=GetObjectByTag("Carth"); // insert NPC's tag here
float x=93.77; // do a whereami cheat
float y=141.06; // to get x, y, and z
float z=0.0;
int bRun=FALSE; // you can set this to TRUE
// if you want the NPC to run
vector vExit=Vector(x,y,z);
location lExit=Location(vExit,0.0f);
ActionDoCommand(SetCommandable(TRUE,oNPC));
AssignCommand (oNPC,ActionForceMoveToLocation(lExit,bRun));
AssignCommand (oNPC,ActionDoCommand(DestroyObject(oNPC)));
// you can omit this last command if you like --
// if the NPC is not able to move to the
// location, this command will prevent
// you from being able to speak with him
// again. But if they're going to leave anyway...
ActionDoCommand(SetCommandable(FALSE,oNPC));
}
This script has been tested on Carth in the "Hideout" when first arriving on Taris.
The trick here is to bury the DestroyObject function into the AssignCommand and ActionDoCommand functions. That way the 'commands' are issued in order. Otherwise the NPC will disappear before they move.