Users who are viewing this thread

cdvader

Documentation on Triggers

I hope this helps anyone. Please note, that Warband triggers are in as well.

ti_simulate_battle
Deprecated, do not use. Use script_game_event_simulate_battle in module_scripts instead.

ti_on_party_encounter
Deprecated, do not use. Use script_game_event_simulate_battle in module_scripts instead.
ti_before_mission_start
No trigger parameters.
This trigger will run on the loading of the scene.

ti_after_mission_start
No trigger parameters.
This trigger will run after the scene has loaded.

ti_tab_pressed
No trigger parameters.
This trigger will run if the Tab key is pressed.

ti_question_answered
Trigger Parameter 1 - Value. '0' if Yes and '1' if No.
This trigger will run if you call the (question_box, <string>) command and press one of the buttons the question box provides.

ti_inventory_key_pressed
No trigger parameters.
This trigger will run if the Inventory key is pressed.
Using the (set_trigger_result, 1) in this trigger will open the inventory.

ti_escape_pressed
No trigger parameters.
This trigger will run if the Escape key is pressed.

ti_battle_window_opened
No trigger parameters.
Need clarification on this one.

ti_on_agent_spawn
Trigger Parameter 1 - The agent which just spawned.
This trigger will run if an agent spawns.

ti_on_agent_killed_or_wounded
Trigger Parameter 1 - The victim agent (who just fell in battle - died/knocked unconscious).
Trigger Parameter 2 - The killer agent (who just killed the victim agent/knocked the victim agent unconscious).
Trigger Parameter 3 - Victim killed/wounded? - Stores the variable '1' if the victim agent is wounded, '0' if killed.
This trigger will run if an agent is either killed or wounded.

ti_on_agent_knocked_down
Trigger Parameter 1 - The victim agent (who was just knocked down).
Trigger Parameter 2 - The killer agent (who knocked the victim down).
This trigger will run if an agent is not killed and not wounded, but knocked down. For example, if you get hit by the enemy and he has a big maul and knocks you down, then this trigger will run.

ti_on_leave_area
No trigger parameters.
This trigger will run if the player exits a scene.
Interesting note: if you place commands inside a scene prop trigger, it will run on that scene prop alone. For example, if you use (play_sound, "snd_your_sound") in a scene prop trigger, the sound will play at that scene prop, not globally like that command usually does.

ti_on_scene_prop_init or ti_on_init_scene_prop
Trigger Parameter 1 - The prop instance (of the initialized prop).
This trigger will run when the prop initializes. For example, when it spawns.

ti_on_scene_prop_hit
Trigger Parameter 1 - The prop instance (of the prop which was just hit).
Trigger Parameter 2 - The damage of the hit.
Position Register 1 - Hit Position (where the hit landed on the scene prop).
Position Register 2 - Position of the attacker. X-axis of this position holds the attacker agent ID.
This trigger will run when a prop is hit. Interesting note: using (position_get_x, <destination>, pos2), will return you the attacker agents ID into <destination>.
Interesting note - if you do (position_get_x, ":attacker", pos2), then you must either set the fixed point multiplier to 1  before getting the :attacker variable.

ti_on_scene_prop_destroy
Trigger Parameter 1 - The prop instance (of the prop which was just destroyed).
This trigger will run if a scene prop is destroyed.

ti_on_scene_prop_use
Trigger Parameter 1 - The agent id (of the agent which just used the scene prop).
Trigger Parameter 2 - The prop instance (of the prop which was just used).
This trigger will run if a prop is used. For example, in multiplayer you can hold the F key down near the Winch prop to open the gate in the Village map.

ti_on_scene_prop_is_animating
Trigger Parameter 1 - The prop instance (of the prop which is animating).
Trigger Parameter 2 - Remaining animation time.
This trigger will run if a prop is animating.

