Victory Cheering (SOLVED)

Users who are viewing this thread

Hello friends! I have been working on adding some simple immersive features to a mod I am making. This includes the ability for the player to cheer along with comrades at the end of fights. Before you jump to conclusions about what I ask, know that I actually successfully did that already! The player can simply press a key and cheer!

My question is actually about bot cheering. I want to add sounds for female cheering. I plan to just add some of the already included woman yelling noises as the cheering noise as well (for now at least). My issue is I simply cannot locate within the module system where the bot victory cheering is.

I ctrl f'd through mission templates looking for victory and cheer, assuming that the codes for bot cheering would be in the same file as the player's, and I also went through animations, but I haven't had any luck. I am assuming there is a place where the man cheering sound is attached to the cheering movement. I just need to find the female version and add a similar sound code attachment as far as I know.

So my question is, does anyone know where to locate the NPC/bot cheering code where I might edit to my hearts content? Thanks ahead of time.
 
Solution
Can you tell how your current module skins entry for the women looks like? It might be that you are simply missing an entry there.

Looking at the Native Module System you have the following entry for the woman skin:
Code:
  (
    "woman", skf_use_morph_key_10,
    "woman_body",  "woman_calf_l", "f_handL",
    "female_head", woman_face_keys,
    ["woman_hair_p","woman_hair_n","woman_hair_o","woman_hair_q","woman_hair_r","woman_hair_t","woman_hair_s"], #woman_hair_meshes
#    ["woman_hair_a","woman_hair_b","woman_hair_c","woman_hair_d","woman_hair_e","woman_hair_f","woman_hair_g"], #woman_hair_meshes
    [],
    ["hair_blonde", "hair_red", "hair_brunette", "hair_black", "hair_white"], #hair textures
    []...
set_cheer_at_no_enemy is the operation responsible for making bots cheer when no enemies are alive in multi-player, although I do not know if such behavior is hardcoded in single-player; in other words bots playing anim_cheer when no enemies are alive might be their default action. Anyway, instances of set_cheer_at_no_enemy are found only in multi-player code (Native source) and the operation was added later to the engine (1.153).

To make female bots play female sounds, you may cycle through all agents in a mission and use troop_get_type operation (its alternative in multi-player is player_get_gender for human players) to get their gender. Then you may make a conditional block to make some agent play a sound through agent_play_sound.

I am not a professional scripter, so do not view the following as bug-free, but use it as a point of reference. You may pair it with other script to be fired when all enemies are defeated in a mission like lead_charge.

Python:
(try_for_agents, ":agent"),
   (agent_is_alive, ":agent"),
   (agent_is_human, ":agent"), #not a horse
   (agent_is_non_player, ":agent"), #bots only
   (agent_get_troop_id, ":troop", ":agent"),
   (troop_get_type, ":is_female", ":troop"),
      (try_begin),
         (eq, ":is_female", 1),
         (agent_play_sound, ":agent", "snd_woman_yell"),
      (else_try),
         (eq, ":is_female", 0),
         (agent_play_sound, ":agent", "snd_man_yell"),
      (try_end),
   (agent_set_animation, ":agent", "anim_cheer", 1),
(try_end),
 
Upvote 0
After much failure, I managed to get this to work about 90% of the way. I placed the code into the common battle section of my mission templates file, rather than in the individual missions like lead charge. This was the only way I could get the woman to make any cheering sounds. They emitted the correct noises, and made the correct movements when the battle ended. The ONLY problem is that it seems the sound is not attached to the animation like with the men.

So what happens is the battle is won, I stare at any women near me, and they are performing the victory animation with no sound. Then, at a specific moment in time after the battle ended, all the women cheer at the exact same time regardless of what part of the animation they are in. In the grand scheme of things I could live with this considering they are now guaranteed to cheer once at the end of the battle, but I guess there is still room for improvement.

My thinking is that the code focuses on the battle's end time, and has the women cheer at a certain amount of time after, rather than doing it every time they do the animation cheer after the battle is won like the men do. Any ideas?

Also, thank you so much for even responding! I know many people are moving to Bannerlord now and I am grateful for your help. Thanks to you I have a serviceable woman cheering noise code!
 
Upvote 0
After much failure, I managed to get this to work about 90% of the way. I placed the code into the common battle section of my mission templates file, rather than in the individual missions like lead charge. This was the only way I could get the woman to make any cheering sounds. They emitted the correct noises, and made the correct movements when the battle ended. The ONLY problem is that it seems the sound is not attached to the animation like with the men.

So what happens is the battle is won, I stare at any women near me, and they are performing the victory animation with no sound. Then, at a specific moment in time after the battle ended, all the women cheer at the exact same time regardless of what part of the animation they are in. In the grand scheme of things I could live with this considering they are now guaranteed to cheer once at the end of the battle, but I guess there is still room for improvement.

My thinking is that the code focuses on the battle's end time, and has the women cheer at a certain amount of time after, rather than doing it every time they do the animation cheer after the battle is won like the men do. Any ideas?

Also, thank you so much for even responding! I know many people are moving to Bannerlord now and I am grateful for your help. Thanks to you I have a serviceable woman cheering noise code!
You are welcome, but please, do not leave yet; there is more to discuss. Yes, you are right; men's sound and animation upon winning a battle are hardcoded, therefore women's behavior must be scripted separately with Module System. The script I provided was meant to be paired with another to be fired when battle is won by either party. Maybe the resolution can be achieved by making a trigger which will check for enemy agents. When there are none alive and others are routed or dead, the trigger will delay the consequences (women cheering). That way, with a sprinkle of fine-tuning, you will be able to synchronize hardcoded men's cheering and scripted women's cheering. Also, store_random_in_range might be used to get values based on which the agents will perform cheering in random order and not at the same time. That way, female agents will behave the same way as their male counterparts.
 
Upvote 0
I am currently attempting to add the store_random_in_range. I scrolled down to look at different situations in which it was used, and its followed by the minimum and maximum values. So I tried to add my own minimum and maximum values to the randomization code I made for the cheering. I don't get any errors when compiling, but i get: "WARNING: Local variable never used: rand, at: 0". I know this is a direct result of my edit because it was not there before I attempted to add the randomization. So my question is, how can I learn what numbers the male cheering have for their randomization, or do I have to just go with a trial and error system until I luck out and pick the right numbers? I also feel like it would be easier if there was a place where the values are stored and I could just add my own section for women cheering, so maybe that is an option?

Everything else seems to be working without an issue so I think we are close!
 
Upvote 0
I am currently attempting to add the store_random_in_range. I scrolled down to look at different situations in which it was used, and its followed by the minimum and maximum values. So I tried to add my own minimum and maximum values to the randomization code I made for the cheering. I don't get any errors when compiling, but i get: "WARNING: Local variable never used: rand, at: 0". I know this is a direct result of my edit because it was not there before I attempted to add the randomization. So my question is, how can I learn what numbers the male cheering have for their randomization, or do I have to just go with a trial and error system until I luck out and pick the right numbers? I also feel like it would be easier if there was a place where the values are stored and I could just add my own section for women cheering, so maybe that is an option?

Everything else seems to be working without an issue so I think we are close!
It is good to hear things are getting better!

Generally speaking, using this local variable: ":unused" should be enough, but it is a warning, not an error after all.

I am not sure if I understand your question, therefore I will clarify my previous point in order to avoid any misunderstandings on your part. Male cheering is hardcoded, so male agents do it after vanquishing their foes for a couple of times in different intervals for every agent. Female cheering must be scripted to make female agents cheer at least once. To avoid having female agents cheer at the same time, store_random_in_range must be used to get a value for every agent which will later be assigned to some period of time after winning a battle. Simply put, female agents will get randomized values which affect when they will cheer. I do not understand the part of your post written in green because every agent will have different value from randomization. Tampering with it would be pointless, I suppose. Also, you may look how Native used the operation with relation to scripts relying on time and so forth.
 
Upvote 0
Ok I see what you are saying. Just ignore the green section altogether. The only issue I have with the warning is that it appears to be preventing the actual randomization from happening. And when I tell the code that it has an unused value, then it turns into an error which is worse. Perhaps I need to go through some more trial and error to get the line into the correct format. Most scripts involving time are either for multiplayer or for situations not involved with battles so I'll have to try different ones to see what works.
 
Upvote 0
Ok I see what you are saying. Just ignore the green section altogether. The only issue I have with the warning is that it appears to be preventing the actual randomization from happening. And when I tell the code that it has an unused value, then it turns into an error which is worse. Perhaps I need to go through some more trial and error to get the line into the correct format. Most scripts involving time are either for multiplayer or for situations not involved with battles so I'll have to try different ones to see what works.
Good luck in your endeavors. When I have more time, I will try writing a script on my own to see if it works or not. Then, we will compare our scripts.
 
Upvote 0
Can you tell how your current module skins entry for the women looks like? It might be that you are simply missing an entry there.

Looking at the Native Module System you have the following entry for the woman skin:
Code:
  (
    "woman", skf_use_morph_key_10,
    "woman_body",  "woman_calf_l", "f_handL",
    "female_head", woman_face_keys,
    ["woman_hair_p","woman_hair_n","woman_hair_o","woman_hair_q","woman_hair_r","woman_hair_t","woman_hair_s"], #woman_hair_meshes
#    ["woman_hair_a","woman_hair_b","woman_hair_c","woman_hair_d","woman_hair_e","woman_hair_f","woman_hair_g"], #woman_hair_meshes
    [],
    ["hair_blonde", "hair_red", "hair_brunette", "hair_black", "hair_white"], #hair textures
    [],
    [("womanface_young",0xffe3e8ef,["hair_blonde"],[0xffffffff, 0xffb04717, 0xff502a19, 0xff19100c]),
     ("womanface_b",0xffdfdfdf,["hair_blonde"],[0xffa5481f, 0xff502a19, 0xff19100c, 0xff0c0d19]),
     ("womanface_a",0xffe8dfe5,["hair_blonde"],[0xff502a19, 0xff19100c, 0xff0c0d19]),
     ("womanface_brown",0xffaf9f7e,["hair_blonde"],[0xff19100c, 0xff0c0d19, 0xff007080c]),
     ("womanface_african",0xff808080,["hair_blonde"],[0xff120808, 0xff007080c]),
#     ("womanface_midage",0xffe5eaf0,["hair_black","hair_brunette","hair_red","hair_white"],[0xffffcded, 0xffbbcded, 0xff99eebb]),
     ],#woman_face_textures
    [(voice_die,"snd_woman_die"),(voice_hit,"snd_woman_hit"),(voice_yell,"snd_woman_yell")], #voice sounds
    "skel_human", 1.0,
    psys_game_blood,psys_game_blood_2,
  ),
Of interest for you is here the tuple field 13, the list of voices.
Code:
    [(voice_die,"snd_woman_die"),(voice_hit,"snd_woman_hit"),(voice_yell,"snd_woman_yell")], #voice sounds
Comparing it to the tuple field 13 of the man skin entry reveals that there are some voices missing:
Code:
    [(voice_die,"snd_man_die"),(voice_hit,"snd_man_hit"),(voice_grunt,"snd_man_grunt"),(voice_grunt_long,"snd_man_grunt_long"),(voice_yell,"snd_man_yell"),(voice_stun,"snd_man_stun"),(voice_victory,"snd_man_victory")], #voice sounds
You basically need to add the voice_victory part to your woman skin entry to activate female cheering.
 
Upvote 0
Solution
I am pretty confident that this is causing the issue, I have however not tested it yet. Chapter 5.3.2.9 of the Modding Guide, Skin/Gender/Race-based Voice Entries, is not done yet but it contains a single note which is about the silent troops problem. It links to the old MBX forum:
For the rest I still need to do research about to be able to tell more.

And sorry that I didn't mention it before but I was quite busy last week and haven't had the time to think fully about the problem.
 
Upvote 0
I just came back to this, and I decided to try out your strategy of editing the skins file. Well... IT WORKED. Not partially, not glitchy, it just straight up worked perfectly. I just copied the man sounds to the women section and renamed man_victory to woman_victory (you can do others like grunts and stuff!). I added the new sounds to be included under the woman_victory category, and bam! Women cheer along with animations, sound comes out, and its beautiful. Thank you so much for your help and my goodness, what a great find in terms of the skins file! This just makes me so happy! Someone make sure this wonderful information isn't lost and forgotten. That thread from 2013 needs to be saved. If anyone needs further clarification on what I did, let me know.
 
Upvote 0
Nice to see that it worked fine for you. This information will also be integrated in the next version of the Modding Guide (around beginning of December), so that it is not getting lost :grin:
Please mark also your problem as solved, for others to find the information quicker. Happy modding!
 
Upvote 0
Back
Top Bottom