block music to make way for musical sound

Users who are viewing this thread

Hello everyone,
I have used the tavern animation pack for a long time in my mod, but I always had a problem that I would like now, they will help me solve ... (I also commented the thread of this code but nobody answered)
The code includes musicians in the taverns and the problem is that when the sound starts at the same time, the music of the tavern is heard ...
I was trying to replace play_sound, by play_track and put the list of music themes, it works, but since the music I added are short themes (so that they are repeated continuously) they are not repeated, so the question is ... how Could I block Tavern's music every time there is a musician in the tavern ?, so that I want hear only the sound of his guitar, and not a mixture of both.
Thank you
 
Last edited:
Solution
sorry for the delay in the answer, the reason is that I did not mark the thread to follow it (I forgot).
If you are working on an older MS base, why are you not updating it? That would make some stuff far easier for you (and for us too when we try helping you)
I do not update it, because I have too many modifications, made with osp and things that I have modified myself and there are many, so many that I do not remember ... and it would be a very hard job to transfer from one place to another.
In any case, on this thread .... I left the tavern without music and increased the musicians. thanks anyway.
Hola Mauro

I never played around with the sound files but after a short look over the scripts:
header_operations
stop_all_sounds

Mission template Tavern ani
agent_play_sound, bla bla
Maybe you can use the operation before that?
 
Last edited by a moderator:
Upvote 0
Upvote 0
I already looked into it and gave you an answer hehe



Do you have header_operations from lav? If not download it... or post the code from your mission temp Tavern anim in the thread if you can't do it than can I look with the phone
 
Upvote 0
I already looked into it and gave you an answer hehe

Do you have header_operations from lav? If not download it... or post the code from your mission temp Tavern anim in the thread if you can't do it than can I look with the phone
header_operations from lav? I dont know, only header_operations
here is the mission triggers template
Code:
# inicio nueva taberna mauro #####################################################
dedal_tavern_animations = (
    ti_on_agent_spawn,1,0,[
        (eq, "$talk_context", tc_tavern_talk),
        (store_trigger_param_1,":agent"),
        (agent_get_troop_id,":troop",":agent"),
        (try_begin),
            (is_between,":troop","trp_musican_male","trp_quastuosa_1"),
            (try_begin),
                (agent_has_item_equipped,":agent","itm_dedal_lutnia"),
                (agent_set_stand_animation, ":agent", "anim_lute_sitting"),
                (agent_set_animation, ":agent", "anim_lute_sitting"),
#                (is_between,9,"track_musica1","track_musica_fin"),
#                (store_repeat_object),
#                (this_or_next|eq, play_cue_track,"track_musica1"),
#                (this_or_next|eq, play_cue_track,"track_musica2"),
#                (this_or_next|eq, play_cue_track,"track_musica3"),
#                (this_or_next|eq, play_cue_track,"track_musica4"),
#                (this_or_next|eq, play_cue_track,"track_musica5"),
#                (this_or_next|eq, play_cue_track,"track_musica6"),
#                (this_or_next|eq, play_cue_track,"track_musica7"),
#                (this_or_next|eq, play_cue_track,"track_musica8"),
#                (eq, play_cue_track,"track_musica9"),
                (agent_play_sound,":agent","snd_dedal_tavern_lute"),
#            (else_try),
#                (agent_has_item_equipped,":agent","itm_dedal_lutnia"),
#                (agent_set_stand_animation, ":agent", "anim_lute_sitting"),
#                (agent_set_animation, ":agent", "anim_lute_sitting"),
#                (agent_play_sound,":agent","snd_dedal_tavern_lute"),
            (try_end),
            (store_random_in_range,":r",0,300),
            (agent_set_animation_progress,":agent",":r"),
        (else_try),
            (is_between,":troop","trp_musican_male","trp_quastuosa_1"),
            (try_begin),
                (agent_has_item_equipped,":agent","itm_dedal_lutnia"),
                (agent_set_stand_animation, ":agent", "anim_lute_standing"),
                (agent_set_animation, ":agent", "anim_lute_standing"),
                (agent_play_sound,":agent","snd_dedal_tavern_lute"),
#            (else_try),
#                (agent_has_item_equipped,":agent","itm_dedal_lutnia"),
#                (agent_set_stand_animation, ":agent", "anim_lute_standing"),
#                (agent_set_animation, ":agent", "anim_lute_standing"),
#                (agent_play_sound,":agent","snd_dedal_tavern_lute"),
            (try_end),
            (store_random_in_range,":r",0,300),
            (agent_set_animation_progress,":agent",":r"),
        (else_try),
            (is_between,":troop","trp_town_walker_1","trp_khergit_townswoman"),
            (try_begin),
                (agent_has_item_equipped,":agent","itm_dedal_kufel"),
                (agent_set_stand_animation, ":agent", "anim_sitting_drinking_low"),
                (agent_set_animation, ":agent", "anim_sitting_drinking_low"),
                (store_random_in_range,":r",0,300),
            (else_try),
                (agent_set_stand_animation, ":agent", "anim_sitting_low"),
                (agent_set_animation, ":agent", "anim_sitting_low"),
                (store_random_in_range,":r",0,300),
            (try_end),
            (agent_set_animation_progress,":agent",":r"),
        (try_end),
    ],[])
    # fin nueva tabena mauro
 
