Now we are going to explore the world of animations and effects. we have our script working and really nothing further must be done - however I think it is a little drab, don't you agree? Lets fancy it up a bit with some visual effects to make the player say "What the ...."

First we need to revise the concept:

Open your Tutorial_2 module and then select "File > Save As" and save it as "tutorial_3". Go to the Area palett and open the "outside_chest" area. Because we are going to be adding a lighting bolt Beam effect, we will want the beam to emit from the chest. So we are going to need to get the chest object. Select the chest and go to the properties tab. Under the TAG parameter, enter "CHEST_GRABBER" (without the quotes). This will give your chest a unique tag for our function we will be adding to the script. Now go to the scripts tab and open the "t_ent_chestgrabber" script. We will need to declare and define another variable under our "//Declare Variables" comment. we can do this the same way we got the Waypoint in tutorial_1, with GetObjectbyTag(). Add this to your script now, object oChest = GetObjectByTag("CHEST_GRABBER"); remember to include the quotes this time.

Now we need to construct the effect of the lighting bolt. The Lighting bolt is a beam effect because it emits from one object to another. If you enter "Beam" in the script assist filter, you wil see EffectBeam as described above. You construct an effect just like you would any other variable. The data type is effect, it needs a variable name, and we need to complete any parameters that do not have defaults. Under the // declare variables section, add effect eBeam = EffectBeam( Now  click the "Globals" tab in the script assist and enter "VFX_BEAM" in the search box. You will get a long list of beam type effects, double click on the "VFX_BEAM_LIGHTING" to enter it into the script. This is our VFX effect. For our next parameter oEffector, (don't forget to separate the parameters with a comma) enter oChest. This specifies that the beam will emit from the chest object. remember that beam effects can't come from a trigger. Lastly we come to the nBodyPart parameter. Enter "BODY" in the script assist (still under "global's") you will get a list of "BODY_NODE_* constants to choose from. Because we are using a chest to emit the beam, select "BODY_NODE_CHEST". NOTE: This means the "CHEST" of a creature type, or "main body" of a object, not because it is an actual "chest" object, just wanted to clarify that.

Inside the if statement, at the start of the scope, enter a new comment,

On the next line we want to use a new function, ClearAllActions();. This function does just what it says, it clears the objects actions. Most likely our player will be running towards the chest. We want to stop them cold before we hit them with the lighting bolt. Assigning this command to the oEnter (or PC) will do just that.

Now we want to make the PC play an animation, one that might look like surprise or pain. You can pick any animation you want - infact, later I encourage you to try different ones. For now, lets use the ANIMATION_FIREFORGET_VICTORY2 animation. Again, because this is an animation, we need to Assign this command to the Player.

Now it is time to apply the effect we constructed. The effect is going to be between the chest object and the player object, so we will want to use the function ApplyEffectToObject(). When we constructed the effect, we specified where (or what object) the effect will emit from, so this function won't need to be assigned. The DURATION_TYPE_ will be TEMPORARY, we only want it to last long enough for the player to see it until they jump. The effect is eBeam (the variable name when we constructed the effect) and the target is the player oEnter, the object in wich we want to apply the effect to. Do you see the logic here? The effect is constructed with the object the effect emits from (the chest) and it is applied to the object we want the beam effect to emit to (the player). nDuration weill be set to about 3 sec. This is a float variable so make sure you include a 'point zero" after the number or 3.0. Feal free to play with other timings, maybe try 2.5.

Now our new script is complete, or so it appears. If you like, go ahead and compile the script - save - and test your mod. Then come back here to answer your immediate question. My Pc jumped but I did not see the lighting effect (or maybe you did) and the animation did not play, what is wrong??" Remember when I discussed the differences between the function JumpToObject() and ActionJumpToObject()? (look back)  This is a perfect time to demonstrate the differences. If you run the module with the script as is, then most likely your PC jumped immediately and you missed the animation and possibly the effect. This is because the function JumpToObject() inserts istelf at the top of the objects action queue, in this case the PC. So that command is executed first. To correct this issue we simply need to change the function from JumpToObject to ActionjumpToObject. This will place the jump command at the end of the PC action queue, so the PC will do the animation first - then jump. Our completed script should now look like this;

Compile, save and Run Module. make sure everything is working as expected. Now run the module a second time but this time when your character enters the trigger and the gets hit my the lighting, click someplace to move or just hit the "W" key to move - do this before the PC jumps. You will see that you can interrupt the commands and your action of moving will cancel the jump action. This is a issue easily corrected (Editors note: this appears to only be an issue with NWN1, but will be covered anyway's) and that will be the basis of our next lesson. I will also be introducing Delays.