Opening a Gate |
| Credits: Jon Hayes - Trog - Sent me this solution at a time when I was brain dead! |
Script: //Put this on action taken
in the conversation editor object oPC = GetPCSpeaker(); object oTarget; AssignCommand(oTarget, ActionOpenDoor(GetObjectByTag("<GATE TAG> "))); AssignCommand(GetObjectByTag("<NPC TAG> "), ActionSpeakString("You may enter now")); } |
Select the NPC that is going to open the gate and create a coversation. Find the line that once spoken will cause the NPC to open the gate, select that line and then click on the Action Taken tab. Go into the script editor and copy in the above script. Before we do any more you need the NPC's tag and the gate or door's tag (In the example I will give below the NPC will be Ned Gred with the tag nf_nedgred and the gate's tag will be nf_biggate). Where you see <NPC TAG> substitute the tag for the NPC (two places) and where you see <GATE TAG> substitute the tag for the gate. Oh you can put in your own text string instead of "You may enter now" if you wish. |
For example: //Put this on action taken
in the conversation editor object oPC = GetPCSpeaker(); object oTarget; AssignCommand(oTarget, ActionOpenDoor(GetObjectByTag("nf_biggate"))); AssignCommand(GetObjectByTag("nf_nedgred"), ActionSpeakString("You may enter now")); } |
Save the script with a unique name and your NPC will open the gate. Point to remember!! If the gate is locked then the NPC will need the key to the lock in his inventory! |
|
I had to structure the conversation so that if the PC had a letter on him then the NPC would unlock the gate and let him in. So the conversation stucture was smething like: IF the PC has letter THEN let him in. ELSE IF NPC spoken to PC before THEN say this ELSE say that. So on the first line of the conversation a check is made to see if the PC has the letter. This is done using the Text Appears When tab and is set up using the wizard. If the PC has not got the letter we ignore that bit and drop down to the next section. Here, using the Text Appears When tab and the wizard we check against a variable to see if its value has been set to 1. If the variable has a null value we assume that this is the first time the NPC has spoken to the PC and so drop down to the last section of conversation where, on the first line, we set the variable value to 1 using the wizard in the Actions Taken tab. All this kind of explains why conversations seem to be structured back to front which will probably later help to show why scripts are structured that way too! |