Hidden Triggers in TRNG
by AkyV

Page 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16

8. More operations with the combinations

8.1. Forcing more values with executable combinations

If you place conditions in the executable formulas then the solution could be different. - For example:

The original basic formula to change Lara's dash power (see: Chapter 3.6.) is this:

Trigger1. An F232 to put a value into Current Value.

Trigger2. An F278 to force Current Value value into the chosen field.

But you change it with two conditions:

Trigger1. A C81 examines if Lara is in a rain room.

Trigger2. An F232 to put Value 60 into Current Value.

Trigger3. An F278 to force Current Value value into the chosen field.

Trigger4. Or else another C81 examines if Lara is in a snow room.

Trigger5. An F232 to put Value 90 into Current Value.

Trigger6. An F278 to force Current Value value into the chosen field.

So, if Lara is in a rain room, then 60 (50%) dash power will be forced on her, but if she's in a snow room, then 90 (75%) dash power will be forced.

Note:

If you activate the formula by an F118, then don't forget: TriggerGroups with condition triggers must be 'multiple' type in their F118.

8.2. Studying more values in condition combinations

You can use double (triple etc.) conditions in condition combinations (even if that doesn't mean a bigger/smaller condition pair). - Let's see a nice example:

You want to simulate this thing with the condition combination in Chapter 2.37.: 'Lara throws/drops the flaming torch and the current of air - caused by this flying torch - will blow the flame out'. - In this case we will change the F244, C43 combination into this:

GlobalTrigger= 1, IGNORE, GT_CONDITION_GROUP, IGNORE, 1, 2, IGNORE

TriggerGroup= 1, F244, C43, C43 (with TGROUP_OR)

TriggerGroup= 2, F199

This GlobalTrigger says if the condition in TriggerGroup#1 is true then TriggerGroup#2 will happen.

This is what happens in TriggerGroup#1:

- F244 puts the value of 'Lara. Test. Throw out item from the Hands (1 = lara is throwing out item) (Short)' Savegame Memory Zone field into Local Short Alfa1 variable.

- Then two C43 conditions will examine if the value in the variable is 1 or 2.

As I said in Chapter 2.37., Value 1 means 'Lara throws the torch by hitting SPACE', Value 2 means 'Lara drops the torch by drawing a weapon (with shortcut keys or in inventory)'. So that double conditions mean 'if Lara throws or drops the torch'.

So when the torch is just being thrown/dropped out of Lara's hand then TriggerGroup2 will be activated (F199) to put out the torch.

8.3. Mathematical operations

You can use some flipeffect triggers to change the value in a variable (mostly in Current Value variable) by mathematical operations (addition, subtraction, multiplication, division).

We could see some cases when the mathematical operations are crucial (see eg. I-21. or I-22. chapters) but we can use those operations only to make the level building more interesting:

Operations with variables:

They are useful because

- We can change the value of the variable that will be forced in a combination (see the example in Chapter I-7.)

- We can change the value of the variable before we examine that in a combination. - Let's see an example:

See Chapter 2.20 condition combination: F244 trigger will put the value of 'Lara. Air for Lara (0 - 1800) (Short)' Savegame Memory Zone field into a variable, and then C40/C43 will study that value in that variable.

For example you'd like to study all the little intervals of the 1800 long scale - it means lots of 'smaller/bigger' condition pairs. So your combination looks this way now:

'F244,

if >=0 or <99 then do A thing,

or else if >=100 or <199 then do B thing,

or else if >=200 or <299 then do C thing,

etc.'

But that would be a very long and complicated combination. So we'll make it a bit easier:

As you definitely remember, variable values can't have digits after the decimal point. So, for example, Value 25,76 will become 25 in the variables.

So values from 0 to 99, divided by 100 are 0.

So values from 100 to 199, divided by 100 are 1.

So values from 200 to 299, divided by 100 are 2.

Etc.

That's why we modify your plan this way:

'F244, F253 divides it by 100,

if =0 then do A thing,

or else if =1 then do B thing,

or else if =2 then do C thing,

etc.'

Types of the operations are:

- Between two numeric variables:

= F285 will add the value of any numeric variable to Current Value. (Overwriting Current Value.)

= F286 will subtract the value of any numeric variable from Current Value. (Overwriting Current Value.)

= F288 will multiply the value of Current Value by any numeric variable. (Overwriting Current Value.)

= F287 will divide the value of Current Value by any numeric variable. (Overwriting Current Value.)

- Between a 0-127 number (defined by the trigger) and a numeric variable:

= F231 will add the number to any numeric variable.

= F233 will subtract the number from any numeric variable.

= F251 will multiply any numeric variable by the number.

= F253 will divide any numeric variable by the number.

- F284 will invert the sign of any numeric variable.

These operations can replace some original trigger of the formula (as in that I-7. example) or can be new triggers in the condition (as you saw in that 'divided by 100' example).

Note:

Don't worry, dividing by 0 never will be an error. Because that operation never happens: i.e. nothing will happen if you want to accomplish that operation.

Special operations:

Usually 'forcing a value' means the forced value totally overwrite the actual value of the field. But we can have special operations in executable formulas, when the mathematical operation means the force itself.

For example, this is a basic formula of Item Memory Zone:

Trigger1. An A54 to define the actual subject of Item Memory Zone.

Trigger2. An F232/F252/F263 to put a value into the chosen variable.

Trigger3. An F257 to force the chosen variable value into the chosen field.

We'll edit that this way:

Trigger1. An A54 to define the actual subject of Item Memory Zone.

Trigger2. An F232/F252/F263 to put a value into Current Value.

Trigger3. An F257 to force the chosen variable value into the chosen field. An F275 will add Current Value value to the chosen field.

The difference between them, if the variable value is 20 and the field value before the force is 50:

- With the original formula: forcing 20 into the field will overwrite the field value, whatever that was, turning it into 20.

- With the edited formula adding 20 will add 20 to the field actual value, so the field value will be 50+20=70 now.

Types of the special operations are:

- Triggers to add Current Value variable values to memory zone field values:

= F273 will add the value to Savegame Memory Zone.

= F275 will add the value to Item Memory Zone.

= F283 will add the value to Code Memory Zone.

- Triggers to subtract Current Value variable values from memory zone field values:

= F274 will subtract the value from Savegame Memory Zone.

= F276 will subtract the value from Item Memory Zone. (The trigger name is wrong, mentioning 'Savegame Memory'.)

Operations directly (without variables):

They are useful because we can replace them in the non-variables type executable formulas by the trigger that forces a value, so we'll have a special operation.

For example, this is the basic formula of Item Memory Zone:

Trigger1. An A54 to define the actual subject of Item Memory Zone.

Trigger2. An F255/F261 to put a value into the chosen field.

We'll replace F255/F261 by F258:

Trigger1. An A54 to define the actual subject of Item Memory Zone.

Trigger2. An F258 to add a number between 0 and 127 to the chosen field.

The difference between them, if the value in the trigger is 20 and the field value before the force is 50:

- With the original formula: forcing 20 into the field will overwrite the field value, whatever that was, turning it into 20.

- With the edited formula adding 20 will add 20 to the field actual value, so the field value will be 50+20=70 now.

Types of the operations are:

- Triggers to add a 0-127 number (defined by the trigger) to memory zone field values:

= F249 will add the value to Savegame Memory Zone.

= F258 will add the value to Item Memory Zone.

= F280 will add the value to Code Memory Zone.

- Trigger to subtract a 0-127 number (defined by the trigger) from memory zone field values:

= F250 will subtract the value from Savegame Memory Zone.

8.4. Saving Current Value

As I said, Current Value is a special variable, you should use it only if it is necessary. (I.e. if you tie it for non-special tasks then you can't use it for special tasks at the same time.) So you should change Current Value for another variable, if you don't really need Current Value.

For example - this is what I said in Chapter 7.1. Condition combination:

Let's say there are two F232 (or F263) triggers placed in the different points of the level to force a value into Current Value variable:

- The value in one of the triggers means the Room Editor object ID of the DOG.

- The value in the other trigger means the Room Editor object ID of the WILD_BOAR.

Lara will activate only one F232 (F263) of them.

After that, Lara starts the combination. F301 and then F245 will define that object game index as the subject of Item Memory Zone.

So if Lara activated F232 (F263) for the ID of DOG then this animal is the one that will be studied now, but if she activated F232 (F263) for the ID of WILD_BOAR then this animal is the one that will be studied now.

So after activating F232 (F263) maybe a lot of time will elapse till activating the combination. So perhaps it ties Current Value unnecessarily.

That's why choose another (any) variable for F232 (F263).

But it means we need another (F271) trigger in the combination before F301, to copy the value of that 'any' variable into Current Value.

But we saved Current Value - not using it unnecessarily, till activating the combination.

8.5. Printing memory zone field values on the screen

Perhaps you'd like to print the actual value of a memory field on the screen. - For example this (see Chapter 2.53.):

X seconds active game time has elapsed so far

(X is naturally a second value, not a real X.)

First of all, see the TriggerGroup of the condition combination, removing the condition trigger itself:

F244

We need the ID of the variable you used in F244. (You can find it here: NG Center\Reference\Variable Placefolders.) The ID is #0070, because eg. we chose Local Long Alfa.

In the TriggerGroup, you need an F253 to divide the value by 30 in the variable (because 30 frames=1 second, and the field value is in frames) and a 'Text. Print,' flipeffect trigger to print an ExtraNG string on the screen:

F244, F253, 'Text. Print,'

You can choose any ExtraNG string for the trigger. Type the required text there with the variable ID:

#0070 seconds active game time has elapsed so far

Activate that TriggerGroup to print that string on the screen.

As Local Long Alfa contains the elapsed time (in seconds after the division), then you will see the elapsed time on the screen (in seconds) where you typed #0070.

Note:

You should activate the TriggerGroup continuously or else the second values won't be refreshed continuously on the screen!

8.6. Using memory zone field values for customized bars

We will use that #XXXX variable ID again to put a value of a field in a bar on the screen. - But we need transform that value, because bars are in percents, so their values are always 0, 1, 2, 98, 99, 100.

For example you have 50 secrets in the game and you want to show in a bar that how many secrets have been found so far. 100/50=2 so each found secrets mean 2 percents in the bar.

First of all, see the condition combination about the found secrets in Chapter 2.41. Remove the condition itself:

F244

You need to print eg. this into the Script  (supposing we use Global Byte Alfa1 now=#0000):

ColorRGB= 1, 0, 0, 255

ColorRGB= 2, 0, 255, 0

Customize= CUST_BAR, BAR_CUSTOM1, IGNORE, 280, 30, 120, 20, 1, 2, #0000

GlobalTrigger= 1, IGNORE, GT_ALWAYS, IGNORE, IGNORE, 1, IGNORE

TriggerGroup= 1, F244, F251, F331

F251 multiplies Global Byte Alfa1 by 2. (So eg. 16 found secrets will be 32 percents.) F331 puts the bar on the screen 'forever'. (GlobalTrigger is needed. I.e. you should activate the TriggerGroup continuously or else the values won't be refreshed on the screen when a secret has just been found!)

Customize= CUST_BAR command defines the parameters of the bar:

BAR_CUSTOM1: ID of the bar

280, 30, 120, 20: coordinates of the bar

1, 2: references to the ColorRGB's above (for the colors of the bar)

#0000: it naturally means the value of this variable will be shown in the bar

Note:

100/50=2 is easy but eg. a 100/1700= 0,0588 could be harder. What should we do with a value like 0,0588? - But see more about these complicated bar values eg. in  Enemy Health Bar tutorial on Skribblerz.

8.7. Using keypad switch with memory zone fields

Last Input Number variable works like a 'global long' variable. The variable always contains the last number Lara typed on the keypad switch.

You can use Last Input Number for example as the chosen variable for the condition combinations. I.e. in those conditions you can study the value Lara typed in the keypad.

And it is useful because the original setup of the keypad could work with only one code - but the formula of Last Input Number says we could use more codes now for the keypad:

'if Last Input Number value is X then do A thing,

or else if Last Input Number value is Y then do B thing,

etc.'

So if Lara types X code then A thing will be activated, but if types Y code then B thing will be activated etc. (A thing and B thing naturally could be even a TriggerGroup for an executable combination.)

But it is easier to do it with a Switch Script command.

If you want to use Last Input Number for 'a typical memory zone type usage' (i.e. which is probably not considered by Switch command) then here's an example:

Lara typed the number in the keypad. That will be Last Input Number. (That's all, i.e. you haven't used any trigger so far.)

Then you activate an F285 trigger that will adds Last Input Number value to the V=0 value of a variable (that must be Current Value this time) in an executable combination.* So when the combination will be activated after that then the value (typed by Lara) will be forced.

*: just as in the 'divided by 100' example above. I.e. F285 must be a 'new trigger' in combination.

Note:

If you use the keypad with the Last Input Number then don't place triggers below the keypad. Instead of that, activate the formula by a GT_ALWAYS GlobalTrigger. (Which GlobalTrigger must be enabled while Lara is using the keypad.)

8.8. Using variable-type timers with memory zone fields

Local/Global Long Timer values are values of the timers you can adjust by 'Variables. Timer' FLIPEFFECT triggers.

1 second means Value 30 in the variable.

You can use these timers in several ways with the combinations. For example:

A local timer is just running on the screen. You start a condition combination. If the condition is true then an F263 trigger forces X value into Local Long Timer variable, adjusting the local timer to X frames.

8.9. Store variables

If you defined a value in a variable (for example with F263) but you don't want to use it right now in a field, then

- store it (from Current Value) in a Store variable (by F236 trigger),

- so you can use it later (by F237 trigger) - putting it into Current Value.

Notes:

- This is also a good method to save Current Value, so you don't need to have the value in Current Value when you don't need the value.

- Store variables work like global variables.