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

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+. In simple triggers will fire after switching to map. (In Viking Conquest it changes weather).
## 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)
5 = shield
8 = friendly agent
9 = neutral agent
10 = under water
pos1 = Missile moves by defined array of positions. Returned pos1 is position from this array after missile intersects with collision mesh. To get the exact position use <cast\_ray> operation.
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). Doesn't fire during dialogs.
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.
`trigger_param_3` will not change value in the second and subsequent `ti_on_agent_killed_or_wounded` triggers.
`agent_is_wounded` operand will change the returning value after all `ti_on_agent_killed_or_wounded` triggers finished.
If horse killed somebody shows it's rider as killer/attacker.
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
Trigger fire even when 0 damage was inflicted.
If (set\_trigger\_result) is used in the code with operation parameter equal or greater than zero, it will override the inflicted damage.
If multiple triggers changed damage as result only the last <set\_trigger\_result> will be applied.
If agent health is set to 0 it will be killed even when damage is none.
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. Has access to horse <agent\_get\_horse> inside trigger.
trigger param 1 = agent\_id
trigger param 2 = horse agent\_id
ti\_on\_agent\_dismount = -56.0

An agent has dismounted a horse. Has access to horse <agent\_get\_horse> inside trigger.
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 after mission timer triggers.
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.
This trigger can be used to retrieve new positions of agents for the next frame.
trigger param 1 = prop instance\_id reference

## Keyboard key codes

Checked by key\_is\_down and key\_clicked operations

key\_2 = 0x03
key\_3 = 0x04
key\_4 = 0x05
key\_5 = 0x06
key\_6 = 0x07
key\_7 = 0x08
key\_8 = 0x09
key\_9 = 0x0a
key\_0 = 0x0b
key\_a = 0x1e
key\_b = 0x30
key\_c = 0x2e
key\_d = 0x20
key\_e = 0x12
key\_f = 0x21
key\_g = 0x22
key\_h = 0x23
key\_i = 0x17
key\_j = 0x24
key\_k = 0x25
key\_l = 0x26
key\_m = 0x32
key\_n = 0x31
key\_p = 0x19
key\_q = 0x10
key\_r = 0x13
key\_s = 0x1f
key\_t = 0x14
key\_u = 0x16
key\_v = 0x2f
key\_w = 0x11
key\_x = 0x2d
key\_y = 0x15
key\_z = 0x2c
key\_1 = 0x02
key\_2 = 0x03
key\_3 = 0x04
key\_4 = 0x05
key\_5 = 0x06
key\_6 = 0x07
key\_7 = 0x08
key\_8 = 0x09
key\_9 = 0x0a
key\_0 = 0x0b
key\_a = 0x1e
key\_b = 0x30
key\_d = 0x20
key\_e = 0x12
key\_f = 0x21
key\_g = 0x22
key\_h = 0x23
key\_i = 0x17
key\_j = 0x24
key\_k = 0x25
key\_l = 0x26
key\_m = 0x32
key\_n = 0x31
key\_o = 0x18
key\_p = 0x19
key\_q = 0x10
key\_r = 0x13
key\_s = 0x1f
key\_t = 0x14
key\_u = 0x16
key\_v = 0x2f
key\_w = 0x11
key\_x = 0x2d
key\_y = 0x15

key\_numpad\_1 = 0x4f
key\_numpad\_2 = 0x50
key\_numpad\_3 = 0x51
key\_numpad\_4 = 0x4b
key\_numpad\_5 = 0x4c
key\_numpad\_6 = 0x4d
key\_numpad\_7 = 0x47
key\_numpad\_8 = 0x48
key\_numpad\_9 = 0x49
key\_numpad\_slash = 0xb5
key\_numpad\_multiply = 0x37
key\_numpad\_minus = 0x4a
key\_numpad\_plus = 0x4e
key\_numpad\_enter = 0x9c
key\_numpad\_period = 0x53
key\_insert = 0xd2
key\_delete = 0xd3
key\_home = 0xc7
key\_page\_up = 0xc9
key\_page\_down = 0xd1
key\_up = 0xc8
key\_down = 0xd0
key\_left = 0xcb

