Scripts to Replace Switch, Key and Pickup Triggers
by Leonvdn

This tutorial will show you how to create a switch, key or pickup event without the need for in game triggers. This comes in handy for a variety of things.
- Having a camera on Lara while she performs a switch, key or pickup action
- Having switches above each other (perhaps 2 jump switches with an elevator like setup)
- Moving a switch to a new location where it has a new purpose
- A way to trigger multiple special triggers
Though the possibilities are many I will show one possible setup. Lara pulls a switch and falls through the floor. Like tr5 Colosseum level where Lara has to think fast after pulling a switch. 
What you'll need is a switch object and the falling block object (Both can be found in the JOBY2.TR4 wad)
STEP 1

- To start with build a basic room, place a Falling_block object 4 clicks up off the ground, change OCB to 1 
- Put a dummy trigger on the ground under the falling block.



- Now place a switch on the same square (also 4 clicks up)
- Put Lara wherever you'd like
- Take note of the room number. (in my case Room 0. I find it helpful to use a notepad file and jot down the nrs)
STEP 2

- Still in the editor open the Set trigger type panel
- Go to CONDITION in the type field, Scroll down to MultEnvCondition script command in (E)way
- Scroll down to In AND way. (All ENV conditions have to be true) in the extra field
- Set Object to trigger field to MultEnvCondition= 1
- It should now look like this:


Press export Script Trigger;what you should get is this...

; Exporting: CONDITION(16:62) for PARAMETER(1)
; <#> : MultEnvCondition= 1
; <&> : Multiple condition of <#>MultEnvCondition script command in (E)way
; (E) : In AND way. (All ENV conditions have to be true)
; Values to add in script command: $8000, 1, $10


- You won't need anything except the $8000, 1, $10 part so copy that to your notes file.

- Place a comma after this and paste the same thing again but change the 1 in the middle to 2.

- It should now look like this $8000, 1, $10, $8000, 2, $10

- We'll come back for this in a minute, close the set trigger type box.

STEP 3

Next you'll need to figure out the animation Lara uses when she pulls a switch, there are a few ways of doing this, one way is to put the Diagnostic=ENABLED line in your script and see what number comes up when Lara uses a switch. I find it handy however to refer to Fluen's Lara's animations tutorial Lara's animations

- According to this tutorial the animation number we are looking for is 063

- Navigate back to the set trigger type window, change the type field to CONDITION 

- In the timer field scroll down to Lara. (Animation) Lara is performing <#>animation

- In the object to trigger field scroll down to Animation= 63

- Press export script trigger and copy the code at the end

- It should look like this $8000, 63, $1E copy that to your notes file

STEP 4

- Again select your falling block object

- Open up the set trigger type box

- Set trigger type to action and in timer field navigate down to Trigger. (Moveable) Activate <#>Object with (E)Timer value

- If you've done it right your falling block should appear in the Object to trigger field

- Again export script trigger and copy the code at the end to your notes file, it should look something like this $5000, 1107, $2B 

- (the nr in the middle will be different according to the object id of your falling_block object so don't worry if it's different for you)

- We're done with the NGLE now so you can build your level (no need to play yet)

STEP 5

- Open your NG Center and in the level you'll be using set up the following script lines...

;--------------------------------------
;FALLING BLOCK SET UP

;LARA IS IN ROOM...
MultEnvCondition=1, 

;LARA AT THE END OF HER ANIMATION
MultEnvCondition=2, 

;CONDITIONS FOR GLOBAL TRIGGER
Triggergroup=1, 

;TRIGGERED BY GLOBAL TRIGGER
TriggerGroup=2,

GlobalTrigger=1,
;--------------------------------------


- I'll go through these one at a time

- After MultEnvCondition=1, put in ENV_ROOM_IS, 0, IGNORE ,replace the 0 with the room number you put down earlier.

- this line will cause the game to check if Lara is in the room we just built.

- After MultEnvCondition=2, put in ENV_ANIM_COMPLETE, IGNORE, IGNORE ,this sets triggers to activate on the last frame of the animation

- After Triggergroup=1, put in all the codes you took down for steps 2 and 3 separated by commas, should look something like this...
- Triggergroup=1, $8000, 1, $10, $8000, 2, $10, $8000, 63, $1E 

- After Triggergroup=2, put in your code from step 4 which should look something like this...
- Triggergroup=2, $5000, 1107, $2B 

- After GlobalTrigger=1, put in IGNORE, GT_CONDITION_GROUP, IGNORE, 1, 2, IGNORE 

- The GT_CONDITION GROUP tells the game to check if all the conditions from triggergroup 1 are true. 

- The 1, 2 points to the triggergroup ID's, so the game will ask if all the conditions of triggergroup 1 are true & if they are it will activate triggergroup 2. 

- It should now look something like this (below)

;--------------------------------------
;FALLING BLOCK SET UP

;LARA IS IN ROOM...
MultEnvCondition=1, ENV_ROOM_IS, 0, IGNORE

;LARA AT THE END OF HER ANIMATION
MultEnvCondition=2, ENV_ANIM_COMPLETE, IGNORE, IGNORE 

;CONDITIONS FOR GLOBAL TRIGGER
Triggergroup=1, $8000, 1, $10, $8000, 2, $10, $8000, 63, $1E 

;TRIGGERED BY GLOBAL TRIGGER
TriggerGroup=2, $5000, 1107, $2B 

GlobalTrigger=1, IGNORE, GT_CONDITION_GROUP, IGNORE, 1, 2, IGNORE
;--------------------------------------


If everything has gone right you can now save and build your script and test your setup in game. Pull the switch and fall through the floor :D

NOTES

This is only one of many possible setups; you can export whatever triggers you want from the ACTION and FLIPEFFECT triggers and put them into your triggergroup 2, any trigger you would usually put under your switch trigger can be found here and exported, just remember to keep it all on one line in your script and separate with commas. The sky is your limit.

Anything after a ; symbol is ignored in game so the lines I've used in my script (such as ;TRIGGERED BY GLOBAL TRIGGER) can be deleted or renamed in whatever way you'd like, they are just guidelines to help me keep track of what I'm doing.

The only downfall is that any other switches of the same slot in the same room also trigger the same globaltrigger, to get around this there are several tricks,

- put the setup in a small room away from other switches
- Use different switch types (as they use different animation nr's)
- With the latest version of the NGLE you can set the animation Lara uses so you can copy the switch animation into an empty slot in Wadmerger and use that instead

This kind of setup will also work with puzzle and pickup objects but your options are slightly more limited as puzzle_hole objects usually use the same animation, so just one per room is advisable. You have some choice with the pickup animations depending on the ocb of the object.

Switches like the one I've used can't be deactivated without a standard switch trigger and therefore can't be used more than once. You can likely get around this by using the new switch OCB's or by using an action trigger in game to force the switch back to its original position. 

To move a switch and give it a new purpose you can use ACTION triggers to move it into a different room where Lara will activate a different GLOBALTRIGGER.

Hopefully this tutorial will come in handy for someone :D, I realize it may look daunting, it certainly did for me but with a bit of practise it's a 2 minute job, just like many things with the NGLE its actually a lot easier than it looks. 

A few other tutorials that may be relevant to the setup of this tutorial.

NGLE global triggers
NGLE multiple condition triggers
Script and triggergroup commands
NGLE moving objects