ti_on_scene_prop_animation_finished
Trigger Parameter 1 - The prop instance (of the prop whose animation just ended).
This trigger will run if a scene prop finishes animation.
ti_on_init_item
Trigger Parameter 1 - The agent id (of the item wearer).
Trigger Parameter 2 - The troop id (of the item wearer).
This trigger will run if a item is initialized. For example, in the Inventory window or in scenes.

ti_on_weapon_attack
Position Register 1 - The weapon items position (of the weapon which just "attacked").
This trigger will run if a item is used. For example, if you shoot a crossbow.
It works only on ranged items.

ti_on_missile_hit
Trigger Parameter 1 - The shooter agent (who just fired the missile).
Position Register 1 - The position of the missile (which just landed somewhere).
This trigger will run if a missile lands somewhere. For example, if you shoot your bow and the arrow lands.
It works only on missiles themselves. It won't work on bows, crossbows and so on.
ti_on_presentation_load
No trigger parameters.
This trigger will run on the initialization of a presentation.

ti_on_presentation_run
Trigger Parameter 1 - Stores the time of how long the presentation has run in milliseconds.
This trigger will run each millisecond/frame of the presentation.

ti_on_presentation_event_state_change
Trigger Parameter 1 - The ID of the Object at which a event just occurred.
Trigger Parameter 2 - Value (If available).
This trigger will run if a event occurs on a Object. For example, if you have made a Slider overlay and have it stored to the variable $slider, then when you change the Sliders value this trigger will run and the Trigger Parameter 1 will be $slider and Value will be the new value of the slider.

ti_on_presentation_mouse_enter_leave
Trigger Parameter 1 - The ID of the Object at which the mouse enters/leaves.
Trigger Parameter 2 - Mouse entered/leaved? Stores '0' if enters, '1' if leaves.
This trigger will run if a mouse enters or leaves a Object. For example, if you have made a Text Box overlay and have it stored to $tbox, then when you point the mouse at the overlay this trigger will run and the Trigger Parameter 1 will be $tbox and Trigger Parameter 2 will be 0.

ti_on_presentation_mouse_press
Trigger Parameter 1 - The ID of the Object at which the mouse is pressed.
Trigger Parameter 2 - Mouse key? Stores '0' if the left mouse button is pressed, '1' if the right mouse button and '2' if the middle mouse button.
This trigger will run if you press a mouse key at a Object. For example, you have made a Button overlay and stored it into $button, then when you press the left mouse button at the Button, this trigger will run and the Trigger Parameter 1 will be $button and Trigger Parameter 2 will be '0'.
ti_on_init_map_icon Can only be used in module_map_icons.
Trigger Parameter 1 - The ID of the Party whose map icon was just initialized.
This trigger will run if a map icon is initialized.

cdvader
 
No problems.

Some are listed in header_triggers.py, some I have found out by trial and error, but most of them I have spotted in other triggers in the ModuleSystem. I understand their meanings by looking at "native" code made by TaleWorlds Developers and then understand what it does.
 
If you place commands inside a scene prop trigger, it will run on that scene prop alone. For example, if you use (play_sound, "snd_your_sound") in a scene prop trigger, the sound will play at that scene prop, not globally like that command usually does.

Interesting thing. For example we can add invisible scene prop near a bard in the tavern and place inside it command "(play_sound, "snd_your_sound")", when we enter tavern. So the bard will start telling a poem and only the nearest people would hear him.

 
Kolba said:
Interesting thing. For example we can add invisible scene prop near a bard in the tavern and place inside it command "(play_sound, "snd_your_sound")", when we enter tavern. So the bard will start telling a poem and only the nearest people would hear him.
It's more natural to just get the bard play the sound with (agent_play_sound,,). He's an agent after all.
Playing sound with scene props is dearly needed for animated ones. Like carts, windmills, chariots e.t.c. Now you are resorted to kick around with invisible agents for those
 
It's more natural to just get the bard play the sound with (agent_play_sound,,). He's an agent after all.

Yes, but coupling agent_play_sound and play_sound on the scene prop, we can have two different sounds for one agent.
 
