How to Trigger Animation?

Users who are viewing this thread

Karsontr

Regular
I created a sitting animation for Warband. I want a key pressed to trigger this animation, likewise a key pressed to end the animation. Is there any code script that will enable this?
 
I have a sit function in my own mod.
First, You need to add your sit animation into module_animations and make sure it have amf_keep flag.
And you need a stand up animation for cancel sitting, it's like native animation "stand_to_crouch" and "crouch_to_stand".

Next, add a new slot for your animation in constants. This for check you are sitting or not.
e.g. slot_agent_sitting = 29

And here's the code in mission templates. Editing it and add the trigger to every mission you want.
Python:
player_sit = (
  0, 0, 2,
  [
    (key_clicked, key_x),
    (get_player_agent_no, ":player_agent"),
    (agent_is_alive, ":player_agent"),
    (agent_is_human, ":player_agent"),
    (agent_get_horse, ":horse", ":player_agent"),
    (le, ":horse", 0),
    (try_begin),
       (agent_get_slot, ":sitting", ":player_agent", slot_agent_sitting),
       (eq, ":sitting", 0),
       (agent_set_animation, ":player_agent", "anim_stand_to_sit"), # sit animation
       (agent_set_slot, ":player_agent", slot_agent_sitting, 1),
    (else_try),      
       (agent_set_animation, ":player_agent", "anim_sit_to_stand"), # stand up animation
       (agent_set_slot, ":player_agent", slot_agent_sitting, 0),
    (try_end)], [])

(key_clicked, key_x) here to change what key you want to click to sit.
(agent_set_animation, "X", "Y") this is you make X to do Y animation.

You might have cam's problem after this. You can find many threads about "mission_cam_set_mode" in this forum.
 
Last edited:
Kendi modumda oturma işlevim var.
Öncelikle, oturma animasyonunuzu module_animations içine eklemeniz ve amf_keep bayrağına sahip olduğundan emin olmanız gerekir.
Ve oturmayı iptal etmek için bir ayağa kalkma animasyonuna ihtiyacınız var, bu yerel animasyon "stand_to_crouch" ve "crouch_to_stand" gibi.

Ardından, animasyonunuz için sabitlerde yeni bir yuva ekleyin. Bu, oturup oturmadığınızı kontrol etmek içindir.
örneğin slot_agent_sitting = 29

Ve işte görev şablonlarındaki kod. Düzenleyin ve tetikleyiciyi istediğiniz her göreve ekleyin.
Python:
player_sit = (
  0, 0, 2,
  [
    (key_clicked, key_x),
    (get_player_agent_no, ":player_agent"),
    (agent_is_alive, ":player_agent"),
    (agent_is_human, ":player_agent"),
    (agent_get_horse, ":at", ":player_agent"),
    (le, ":at", 0),
    (try_begin),
       (agent_get_slot, ":oturma", ":player_agent", slot_agent_sitting),
       (eq, ":oturma", 0),
       (agent_set_animation, ":player_agent", "anim_stand_to_sit"), # oturma animasyonu
       (agent_set_slot, ":player_agent", slot_agent_sitting, 1),
    (else_try),    
       (agent_set_animation, ":player_agent", "anim_sit_to_stand"), # ayağa kalkma animasyonu
       (agent_set_slot, ":player_agent", slot_agent_sitting, 0),
    (try_end)], [])

(key_clicked, key_x) buraya tıklayarak oturmak istediğiniz tuşu değiştirebilirsiniz.
(agent_set_animation, "X", "Y") bu, X'i Y yapmak için yaptığınız animasyondur.

Bundan sonra kamera sorununuz olabilir. Bu forumda "mission_cam_set_mode" ile ilgili birçok konu bulabilirsiniz.
This will really work for me. Thank you very much my friend, you are great.
 
I have a sit function in my own mod.
First, You need to add your sit animation into module_animations and make sure it have amf_keep flag.
And you need a stand up animation for cancel sitting, it's like native animation "stand_to_crouch" and "crouch_to_stand".

Next, add a new slot for your animation in constants. This for check you are sitting or not.
e.g. slot_agent_sitting = 29

