Jump to content

Home

[K1]NPC exit script problem


jimbo32

Recommended Posts

I'm having trouble getting rid of an NPC, and am hoping someone can help me out. I've tried a "walk to exit and disappear" script, and when I couldn't get that to work I tried a basic destroy script. No luck there either. I've got an "executescript" command at the end that fires just fine.

 

Here's what I tried first:

 

void main () {
object oNPC=GetObjectByTag("n_chaal");    
float x=109.08;                         
float y=183.97;                        
float z=0.0;              
int bRun=FALSE;                         
vector vExit=Vector(109.08,183.97,0.0);
location lExit=Location(vExit,0.0f);
ActionDoCommand(SetCommandable(TRUE,oNPC));
AssignCommand (oNPC,ActionForceMoveToLocation(lExit,bRun));
AssignCommand (oNPC,ActionDoCommand(DestroyObject(oNPC)));
ActionDoCommand(SetCommandable(FALSE,oNPC));
ExecuteScript("Yuthura_recruit", GetFirstPC());

}

 

And when that didn't work, I tried this:

 

void main() 
{
object oGoodbye;
oGoodbye = GetObjectByTag("n_chaal");
SetGlobalFadeOut(1.5, 0.5);    
DelayCommand(1.0, DestroyObject(oGoodbye));
DelayCommand(1.0, SetGlobalFadeIn(2.5,0.5));
ExecuteScript("Yuthura_recruit", GetFirstPC());
}

 

Although I'm no expert, it looks like it should work. Anyone have any ideas?

Link to comment
Share on other sites

I don't know if it makes a difference to your problem, but you should remove ActionDoCommand() from ActionDoCommand(SetCommandable(FALSE,oNPC));.

 

ActionDoCommand would put it in the action queue, thus it would only get triggered after all the other actions are performed. You want it to lock the queue once the move actions have been queued to prevent them from being overridden.

 

Also, if it's a "go away and be destroyed" script you can remove the line...

 

ActionDoCommand(SetCommandable(TRUE,oNPC));

 

... as well since you have no reason to make the NPC commandable again.

 

Further, make sure the coordinates are reachable from where the character is, or they will not attempt to move there. And that the Tag (set in the UTC file, isn't necessarily the same as the filename) of the NPC really is n_chaal.

 

 

I don't remember if it matters to DestroyObject(), but you could also make sure the NPC isn't plot flagged with SetPlotFlag(), and is set as destroyable with SetIsDestroyable().

Link to comment
Share on other sites

If it can help, this script works for me (note that I didn't checked your coordinates. I replaced my coordinates by yours) :

void main () {
object oNPC=GetObjectByTag("n_chaal");    
float x=109.08;                         
float y=183.97;                        
float z=0.0;              
int bRun=FALSE;                         
vector vExit=Vector(109.08,183.97,0.0);
location lExit=Location(vExit,0.0f);
AssignCommand (oNPC,ActionForceMoveToLocation(lExit, FALSE));
//replace 0.0 by appropriate delay in seconds
DelayCommand(0.0, DestroyObject(oNPC)));
DelayCommand(0.0, ExecuteScript("Yuthura_recruit", GetFirstPC()));
}

Link to comment
Share on other sites

Yeah I finally figured it out (thanks to stoffe).

 

It was actually the Tag. I don't know how I managed to screw that up. Everything's (finally) behaving as it should.

 

Now on to my next question (after that, I promise I'm done).

 

When spawning an NPC, how do you get their approach to be viewed as a cut-scene? (ie: you are unable to move during the time they're running up to you) I've searched through the scripts in the mods I'm using, as well as the decompiled ones using Kotor Tool, but haven't been able to find anything.

 

Thanks again.

Link to comment
Share on other sites

When spawning an NPC, how do you get their approach to be viewed as a cut-scene? (ie: you are unable to move during the time they're running up to you)

 

You start the dialog immediately before the NPC moves to you. Add a blank dialog entry first with no text where you set an action script that causes the NPC to move towards the party (The camera will follow the NPC since they are the Speakers of that dialog node, use a camera angle that views from some distance to the side). Set a Delay on this node for as many seconds as you want the camera to follow the NPC walking towards the player. After that put a blank Reply node and then begin the actual conversation on the entry node below that.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...