Upvote 0
In module_missions_templates.py find this code 2 instances:
Code:
(call_script, "script_music_set_situation_with_culture", mtf_sit_tavern),
And replace mtf_sit_tavern with 0.
Code:
(call_script, "script_music_set_situation_with_culture", 0),

This will stop any music track that doesn't have mtf_persist_until_finished flag.
 
Upvote 0
In module_missions_templates.py find this code 2 instances:
Code:
(call_script, "script_music_set_situation_with_culture", mtf_sit_tavern),
And replace mtf_sit_tavern with 0.
Code:
(call_script, "script_music_set_situation_with_culture", 0),

This will stop any music track that doesn't have mtf_persist_until_finished flag.
the problem is that I want to stop the music when a sound starts (I have the tavern animation pack). then the tavern music begins while the character plays the guitar. and that is annoying
 
Upvote 0
it doesn't work, I put it down, then up, I also put (neq, call_script, "script_music_set_situation_with_culture", mtf_sit_tavern),
later I put him in the mission Town_defaul (where the music is called)
changing the variable: agent to $ g_agent_cantor, but it didn't work either ... (when compiling, no errors)
Code:
(else_try),
         (eq, agent_play_sound, "$ g_agent_cantor", "snd_dedal_tavern_lute"),
         (call_script, "script_music_set_situation_with_culture", 0),
           (eq, "$ talk_context", tc_tavern_talk),
           (call_script, "script_music_set_situation_with_culture", mtf_sit_tavern),
         (else_try),
 
Last edited:
Upvote 0
I have tested and it works. Just you need to replace in the mission templates mtf_sit_tavern to 0 and it will remove tavern music completely. Or place this code right after agent_play_sound (every instance) if you want to play tavern music when there is now musician.

But your code is seems to be broken.
 
