Jump to content

Home

Walk and talk script?


supreme kotor

Recommended Posts

I'm trying to make two NPC's walk together and have a dialog while walking start running during the dialog and then stop at a certain point in the dialog. An example of the walking would be like the twin suns in Kotor TSL where they walk and talk about how

Show spoiler
(hidden content - requires Javascript to show)
they are about to attack your party members.
Link to comment
Share on other sites

Well you could do this a couple ways but I think the easiest way to do it would be with three or four scripts, so let's go that route (I'll assume you know the basics of modding, including how the dialogue editor works and how to compile scripts).

 

So I'll use an example conversation to show you what to do with the scripts. Below you'll see my example conversation. It has two people talking, then they decide to walk together.

 

20rtj4y.jpg

 

Now, in order to actually make them walk together, rather than just saying they will, you will need to use a script to make them walk, which you can find below.

void main()
{

  object oNPC = GetObjectByTag("[color="Red"]Bob[/color]");

  object oNPC2 = GetObjectByTag("[color="Red"]Friend[/color]");

   int bRun = FALSE;

     AssignCommand(oNPC, ActionForceMoveToLocation (Location(Vector([color="SeaGreen"]508.24, 33.24, 7.04[/color]), 0.0), bRun));


     AssignCommand(oNPC2, ActionForceMoveToLocation (Location(Vector([color="SeaGreen"]508.24, 33.24, 7.04[/color]), 0.0), bRun));


}

In this script, you would replace the red text with whatever the tags of your NPC's are, and you'd replace the greenish text with the coordinates of the location you want them to walk to (preferably you have them walk to generally the same place, but not the exact same coordinates).

 

So, once your script is compiled and you have the .NCS format, you are going to need to have it be executed. You do this by clicking on the node where you want them to first start walking, then putting the script name (without the file extension) in the "Script that fires when spoken" box.

 

oggcqt.jpg

 

You'll see in the node I selected above, there's text saying "[The two start walking together.]." This is completely unnecessary, and should be removed when you are finished making the dialogue. I just use it to keep track of where everything is/happens.

 

Also, remember to keep in mind that they will continue walking until they reach their destination, so if it's a long conversation you might want to have them walk to several locations, placing them all in the order you want them to be walked to, such as in the script below.

void main()
{

  object oNPC = GetObjectByTag("Bob");

  int bRun = FALSE;

     AssignCommand(oNPC, ActionForceMoveToLocation (Location(Vector(508.24, 33.24, 7.04), 0.0), bRun));

     AssignCommand(oNPC, ActionForceMoveToLocation (Location(Vector(525.21, 43.11, 6.04), 0.0), bRun));

     AssignCommand(oNPC, ActionForceMoveToLocation (Location(Vector(611.01, 55.17, 6.42), 0.0), bRun));


}

 

Alternatively you could just make sure that the destination they are walking to is far enough away that they won't stop walking before they are supposed to.

 

Now next you wanted them to start running. Doing that is really simple. All you do is take the scripts I posted above, change the coordinates to what you want them to be, and then change the value of "int bRun = FALSE;" to "int bRun = TRUE;" such as what is below.

 

void main()
{

  object oNPC = GetObjectByTag("Bob");

  object oNPC2 = GetObjectByTag("Friend");

  int bRun = TRUE;

     AssignCommand(oNPC, ActionForceMoveToLocation (Location(Vector(518.24, 43.24, 7.04), 0.0), bRun));

     AssignCommand(oNPC2, ActionForceMoveToLocation (Location(Vector(518.24, 43.24, 7.04), 0.0), bRun));


}

 

If you try this script and the NPC's don't stop walking and start running, you could try making them call ClearAllActions(); first, like in the script below.

 

void main()
{

  object oNPC = GetObjectByTag("Bob");

  object oNPC2 = GetObjectByTag("Friend");

  int bRun = TRUE;

     AssignCommand(oNPC, ClearAllActions());

     AssignCommand(oNPC, ActionForceMoveToLocation (Location(Vector(518.24, 43.24, 7.04), 0.0), bRun));

     AssingCommand(oNPC2, ClearAllActions());

     AssignCommand(oNPC2, ActionForceMoveToLocation (Location(Vector(518.24, 43.24, 7.04), 0.0), bRun));


}

 

Now after that's done and compiled, you'll want to put the script's name in a node's "Script that fires when spoken" box, just like the walking script. I won't go into too much detail on this, seeing as I already explained it, so if you get confused just look at the picture below.

 

2wfjo8i.jpg

 

Okay, now all that's left is to make them stop running at a certain point. To do this, all you have to do is take those ClearAllActions(); calls I had above, and put them in their own separate script, similar to the one below.

 

void main()
{

  object oNPC = GetObjectByTag("Bob");

  object oNPC2 = GetObjectByTag("Friend");

     AssignCommand(oNPC, ClearAllActions());

     AssignCommand(oNPC2, ClearAllActions());

}

 

Again, you'll want to put this in a node's "Script that fires when spoken" box.

 

b6f4tx.jpg

 

All right, with that all done everything should work okay in-game. However, in order to make this scene look better, I would suggest using placeable cameras, animated cameras and delays/wait calls on some of the nodes. I hope this helped.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...