Check out our discord at https://discord.gg/3u69jMa 

Triggers and ScriptedTriggers

From SWRC Wiki
Revision as of 10:51, 2 August 2024 by Plasma (talk | contribs) (→‎Actions)
Jump to navigation Jump to search

Setup

The purpose of a Trigger is to let some action happen when it gets triggered. (captain obvious)

So what we need for our map, is a Trigger, which will be activated/triggered when the player walks in and a ScriptedTrigger to make the action happen.


Place the trigger on your map where it should get triggered.

Open up the properties of the trigger and change the colission radius width and height to fit your map/room. Remember the action will be triggered when the player touches/walks in the radius of that Trigger.


While having the properties window open for the Trigger, head to the Events tab and enter an event name. This example will use the event name "tutorial".


Now when the player walks into the trigger radius, an event with the name "tutorial" will trigger. To let the actual action happen, we need a ScriptedTrigger. So open up the actor window and navigate to Actor -> AIScript -> ScriptedSequence -> ScriptedTrigger and place it next to the normal trigger.

To keep the map nice and clean, it's recommended to put the Trigger and ScriptedTrigger right next to each other so it won't be a mess when you place lots of them.

Open properties window and go to the AIScript category. Click on the plus icon in the Actions section. You are now able to to add a new action by clicking on the "Add" button on the right border of the window.


After adding a new action, we have to select a specific one which is called "ACTION_WaitForEvent". So open up the drop down menu by clicking on ACTION_AddAmmo and select WaitForEvent. (Right on the bottom) After that, click on "New". We tell the action chain to wait for a certain event to trigger.


For ExternalEvent, add the event name of the Trigger which is "tutorial" in this case. The ScriptedTrigger waits until an event with this exact name is getting triggered.


To sum up everything so far, we created a trigger with a specific event name. It gets triggered when the player steps into the radius. The ScriptedTrigger has an action called "WaitForEvent", which then gets activated when the trigger gets activated. The rest of the action gets handled by the ScriptedTrigger.


So we have a ScriptedTrigger ready to do some action, the actual process of the actions is the same now. You minimize the first Actions tab "[0]" by clicking on the minus and click on "Add" to add a new tab for the actions.

For a list of detailed actions, see below. For this tutorial we will be using PlaySound action.


To add the actual sound, go to the sound browser and select a sound you want to use. Go back to the ScriptedTrigger, click in the Sound field and click on "Use" button on right side of the properties window. The ScriptedTrigger adds the sound automatically to the field.

This "PlaySound" action got some additional parameters, for example Volume and bWaitForFinish. While Volume is self explaining, bWaitForFinish is being used to halt the action flow until the sound finished playing, so setting this value to true will wait until the sound is done playing and afterwards continue with the action flow.


Trigger Behaviour

A Trigger can activate one or more ScriptedTriggers at the same time if the event name is the same.

One or more Triggers can activate one ScriptedTrigger when the event name is the same.

                 |------- ScriptedTrigger0
Trigger0 --------|
                 |------- ScriptedTrigger1



Trigger0 --------|
                 |------- ScriptedTrigger0
Trigger1 --------|


Trigger Properties

The trigger provides some additional customizable properties which are very handy.

Property Description
bInitiallyActive Whether the trigger is active or not. Can be toggled via scripted actions.
bTriggerOnceOnly Whether the trigger should trigger once or multiple times
Message A message to display when it gets triggered
ReTriggerDelay Delay in seconds before a retrigger can happen if bTriggerOnceOnly is set to false
TriggerType What can trigger it


TriggerType

Type Behaviour
TT_PlayerProximity Trigger is activated by player proximity
TT_PawnProximity Trigger is activated by any pawn's proximity
TT_ClassProximity Trigger is activated by actor of ClassProximityType only
TT_AnyProximity Trigger is activated by any actor in proximity
TT_Shoot Trigger is activated by player shooting it
TT_HumanPlayerProximity Trigger is activated by human player (not bot)
TT_Use Trigger is activated manually by player pressing use key ("F" by default)
TT_SquadMemberProximity Trigger is activated by squad member


Actions

Action Description
AddAmmo Adds a specified amount of ammo to selected weapon
AnimateVisorFX X
AttachToGunship Attach an actor's bone to gunship actor (used by briefing levels)
AttachToTurret Attach a bot/AIController to specified turret
BlinkHUDGrenade Flash the grenade icons on the HUD (used by first two levels)
BlinkHUDHealth Flash the health bar on the HUD (used by first two levels)
BlinkHUDShields Flash the shield bar on the HUD (used by first two levels)
BlinkHUDSquad Flash the squad icons on the HUD (used by first two levels)
BlinkHUDSquadCommandPrompt X
Briefing Makes the player frozen und locked to certain view angle
ChangeLevel X
ChangeScript X
ChangeSquadMember X
ChangeSquadStance X
ChangeZoneAudio X
ConsoleCommand Execute a console command
Crouch X
DamageInstigator X
DestroyActor X
DestroyPawn X
DisplayCriticalMessage X
DisplayMessage X
EnableAIState X
EnableAIVoice X
EnableBattleEngine X
EnableBlockedComputations X
EnableNavPtSpecial X
EnableSecurePosition X
EndSection X
FadeView X
FailMission X
FlickerActor X
ForceBattleMusic X
ForceState X
ForceVictoryFlourish X
GenerateStimulus X
GotoAction X
GotoLabel Jump to specific label name
GotoState Set the state of certain actor(s) referenced by tags
HurtActor X
IfCondition X
IfRandomPct X
Killinstigator X
Label Creates a label with specified name
MakeInvulnerable X
MoverToKeyframe X
MoveToPlayer X
MoveToPoint X
ObjectiveUpdate X
PlayAmbientSound X
PlayAnim X
PlayLocalSound X
PlayMovie X
PlayMusic X
PlayPropAnim X
PlaySound X
PlaySoundCue X
ResetFactory X
Revive Revive a certain pawn (intended for player and squad members)
ScreenFade Makes the screen fade in a certain color
SetBattleEngineParams X
SetBattleMusicMulti X
SetBlocked X
SetCanCancelMarker X
SetCannotDie Sets the property bCannotDie of a specified pawn tag to true or false
SetCollision Sets various collision properties of actor(s) with specified tag
SetHidden Hide/unhide actor(s) with specified tag
SetImuseState X
SetPawnIdle X
SetPhysics X
SetScriptPriority X
SetSightRadius X
SetTeamIndex X
SetThreat X
SetTurretUsable X
SetViewTarget X
ShakeView X
ShootTarget X
ShowActorObjectiveTracker X
ShowDebriefingScreen X
ShowMarker X
ShowMenuScreen X
ShowPrompt X
ShowTitleCardScreen X
ShowVisor X
SpawnActor X
SpawnStatusEffect X
StopFactorySpawning X
StopShooting X
SuggestEnemy X
TeleportToPoint X
TriggerEvent Trigger a certain event name
TurnTowardPlayer X
UnforceState X
WaitForAnimEnd X
WaitForEvent Wait for a certain event to trigger to start the action flow
WaitForPlayer X
WaitForRandomTimer X
WaitForTimer Wait for n seconds before continuing the action flow