Upvote 0
Code:
# inicio nueva taberna mauro #####################################################
dedal_tavern_animations = (
    ti_on_agent_spawn,1,0,[
        (eq, "$talk_context", tc_tavern_talk),
        (store_trigger_param_1,":agent"),
        (agent_get_troop_id,":troop",":agent"),
        (try_begin),
            (is_between,":troop","trp_musican_male","trp_quastuosa_1"),
            (try_begin),
                (agent_has_item_equipped,":agent","itm_dedal_lutnia"),
                (agent_set_stand_animation, ":agent", "anim_lute_sitting"),
                (agent_set_animation, ":agent", "anim_lute_sitting"),
#                (is_between,9,"track_musica1","track_musica_fin"),
#                (store_repeat_object),
#                (this_or_next|eq, play_cue_track,"track_musica1"),
#                (this_or_next|eq, play_cue_track,"track_musica2"),
#                (this_or_next|eq, play_cue_track,"track_musica3"),
#                (this_or_next|eq, play_cue_track,"track_musica4"),
#                (this_or_next|eq, play_cue_track,"track_musica5"),
#                (this_or_next|eq, play_cue_track,"track_musica6"),
#                (this_or_next|eq, play_cue_track,"track_musica7"),
#                (this_or_next|eq, play_cue_track,"track_musica8"),
#                (eq, play_cue_track,"track_musica9"),
                (agent_play_sound,":agent","snd_dedal_tavern_lute"),
                (call_script, "script_music_set_situation_with_culture", 0),
#            (else_try),
#                (agent_has_item_equipped,":agent","itm_dedal_lutnia"),
#                (agent_set_stand_animation, ":agent", "anim_lute_sitting"),
#                (agent_set_animation, ":agent", "anim_lute_sitting"),
#                (agent_play_sound,":agent","snd_dedal_tavern_lute"),
            (try_end),
            (store_random_in_range,":r",0,300),
            (agent_set_animation_progress,":agent",":r"),
        (else_try),
            (is_between,":troop","trp_musican_male","trp_quastuosa_1"),
            (try_begin),
                (agent_has_item_equipped,":agent","itm_dedal_lutnia"),
                (agent_set_stand_animation, ":agent", "anim_lute_standing"),
                (agent_set_animation, ":agent", "anim_lute_standing"),
                (agent_play_sound,":agent","snd_dedal_tavern_lute"),
                (call_script, "script_music_set_situation_with_culture", 0),
#            (else_try),
#                (agent_has_item_equipped,":agent","itm_dedal_lutnia"),
#                (agent_set_stand_animation, ":agent", "anim_lute_standing"),
#                (agent_set_animation, ":agent", "anim_lute_standing"),
#                (agent_play_sound,":agent","snd_dedal_tavern_lute"),
            (try_end),
            (store_random_in_range,":r",0,300),
            (agent_set_animation_progress,":agent",":r"),
        (else_try),
            (is_between,":troop","trp_town_walker_1","trp_khergit_townswoman"),
            (try_begin),
                (agent_has_item_equipped,":agent","itm_dedal_kufel"),
                (agent_set_stand_animation, ":agent", "anim_sitting_drinking_low"),
                (agent_set_animation, ":agent", "anim_sitting_drinking_low"),
                (store_random_in_range,":r",0,300),
            (else_try),
                (agent_set_stand_animation, ":agent", "anim_sitting_low"),
                (agent_set_animation, ":agent", "anim_sitting_low"),
                (store_random_in_range,":r",0,300),
            (try_end),
            (agent_set_animation_progress,":agent",":r"),
        (try_end),
    ],[])
    # fin nueva tabena mauro
 
Upvote 0
Code:
# inicio nueva taberna mauro #####################################################
dedal_tavern_animations = (
    ti_on_agent_spawn,1,0,[
        (eq, "$talk_context", tc_tavern_talk),
        (store_trigger_param_1,":agent"),
        (agent_get_troop_id,":troop",":agent"),
        (try_begin),
            (is_between,":troop","trp_musican_male","trp_quastuosa_1"),
            (try_begin),
                (agent_has_item_equipped,":agent","itm_dedal_lutnia"),
                (agent_set_stand_animation, ":agent", "anim_lute_sitting"),
                (agent_set_animation, ":agent", "anim_lute_sitting"),
#                (is_between,9,"track_musica1","track_musica_fin"),
#                (store_repeat_object),
#                (this_or_next|eq, play_cue_track,"track_musica1"),
#                (this_or_next|eq, play_cue_track,"track_musica2"),
#                (this_or_next|eq, play_cue_track,"track_musica3"),
#                (this_or_next|eq, play_cue_track,"track_musica4"),
#                (this_or_next|eq, play_cue_track,"track_musica5"),
#                (this_or_next|eq, play_cue_track,"track_musica6"),
#                (this_or_next|eq, play_cue_track,"track_musica7"),
#                (this_or_next|eq, play_cue_track,"track_musica8"),
#                (eq, play_cue_track,"track_musica9"),
                (agent_play_sound,":agent","snd_dedal_tavern_lute"),
                (call_script, "script_music_set_situation_with_culture", 0),
#            (else_try),
#                (agent_has_item_equipped,":agent","itm_dedal_lutnia"),
#                (agent_set_stand_animation, ":agent", "anim_lute_sitting"),
#                (agent_set_animation, ":agent", "anim_lute_sitting"),
#                (agent_play_sound,":agent","snd_dedal_tavern_lute"),
            (try_end),
            (store_random_in_range,":r",0,300),
            (agent_set_animation_progress,":agent",":r"),
        (else_try),
            (is_between,":troop","trp_musican_male","trp_quastuosa_1"),
            (try_begin),
                (agent_has_item_equipped,":agent","itm_dedal_lutnia"),
                (agent_set_stand_animation, ":agent", "anim_lute_standing"),
                (agent_set_animation, ":agent", "anim_lute_standing"),
                (agent_play_sound,":agent","snd_dedal_tavern_lute"),
                (call_script, "script_music_set_situation_with_culture", 0),
#            (else_try),
#                (agent_has_item_equipped,":agent","itm_dedal_lutnia"),
#                (agent_set_stand_animation, ":agent", "anim_lute_standing"),
#                (agent_set_animation, ":agent", "anim_lute_standing"),
#                (agent_play_sound,":agent","snd_dedal_tavern_lute"),
            (try_end),
            (store_random_in_range,":r",0,300),
            (agent_set_animation_progress,":agent",":r"),
        (else_try),
            (is_between,":troop","trp_town_walker_1","trp_khergit_townswoman"),
            (try_begin),
                (agent_has_item_equipped,":agent","itm_dedal_kufel"),
                (agent_set_stand_animation, ":agent", "anim_sitting_drinking_low"),
                (agent_set_animation, ":agent", "anim_sitting_drinking_low"),
                (store_random_in_range,":r",0,300),
            (else_try),
                (agent_set_stand_animation, ":agent", "anim_sitting_low"),
                (agent_set_animation, ":agent", "anim_sitting_low"),
                (store_random_in_range,":r",0,300),
            (try_end),
            (agent_set_animation_progress,":agent",":r"),
        (try_end),
    ],[])
    # fin nueva tabena mauro
