Trigger

From Dragon Age Toolset Wiki
Jump to: navigation, search
Area topics

Triggers are polygonal shapes painted onto areas that receive an event when a creature enters or exits it, which generally is then processed by a script to perform some action.

A trigger's volume object in the area editor

Creating triggers in the toolset

Area triggers can be painted using the trigger icon (green diamond) in the designer toolset, onto an area that has a layout.

To create a new trigger, either select File -> New -> Trigger from the top menu or right click on any icon in the palette and choose New -> Trigger.

After selecting a trigger from the palette, paint it by clicking on the terrain one point at a time. Each point will become a corner of a mostly flat surface. Double clicking will connect that point to the first point placed, and finish it. See the Area page for more detail on how to paint area triggers in an area.

Note that while the displayed plane of the trigger area may dip below the surface of the floor it's placed on, the perimeter extends upward invisibly and will still detect when something passes over one of its edges. A creature can't slip inside a trigger area by stepping "over" it.

Area Transitions

To make a trigger into an area transition, right click on trigger in the module tree view and choose Open Resource. You will need to check it out to modify it, if you haven't already. Select the Variable field in the Attributes section and click on the elipses (Ellipsis.png) icon on the right side.

The variables we need are:

  • TRIGGER_AT_DEST_TAG - the tag for the waypoint that the trigger teleports the player to
  • TRIGGER_AT_DEST_AREA_TAG - the tag for the area the waypoint is in, if it isn't the current area.
  • TRIGGER_AT_DEST_AREALIST_TAG - the tag for the arealist the area is in if it is not in the current arealist. !!not seeing this one in the toolset, is it still used?!!

Trigger Scripts

Any other functionality for a trigger must be put in a script manually. The trigger_core.nss script (which may change) in the _Core Scripts directory is a good template for such a script.

Without any modifications this script performs the area transition. The code to do so is in a switch statement that looks for the event matching the predefined constant EVENT_TYPE_ENTER.

Note that there is an if statement in here that checks to see if it was the player who set off the trigger, (it also checks to see if there was an area transition tag set). If you want to have the trigger do something only when the player enters it you should do a similar check, otherwise it will activate whenever any creature enters.

Example: Have a cutscene play, but only the first time the player enters the trigger.

    if(IsPartyMember(oCreature)) 
    { 
      resource rCutscene = R"mycutscene.cut";
      LoadCutscene(rCutscene);
      PlayCutscene(oCreature);
      DestroyObject(OBJECT_SELF, 0);
    }

If you do create a custom trigger script you should call the following after the switch statement:

    HandleEvent(ev, RESOURCE_SCRIPT_TRIGGER_CORE);

This ensures that anything your custom script doesn't process still gets processed correctly by the default script.

Once you have created your script, click on the "script" field of the attributes of the trigger, and then choose your script from the ellipsis (Ellipsis.png) browser.

Note that triggers do not behave as expected when you use SetObjectActive(OBJECT_SELF, FALSE);. This function sets the trigger to inactive, but the trigger will still fire when inactive. Therefore any trigger script that needs to account for whether the trigger is active should be surrounded by an if(GetObjectActive(OBJECT_SELF)) statement to explicitly test whether it should fire. Alternately, if the trigger is never intended to fire again, use DestroyObject(OBJECT_SELF, 0); instead of setting it inactive.

Traps

Triggers are similar to how traps were defined in Neverwinter Nights, but in Dragon Age it is preferred to construct traps using placeable floor plates as triggers instead. This makes traps easier for the player to interact with in a realistic manner.

See the Trap system for details on how to handle traps.

Talk triggers

A talk trigger is a trigger that initiates a conversation. This occurs so frequently in Dragon Age's game design that a generic script, gen00tr_talk.nss, is available for this purpose. To use it with a trigger, set the trigger's "Script" property to "gen00tr_talk" and set the "Variable 2da" property to "var_trigger_talk".

The following set of variables are available in the var_trigger_talk variable 2da:

