Events and Context: Difference between revisions
m finished first two event types table |
m formatting |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 17: | Line 17: | ||
• For events which can be reacted to, fetch the events for every reaction with timing <code>ReactionBus.TIMING.POST</code>. | • For events which can be reacted to, fetch the events for every reaction with timing <code>ReactionBus.TIMING.POST</code>. | ||
• 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.</blockquote> | • 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.</blockquote> | |||
* Run child events: | * Run child events: | ||
<blockquote>• These are events queued to the EventCore with <code>event.queue_event()</code>. | <blockquote>• These are events queued to the EventCore with <code>event.queue_event()</code>. | ||
| Line 235: | Line 237: | ||
|<code>unit</code> | |<code>unit</code> | ||
<code>string</code> - kit id | <code>string</code> - kit id | ||
<code>number</code> - action index | <code>number</code> - action index | ||
|<code>target_tiles</code> | |<code>target_tiles</code> | ||
<code>target_units</code> | <code>target_units</code> | ||
<code>flags</code> - Action.FLAG | <code>flags</code> - Action.FLAG | ||
<code>gear</code> | <code>gear</code> | ||
<code>action</code> | <code>action</code> | ||
|executes an <code>event_gear_activate</code> which in turn runs <code>unit_action</code> reactions with a context matching this event | |executes an <code>event_gear_activate</code> which in turn runs <code>unit_action</code> reactions with a context matching this event | ||
| Line 246: | Line 252: | ||
|<code>unit</code> | |<code>unit</code> | ||
<code>category</code> | <code>category</code> | ||
<code>flags</code> | <code>flags</code> | ||
|<code>string</code> - persistent id of source gear | |<code>string</code> - persistent id of source gear | ||
| Line 295: | Line 302: | ||
|<code>unit</code> | |<code>unit</code> | ||
<code>target_tiles</code> - tile collided with | <code>target_tiles</code> - tile collided with | ||
<code>event</code> | <code>event</code> | ||
| | | | ||
| Line 368: | Line 376: | ||
|<code>unit</code> - origin unit | |<code>unit</code> - origin unit | ||
<code>gear</code> - origin gear | <code>gear</code> - origin gear | ||
<code>action</code> - origin action | <code>action</code> - origin action | ||
<code>string</code> - combat state key for success boolean to be saved to | <code>string</code> - combat state key for success boolean to be saved to | ||
|<code>forced_save</code> | |<code>forced_save</code> | ||
| Line 425: | Line 435: | ||
<code>boolean</code> - is complete? | <code>boolean</code> - is complete? | ||
|<code>string</code> - objective text | |<code>string</code> - objective text | ||
<code>array</code> - [2,4] | <code>array</code> - [2,4] -> "Search all zones! (2/4)" | ||
<code>flags</code> | <code>flags</code> | ||
| Line 512: | Line 522: | ||
|<code>target_tiles</code> | |<code>target_tiles</code> | ||
<code>target_units</code> | <code>target_units</code> | ||
<code>boolean</code> - wait for effect to end | <code>boolean</code> - wait for effect to end | ||
|- | |- | ||
| Line 557: | Line 568: | ||
|<code>unit</code> | |<code>unit</code> | ||
<code>target_units</code> | <code>target_units</code> | ||
<code>boolean</code> - attach or release | <code>boolean</code> - attach or release | ||
| | | | ||
| Line 600: | Line 612: | ||
|(<code>target_tiles</code> - Array[Vector2i] - tiles for Pathfinder | |(<code>target_tiles</code> - Array[Vector2i] - tiles for Pathfinder | ||
'''or''' | '''or''' | ||
<code>number</code> - movement budget) | <code>number</code> - movement budget) | ||
<code>array</code> - Array[Vector2i] - knockback origin tiles | <code>array</code> - Array[Vector2i] - knockback origin tiles | ||
<code>unit</code> - origin unit | <code>unit</code> - origin unit | ||
<code>gear</code> - origin gear | <code>gear</code> - origin gear | ||
<code>action</code> - origin action | <code>action</code> - origin action | ||
|- | |- | ||
| Line 609: | Line 626: | ||
|<code>unit</code> | |<code>unit</code> | ||
<code>string</code> | <code>string</code> | ||
<code>category</code> - FetcherNameType.WHICH_NAME | <code>category</code> - FetcherNameType.WHICH_NAME | ||
| | | | ||
| Line 615: | Line 633: | ||
|<code>unit</code> | |<code>unit</code> | ||
<code>category</code> - Statblock.PROP | <code>category</code> - Statblock.PROP | ||
<code>number</code> | <code>number</code> | ||
| | | | ||
| Line 621: | Line 640: | ||
|<code>unit</code> | |<code>unit</code> | ||
<code>string</code> - sitrep tag to add/remove | <code>string</code> - sitrep tag to add/remove | ||
<code>boolean</code> | <code>boolean</code> | ||
| | | | ||
| Line 642: | Line 662: | ||
|<code>string</code> - reinforcement group id or name | |<code>string</code> - reinforcement group id or name | ||
<code>number</code> - number of units to deploy | <code>number</code> - number of units to deploy | ||
<code>array</code> - Array[ZoneCore] | <code>array</code> - Array[ZoneCore] | ||
|<code>flags</code> - EventZoneReinforce.FLAG | |<code>flags</code> - EventZoneReinforce.FLAG | ||
| Line 648: | Line 669: | ||
|<code>array</code> - Array[ZoneCore] | |<code>array</code> - Array[ZoneCore] | ||
<code>category</code> - Zone.TYPE | <code>category</code> - Zone.TYPE | ||
<code>boolean</code> - is visible | <code>boolean</code> - is visible | ||
|<code>string</code> - zone name | |<code>string</code> - zone name | ||
| Line 664: | Line 686: | ||
|<code>array</code> - Array[ZoneCore] | |<code>array</code> - Array[ZoneCore] | ||
<code>category</code> - Zone.TYPE | <code>category</code> - Zone.TYPE | ||
<code>flags</code> | <code>flags</code> | ||
|<code>string</code> - zone name | |<code>string</code> - zone name | ||
| Line 677: | Line 700: | ||
| | | | ||
|- | |- | ||
|event_zone_usable | |<code>event_zone_usable</code> | ||
|<code>array</code> - Array[ZoneCore] | |<code>array</code> - Array[ZoneCore] | ||
<code>string</code> - name of action | <code>string</code> - name of action | ||
<code>object</code> - desc of action (String) | <code>object</code> - desc of action (String) | ||
|<code>target_units</code> - unit whitelist | |<code>target_units</code> - unit whitelist | ||
Latest revision as of 17:49, 27 July 2026
The Events System
[edit | edit source]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.
Olive's devlog on the subject (which you should check out just for the meme).
Execution Sequence
[edit | edit source]- 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.
Context
[edit | edit source]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
[edit | edit source]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
[edit | edit source]The scripts defining the game's events can be found in the res://content/events/ folder.
Events with Reactions
[edit | edit source]| 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_round_new
|
new_round
| ||
event_turn_end
|
unit
|
end_turn
| |
event_turn_start
|
unit
|
new_turn
| |
event_unit_action
|
unit
|
target_tiles
|
executes an event_gear_activate which in turn runs unit_action reactions with a context matching this event
|
event_unit_apply_status
|
unit
|
string - persistent id of source gear
|
statuses_changed (only PRE)
|
event_unit_attack
|
target_unit - attacked unit
|
flags - Action.FLAG
|
attack
|
event_unit_attack_declared
|
unit
|
attack_declared
| |
event_unit_boost
|
unit
|
event
|
boost
|
event_unit_brace
|
unit
|
brace
| |
event_unit_clear_status
|
unit
|
string - persistent id of source gear
|
statuses_changed (only POST)
|
event_unit_collide
|
unit
|
collision
| |
event_unit_cool
|
unit
|
clear_heat
| |
event_unit_damage
|
unit
|
category - Lancer.DAMAGE_TYPE - default kinetic
|
damage
|
event_unit_die
|
unit
|
flags - EventService.DIE_FLAG
|
death
|
event_unit_exile
|
unit
|
string - persistent id of source gear
|
exiled
|
event_unit_intangible
|
unit
|
string - persistent id of source gear
|
intangible
|
event_unit_lose_hidden
|
unit
|
lose_hidden
| |
event_unit_meltdown
|
unit
|
meltdown
| |
event_unit_move
|
unit
( or
|
resource - MovementType
|
step
|
event_unit_save
|
target_unit
|
unit - origin unit
|
forced_save
|
event_unit_spawn
|
unit
|
number - direction (0-3)
|
unit_spawn
|
event_unit_stress
|
unit
|
flags - EventService.STRESSED_FLAG
|
stressed
|
event_unit_structure
|
unit
|
flags - EventService.STRUCTURED_FLAG
|
structured
|
Other Events
[edit | edit source]| 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)
|
event_map_doodad_remove
|
target_tiles
|
|
event_map_effect
|
string - FXGroup id
|
target_tiles
|
event_map_setpiece_add
|
target_tiles
|
number - rotation (0-3)
|
event_map_setpiece_remove
|
target_tiles
|
|
event_map_set_water
|
number - elevation
|
|
event_map_text
|
string
|
flags
|
event_map_weather_toggle
|
string - weather id
|
|
event_music_play
|
string - fmod event path
|
flags
|
event_music_stop
|
||
event_round_end
|
||
event_round_set_next_faction
|
category - Faction.SIDE
|
|
event_unit_attach
|
unit
|
|
event_unit_deploy
|
resource - UnitCore
|
number - direction (0-3)
|
event_unit_extract
|
unit
|
flags - EventUnitExtract.FLAG
|
event_unit_faction
|
unit
|
flags - flags[0] is Lancer.UNTIL
|
event_unit_heal
|
unit
|
|
event_unit_mount
|
unit
|
flags
|
event_unit_overkill
|
unit
|
|
event_unit_overshield
|
unit
|
|
event_unit_pick_move
|
target_unit
|
(target_tiles - Array[Vector2i] - tiles for Pathfinder
or
|
event_unit_rename
|
unit
|
|
event_unit_set_stat
|
unit
|
|
event_unit_sitrep_tag
|
unit
|
|
event_unit_teleport
|
unit
|
|
event_zone_equip
|
string - kit id
|
|
event_zone_launch
|
array - Array[ZoneCore]
|
|
event_zone_reinforce
|
string - reinforcement group id or name
|
flags - EventZoneReinforce.FLAG
|
event_zone_setup
|
array - Array[ZoneCore]
|
string - zone name
|
event_zone_set_guides
|
array - Array[ZoneCore]
|
flags - Zone.GUIDE
|
event_zone_set_name
|
array - Array[ZoneCore]
|
|
event_zone_set_properties
|
array - Array[ZoneCore]
|
string - zone name
|
event_zone_set_type
|
array - Array[ZoneCore]
|
|
event_zone_set_visible
|
array - Array[ZoneCore]
|
|
event_zone_usable
|
array - Array[ZoneCore]
|
target_units - unit whitelist
|
Module Events
[edit | edit source]TODO
| Event ID | Required Context | Optional Context |
|---|---|---|