I deleted that, because I previously tried to put the sounds as music, but it was not the same, because the repetition of the music was not progressive ...
what I have now is the following:
Code:
dedal_tavern_animations = (
    ti_on_agent_spawn,1,0,[

        (eq, "$talk_context", tc_tavern_talk),
        (store_trigger_param_1,"$g_agent_cantor"),
        (agent_get_troop_id,":troop","$g_agent_cantor"),
        (try_begin),
            (is_between,":troop","trp_musican_male","trp_quastuosa_1"),
            (try_begin),
                (agent_has_item_equipped,"$g_agent_cantor","itm_dedal_lutnia"),
                (agent_set_stand_animation, "$g_agent_cantor", "anim_lute_sitting"),
                (agent_set_animation, "$g_agent_cantor", "anim_lute_sitting"),
                (agent_play_sound,"$g_agent_cantor","snd_dedal_tavern_lute"),
                (call_script, "script_music_set_situation_with_culture", 0),
            (try_end),

            (store_random_in_range,":r",0,300),
            (agent_set_animation_progress,"$g_agent_cantor",":r"),
        (else_try),
            (is_between,":troop","trp_musican_male","trp_quastuosa_1"),
            (try_begin),
                (agent_has_item_equipped,"$g_agent_cantor","itm_dedal_lutnia"),
                (agent_set_stand_animation, "$g_agent_cantor", "anim_lute_standing"),
                (agent_set_animation, "$g_agent_cantor", "anim_lute_standing"),
                (agent_play_sound,"$g_agent_cantor","snd_dedal_tavern_lute"),
                (call_script, "script_music_set_situation_with_culture", 0),
            (try_end),

            (store_random_in_range,":r",0,300),
            (agent_set_animation_progress,"$g_agent_cantor",":r"),
        (else_try),
            (is_between,":troop","trp_town_walker_1","trp_khergit_townswoman"),
            (try_begin),
                (agent_has_item_equipped,"$g_agent_cantor","itm_dedal_kufel"),
                (agent_set_stand_animation, "$g_agent_cantor", "anim_sitting_drinking_low"),
                (agent_set_animation, "$g_agent_cantor", "anim_sitting_drinking_low"),
                (store_random_in_range,":r",0,300),
            (else_try),
                (agent_set_stand_animation, "$g_agent_cantor", "anim_sitting_low"),
                (agent_set_animation, "$g_agent_cantor", "anim_sitting_low"),
                (store_random_in_range,":r",0,300),
            (try_end),
            (agent_set_animation_progress,"$g_agent_cantor",":r"),
        (try_end),

    ],[])
when I tried again, in the taverns that had musicians, the tavern music was not heard until the repetition of the sound began again
 
