Triggers

Simple triggers
Used in module_simple_triggers

ti_on_game_start = -2.0
 * Supossedly used to make old version saves of mod run on new version. Need to check old versions of Viking Conquest.

ti_simulate_battle = -5.0 DEPRECATED

ti_on_party_encounter = -6.0 DEPRECATED

Generic triggers
Used in module_items

ti_question_answered = -8.0
 * Player selected an option in (question_box, ...) dialog. Commonly used in module_mission_templates, but should be usable on the global map as well.
 * trigger param #1 = player's selected response: 0 = first button (usually "Yes"), 1 = second button (usually "No").

ti_on_switch_to_map = -75.0
 * Patch 1.165+. UNTESTED.

Item triggers
Used in module_items.py

ti_on_init_item = -50.0
 * Item mesh has been created.
 * trigger param #1 = agent_id who has this item equipped (-1 if none)
 * trigger param #2 = troop_id who has this item equipped (-1 if none)

ti_on_weapon_attack = -51.0
 * Agent has performed an attack with this item. Does not fire on client side in multiplayer missions.
 * trigger param #1 = attacking agent_id
 * pos1 = weapon item position. If wielded weapon is bow than gets arrow quiver position.

ti_on_missile_hit = -52.0
 * Missile has hit something. Not all hits will be registered on client-side in multiplayer missions.
 * trigger param #1 = shooter agent_id
 * trigger param #2 = hit object type:
 * 0 = world (landscape)
 * 1 = hostile agent
 * 2 = dynamic prop
 * 3 = world object (trees, stones, scene interior basic mesh)
 * 4 = mission object (most scene props)
 * 8 = friendly agent
 * 9 = neutral agent
 * 10 = under water
 * pos1 = Missile Position, Y-axis points to missile arrowhead

ti_on_shield_hit = -80.0
 * trigger param 1 = defender agent_id
 * trigger param 2 = attacker agent_id
 * trigger param 3 = inflicted damage
 * trigger param 4 = weapon item_id (ranged weapon in case of ranged attack)
 * trigger param 5 = missile item_id (ammo in case of ranged attack)
 * If (set_trigger_result) is used in the code, operation parameter will override the damage dealt to the shield

Map icon triggers
Uused in module_map_icons.py

ti_on_init_map_icon = -70.0
 * Map icon mesh has been created.
 * trigger param 1 = party_id that is using this icon

Mission template triggers
Used in module_mission_templates. After mission has started triggers fire in this order:


 * 1) ti_on_agent_spawn
 * 2) Some triggers with timer like (1,0,0, (0,0,0 can fire right for one frame before others (3),(4)
 * 3) ti_after_mission_start
 * 4) ti_battle_window_opened

So any scripting before agent spawn should go in ti_before_mission_start

ti_server_player_joined = -15.0
 * Multiplayer server-side trigger. New player has connected to the server.
 * trigger param 1 = player_id of joined player

ti_on_player_exit = -29.0
 * Multiplayer server-side trigger. A player is leaving the multiplayer mission.
 * trigger param 1 = leaving player_id

ti_on_multiplayer_mission_end = -16.0
 * Multiplayer trigger. Multiplayer mission has completed. Fires on both server and client.

ti_battle_window_opened = -24.0
 * Fires when player enters a scene from game engine menus

ti_before_mission_start = -19.0
 * Scene has been loaded, but mission hasn't started yet. Called before initialization of all scene objects.