And here's the code in mission templates. Editing it and add the trigger to every mission you want.
Python:
player_sit = (
  0, 0, 2,
  [
    (key_clicked, key_x),
    (get_player_agent_no, ":player_agent"),
    (agent_is_alive, ":player_agent"),
    (agent_is_human, ":player_agent"),
    (agent_get_horse, ":horse", ":player_agent"),
    (le, ":horse", 0),
    (try_begin),
       (agent_get_slot, ":sitting", ":player_agent", slot_agent_sitting),
       (eq, ":sitting", 0),
       (agent_set_animation, ":player_agent", "anim_stand_to_sit"), # sit animation
       (agent_set_slot, ":player_agent", slot_agent_sitting, 1),
    (else_try),     
       (agent_set_animation, ":player_agent", "anim_sit_to_stand"), # stand up animation
       (agent_set_slot, ":player_agent", slot_agent_sitting, 0),
    (try_end)], [])

(key_clicked, key_x) here to change what key you want to click to sit.
(agent_set_animation, "X", "Y") this is you make X to do Y animation.

You might have cam's problem after this. You can find many threads about "mission_cam_set_mode" in this forum.

I wrote the code in the module templates file, but I'm getting an error.

Traceback (most recent call last):
File "process_init.py", line 2, in <module>
from process_operations import *
File "C:\Users\KarsonTR\Desktop\mb_warband_module_system_1171 (1) - Kopya\Module_system 1.171\process_operations.py", line 21, in <module>
from module_mission_templates import *
File "C:\Users\KarsonTR\Desktop\mb_warband_module_system_1171 (1) - Kopya\Module_system 1.171\module_mission_templates.py", line 50, in <module>
(agent_set_animation, ":player_agent", "standing_1"),
TypeError: 'int' object is not callable
Traceback (most recent call last):
File "process_global_variables.py", line 12, in <module>
from process_operations import *
File "C:\Users\KarsonTR\Desktop\mb_warband_module_system_1171 (1) - Kopya\Module_system 1.171\process_operations.py", line 21, in <module>
from module_mission_templates import *
File "C:\Users\KarsonTR\Desktop\mb_warband_module_system_1171 (1) - Kopya\Module_system 1.171\module_mission_templates.py", line 50, in <module>
(agent_set_animation, ":player_agent", "standing_1"),
TypeError: 'int' object is not callable
Exporting strings...
Exporting skills...
Exporting tracks...
Exporting animations...
Exporting meshes...
Exporting sounds...
Exporting skins...
Traceback (most recent call last):
File "process_map_icons.py", line 6, in <module>
from process_operations import *
File "C:\Users\KarsonTR\Desktop\mb_warband_module_system_1171 (1) - Kopya\Module_system 1.171\process_operations.py", line 21, in <module>
from module_mission_templates import *
File "C:\Users\KarsonTR\Desktop\mb_warband_module_system_1171 (1) - Kopya\Module_system 1.171\module_mission_templates.py", line 50, in <module>
(agent_set_animation, ":player_agent", "standing_1"),
TypeError: 'int' object is not callable
Exporting faction data...
Exporting item data...
Traceback (most recent call last):
File "process_items.py", line 66, in <module>
from process_operations import *
File "C:\Users\KarsonTR\Desktop\mb_warband_module_system_1171 (1) - Kopya\Module_system 1.171\process_operations.py", line 21, in <module>
from module_mission_templates import *
File "C:\Users\KarsonTR\Desktop\mb_warband_module_system_1171 (1) - Kopya\Module_system 1.171\module_mission_templates.py", line 50, in <module>
(agent_set_animation, ":player_agent", "standing_1"),
TypeError: 'int' object is not callable
Exporting scene data...
Traceback (most recent call last):
File "process_scenes.py", line 15, in <module>
from process_operations import *
File "C:\Users\KarsonTR\Desktop\mb_warband_module_system_1171 (1) - Kopya\Module_system 1.171\process_operations.py", line 21, in <module>
from module_mission_templates import *
File "C:\Users\KarsonTR\Desktop\mb_warband_module_system_1171 (1) - Kopya\Module_system 1.171\module_mission_templates.py", line 50, in <module>
(agent_set_animation, ":player_agent", "standing_1"),
TypeError: 'int' object is not callable
Exporting troops data
Exporting particle data...
Traceback (most recent call last):
File "process_scene_props.py", line 7, in <module>
from process_operations import *
File "C:\Users\KarsonTR\Desktop\mb_warband_module_system_1171 (1) - Kopya\Module_system 1.171\process_operations.py", line 21, in <module>
from module_mission_templates import *
File "C:\Users\KarsonTR\Desktop\mb_warband_module_system_1171 (1) - Kopya\Module_system 1.171\module_mission_templates.py", line 50, in <module>
(agent_set_animation, ":player_agent", "standing_1"),
TypeError: 'int' object is not callable
Traceback (most recent call last):
File "process_tableau_materials.py", line 8, in <module>
from process_operations import *
File "C:\Users\KarsonTR\Desktop\mb_warband_module_system_1171 (1) - Kopya\Module_system 1.171\process_operations.py", line 21, in <module>
from module_mission_templates import *
File "C:\Users\KarsonTR\Desktop\mb_warband_module_system_1171 (1) - Kopya\Module_system 1.171\module_mission_templates.py", line 50, in <module>
(agent_set_animation, ":player_agent", "standing_1"),
TypeError: 'int' object is not callable
Traceback (most recent call last):
File "process_presentations.py", line 8, in <module>
from process_operations import *
File "C:\Users\KarsonTR\Desktop\mb_warband_module_system_1171 (1) - Kopya\Module_system 1.171\process_operations.py", line 21, in <module>
from module_mission_templates import *
File "C:\Users\KarsonTR\Desktop\mb_warband_module_system_1171 (1) - Kopya\Module_system 1.171\module_mission_templates.py", line 50, in <module>
(agent_set_animation, ":player_agent", "standing_1"),
TypeError: 'int' object is not callable
Exporting party_template data...
Traceback (most recent call last):
File "process_parties.py", line 6, in <module>
from process_operations import *
File "C:\Users\KarsonTR\Desktop\mb_warband_module_system_1171 (1) - Kopya\Module_system 1.171\process_operations.py", line 21, in <module>
from module_mission_templates import *
File "C:\Users\KarsonTR\Desktop\mb_warband_module_system_1171 (1) - Kopya\Module_system 1.171\module_mission_templates.py", line 50, in <module>
(agent_set_animation, ":player_agent", "standing_1"),
TypeError: 'int' object is not callable
Exporting quest data...
Exporting info_page data...
Traceback (most recent call last):
File "process_scripts.py", line 7, in <module>
from process_operations import *
File "C:\Users\KarsonTR\Desktop\mb_warband_module_system_1171 (1) - Kopya\Module_system 1.171\process_operations.py", line 21, in <module>
from module_mission_templates import *
File "C:\Users\KarsonTR\Desktop\mb_warband_module_system_1171 (1) - Kopya\Module_system 1.171\module_mission_templates.py", line 50, in <module>
(agent_set_animation, ":player_agent", "standing_1"),
TypeError: 'int' object is not callable
Traceback (most recent call last):
File "process_mission_tmps.py", line 5, in <module>
from module_mission_templates import *
File "C:\Users\KarsonTR\Desktop\mb_warband_module_system_1171 (1) - Kopya\Module_system 1.171\module_mission_templates.py", line 50, in <module>
(agent_set_animation, ":player_agent", "standing_1"),
TypeError: 'int' object is not callable
Traceback (most recent call last):
File "process_game_menus.py", line 8, in <module>
from process_operations import *
File "C:\Users\KarsonTR\Desktop\mb_warband_module_system_1171 (1) - Kopya\Module_system 1.171\process_operations.py", line 21, in <module>
from module_mission_templates import *
File "C:\Users\KarsonTR\Desktop\mb_warband_module_system_1171 (1) - Kopya\Module_system 1.171\module_mission_templates.py", line 50, in <module>
(agent_set_animation, ":player_agent", "standing_1"),
TypeError: 'int' object is not callable
Traceback (most recent call last):
File "process_simple_triggers.py", line 5, in <module>
from process_operations import *
File "C:\Users\KarsonTR\Desktop\mb_warband_module_system_1171 (1) - Kopya\Module_system 1.171\process_operations.py", line 21, in <module>
from module_mission_templates import *
File "C:\Users\KarsonTR\Desktop\mb_warband_module_system_1171 (1) - Kopya\Module_system 1.171\module_mission_templates.py", line 50, in <module>
(agent_set_animation, ":player_agent", "standing_1"),
TypeError: 'int' object is not callable
Traceback (most recent call last):
File "process_dialogs.py", line 9, in <module>
from process_operations import *
File "C:\Users\KarsonTR\Desktop\mb_warband_module_system_1171 (1) - Kopya\Module_system 1.171\process_operations.py", line 21, in <module>
from module_mission_templates import *
File "C:\Users\KarsonTR\Desktop\mb_warband_module_system_1171 (1) - Kopya\Module_system 1.171\module_mission_templates.py", line 50, in <module>
(agent_set_animation, ":player_agent", "standing_1"),
TypeError: 'int' object is not callable
Traceback (most recent call last):
File "process_global_variables_unused.py", line 3, in <module>
from process_operations import *
File "C:\Users\KarsonTR\Desktop\mb_warband_module_system_1171 (1) - Kopya\Module_system 1.171\process_operations.py", line 21, in <module>
from module_mission_templates import *
File "C:\Users\KarsonTR\Desktop\mb_warband_module_system_1171 (1) - Kopya\Module_system 1.171\module_mission_templates.py", line 50, in <module>
(agent_set_animation, ":player_agent", "standing_1"),
TypeError: 'int' object is not callable
Exporting postfx_params...

