Getting
NPCs to Sit Down |
| Credits: I got the script and how to use it from Scripting Tutorial: Sitting in Chairs and Sleeping by David Gaider. David has written a number of excellent tutorials that can be obtained via the Bioware, Neverwinter Nights site. |
Script addition: ActionSit (GetNearestObjectByTag ("CHAIR", OBJECT_SELF)); |
| Preperation: Paint a chair near to an NPC. Make the chair both useable and sitonable (as described in sitting_1) and, at the Basic tab, give the object the tag "CHAIR". Now you have a chair that anyone can sit on. |
Now select the NPC and right click on it to bring up the properties. At the Scripts tag find the OnSpawned line. There is already a script there, Click on its Edit button to open it in the script editor. Now this next bit is important! You are going to make a change to this script that affects only this NPC. The script, however is used by lots of NPCs. If you made the change and just saved it under the same name it would affect them all! So, before we do anything else, we are going to save the script with a different name. Find the editor's Save As icon and select it. Give the script a new name, for example if the NPC had the name Rose you could call it RoseSit, and save it. Now scroll down to near the bottom of the script and add in the line given above as the last line of the script. Before the closing '}' Save the new script and close the script editor. You should see the name of your new script is now in the OnSpawned space. Now the NPC will sit on the chair instead of standing next to it. Trouble is, If your player talks to the NPC, the NPC will politely stand up but will not sit down again when the conversation is finished. |
| At the Basic tag you will see a bit for Conversation near the bottom of the window, select the Edit button there to go into the Conversation Editor. Down the bottom right in the editor are a number of tabs. Choose the one called Current File. There you will see the names of the default scripts that are run when a conversation ends. Click on the edit button for either of them. You will probably see a script like this: |
| #include "NW_I0_GENERIC"
void main() |
NOTE: It is possible that the script will be quite different to this. If so, first check that you have the right NPC. then, if so, carry on as detailed below. First save it under a different name - using the example like before this could be RoseSitBack for example - and then change it to: |
| #include "NW_I0_GENERIC"
void main() |
You will notice all we have done is replace the WalkWayPoints(); line with the line we used in the OnSpawn script. Save it and close the editor. You will see that your script has replaced the default one. Change the other script by overwriting its name with the name of your script and then close the conversation editor saving any changes. Now your NPC will stand up to speak to the PC and then sit down when finished. |