Kolba said:
Yes, but coupling agent_play_sound and play_sound on the scene prop, we can have two different sounds for one agent.
Noone forbids you to use agent_play_sound as many times as you like for a particular agent, with different sounds in differently timed triggers :smile:
 
I use the scene props unique feature in my grenades. I "animate" my grenade prop down the Z axis by -1. Once my grenade prop finishes the animation, it will play a explosion sound at the prop.

Good stuff.
 
Thank you, cdvader. It's a very useful information pool for any coder.
BTW I want to ask some questions about ti_on_scene_prop_hit.

Position Register 1 - Hit Position (where the hit landed on the scene prop).
  pos1 is absolute position or refers to position of the scene prop?

Position Register 2 - Position of the attacker. X-axis of this position holds the attacker agent ID.
This trigger will run when a prop is hit. Interesting note: using (position_get_x, <destination>, pos2), will return you the attacker agents ID into <destination>.

    Does it mean that pos2 is not normal position data? how about it's y and z axis?
    True location of attacker's retrieved by position of agent that it's ID = pos2.x?

Thanks before,

dunde
 
dunde said:
Position Register 1 - Hit Position (where the hit landed on the scene prop).
  pos1 is absolute position or refers to position of the scene prop?
It refers to the position of the scene prop. I'll make it easy for you: you shoot a arrow at the scene prop, then pos1 will be the location where the arrow landed. Exactly the same with melee weapons. You can see this trigger in action at the Fight & Destroy gamemode.

dunde said:
Position Register 2 - Position of the attacker. X-axis of this position holds the attacker agent ID.
This trigger will run when a prop is hit. Interesting note: using (position_get_x, <destination>, pos2), will return you the attacker agents ID into <destination>.

    Does it mean that pos2 is not normal position data? how about it's y and z axis?
    True location of attacker's retrieved by position of agent that it's ID = pos2.x?
Actually, I think the pos2 which is returned by that script is normal position data. I did some research and if you do (position_get_x, ":attacker", pos2), then you must

a) Set the fixed point multiplier to 1 before getting the :attacker variable.

If you do that then you will get the attacker ID. Which is pretty interesting, in my opinion.
 
cdvader said:
Actually, I think the pos2 which is returned by that script is normal position data.
...
If you do either of those then you will get the attacker ID. Which is pretty interesting, in my opinion.
Umm, if x coord in pos2 is not a real x coord on the battlemap, but an ID*100 then its not a normal position data :wink:
 
Hold on, let me do a test..  :razz:

EDIT: Dude, sorry, my bad on the divide by 100. You only have to divide by 100 if you have set the fixed point multiplier to 100. I quickly skimmed through TW Developers code and didn't notice that one.

EDIT2: Did a test and pos2 does seem to, indeed, be a "not normal position data". I guess they got lazy and didn't want to implement it as a trigger parameter?  :razz:
 
cdvader said:
Did a test and pos2 does seem to, indeed, be a "not normal position data".

Thanks, cdvader and GetAssista. It's clear enough for me to make a try to use pos2 there then.

BTW, params of presentation's triggers have  not been covered yet by this documentation.
 
Here's one you left out.

Code:
 ti_question_answered
 trigger_param_1, stores a 0 or 1 when a question box is answered. 0 for yes and 1 for no.
 Can be used in simple_triggers  or mission_templates.  As far as I know, there are no other parameters, 
but I would think that they would return the dialog box id somehow (probably hard coded in with the map view buttons). 
 You can differentiate different dialog boxes by setting a global variable before calling a dialog box and then checking it in the trigger.

Also, ti_battle_window_opened  refers to the backspace key battlemap, I believe.
 
[quote author= Tempered]Also, ti_battle_window_opened  ...[/quote]
That's what I thought, but if you look at Native code they use it to open Stats Chart. So it's the end mission/tab key?

I should do a test, but I'm a lazy bastard atm.
Thanks for your ti_question_answered, I will add it.
 
Back
Top Bottom