View Single Post
Old 07-05-15, 07:52   #1
AkyV
Moderator
 
Joined: Dec 2011
Posts: 4,881
Default TRNG – Audio and sound special

Instructions:

1. Copy the setup in your Script.
2. Build the Script.

Special instructions, if the Script doesn’t work/cannot be built:

1. Check TriggerGroup, and GlobalTrigger ID’s and change them if you are already using the ID in another TriggerGroup/GlobalTrigger.
2. If you already have a Parameters= PARAM_BIG_NUMBERS command at your level, then remove the same command of the setup you’ve just copied, and type the amount value of the removed command into the old command.
3. Open the Find Trigger Number window in Set Trigger Type panel, and copy-paste the underlined triggers there (one by one), to check them:

- If you changed TriggerGroup/GlobalTrigger ID’s, then you also need to change the TriggerGroup/GlobalTrigger ID in the trigger (if it is a trigger about a TriggerGroup/GlobalTrigger).
- If you removed the new Parameters= PARAM_BIG_NUMBERS command, you need to check if the big number index is still okay in the trigger (if it is a trigger about big numbers). If it is not, then choose the good one.

Export the trigger you have changed, replacing the previous trigger in the Script.
3. Build the Script.


Condition:
If X background loop audio track plays on channel1

TriggerGroup= 1, $2000, 277, $0, > ; put the actual track into Current Value variable
$8000, 255, $W028 ; if Current Value is the number at W0 position of PARAM_BIG_NUMBERS, W0 (must be typed in hexadecimal format now in the trigger code) is 0 in this example
Parameters= PARAM_BIG_NUMBERS, X

X is the numeric ID that the required audio track has in audio folder.

The easiest solutions to use the conditions:
- The TriggerGroup (1) ID is referred by a C15 trigger. There is a TRIGGER placed in the map, overlapped with the CONDITION trigger. The TRIGGER will be executed if Lara is in the trigger zone when the CONDITION is true.
- The TriggerGroup (1) ID is referred by the IdConditionTriggerGroup field of a GlobalTrigger.

Note:
Use this formula, if the condition must be true if there is no background track (because a track ID without a track file is adjusted in “Level” Script command, or because you stopped the track with F69 or with F130):

TriggerGroup= 1, $2000, 277, $0, > ; put the actual track into Current Value variable
$8000, 255, $2A ; if Current Value < 0

Condition:
If X foreground single audio track plays on channel2

TriggerGroup= 1, $2000, 277, $1, > ; put the actual track into Current Value variable
$8000, 255, $W028 ; if Current Value is the number at W0 position of PARAM_BIG_NUMBERS, W0 (must be typed in hexadecimal format now in the trigger code) is 0 in this example
Parameters= PARAM_BIG_NUMBERS, X

X is the numeric ID that the required audio track has in audio folder.

Known bug:
The condition will be true, even if the track ends, till you start another track. That is why usually you should use the condition only if you stop the track with F69 or with F130, or with starting another track, before the track ends. If you don’t want to abort the track this way, then you should use this trick:
Don’t start the audio directly. Instead, start this Organizer when you want to start the track:

Organizer= 1, IGNORE, IGNORE, 0, 2, Y, 3
TriggerGroup= 2, F129 (to start the required track)
TriggerGroup= 3, F130 (to stop the required track)

Y is the length of the track.
So the Organizer will start the track right away, and “technically” abort it exactly when the track ends. “Technically” means the Organizer won’t really do anything with the track, because the track will end by itself when the length expires – so what the Organizer will really do is it removes the track ID from Current Value.

Be careful: if you abort the track (because eg. you start another single track when the previous single track is still playing) then you need to stop the Organizer, or else TriggerGroup#3 will abort the new track.

Note:
Use this formula, if the condition must be true if there is no foreground track:

TriggerGroup= 1, $2000, 277, $1, > ; put the actual track into Current Value variable
$8000, 255, $2A ; if Current Value < 0

Be careful: if you start at least one foreground track on the level, then this „no track” condition is useable only if you aborted the track and that is why you can hear silence. (So don’t use this condition if you can hear silence because the track ended by itself.)

Command:
Adjust master audio volume in Options menu to X percent

; Set Trigger Type - FLIPEFFECT 279
; Exporting: TRIGGER(…:0) for FLIPEFFECT(279)
; <#> : Variables. Memory. Set in <&>Code Memory the (E)Value
; <&> : Music volume (max = 100) (Long)
; (E) : Value X
; Values to add in script command: $2000, 279, $Y0F

X is between 0 and 100.
Y is the hexadecimal version of X.

Note:
You can force a preset master audio volume for your game, with SoundSettings Script command. But that is useable only when the game starts. This trigger is useful any time during the game.

Condition:
If master audio volume in Options menu is Y equal/more/less than X percent

TriggerGroup= 1, $2000, 277, $F, > ; put the actual volume into Current Value variable
$8000, 255, $W0Y ; if Current Value is the number at W0 position of PARAM_BIG_NUMBERS, W0 (must be typed in hexadecimal format now in the trigger code) is 0 in this example
Parameters= PARAM_BIG_NUMBERS, X

X is between 0 and 100.

Y values are:
26 – for a “bigger” condition (this time X must be the original X plus 1, so eg. if you want a “bigger than 50” condition, then X is 51)
27 – for a “smaller” condition
28 – for an “equal” condition

Command:
Adjust master SFX volume in Options menu to X percent

; Set Trigger Type - FLIPEFFECT 279
; Exporting: TRIGGER(…:0) for FLIPEFFECT(279)
; <#> : Variables. Memory. Set in <&>Code Memory the (E)Value
; <&> : Sound SFX volume (max = 100) (Long)
; (E) : Value X
; Values to add in script command: $2000, 279, $Y10

X is between 0 and 100.
Y is the hexadecimal version of X.

Note:
You can force a preset master SFX volume for your game, with SoundSettings Script command. But that is useable only when the game starts. This trigger is useful any time during the game.

Condition:
If master SFX volume in Options menu is Y equal/more/less than X percent

TriggerGroup= 1, $2000, 277, $10, > ; put the actual volume into Current Value variable
$8000, 255, $W0Y ; if Current Value is the number at W0 position of PARAM_BIG_NUMBERS, W0 (must be typed in hexadecimal format now in the trigger code) is 0 in this example
Parameters= PARAM_BIG_NUMBERS, X

X is between 0 and 100.

Y values are:
26 – for a “bigger” condition (this time X must be the original X plus 1, so eg. if you want a “bigger than 50” condition, then X is 51)
27 – for a “smaller” condition
28 – for an “equal” condition


Made using TRNG 1.2.2.7.
AkyV is offline