If you want to help us maintaining this wiki, check out our discord server: https://discord.gg/3u69jMa 

Basics of Triggers and ScriptedTriggers

From SWRC Wiki
Jump to navigation Jump to search

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.


Trigger1.PNG


Place both actors on your map where the action should be going on. 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 more than 20 of them.

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


Trigger2.PNG


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".


Trigger3.PNG


Now when the player walks into the trigger's radius, a event with the name "tutorial" will be triggered. To let the actual action happen we need the ScriptedTrigger. So open up the properties and head to the AIScript tab and click on the plus icon at 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.


Trigger4.PNG


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".


Trigger5.PNG


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 triggered. 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.

Most if the ACTION names are self explaining, this tutorial will stick with the most common and default actions. For example "PlaySound".


Trigger6.PNG


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 to play, so setting this value to true will wait until the sound is done playing and afterwards continue with the action flow.


Important

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 --------|


Actions

All Actions explained