Events and Context: Difference between revisions
m updated events table (still WIP) |
m formatting |
||
| Line 170: | Line 170: | ||
|<code>number</code> | |<code>number</code> | ||
<code>boolean</code> | <code>boolean</code> | ||
<code>unit</code> | <code>unit</code> | ||
<code>object</code> | <code>object</code> | ||
<code>array</code> - if given, emits the signal more than once for each item in the array | <code>array</code> - if given, emits the signal more than once for each item in the array | ||
|<code>trigger_signal</code> | |<code>trigger_signal</code> | ||
| Line 178: | Line 181: | ||
|<code>unit</code> | |<code>unit</code> | ||
<code>gear</code> | <code>gear</code> | ||
<code>action</code> | <code>action</code> | ||
|<code>target_tiles</code> - targeting hint | |<code>target_tiles</code> - targeting hint | ||
<code>target_units</code> - targeting hint | <code>target_units</code> - targeting hint | ||
<code>event</code> - parent event during reactions | <code>event</code> - parent event during reactions | ||
<code>flags</code> - Action.FLAG | <code>flags</code> - Action.FLAG | ||
<code>object</code> - Pathfinder if can move before taking action | <code>object</code> - Pathfinder if can move before taking action | ||
<code>string</code> - id of variant Action to be used | <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>unit_action</code> - generates a fake Context matching that of <code>event_unit_action</code>. Context cannot be modified by <code>PRE</code> events | ||
| Line 197: | Line 205: | ||
|<code>unit</code> | |<code>unit</code> | ||
(<code>gear</code> | (<code>gear</code> | ||
'''and/or''' | '''and/or''' | ||
<code>array</code> - Array[GearCore]) | <code>array</code> - Array[GearCore]) | ||
| | | | ||
| Line 207: | Line 217: | ||
|<code>flags</code> - EventMapDamage.FLAG | |<code>flags</code> - EventMapDamage.FLAG | ||
<code>object</code> - elevation to destroy down to (int) | <code>object</code> - elevation to destroy down to (int) | ||
<code>boolean</code> - set to true if terrain got destroyed | <code>boolean</code> - set to true if terrain got destroyed | ||
|<code>terrain_damage</code> | |<code>terrain_damage</code> | ||
| Line 223: | Line 234: | ||
|<code>target_unit</code> - attacked unit | |<code>target_unit</code> - attacked unit | ||
<code>unit</code> - attacking unit | <code>unit</code> - attacking unit | ||
<code>gear</code> | <code>gear</code> | ||
<code>action</code> | <code>action</code> | ||
<code>resource</code> - DeclaredAttackSummary | <code>resource</code> - DeclaredAttackSummary | ||
<code>event</code> - <code>event_unit_attack_declared</code> | <code>event</code> - <code>event_unit_attack_declared</code> | ||
|<code>flags</code> - Action.FLAG | |<code>flags</code> - Action.FLAG | ||
| Line 233: | Line 248: | ||
|<code>unit</code> | |<code>unit</code> | ||
<code>gear</code> | <code>gear</code> | ||
<code>action</code> | <code>action</code> | ||
<code>resource</code> - DeclaredAttackSummary | <code>resource</code> - DeclaredAttackSummary | ||
| | | | ||
| Line 246: | Line 263: | ||
|<code>unit</code> | |<code>unit</code> | ||
<code>number</code> | <code>number</code> | ||
|<code>category</code> - Lancer.DAMAGE_TYPE | |<code>category</code> - Lancer.DAMAGE_TYPE - default kinetic | ||
<code>object</code> - AttackRoll | <code>object</code> - AttackRoll | ||
<code>flags</code> - EventService.DAMAGE_FLAG | <code>flags</code> - EventService.DAMAGE_FLAG | ||
<code>target_unit</code> - attacker | <code>target_unit</code> - attacker | ||
<code>gear</code> - attacker gear | <code>gear</code> - attacker gear | ||
<code>action</code> - attacker Action | <code>action</code> - attacker Action | ||
|<code>damage</code> | |<code>damage</code> | ||
| Line 257: | Line 278: | ||
|<code>unit</code> | |<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 | (<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''' | '''or''' | ||
<code>array</code> - Array[Pathfinder.Step] - final path) | <code>array</code> - Array[Pathfinder.Step] - final path) | ||
|<code>resource</code> - MovementType | |<code>resource</code> - MovementType | ||
<code>flags</code> - EventUnitMove.FLAG | <code>flags</code> - EventUnitMove.FLAG | ||
<code>object</code> - SpecificAction which caused the move | <code>object</code> - SpecificAction which caused the move | ||
|<code>step</code> | |<code>step</code> | ||
| Line 275: | Line 299: | ||
|<code>buff</code> | |<code>buff</code> | ||
<code>unit</code> - the unit the buff is applied to. | <code>unit</code> - the unit the buff is applied to. | ||
<code>event</code> - the event which triggered the activation. | <code>event</code> - the event which triggered the activation. | ||
| | | | ||
| Line 301: | Line 326: | ||
|<code>string</code> - objective text | |<code>string</code> - objective text | ||
<code>array</code> - [2,4] => "Search all zones! (2/4)" | <code>array</code> - [2,4] => "Search all zones! (2/4)" | ||
<code>flags</code> | <code>flags</code> | ||
|- | |- | ||
| Line 340: | Line 366: | ||
|<code>unit</code> | |<code>unit</code> | ||
<code>gear</code> | <code>gear</code> | ||
<code>action</code> | <code>action</code> | ||
<code>array</code> - Array[SpecificAction] - actions to pick from | <code>array</code> - Array[SpecificAction] - actions to pick from | ||
|<code>boolean</code> - is overwatch? | |<code>boolean</code> - is overwatch? | ||
<code>string</code> - variant action id if mandatory | <code>string</code> - variant action id if mandatory | ||
<code>flags</code> - Action.FLAG | <code>flags</code> - Action.FLAG | ||
('''if''' Action.FLAG.TARGETS_ARE_MANDATORY: | ('''if''' Action.FLAG.TARGETS_ARE_MANDATORY: | ||
<code>target_units</code> - mandatory targets | <code>target_units</code> - mandatory targets | ||
<code>target_tiles</code> - mandatory targets) | <code>target_tiles</code> - mandatory targets) | ||
|- | |- | ||
| Line 352: | Line 384: | ||
|<code>target_tiles</code> | |<code>target_tiles</code> | ||
<code>category</code> - block id (int) | <code>category</code> - block id (int) | ||
<code>number</code> - elevation | <code>number</code> - elevation | ||
|<code>flags</code> - EventMapBlockAdd.FLAG | |<code>flags</code> - EventMapBlockAdd.FLAG | ||
Revision as of 15:17, 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
( and/or
|
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
( or
|
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?
(if Action.FLAG.TARGETS_ARE_MANDATORY:
|
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)
|