key\_f2 = 0x3c
key\_f3 = 0x3d
key\_f4 = 0x3e
key\_f5 = 0x3f
key\_f6 = 0x40
key\_f7 = 0x41
key\_f8 = 0x42
key\_f9 = 0x43
key\_f10 = 0x44
key\_f11 = 0x57
key\_f12 = 0x58
key\_escape = 0x01
key\_enter = 0x1c
key\_tab = 0x0f
key\_back\_space = 0x0e
key\_open\_braces = 0x1a
key\_close\_braces = 0x1b
key\_comma = 0x33
key\_period = 0x34
key\_slash = 0x35
key\_back\_slash = 0x2b
key\_equals = 0x0d
key\_semicolon = 0x27
key\_apostrophe = 0x28
key\_tilde = 0x29
key\_caps\_lock = 0x3a
key\_left\_shift = 0x2a
key\_right\_shift = 0x36
key\_left\_control = 0x1d
key\_right\_control = 0x9d
key\_left\_alt = 0x38

key\_right\_mouse\_button = 0xe1
key\_middle\_mouse\_button = 0xe2
key\_mouse\_button\_4 = 0xe3
key\_mouse\_button\_5 = 0xe4
key\_mouse\_button\_6 = 0xe5
key\_mouse\_button\_7 = 0xe6
key\_mouse\_button\_8 = 0xe7
key\_mouse\_scroll\_up = 0xee

key\_xbox\_b = 0xf1
key\_xbox\_x = 0xf2
key\_xbox\_y = 0xf3
key\_xbox\_dpad\_up = 0xf4
key\_xbox\_dpad\_down = 0xf5
key\_xbox\_dpad\_right = 0xf6
key\_xbox\_dpad\_left = 0xf7
key\_xbox\_start = 0xf8
key\_xbox\_back = 0xf9
key\_xbox\_rbumper = 0xfa
key\_xbox\_lbumper = 0xfb
key\_xbox\_ltrigger = 0xfc
key\_xbox\_rtrigger = 0xfd
key\_xbox\_rstick = 0xfe

## Game key codes

Cchecked by game\_key\_is\_down and game\_key\_clicked operations

gk\_move\_backward = 1
gk\_move\_left = 2
gk\_move\_right = 3
gk\_action = 4
gk\_jump = 5
gk\_attack = 6
gk\_defend = 7
gk\_kick = 8
gk\_parry\_then\_attack = 8
gk\_toggle\_weapon\_mode = 9
gk\_equip\_weapon\_1 = 10
gk\_equip\_weapon\_2 = 11
gk\_equip\_weapon\_3 = 12
gk\_equip\_weapon\_4 = 13
gk\_equip\_primary\_weapon = 14
gk\_equip\_secondary\_weapon = 15
gk\_drop\_weapon = 16
gk\_sheath\_weapon = 17
gk\_leave = 18
gk\_zoom = 19
gk\_view\_char = 20
gk\_view\_orders = 22
gk\_order\_1 = 23
gk\_order\_2 = 24
gk\_order\_3 = 25
gk\_order\_4 = 26
gk\_order\_5 = 27
gk\_order\_6 = 28
gk\_order\_halt = 22
gk\_order\_follow = 23
gk\_order\_charge = 24
gk\_order\_dismount = 25
gk\_order\_hold\_fire\_toggle = 26
gk\_order\_advance = 27
gk\_order\_fall\_back = 28
gk\_order\_stand\_closer = 29
gk\_order\_spread\_out = 30
gk\_order\_blunt\_weapons\_toggle = 31
gk\_everyone\_hear = 29
gk\_infantry\_hear = 30
gk\_archers\_hear = 31
gk\_cavalry\_hear = 32
gk\_group1\_hear = gk\_archers\_hear
gk\_group2\_hear = gk\_cavalry\_hear
gk\_group3\_hear = 33
gk\_group4\_hear = 34
gk\_group5\_hear = 35
gk\_group6\_hear = 36
gk\_group7\_hear = 37
gk\_group8\_hear = 38
gk\_reverse\_order\_group = 39
gk\_everyone\_around\_hear = 40
gk\_mp\_message\_all = 41
gk\_mp\_message\_team = 42
gk\_character\_window = 43
gk\_inventory\_window = 44
gk\_party\_window = 45
gk\_quests\_window = 46
gk\_game\_log\_window = 47
gk\_quick\_save = 48
gk\_crouch = 49
gk\_order\_7 = 50