Global Triggers
by Cook

A GlobalTrigger is like a CONDITION trigger. It activates if some event happens in the game. It is a way to trigger (activate) a TriggerGroup without placing a trigger sector in your level in NGLE.

TriggerGroups are explained in this tutorial - Script Triggers and Triggergroup Commands

This means your TriggerGroup can be activated anywhere in the level if a particular event happens. It is as if you had placed a CONDITION trigger and the triggers in your TriggerGroup on every sector in the level. You can disable a GlobalTrigger by a FLIPEFFECT trigger if you don't want it to apply in an area of your level. The same FLIPEFFECT trigger can be used to enable it again.

You can gain some understanding of what GlobalTriggers are by looking at the names of the different types. They are the constants that start with GT_ in the mnemonic constants list of NGCenter's reference tab. These are current as of TRNGdll 1.2.2.3 

GT_AFTER_RELOADING_VARIABLES
GT_ALWAYS
GT_BEFORE_SAVING_VARIABLES
GT_COLLIDE_CREATURE
GT_COLLIDE_ITEM
GT_COLLIDE_SLOT
GT_COLLIDE_STATIC_SLOT
GT_CONDITION_GROUP
GT_DAMAGE_BAR_LESS_THAN
GT_DISTANCE_FROM_ITEM
GT_DISTANCE_FROM_STATIC
GT_ELEVATOR_STARTS_FROM_FLOOR
GT_ELEVATOR_STOPS_AT_FLOOR
GT_ENEMY_KILLED
GT_FMV_COMPLETED
GT_GAME_KEY1_COMMAND
GT_GAME_KEY2_COMMAND
GT_KEYBOARD_CODE
GT_LARA_HOLDS_ITEM
GT_LARA_HP_HIGHER_THAN
GT_LARA_HP_LESS_THAN
GT_LARA_POISONED
GT_LOADED_SAVEGAME
GT_NO_ACTION_ON_ITEM
GT_SAVED_SAVEGAME
GT_SCREEN_TIMER_REACHED
GT_TITLE_SCREEN
GT_TRNG_G_TIMER_EQUALS
GT_TRNG_L_TIMER_EQUALS
GT_USED_BIG_MEDIPACK
GT_USED_INVENTORY_ITEM
GT_USED_LITTLE_MEDIPACK
GT_USING_BINOCULAR
GT_VSCROLL_COMPLETE
GT_VSCROLL_LAST_VISIBLE

To get the syntax for the command (i.e. what values to use and what order), in the reference tab of NGCenter select new script commands in the dropdown box and find GlobalTrigger on the list and press expand info. 

Syntax: GlobalTrigger=IdGlobalTrigger, Flags Global Trigger (FGT_...), Global Trigger (GT_..), Parameter, IdConditionTriggerGroup, IdPerformTriggerGroup, IdOnFalseTriggerGroup
Scope: To use in [LevelSection]

What does this tell you?

First it tells you where to type the command in the script. The line starting with "Scope:" says the command is typed in the [Level] section.

So to create a GlobalTrigger, in NGCenter add GlobalTrigger= to the [Level] section of your script.

Next it tells you the command must have seven values (on one line) separated by commas "," after the "=".

The seven places where you type the values are known as fields. For all commands you cannot have an empty field (,,).

The first value is just a number you give the GlobalTrigger to identify it. Each GlobalTrigger in the same [Level] section must have a different number.

The next field may contain a flag value that starts with FGT_.

Change the dropdown box from new script commands to mnemonic constants and find in the list all the values that start with FGT_ and read the info. For example, FGT_SINGLE_SHOT. If you type this value your GlobalTrigger will only activate once. If you do not want this, what do you type? You must type something because an empty field is not allowed. Whenever a field will be empty type IGNORE.

The FGT_SINGLE_SHOT value must be used with many GlobalTriggers. Every tick (frame) of the game, and that is 30 times a second, your GlobalTrigger is asking tomb4.exe if some event has happened. So every frame that event is happening the GlobalTrigger will activate your TriggerGroup. 

This can be seen by creating a TriggerGroup that forces Lara into animation and a GlobalTrigger without the FGT_SINGLE_SHOT value that activates when Lara holds a flare (GT_HOLDS_ITEM). 

If you use the GT_ENEMY_KILLED GlobalTrigger without a FGT_SINGLE_SHOT value your TriggerGroup will activate every 1/30 seconds until the end of the level once the enemy is killed since the enemy will still be killed in every frame.

The third field is where you choose what type of GlobalTrigger you are using. You must choose one of the GT_ values in the mnemonic constants. See the list above.

The value you type in the next field depends on which GT_ value you choose. You have to read the info in the mnemonic constants list in NGCenter for that GT_ value.

The fifth field is an ID number of a TriggerGroup or IGNORE. The TriggerGroup you use must contain only exported CONDITION triggers. See this tutorial - Multiple Condition Triggers. You only use a TriggerGroup ID number if you want to impose further restrictions on the GlobalTrigger. For example if you want to trigger something when Lara holds a flare (GT_HOLDS_ITEM) and when Lara is running.

The sixth field is where you type the ID number of the TriggerGroup you want to activate when the GlobalTrigger is activated (all conditions are true).

The final field is where you type the ID number of a TriggerGroup you want to activate when the GlobalTrigger is not activated (not all conditions are true).

Take care if using this field since the GlobalTrigger may not be activated for many frames of the game which means this TriggerGroup will be activated every frame.

Type IGNORE in this field if you do not want to activate any TriggerGroup when not all conditions are true.

Notes

You have to be careful how you set up a GlobalTrigger and have a suitable level design for most of them. How you set them up depends on what you want them to trigger.

For example, say you use a GT_HOLDS_ITEM GlobalTrigger to activate a TriggerGroup that will move Lara very quickly up a vertical pole. If you don't use FGT_SINGLE_SHOT, Lara won't be able to come down the pole and if she grabs it at the top she may be moved into the ceiling. If you do use FGT_SINGLE_SHOT what happens if Lara falls off the pole before reaching the top. To get around these problems you're going to have to set up triggers near the pole that enable and disable the GlobalTrigger.

Nowid used GlobalTriggers to make it possible to use a fired torch from the inventory, something I would never have thought of. Another example of GlobalTriggers can be found in Paolone's quicksand project where one is used to end the game after Lara has collected six urns.

If you are using the latest TRNG, the GlobalTriggers in Paolone's Miscellaneous demo project may need to be updated to the new syntax of seven fields for the script to compile without error. You will need to add the IdOnFalseTriggerGroup field to the end of each GlobalTrigger in the script if there are only six fields present. Use IGNORE as the value.

GT_CONDITION_GROUP

This is the type you use if you want to create your own custom GlobalTrigger. Just export all the condition triggers you want to apply and create a TriggerGroup for them. This will be a CONDITION TriggerGroup since it only contains condition script triggers. Condition script triggers start with $9000 or $8000.

When all the conditions in the CONDITION TriggerGroup are true your GlobalTrigger will activate the TriggerGroup you have nominated in the IDPerformTriggerGroup field.

GT_ALWAYS

This type does not need something to happen in the game to activate it. It is activated automatically every tick (frame) of the game.

This GlobalTrigger will activate the TriggerGroup you have nominated in the IDPerformTriggerGroup field every tick (frame) of the game.

Type IGNORE in the IdConditionTriggerGroup field since any value in this field will not be used.