[Help] How to voice companions in module_dialogs.py?

Users who are viewing this thread

I understand how to use the built in voiceover system,

..[], "snd_sound"]

with snd_sound in the seventh field.


I understand how to call sounds with play_sound

  [trp_ramun_the_slave_trader,"start", [], "Hello, {playername}.", "ramun_talk",[ (play_sound, "sound")]],


But I do not know how to make agent_play_sound work with the above line. I want to use agent_play_sound in order to use agent_stop_sound along with it, in order to prevent sounds from overlapping.

And finally, how do I add voice to companions? To each individual companion, their speeches, disagreements and so on?
I need to be able to differentiate between them, and not play the same set of sounds for all.

Thanks!!
 
In dialogs, the troop you are talking to is stored in "$g_talk_troop" and the agent you are talking to is stored in "$g_talk_agent"
You can use "$g_talk_troop" to test for equality with different companions "trp_npcX" and then choose an appropriate sound and play it with (agent_play_sound, "$g_talk_agent", ":sound_you_found"),
 
Ahh thank you much!

Works perfectly, I can start and stop dialogues whenever I need to.

  [trp_ramun_the_slave_trader,"start", [(agent_play_sound, "$g_talk_agent", "snd_sound_1")], "Hello, {playername}.", "ramun_talk",[]],


  [trp_ramun_the_slave_trader,"ramun_ask_about_capturing", [(agent_stop_sound, "$g_talk_agent"),
                                                                                                (agent_play_sound, "$g_talk_agent", "snd_sound_2")],

And the equality check is perfect as well

  (eq, "$g_talk_troop", trp_npc1),


And so finally I end up with this, and I can make a block for each companion.

Code:
  [anyone, "start", [(is_between, "$g_talk_troop", companions_begin, companions_end),
                     (troop_slot_eq, "$g_talk_troop", slot_troop_occupation, 0),
                     (eq, "$g_talk_troop_met", 0),
                     (troop_get_slot, ":intro", "$g_talk_troop", slot_troop_intro),
                     (str_store_string, 5, ":intro"),
                     (str_store_party_name, 20, "$g_encountered_party"),
                     (eq, "$g_talk_troop", trp_npc1)
                     (agent_play_sound, "$g_talk_agent", "snd_sound_1"),
   ],

Do you have any other tips or suggestions? Thanks again!

EDIT:
I have found that agent_play_sound does not work is if its "|plyr"
  [trp_ramun_the_slave_trader|plyr,"ramun_ask_about_capturing_4", [],
 
nullpat said:
Do you have any other tips or suggestions?
Rather than set up an individual dialog for every troop, you could do a single dialog and use a slot-based system like the dialog texts:
      (troop_get_slot, ":sound", "$g_talk_troop", slot_troop_sound_for_whatever),
      (agent_play_sound, "$g_talk_agent", ":sound"),
having set the troop slots up in the script_initialize_npcs where the strings are set up (like slot_troop_signup_response_1 etc)

or you could use an 'offset' system to select the correct sound by doing
      (store_sub, ":npc_offset", "$g_talk_troop", companions_begin),
      (store_add, ":sound", ":npc_offset", "snd_SOUND_FOR_NPC1"),
      (agent_play_sound, "$g_talk_agent", ":sound"),
which skips the need for the slots, but forces you to put the sounds in order in the module_sounds file.

nullpat said:
EDIT:
I have found that agent_play_sound does not work is if its "|plyr"
  [trp_ramun_the_slave_trader|plyr,"ramun_ask_about_capturing_4", [],
Must be something to do with how agent_play_sound decides whether or not to play the sound--if you're close enough to the source, etc. Have you tried using the player-agent instead of the talk agent for the |plyr options?
    (get_player_agent_no, ":player_agent"),
    (agent_play_sound, ":player_agent", "snd_sound"),

If that doesn't work and you are forced to use (play_sound) you could use the Warband Script Enhancer as it provides new operations to help with this:
Code:
sound_channel_stop          = 4200 #(sound_channel_stop, <sound_channel>), #Stops <sound_channel>
sound_channel_set_frequency = 4201 #(sound_channel_set_frequency, <sound_channel>, <frequency_in_hz>), #Sets the frequency of <sound_channel> to <frequency_in_hz>
sound_channel_set_position  = 4202 #(sound_channel_set_position, <sound_channel>, <position_register>), #Sets <sound_channel>'s position to <position_register>
get_last_sound_channel      = 4203 #(get_last_sound_channel, <destination>), #Stores the last played sound channel by play_sound or play_sound_at_position into <destination>
Use the (get_last_sound_channel), followed by (sound_channel_stop) and you can control it as directly as agent_start/stop_sound

 
Warband Script Enhancer is beautiful.

This is how I'm doing it in case anyone else needs to.

To play:

      (play_sound, "snd_ramun_1"),

      (get_last_sound_channel, "$s1"),

To stop:

      (sound_channel_stop, "$s1"),
 
Back
Top Bottom