Events and Context: Difference between revisions
m formatting |
m updated events table (still WIP) |
||
| Line 28: | Line 28: | ||
== Context == | == Context == | ||
Data is passed between events within a Context object, which contains any parameters an event needs in order to execute. The Context is checked by an event immediately before calling its <code>execute()</code> function to see if it is able to run. Reactions with <code>ReactionBus.TIMING. PRE</code> can modify the Context of the event they are reacting to before the event itself occurs, which allows them to change the event's behavior. | Data is passed between events within a Context object, which contains any parameters an event needs in order to execute. The Context is checked by an event immediately before calling its <code>execute()</code> function to see if it is able to run. Reactions with <code>ReactionBus.TIMING. PRE</code> can modify the Context of the event they are reacting to before the event itself occurs, which allows them to change the event's behavior. | ||
Whether the Context object contains a specific variable can be queried using the <code>context.is_property_present()</code> function. | |||
The Context objects contains the following variables: | The Context objects contains the following variables: | ||
{| class="wikitable mw-collapsible | {| class="wikitable mw-collapsible" | ||
!Variable | !Variable | ||
!Type | !Type | ||
!Additional Info | !Additional Info | ||
|- | |- | ||
|<code>action</code> | |<code>action</code> | ||
| Line 147: | Line 149: | ||
!Optional Context | !Optional Context | ||
!Reactions | !Reactions | ||
|- | |- | ||
|<code>event_combat_end</code> | |||
|<code>boolean</code> - victory? | |||
| | | | ||
|<code>combat_end</code> | |||
|- | |||
|<code>event_combat_set_state</code> | |||
|<code>string</code> | |||
<code>object</code> | |||
| | | | ||
|<code>modified_combat_state</code> | |||
|- | |||
|<code>event_combat_start</code> | |||
| | | | ||
| | | | ||
|<code>combat_start</code> | |||
|- | |||
|<code>event_combat_trigger_signal</code> | |||
|<code>string</code> | |||
|<code>number</code> | |||
<code>boolean</code> | |||
<code>unit</code> | |||
<code>object</code> | |||
<code>array</code> - if given, emits the signal more than once for each item in the array | |||
|<code>trigger_signal</code> | |||
|- | |||
|<code>event_gear_activate</code> | |||
|<code>unit</code> | |||
<code>gear</code> | |||
<code>action</code> | |||
|<code>target_tiles</code> - targeting hint | |||
<code>target_units</code> - targeting hint | |||
<code>event</code> - parent event during reactions | |||
<code>flags</code> - Action.FLAG | |||
<code>object</code> - Pathfinder if can move before taking action | |||
<code>string</code> - id of variant Action to be used | |||
|<code>unit_action</code> - generates a fake Context matching that of <code>event_unit_action</code>. Context cannot be modified by <code>PRE</code> events | |||
<code>stabilize</code> | |||
|- | |||
|<code>event_gear_destroy</code> | |||
|<code>unit</code> | |||
<code>gear</code> | |||
| | | | ||
|<code>gear_destruction</code> | |||
|- | |- | ||
|<code>event_gear_reload</code> | |||
|<code>unit</code> | |||
(<code>gear</code> | |||
'''and/or''' | |||
<code>array</code> - Array[GearCore]) | |||
| | | | ||
|<code>reload</code> | |||
|- | |||
|<code>event_map_damage</code> | |||
|<code>target_tiles</code> | |||
<code>number</code> | |||
|<code>flags</code> - EventMapDamage.FLAG | |||
<code>object</code> - elevation to destroy down to (int) | |||
<code>boolean</code> - set to true if terrain got destroyed | |||
|<code>terrain_damage</code> | |||
|- | |||
| | | | ||
| | | | ||
| Line 165: | Line 219: | ||
| | | | ||
| | | | ||
|- | |||
|<code>event_unit_attack</code> | |||
|<code>target_unit</code> - attacked unit | |||
<code>unit</code> - attacking unit | |||
<code>gear</code> | |||
<code>action</code> | |||
<code>resource</code> - DeclaredAttackSummary | |||
<code>event</code> - <code>event_unit_attack_declared</code> | |||
|<code>flags</code> - Action.FLAG | |||
|<code>attack</code> | |||
|- | |||
|<code>event_unit_attack_declared</code> | |||
|<code>unit</code> | |||
<code>gear</code> | |||
<code>action</code> | |||
<code>resource</code> - DeclaredAttackSummary | |||
| | |||
|<code>attack_declared</code> | |||
|- | |||
|<code>event_unit_brace</code> | |||
|<code>unit</code> | |||
| | | | ||
|<code>brace</code> | |||
|- | |||
|<code>event_unit_damage</code> | |||
|<code>unit</code> | |||
<code>number</code> | |||
|<code>category</code> - Lancer.DAMAGE_TYPE, default kinetic | |||
<code>object</code> - AttackRoll | |||
<code>flags</code> - EventService.DAMAGE_FLAG | |||
<code>target_unit</code> - attacker | |||
<code>gear</code> - attacker gear | |||
<code>action</code> - attacker Action | |||
|<code>damage</code> | |||
|- | |||
|event_unit_move | |||
|<code>unit</code> | |||
(<code>target_tiles</code> - path or single tile to path to. in <code>PRE</code> reactions to <code>step</code>, holds the tile the unit is about to step into | |||
'''or''' | |||
<code>array</code> - Array[Pathfinder.Step] - final path) | |||
|<code>resource</code> - MovementType | |||
<code>flags</code> - EventUnitMove.FLAG | |||
<code>object</code> - SpecificAction which caused the move | |||
|<code>step</code> | |||
<code>entire_movement</code> | |||
|} | |} | ||
| Line 173: | Line 271: | ||
!Required Context | !Required Context | ||
!Optional Context | !Optional Context | ||
|- | |- | ||
|<code>event_buff_activate</code> | |||
|<code>buff</code> | |||
<code>unit</code> - the unit the buff is applied to. | |||
<code>event</code> - the event which triggered the activation. | |||
| | | | ||
|- | |||
|<code>event_camera_move</code> | |||
|<code>target_tiles</code> - moves so it can see all these | |||
|<code>number</code> - move speed in milliseconds, 0 by default | |||
<code>flags</code> | |||
|- | |||
|<code>event_camera_set_locked</code> | |||
|<code>boolean</code> | |||
|<code>flags</code> | |||
|- | |||
|<code>event_combat_banner_intro</code> | |||
| | | | ||
| | | | ||
|- | |||
|<code>event_combat_highlight_ui</code> | |||
|<code>boolean</code> | |||
<code>string</code> - compcon_id(?) | |||
|<code>flags</code> - GoldenPathHighlight.AUTO_CLEAR | |||
|- | |||
|<code>event_combat_set_objective</code> | |||
|<code>number</code> - index of objective to change | |||
<code>boolean</code> - is complete? | |||
|<code>string</code> - objective text | |||
<code>array</code> - [2,4] => "Search all zones! (2/4)" | |||
<code>flags</code> | |||
|- | |||
|<code>event_combat_set_round_max</code> | |||
|<code>number</code> | |||
| | | | ||
|- | |||
|<code>event_combat_set_triggers_enabled</code> | |||
|<code>string</code> - name of trigger group | |||
<code>boolean</code> | |||
| | | | ||
|- | |- | ||
|<code>event_delay</code> | |||
|<code>number</code> - milliseconds | |||
| | | | ||
|- | |||
|<code>event_dialogue</code> | |||
|<code>string</code> - conversation id | |||
|<code>unit</code> - for dynamic text | |||
<code>target_units</code> - for dynamic text | |||
|- | |||
|<code>event_dialogue_bark</code> | |||
|<code>unit</code> | |||
<code>string</code> - line id '''or''' raw text | |||
|<code>target_units</code> - for dynamic text | |||
<code>flags</code> | |||
|- | |||
|<code>event_dialogue_emoji</code> | |||
|<code>unit</code> | |||
<code>category</code> - Emoji.TYPE | |||
|<code>number</code> - length to show in milliseconds | |||
|- | |||
|<code>event_dialogue_face</code> | |||
|<code>unit</code> | |||
<code>target_tiles</code> - tiles to look at | |||
| | | | ||
|- | |- | ||
| | |<code>event_gear_choose_and_use</code> | ||
| | |<code>unit</code> | ||
<code>gear</code> | |||
<code>action</code> | |||
<code>array</code> - Array[SpecificAction] - actions to pick from | |||
|<code>boolean</code> - is overwatch? | |||
<code>string</code> - variant action id if mandatory | |||
<code>flags</code> - Action.FLAG | |||
('''if''' Action.FLAG.TARGETS_ARE_MANDATORY: | |||
<code>target_units</code> - mandatory targets | |||
<code>target_tiles</code> - mandatory targets) | |||
|- | |||
|<code>event_map_block_add</code> | |||
|<code>target_tiles</code> | |||
<code>category</code> - block id (int) | |||
<code>number</code> - elevation | |||
|<code>flags</code> - EventMapBlockAdd.FLAG | |||
|- | |||
|<code>event_map_block_remove</code> | |||
|<code>target_tiles</code> | |||
<code>number</code> - elevation | |||
|<code>flags</code> - EventMapBlockAdd.FLAG | |||
|- | |||
|<code>event_map_dangerous</code> | |||
|<code>unit</code> | |||
<code>category</code> - Lancer.DAMAGE_TYPE - type of damage to do on failure | |||
|<code>resource</code> - MovementType | |||
|- | |||
|<code>event_map_doodad_add</code> | |||
|<code>target_tiles</code> | |||
<code>category</code> - doodad id | |||
|<code>number</code> - rotation (0-3) | |||
<code>flags</code> | |||
|- | |||
| | | | ||
| | | | ||
| | | | ||
|} | |} | ||
Revision as of 15:12, 27 July 2026
The Events System
Lancer is a system famous for its numerous reactions and counter-reactions. In Lancer Tactics, this is handled by generating EventCore objects and then queueing them to each other in one big stack. EventCores each have an EventBase resource in their base variable, which defines the type of event it is. The EventCore object is typically called activation, event or core.
The execution sequence for running a particular event is:
- Run the
execute_preblock()function for the event's EventBase:
• For events which can be reacted to, fetch the events for every reaction with timing
ReactionBus.TIMING.PRE.• The reaction events are ordered according to their priority (low to high).
• Loop through the reaction events and run the whole execution sequence for each reaction event in turn.
- If the event is aborted (
event.aborted == true), or the Context object does not contain the required data, execution stops here. - Run the
execute()function for the event's EventBase:
• Executes any functionality the event has (for example, clearing heat for an
event_unit_cool).• For events which can be reacted to, fetch the events for every reaction with timing
ReactionBus.TIMING.POST.• The reaction events are ordered according to their priority (low to high). • Loop through the reaction events and run the whole execution sequence for each reaction event in turn.
- Run child events:
• These are events queued to the EventCore with
event.queue_event().• The child events are ordered according to their priority (low to high).
• Loop through the child events and run the whole execution sequence for child event in turn.
TODO - provide an example
Olive's devlog on the subject (which you should check out just for the meme).
Context
Data is passed between events within a Context object, which contains any parameters an event needs in order to execute. The Context is checked by an event immediately before calling its execute() function to see if it is able to run. Reactions with ReactionBus.TIMING. PRE can modify the Context of the event they are reacting to before the event itself occurs, which allows them to change the event's behavior.
Whether the Context object contains a specific variable can be queried using the context.is_property_present() function.
The Context objects contains the following variables:
| Variable | Type | Additional Info |
|---|---|---|
action
|
Action | See Actions and Reactions. |
array
|
Array | |
boolean
|
bool | |
buff
|
BuffCore | |
category
|
Variant | Represents an enum or id string. |
category_int
|
int | The category variable, typed as an int. Setting this will modify the category variable.
|
category_string
|
StringName | The category variable, typed as a StringName. Setting this will modify the category variable.
|
event
|
EventCore | Usually the parent event of the current event. |
flags
|
Array | Usually contains enums. |
gear
|
GearCore | |
map
|
MapState | Always populated. |
number
|
int | |
object
|
Variant | |
resource
|
Resource | |
string
|
String | |
target_tiles
|
Array[Vector2i] | |
target_tile
|
Vector2i | target_tiles[0], or Tile.INVALID if it is empty. Setting this will add the Vector2i to target_tiles at index 0.
|
target_units
|
Array[Unit] | |
target_unit
|
Unit | target_units[0], or null if it is empty. Setting this will add the Unit to target_units at index 0.
|
unit
|
Unit |
Event Creation
A Context object is usually created from a dictionary, where each key corresponds to the name of a variable:
var context = Context.create({
string = "Example Context",
boolean = true
})
Events are almost always created using the functions on their parent event, although it is possible to create one directly to make a virtual event not queued to any other event.
An event can be queued to the activation event with:
activation.queue_event(&"event_example_id", {
string = "Example Event",
boolean = true
}, Priority.ACTIVATE.late_followup)
Events can also be executed immediately:
await activation.execute_event(&"event_example_id", {
string = "Example Event",
boolean = true
})
As with any other await function, check your references are not null before proceeding.
Event Types
The scripts defining the game's events can be found in the res://content/events/ folder.
TODO - fill these out
Events with Reactions
| Event ID | Required Context | Optional Context | Reactions |
|---|---|---|---|
event_combat_end
|
boolean - victory?
|
combat_end
| |
event_combat_set_state
|
string
|
modified_combat_state
| |
event_combat_start
|
combat_start
| ||
event_combat_trigger_signal
|
string
|
number
|
trigger_signal
|
event_gear_activate
|
unit
|
target_tiles - targeting hint
|
unit_action - generates a fake Context matching that of event_unit_action. Context cannot be modified by PRE events
|
event_gear_destroy
|
unit
|
gear_destruction
| |
event_gear_reload
|
unit
( |
reload
| |
event_map_damage
|
target_tiles
|
flags - EventMapDamage.FLAG
|
terrain_damage
|
event_unit_attack
|
target_unit - attacked unit
|
flags - Action.FLAG
|
attack
|
event_unit_attack_declared
|
unit
|
attack_declared
| |
event_unit_brace
|
unit
|
brace
| |
event_unit_damage
|
unit
|
category - Lancer.DAMAGE_TYPE, default kinetic
|
damage
|
| event_unit_move | unit
( |
resource - MovementType
|
step
|
Other Events
| Event ID | Required Context | Optional Context |
|---|---|---|
event_buff_activate
|
buff
|
|
event_camera_move
|
target_tiles - moves so it can see all these
|
number - move speed in milliseconds, 0 by default
|
event_camera_set_locked
|
boolean
|
flags
|
event_combat_banner_intro
|
||
event_combat_highlight_ui
|
boolean
|
flags - GoldenPathHighlight.AUTO_CLEAR
|
event_combat_set_objective
|
number - index of objective to change
|
string - objective text
|
event_combat_set_round_max
|
number
|
|
event_combat_set_triggers_enabled
|
string - name of trigger group
|
|
event_delay
|
number - milliseconds
|
|
event_dialogue
|
string - conversation id
|
unit - for dynamic text
|
event_dialogue_bark
|
unit
|
target_units - for dynamic text
|
event_dialogue_emoji
|
unit
|
number - length to show in milliseconds
|
event_dialogue_face
|
unit
|
|
event_gear_choose_and_use
|
unit
|
boolean - is overwatch?
|
event_map_block_add
|
target_tiles
|
flags - EventMapBlockAdd.FLAG
|
event_map_block_remove
|
target_tiles
|
flags - EventMapBlockAdd.FLAG
|
event_map_dangerous
|
unit
|
resource - MovementType
|
event_map_doodad_add
|
target_tiles
|
number - rotation (0-3)
|