______________________________

Script processing has ended.
Press any key to exit. . .

I made two animations as standing_1 and sitting_1. I placed these animations in the resource folder of my mod with open brf. (I created a new resource file for my animations and put my animations in it) then I wrote the code load_mod_resource = my_mod in the module ini file. I wrote the following codes instead of two of the unused_human_anim codes in the module animation file.

["sitting_1", acf_enforce_all, amf_priority_die|amf_keep,
[18.0, "sitting_1", 3, 301, arf_use_stand_progress|arf_cyclic, 0, (0, 0, 0), 0.25],],

["standing_1", acf_enforce_all, amf_priority_die|amf_keep,
[18.0, "standing_1", 3, 301, arf_use_stand_progress|arf_cyclic, 0, (0, 0, 0), 0.25],],

But I am getting the above error. What would be the reason?
 
I wrote the code in the module templates file, but I'm getting an error.



I made two animations as standing_1 and sitting_1. I placed these animations in the resource folder of my mod with open brf. (I created a new resource file for my animations and put my animations in it) then I wrote the code load_mod_resource = my_mod in the module ini file. I wrote the following codes instead of two of the unused_human_anim codes in the module animation file.

["sitting_1", acf_enforce_all, amf_priority_die|amf_keep,
[18.0, "sitting_1", 3, 301, arf_use_stand_progress|arf_cyclic, 0, (0, 0, 0), 0.25],],