Variable name Type Default Description
TRIG_TALK_ACTIVE_FOR_FLAG int triggers only if a specific plot/flag is active - works with TRIG_TALK_ACTIVE_FOR_PLOT
TRIG_TALK_ACTIVE_FOR_PLOT string triggers only if a specific plot/flag is active - works with TRIG_TALK_ACTIVE_FOR_FLAG
TRIG_TALK_DIALOG_OVERRIDE resource a dialog file to override the default one for the NPC. Type it in the format of "gen000_example.dlg" (without the quotes)
TRIG_TALK_INACTIVE_FOR_FLAG and FLAG2 int triggers only if a specific plot/flag is inactive - works with TRIG_TALK_ACTIVE_FOR_PLOT
TRIG_TALK_INACTIVE_FOR_PLOT and PLOT2 string triggers only if a specific plot/flag is inactive - works with TRIG_TALK_ACTIVE_FOR_FLAG
TRIG_TALK_LISTENER string a string for an NPC listener. Should be used for ambient conversations
TRIG_TALK_REPEAT int 1 so the trigger can re-fire, 0 - the trigger fires only once
TRIG_TALK_SET_FLAG and FLAG2 int sets the plot and flag when triggered, works with TRIG_TALK_SET_PLOT
TRIG_TALK_SET_PLOT and PLOT2 string sets the plot and flag when triggered, works with TRIG_TALK_SET_FLAG
TRIG_TALK_SPEAKER string NPC initiating the dialog - this is the only mandatory field

Variables

The following set of variables are available if you're using the basic var_trigger 2da:

Variable name Type Default Description
TRIGGER_ACTIVATE_TEAM_HELP int Activates team-help system on a team of creatures using SetLocalVarOnTeam(oCreature, TRIGGER_ACTIVATE_TEAM_HELP, AI_HELP_TEAM_STATUS, 1);
TRIGGER_ACTIVATE_TEAM_STATIONARY_HARD int Activates a team to be stationary (AI system) using SetLocalVarOnTeam(oCreature, TRIGGER_ACTIVATE_TEAM_STATIONARY_HARD, AI_FLAG_STATIONARY, 2);
TRIGGER_ACTIVATE_TEAM_STATIONARY_SOFT int Activates a team to be stationary (AI system) using SetLocalVarOnTeam(oCreature, TRIGGER_ACTIVATE_TEAM_STATIONARY_SOFT, AI_FLAG_STATIONARY, 1);
TRIGGER_AT_DEST_AREA_TAG string The tag of the area that this trigger sends the player to (area transition)
TRIGGER_AT_DEST_TAG string The tag of the waypoint within the destination area this trigger sends the player to (area transition)
TRIGGER_COUNTER_1 to 3 int
TRIGGER_DO_ONCE_A and B int
TRIGGER_ENCOUNTER_TEAM int
TRIGGER_PARTY_TRIGGER_LOCATION int
TRIGGER_ROOM_TEXT int

These are in the var_trigger_ambient 2da, for use with the gentr_ambient.nss script:

Variable name Type Default Description
AMBIENT_ANIM_FREQ_OVERRIDE float If non-zero, takes precedence over AMBIENT_ANIM_FREQ value set on the creature's template. Format is a float (x.y) to play a random number of animations between x and y. Specify -1.0 to play all animations (in order) listed in ambient_ai.xls.
AMBIENT_ANIM_OVERRIDE_COUNT int
AMBIENT_ANIM_PATTERN_OVERRIDE int Index into ambient_ai.xls. If non-zero, this value takes precedence over the AMBIENT_ANIM_PATTERN value set on the creature's template.
AMBIENT_TARGET_FILTER string The creature entering or in the trigger will have its ambient behaviour overridden if its tag appears somewhere in this comma-separated list.
AMBIENT_TRIGGER_FILTER string The ambient behaviour of the target creature will be overridden when a creature with a tag somewhere in this coma-separated list enters the trigger. Use <hero> to specify the player. Will default to AMBIENT_TARGET_FILTER if blank.

Properties

General
Comments
Group The group to which this trigger belongs. Used when the trigger is used as a trap trigger.
Resource Name A unique string identifier the toolset and the game both use to refer to this resource.
Tag A non-unique string identifier used mostly by scripts and other resources to refer to this resource.
Attributes
Script Event script assigned to the resource
Target Waypoint
Variable 2da Allows selection of a variable table. Only the values in the table can be set and retrieved by scripting.
Variables Displays the table selected in the variable 2da field. Allows initial values to be defined.


Language: English  • русский