Note: LucasForums Archive Project
The content here was reconstructed by scraping the Wayback Machine in an effort to restore some of what was lost when LF went down. The LucasForums Archive Project claims no ownership over the content or assets that were archived on archive.org.

This project is meant for research purposes only.

2 npc's leaving at once.

Page: 1 of 1
 darthriddick
02-08-2007, 3:21 AM
#1
I've been working on a recruit npc mod, and i've maneged to get the npc to leave using This script

void main () {

// goodbye.nss

// This script will make any NPC
// move to a desired location and vanish.

object oNPC=GetObjectByTag("not_rec_yet"); // insert NPC's tag here

float x=85.41; // do a whereami cheat
float y=41.44; // to get x, y, and z
float z=-0.22;

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));

}


However, the npc is spawned off of the last dialog line that carth has in the end_m01ab modual.

and if i talk to Carth i will get my new npc, and the npc that was used for the recruiting will go to the escape pod and dissipate.(go away)

but Carth remains, and if i talk to him again, it re-spawns my npc. . .
so i want a script to make carth leave at the same time my npc does.


the other problem i'm having is that the npc will not spawn unless i talk with carth twice.
on the second time the npc spawns.
that dialog is ( end_carth001.dlg )


Can someone PLEASE help me?
thanks in advance.
~DR
 Hangout Hermit
02-08-2007, 4:17 AM
#2
The script seems okay, it's just you need to add a global boolean. Try this
void main () {

// HH: Will chack if creature has been spawned. If not then will exit.
int nCreatureBoolean = GetGlobalBoolean("not_rec_yet");
if (nCreatureBoolean==FALSE)
{

object oNPC=GetObjectByTag("not_rec_yet"); // insert NPC's tag here

float x=85.41; // do a whereami cheat
float y=41.44; // to get x, y, and z
float z=-0.22;

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));

// HH: Will close the door so you cant re-enter...
SetGlobalBoolean("not_rec_yet_s",TRUE);
}

}


~HH

I think you will need to edit Globalcat.2da to add a boolean.
 Darkkender
02-08-2007, 1:29 PM
#3
void main () {

// goodbye.nss

// This script will make any NPC
// move to a desired location and vanish.

object oNPC=GetObjectByTag("not_rec_yet"); // insert NPC's tag here
object oNPC1=GetObjectByTag("CARTH");

float x=85.41; // do a whereami cheat
float y=41.44; // to get x, y, and z
float z=-0.22;

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)));
vector vExit=Vector(x,y,z);
location lExit=Location(vExit,0.0f);
ActionDoCommand(SetCommandable(TRUE,oNPC1));
AssignCommand (oNPC1,ActionForceMoveToLocation(lExit,bRun));
AssignCommand (oNPC1,ActionDoCommand(DestroyObject(oNPC1)));

// 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));
ActionDoCommand(SetCommandable(FALSE,oNPC1));
//assuming you want Carth doing the same thing

}

The modified part of your code in green above should give you the desired results.

As to why you sometimes have to talk to carth twice you may want to double check that you are placing the script to be fired in the right part of the dialogue. You also may want to place a delay in the dialogue or in the script.
 stoffe
02-08-2007, 3:46 PM
#4
Just a few things I noticed:

You shouldn't wrap SetCommandable(FALSE) in a ActionDoCommand() function call in this case, that would negate the reason you use it in the first place. You want to lock the action queue after you've filled it to ensure that the movement commands aren't interrupted, but using ActionDoCommand() would put the lock function at the end of the action queue and make sure the queue isn't locked until everything else in it has been done.

Just in case you may want to disable the AI scripts as well (though most of them should be blocked when locking the action queue), and clear out any existing commands in the action queue before making the NPC leave.

With those changes you may end up with something like:

void ExitToLocation(location lLoc, int bRun=FALSE);

void main () {
// ST: (x,y,z) coordinates to move to before disappearing.
location lExit = Location(Vector(85.41, 41.44, -0.22), 0.0f);

// ST: Move the NPCs to the exit and destroy them.
AssignCommand(GetObjectByTag("not_rec_yet"), ExitToLocation(lExit));
AssignCommand(GetObjectByTag("CARTH"), ExitToLocation(lExit));
}

void ExitToLocation(location lLoc, int bRun=FALSE) {
SetCommandable(TRUE);
SetLocalBoolean(OBJECT_SELF, 87, TRUE);
ClearAllActions();
ActionForceMoveToLocation(lLoc, bRun);
ActionDoCommand(DestroyObject(OBJECT_SELF));
SetCommandable(FALSE);
}
 darthriddick
02-09-2007, 1:33 AM
#5
YAY! it worked! thanks stoffe!
and everyonme else who posted here. (Darkkender, Hangout Hermit.)
thanks guys!
this mod is almost fineshed, and ready for beta testing!
Page: 1 of 1