["standing_1", acf_enforce_all, amf_priority_die|amf_keep,
[18.0, "standing_1", 3, 301, arf_use_stand_progress|arf_cyclic, 0, (0, 0, 0), 0.25],],

But I am getting the above error. What would be the reason?
That's my problem, I can't explain clearly for the tutorial.
English is not my mother tongue.

(agent_set_animation, ": player_agent", "anim_standing_1")
The red part might be the reason for the error. You should add it.

And you don't need amf_keep flag in stand up animation, that might cause another problem when you stand up. Change it to amf_play and replace arf_use_stand_progress|arf_cyclic to arf_blend_in_1 for smooth animation stand up.
 
Last edited:
That's my problem, I can't explain clearly for the tutorial.
English is not my mother tongue.

(agent_set_animation, ": player_agent", "anim_standing_1")
The red part might be the reason for the error. You should add it.

And you don't need amf_keep flag in stand up animation, that might cause another problem when you stand up. Change it to amf_play and replace arf_use_stand_progress|arf_cyclic to arf_blend_in_1 for smooth animation stand up.
I did what you said but I still get the error. I changed the codes to anim_sitting_1 and anim_standing_1 and this time it gave the same error with the anim tag. I didn't understand how to solve it

By the way I put the code at the top of the task templates file. At first I put it in a different place and it gave a complete error. Then, when I placed it at the top (after the titles, of course), it started giving this error.
 