Upvote 0
Hola @mauromagno, I can help you with this. First, I see that the flow of execution checks the same range of troops, let's see:
Python:
(is_between, ":troop", "trp_musican_male", "trp_quastuosa_1"),
You must correct this with another troop range or eliminate it.



You can check if the troop has an instrument equipped with a global variable 'g_dedal_tavern_animations'.
Python:
dedal_tavern_animations = (
    ti_on_agent_spawn, 1, 0,
        [
            (eq, "$talk_context", tc_tavern_talk),

            (store_trigger_param_1, "$g_agent_cantor"),

            (agent_get_troop, ":troop_id", "$g_agent_cantor"),

            (set_fixed_point_multiplier, 100),
            (assign, ":animation_id", -1),
            (try_begin),
                (is_between, ":troop_id", "trp_musican_male", "trp_quastuosa_1"),

                (try_begin),
                    (agent_has_item_equipped, "$g_agent_cantor", "itm_dedal_lutnia"),

                    (assign, "$g_dedal_tavern_animations", 1),
                    (assign, ":animation_id", "anim_lute_sitting"),
                    (agent_play_sound, "$g_agent_cantor", "snd_dedal_tavern_lute"),
                # (else_try),
                    # (agent_has_item_equipped, "$g_agent_cantor", "itm_dedal_lira"),

                    # (assign, "$g_dedal_tavern_animations", 1),
                    # (assign, ":animation_id", "anim_lyre_sitting"),
                    # (agent_play_sound, "$g_agent_cantor", "snd_dedal_tavern_lyre"),
                (try_end),
            (else_try),
                (is_between, ":troop_id", "trp_musican_male", "trp_quastuosa_1"), #correct this with another troop range, tavern minstrel?

                (try_begin),
                    (agent_has_item_equipped, "$g_agent_cantor", "itm_dedal_lutnia"),

                    (assign, "$g_dedal_tavern_animations", 1),
                    (assign, ":animation_id", "anim_lute_standing"),
                    (agent_play_sound, "$g_agent_cantor", "snd_dedal_tavern_lute"),
                # (else_try),
                    # (agent_has_item_equipped, "$g_agent_cantor", "itm_dedal_lira"),

                    # (assign, "$g_dedal_tavern_animations", 1),
                    # (assign, ":animation_id", "anim_lyre_standing"),
                    # (agent_play_sound, "$g_agent_cantor", "snd_dedal_tavern_lyre"),
                (try_end),
            (else_try),
                (is_between, ":troop_id", "trp_town_walker_1", "trp_khergit_townswoman"),

                (try_begin),
                    (agent_has_item_equipped, "$g_agent_cantor", "itm_dedal_kufel"),

                    (assign, ":animation_id", "anim_sitting_drinking_low"),
                (else_try),
                    (assign, ":animation_id", "anim_sitting_low"),
                (try_end),
            (try_end),

            #set animation
            (try_begin),
                (ge, ":animation_id", 0),

                (agent_set_stand_animation, "$g_agent_cantor", ":animation_id"),
                (agent_set_animation, "$g_agent_cantor", ":animation_id"),
                (store_random_in_range, ":r", 0, 100),
                (agent_set_animation_progress, "$g_agent_cantor", ":r"),
            (try_end),
        ],
        [])

Initialize the variable in game_menus, before Dedal's code, for more order: (assign, "$g_dedal_tavern_animations", 0),

In the town template trigger:
Python:
                        # Dedal Tavern Animations
                        (try_begin), #
                            (ge, "$g_dedal_tavern_animations", 1), #

                            (music_set_situation, 0), #
                        (else_try), #
                            (call_script, "script_music_set_situation_with_culture", mtf_sit_tavern),
                        (try_end), #
I just added it to my mod after seeing this post and everything is OK.
 
Upvote 0
Hola @mauromagno, I can help you with this. First, I see that the flow of execution checks the same range of troops, let's see:
Python:
(is_between, ":troop", "trp_musican_male", "trp_quastuosa_1"),
You must correct this with another troop range or eliminate it.



