This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

WorldTriggers

Overview

The World Trigger System is a simple, but robust, pattern of using Trigger Actions as reactors, or nerve endings, to evaluate and fire off a triggering event to a World Trigger.

Using trigger channels, the Trigger Actions and World Triggers can target and respond to specific events, regardless of if they are arranged on the same entity.

The power of the pattern of Trigger Actions and World Triggers is that nearly any Trigger Action, can trigger any World Trigger.

Their extensibility allows for easy implementation of unique features, while allowing the underlying class structure to process, and handle, the interaction between the two component types.

Trigger Actions

The Sensory component of the World Trigger pattern. TAs (Trigger Actions) receive/or monitor for changes in the world state, then, if everything is right, fires off to the receiving World Trigger to enact the outcome back into the world. Hence the naming: “World” triggers.

There are a couple extended TAs to create some common sub-types for regular patterns in use: Interact Trigger Actions, and Collision Trigger Actions. They both follow the same triggering process, but have an additional layer of functionality to interface with Interaction, or Collision/Triggering processing.

World Triggers

The Output component of the World Trigger Pattern. WTs (World Triggers) receive Trigger or Reset events from the TAs, and process how they will affect the world state.

They can be as simple at toggling an entity on and off. Or as complex as holding a multi-staged Activation/Deactivation tree to display a changing piece of environment over multiple stages of growth or destruction.

Wts never need to know what is driving the reason for firing. They simply do the act of changing the world environment. Hence the naming: “World” triggers.

Setup

Refer to the Interaction Set Up Guide in Get Started section.

Features

1 - Trigger Actions

Image showing a Player Interact TriggerAction component, as seen in the Entity Inspector.

Trigger Actions Overview

Functionality

Action Types

Environmental

  • Difficulty (Game, Dungeon, Quest, Boss)
  • Population (AG Village)
  • Time
  • Record
  • Dungeon In/Complete
  • Quest In/Complete
  • Has Quest
  • Weather
  • OnStart
  • Player Stats
  • Player HasItem
  • Every Seconds
  • OnQuestStart
  • OnQuestEnd

Collision Fields

  • Proximity
  • Correct InWorldObject Conditions
  • Unit Stats
  • Unit Inventory
  • Pulse React

On Unit

  • OnDeath
  • Has/HasNot Stats
  • Has/HasNot Item/Inventory
  • Has/HasNot Equip

Interact Trigger Actions

Specific Trigger Actions activated by The Interact Input.

Passes Source interactor to DoActonFromInteractor, which fires the regular DoAction.

Interact Types

Self Firing

  • World Item Interact
  • Carry
  • Pilot Unit
  • Bonfire/Menu Open

Triggering

  • Select
  • Give Item
  • Channel
  • Craft

Using Trigger Actions


API

//! Override to establish your own DoAction process
//! Call Parent DoAction to see if Action Succeeds. Then use returned bool to process final behaviour.
virtual bool DoAction();
//! Override to establish your own ResetAction process
//! Call Parent ResetAction to see if Reset Succeeds. Then use returned bool to process final behaviour.
virtual bool DoResetAction();

//! Override to establish your own evaluation criteria.
virtual bool EvaluateAction() { return true; };
//! Override to establish your own reset evaluation criteria.
virtual bool EvaluateResetAction() { return true; };

Extending Trigger Actions

1.1 - Record Trigger Action

Image showing the RecordTriggerAction component, as seen in the Entity Inspector.

Record Trigger Action Overview

A component that triggers when the a defined record is changed to a certain value. Useful for connecting events on story progression flags, world variables etc.

Functionality

Inheriting from the RecordKeeperComponent’s Incoming Event Bus. It will automatically take in record updates and call TriggerActionComponent’s DoAction() if the changed record matches the local record’s name and value saved on the component.


Using Record Trigger Action

  1. Create an Entity and add the Record Trigger Action Component in the inspector.
  2. Set the Trigger Channel to the channel where you want your trigger to fire.
  3. Define the record name, this is the name of the record you are looking at for changes.
  4. Define the record value, set this value to what value the recordName needs to be at in order to trigger the action.

API

From TriggerActionComponent

//! Returns true if the values of the changed record's data is the same as our local record (This runs when DoAction() is called).
//! Override to establish your own evaluation criteria.
virtual bool EvaluateAction() { return true; };

From RecordKeeperIncomingEvents

//! Calls TriggerActionComponent's Definition of DoAction() when the defined record is changed.
//! Override to trigger when your record is changed.
virtual void RecordChanged() { return true; };

Extending Record Trigger Action

2 - World Triggers

Image showing a PrintLog World Trigger component, as seen in the Entity Inspector.

World Trigger Overview

Functionality

World Triggers do the actual processing once an input fires.

Triggers can Trigger Other Triggers.

Triggers can have Reset Enabled or Disabled.

Reset can be by toggle, or by direct command.

Repeated Activations can just keep firing the same Trigger if valid.

Triggers have logic for:

  • Trigger

  • Sets Triggered

  • Updates Listening

  • Reset

  • Removes Triggered

  • Updates Listening

Some can have boolean logic like “Any“ or “All“ as requirements to finally activate. Allowing the need for multiple Switches.

TriggerTypes

Basic Types

  • Toggle (On/Off)
  • ProgressionSwitch (Count Up/Down)
  • Make Sound
  • Play/Stop Cinematic/Timeline
  • Dialogue
  • Item Spawn
  • Spawn Object
  • Spawn Pulse
  • GS_Action
  • SetRecord
  • Play/Stop Animation

Unit Facing

Has various means of targeting a Unit.

  • Equip Item
  • Affect Stats
  • Give Item
  • Status Effect
  • Level Up
  • Change Stage (player only)
  • Teleport

Repeater/Boolean Types

  • Invert Trigger
  • Any/All Trigger
  • Timeout Trigger

Using World Triggers


API

// WorldTriggerIncomingEvents
//! Trigger intakes a list of channels to determine if it should fire.
//! If onlyOnce, will not fire a second time.
//! Call parent to determine if Trigger goes through before handling additional logic.
bool Trigger(AZStd::unordered_set<AZStd::string> channels) override;

//! Reset takes channels like Trigger, but processes the reveral of what the Trigger did.
//! If can't reset, will not fire.
//! Call parent to determine if Reset goes through before handling additional logic.
bool Reset(AZStd::unordered_set<AZStd::string> channels) override;


// Local Methods
// Utility that quickly checks for channels being fired.
virtual bool EvaluateChannels(AZStd::unordered_set<AZStd::string> channels);
virtual bool IsTriggered() { return isTriggered; };

Extending World Triggers