Ok, I'll give you an example.

In animations.py.

["sitting_1", acf_enforce_all, amf_priority_die|amf_keep,
[18.0, "sitting_1", 3, 301, arf_use_stand_progress|arf_cyclic, 0, (0, 0, 0), 0.25],],

In mission_templates.py.

...
...
(agent_get_slot, ":sitting", ":player_agent", slot_agent_sitting),
(eq, ":sitting", 0),
(agent_set_animation, ":player_agent", "anim_sitting_1"), # sit animation
...
...

Then first, add the trigger code after "af_castle_lord = af_override_horse | af_override_weapons| af_require_civilian".
It looks like this.
Python:
af_castle_lord = af_override_horse | af_override_weapons| af_require_civilian

player_sit = (
    ...
    ...

Now, add the trigger to the mission you want. Like if you want to sit in the town. Searching "town_default" and add trigger like this.
Python:
...
...
     (30,mtef_visitor_source,af_override_horse,0,1,[]),
     (31,mtef_visitor_source,af_override_horse,0,1,[]),

     ],   
     [
     player_sit, 
      (1, 0, ti_once, [], 
...
...
 
Ok, I'll give you an example.

In animations.py.

["sitting_1", acf_enforce_all, amf_priority_die|amf_keep,
[18.0, "sitting_1", 3, 301, arf_use_stand_progress|arf_cyclic, 0, (0, 0, 0), 0.25],],

In mission_templates.py.

...
...
(agent_get_slot, ":sitting", ":player_agent", slot_agent_sitting),
(eq, ":sitting", 0),
(agent_set_animation, ":player_agent", "anim_sitting_1"), # sit animation
...
...

Then first, add the trigger code after "af_castle_lord = af_override_horse | af_override_weapons| af_require_civilian".
It looks like this.
Python:
af_castle_lord = af_override_horse | af_override_weapons| af_require_civilian

player_sit = (
    ...
    ...

Now, add the trigger to the mission you want. Like if you want to sit in the town. Searching "town_default" and add trigger like this.
Python:
...
...
     (30,mtef_visitor_source,af_override_horse,0,1,[]),
     (31,mtef_visitor_source,af_override_horse,0,1,[]),

     ],  
     [
     player_sit,
      (1, 0, ti_once, [],
...
...
I did what you said and imported my module without any problems, thank you. But I have one more question. I have no idea what trigger to add under town_default. I want to be able to use the animation in the tavern. But I don't know how to write a trigger. (I'm not very good at coding.) I'm sorry if I made you too busy.
 
This is a simple explanation for triggers.

For example:

player_sit = (
...
...

The red part is the trigger you need to add in any missions you want.
"town_default" is the mission for town scenes. Tavern scene is in town_default, too.
And there's more, like "village_center", is for normal village scenes. "lead_charge" is field battle.
 
This is a simple explanation for triggers.

For example:

player_sit = (
...
...

The red part is the trigger you need to add in any missions you want.
"town_default" is the mission for town scenes. Tavern scene is in town_default, too.
And there's more, like "village_center", is for normal village scenes. "lead_charge" is field battle.
Now I understand very well what you mean. I tried to interpret the code incorrectly. My stupidity :grin: Thank you again.
 
This is a simple explanation for triggers.

For example:

player_sit = (
...
...

The red part is the trigger you need to add in any missions you want.
"town_default" is the mission for town scenes. Tavern scene is in town_default, too.
And there's more, like "village_center", is for normal village scenes. "lead_charge" is field battle.
As of now, the animation is working smoothly, thank you for your help, my friend :smile:
 
If you know anything else about coding, can I ask you a few more questions?
You can ask in this forum. If I know that, I will answer you the question. Or maybe anyone can help you.
I don't have any python experience before.
All I learned is from this game in these two years.
 
Back
Top Bottom