ti_after_mission_start = -20.0
 * Scene has been loaded and all objects have been initialized. Not all agents can be spawned at this time. This trigger executed only once. Consequences code block is executed immediately (doesn't use timer offset).

ti_tab_pressed = -21.0
 * Player has clicked `Leave location/Retreat` game key ('Tab' by default).

ti_inventory_key_pressed = -22.0
 * Player has clicked `Inventory` game key ('I' by default).

ti_escape_pressed = -23.0
 * Player has clicked 'Escape' button.

ti_on_agent_spawn = -25.0
 * A new agent has been spawned on the scene. Note that horse agents are spawned after the human agents.
 * trigger param 1 = agent_id of spawned agent
 * The second parameter delaying consequence code doesn't work.

ti_on_agent_killed_or_wounded = -26.0
 * Agent has been defeated in battle (killed or wounded)
 * trigger param 1 = defeated agent_id
 * trigger param 2 = attacker agent_id
 * trigger param 3 = wounded flag: 0 = agent is killed, 1 = agent is wounded
 * If (set_trigger_result) with non-zero parameter is used in the code, it will override the agent's fate. Trigger result: 0 = do not alter the result, 1 = force kill, 2 = force wound.

ti_on_agent_knocked_down = -27.0
 * Agent has been knocked down, used in combination with (agent_set_no_death_knock_down_only) operation.
 * trigger param 1 = defeated agent_id
 * trigger param 2 = attacker agent_id

ti_on_agent_hit = -28.0
 * Agent has been damaged with a weapon attack. Does not fire on client side in multiplayer missions.
 * trigger param 1 = damage inflicted agent_id
 * trigger param 2 = attacker agent_id
 * trigger param 3 = inflicted damage
 * trigger param 4 = hit bone
 * trigger param 5 = item_id of missile used to attack (if attack was with a ranged weapon)
 * reg0 = weapon item_id
 * pos0 = position of the hit area, rotation fields contain the direction of the blow
 * If (set_trigger_result) is used in the code with operation parameter equal or greater than zero, it will override the inflicted damage.

ti_on_leave_area = -30.0
 * Player has walked to scene border and activated it to leave the area.

ti_on_item_picked_up = -53.0
 * An agent has picked an item from the ground. Does not fire on client side in multiplayer missions.
 * trigger param 1 = agent_id who picked the item
 * trigger param 2 = item_id that was picked up
 * trigger param 3 = item's instance_id at the moment of being picked up, can be used to retrieve item's position on the scene. Will be deleted after trigger fires.

ti_on_item_dropped = -54.0
 * An agent has dropped an item on the ground. Does not fire on client side in multiplayer missions.
 * trigger param 1 = agent_id
 * trigger param 2 = item_id
 * trigger param 3 = item's instance_id

ti_on_agent_mount = -55.0
 * An agent has mounted a horse
 * trigger param 1 = agent_id
 * trigger param 2 = horse agent_id

ti_on_agent_dismount = -56.0
 * An agent has dismounted a horse
 * trigger param 1 = agent_id
 * trigger param 2 = horse agent_id

ti_on_item_wielded = -57.0
 * An agent has selected a weapon to wield
 * trigger param 1 = agent_id
 * trigger param 2 = item_id

ti_on_item_unwielded = -58.0
 * An agent has sheathed his current weapon or switched to another one
 * trigger param 1 = agent_id
 * trigger param 2 = item_id

ti_on_order_issued = -71.0
 * An agent has issued a tactical order
 * trigger param 1 = order_code (see mordr_* constants in header_mission_templates.py)
 * trigger param 2 = agent_id

Presentation triggers
Used in module_presentations

ti_on_presentation_load = -60.0
 * Presentation has been loaded by the engine. Use this trigger to initialize the presentation and it's overlays.

ti_on_presentation_run = -61.0
 * This trigger is activated every frame while the presentation is running. Use it to handle real-time behavior within the presentation.
 * trigger param 1 = how much time has passed since presentation has been started (in milliseconds)

ti_on_presentation_event_state_change = -62.0
 * Some overlay has changed it's state (button clicked, checkbox switched state, slider moved, list has it's active element changed etc).
 * trigger param 1 = overlay_id of the object that initiated the event
 * trigger param 2 = new overlay value (if appropriate)

ti_on_presentation_mouse_enter_leave = -63.0
 * Reports that mouse cursor has entered or left an overlay.
 * trigger param 1 = overlay_id of the object that mouse enters/leaves
 * trigger param 2 = 0 if mouse enters, 1 if mouse leaves

ti_on_presentation_mouse_press = -64.0
 * A mouse click has been detected on one of presentation overlays.
 * trigger param 1 = overlay_id of the object that mouse is pressed on
 * trigger param 2 = 0 left mouse button, 1 right mouse button, 2 middle mouse button

Scene prop triggers
Used in module_scene_props

ti_on_scene_prop_init = -40.0
 * A scene prop instance has been created on the scene.

ti_on_init_scene_prop = ti_on_scene_prop_init
 * Alternate syntax
 * trigger param 1 = prop instance_id reference

ti_on_scene_prop_hit = -42.0
 * A scene prop has been hit by some agent.
 * Note that on client-side in multiplayer missions only trigger param 1 and position registers are available. Trigger params 2..7 are only available to server or in singleplayer.
 * trigger param 1 = prop instance_id reference
 * trigger param 2 = amount of damage delivered to the scene prop (not available on client side in multiplayer)
 * trigger param 3 = attacker agent_id (not available on client side in multiplayer)
 * trigger param 4 = item_id of the weapon used to attack
 * trigger param 5 = weapon item modifier
 * trigger param 6 = item_id of missile used to attack (if attack was by ranged weapon)
 * trigger param 7 = missile item modifier
 * pos1 = position of the hit area
 * pos2 = X field holds attacker's agent_id reference

ti_on_scene_prop_destroy = -43.0
 * A destructible scene prop has been destroyed by some agent. Does not fire on client side in multiplayer missions.
 * trigger param 1 = prop instance_id reference
 * trigger param 2 = attacker agent_id

ti_on_scene_prop_start_use = -47.0
 * An agent is attempting to activate a usable scene prop. Useful if you want a scene prop to be activated instantly without any timeout. Does not fire on client side in multiplayer missions.
 * trigger param 1 = agent_id of the agent who has started using the scene prop
 * trigger param 2 = prop instance_id reference

ti_on_scene_prop_cancel_use = -48.0
 * An agent has cancelled using the scene prop. Does not fire on client side in multiplayer missions.
 * trigger param 1 = agent_id of the agent who cancelled using the scene prop
 * trigger param 2 = prop instance_id reference

ti_on_scene_prop_use = -44.0
 * A usable scene prop has been activated by some agent. Does not fire on client side in multiplayer missions.
 * trigger param 1 = agent_id of the agent who activated the scene prop
 * trigger param 2 = prop instance_id reference

ti_on_scene_prop_is_animating = -45.0
 * Called each frame when a scene prop is animating.
 * trigger param 1 = prop instance_id reference
 * trigger param 2 = remaining animation time (apparently in 1/100th of second).

ti_on_scene_prop_animation_finished = -46.0
 * Animation sequence has been completed for a scene prop.
 * trigger param 1 = prop instance_id reference

ti_scene_prop_deformation_finished = -76.0
 * Deformation sequence has been completed for a scene prop.
 * trigger param 1 = prop instance_id reference

Trigger repeat frequency constants
ti_once = 100000000.0

Keyboard key codes
Checked by key_is_down and key_clicked operations

Game key codes
Cchecked by game_key_is_down and game_key_clicked operations