darthriddick Posted February 8, 2007 Share Posted February 8, 2007 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 Link to comment Share on other sites More sharing options...
Hangout Hermit Posted February 8, 2007 Share Posted February 8, 2007 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. Link to comment Share on other sites More sharing options...
Darkkender Posted February 8, 2007 Share Posted February 8, 2007 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 [color=green]object oNPC1=GetObjectByTag("CARTH");[/color] 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))); [color=green]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)));[/color] // 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)); [color=green]ActionDoCommand(SetCommandable(FALSE,oNPC1)); //assuming you want Carth doing the same thing[/color] } 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. Link to comment Share on other sites More sharing options...
stoffe Posted February 8, 2007 Share Posted February 8, 2007 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 () { [color=PaleGreen]// ST: (x,y,z) coordinates to move to before disappearing.[/color] location lExit = Location(Vector(85.41, 41.44, -0.22), 0.0f); [color=PaleGreen]// ST: Move the NPCs to the exit and destroy them.[/color] 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); } Link to comment Share on other sites More sharing options...
darthriddick Posted February 9, 2007 Author Share Posted February 9, 2007 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! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.