You can check if the troop has an instrument equipped with a global variable 'g_dedal_tavern_animations'.
Python:
dedal_tavern_animations = (
    ti_on_agent_spawn, 1, 0,
        [
            (eq, "$talk_context", tc_tavern_talk),

            (store_trigger_param_1, "$g_agent_cantor"),

            (agent_get_troop, ":troop_id", "$g_agent_cantor"),

            (set_fixed_point_multiplier, 100),
            (assign, ":animation_id", -1),
            (try_begin),
                (is_between, ":troop_id", "trp_musican_male", "trp_quastuosa_1"),

                (try_begin),
                    (agent_has_item_equipped, "$g_agent_cantor", "itm_dedal_lutnia"),

                    (assign, "$g_dedal_tavern_animations", 1),
                    (assign, ":animation_id", "anim_lute_sitting"),
                    (agent_play_sound, "$g_agent_cantor", "snd_dedal_tavern_lute"),
                # (else_try),
                    # (agent_has_item_equipped, "$g_agent_cantor", "itm_dedal_lira"),

                    # (assign, "$g_dedal_tavern_animations", 1),
                    # (assign, ":animation_id", "anim_lyre_sitting"),
                    # (agent_play_sound, "$g_agent_cantor", "snd_dedal_tavern_lyre"),
                (try_end),
            (else_try),
                (is_between, ":troop_id", "trp_musican_male", "trp_quastuosa_1"), #correct this with another troop range, tavern minstrel?

                (try_begin),
                    (agent_has_item_equipped, "$g_agent_cantor", "itm_dedal_lutnia"),

                    (assign, "$g_dedal_tavern_animations", 1),
                    (assign, ":animation_id", "anim_lute_standing"),
                    (agent_play_sound, "$g_agent_cantor", "snd_dedal_tavern_lute"),
                # (else_try),
                    # (agent_has_item_equipped, "$g_agent_cantor", "itm_dedal_lira"),

                    # (assign, "$g_dedal_tavern_animations", 1),
                    # (assign, ":animation_id", "anim_lyre_standing"),
                    # (agent_play_sound, "$g_agent_cantor", "snd_dedal_tavern_lyre"),
                (try_end),
            (else_try),
                (is_between, ":troop_id", "trp_town_walker_1", "trp_khergit_townswoman"),

                (try_begin),
                    (agent_has_item_equipped, "$g_agent_cantor", "itm_dedal_kufel"),

                    (assign, ":animation_id", "anim_sitting_drinking_low"),
                (else_try),
                    (assign, ":animation_id", "anim_sitting_low"),
                (try_end),
            (try_end),

            #set animation
            (try_begin),
                (ge, ":animation_id", 0),

                (agent_set_stand_animation, "$g_agent_cantor", ":animation_id"),
                (agent_set_animation, "$g_agent_cantor", ":animation_id"),
                (store_random_in_range, ":r", 0, 100),
                (agent_set_animation_progress, "$g_agent_cantor", ":r"),
            (try_end),
        ],
        [])

Initialize the variable in game_menus, before Dedal's code, for more order: (assign, "$g_dedal_tavern_animations", 0),

In the town template trigger:
Python:
                        # Dedal Tavern Animations
                        (try_begin), #
                            (ge, "$g_dedal_tavern_animations", 1), #

                            (music_set_situation, 0), #
                        (else_try), #
                            (call_script, "script_music_set_situation_with_culture", mtf_sit_tavern),
                        (try_end), #
I just added it to my mod after seeing this post and everything is OK.
ok friend thanks, I'll try as soon as I can ...
sorry for the delay in reply, I have been very busy with frigate models: p
 
Upvote 0
@Dj_FRedy
The same thing happens friend, I tried putting your code in MT and also the lines in Game Menu, but the same thing happened ...
I think it may be my MSysttem, since it is not the latest version, it is quite old, from before 2017, so sometimes I have problems that nobody has hahaha. What I have thought is to leave the tavern without tavern music, but let the musicians appear in all of them and I don't know how to do it.
 
Upvote 0
sorry for the delay in the answer, the reason is that I did not mark the thread to follow it (I forgot).
If you are working on an older MS base, why are you not updating it? That would make some stuff far easier for you (and for us too when we try helping you)
I do not update it, because I have too many modifications, made with osp and things that I have modified myself and there are many, so many that I do not remember ... and it would be a very hard job to transfer from one place to another.
In any case, on this thread .... I left the tavern without music and increased the musicians. thanks anyway.
 
Upvote 0
Solution
Back
Top Bottom