Is Possible to Invoke play_sound from within Strings Module?

Users who are viewing this thread

Ashmond

Sergeant at Arms
From what I've learned so far, this has resulted in incredible failure.  Once I got a compilable syntax, the error "play_sound is undefined" persists.  What steps do I need to take to make this work?
 
if you meant module_strings.py, I have a feeling that there's some misunderstanding in whatever you've learnt.  the string table in module_strings.py do not contain operation blocks.
 
Yes, misunderstanding... hence the failure.  I was hoping that a script and/or trigger could be concocted.  Or, maybe if play_sound could be defined inside the module itself.  Or something...  Considering how little I've learned in the past week or so, it is very disappointing to run into so many limitations while I'm yet on the surface of it all.  :roll:
 
Module_strings is basically just a giant data dump; it's no sweat.  Calling a sound right before you call a string isn't a big deal- if it's for a Menu / Dialog that will show next, just add a quarter-second delay to the sound so that it seems to happen simultaneously with the action.
 
Maybe you guys can help me then, I'm not sure if I'm looking to do what you were just explaining, but I know nothing about the module strings or triggers, but I want to try and play a sound file for the text in the dialog screens. Basically a sound file voicing what is written in the dialog text. What exacctly would be the script I would put in before the dialog trigger to have it play the sound file?
 
Moshein_Gunn said:
Maybe you guys can help me then, I'm not sure if I'm looking to do what you were just explaining, but I know nothing about the module strings or triggers, but I want to try and play a sound file for the text in the dialog screens. Basically a sound file voicing what is written in the dialog text. What exacctly would be the script I would put in before the dialog trigger to have it play the sound file?

iirc, there should be a way to add it in module_dialogs.py as an optional parameter after the usual elements in a dialog entry.
 
sphere said:
Moshein_Gunn said:
Maybe you guys can help me then, I'm not sure if I'm looking to do what you were just explaining, but I know nothing about the module strings or triggers, but I want to try and play a sound file for the text in the dialog screens. Basically a sound file voicing what is written in the dialog text. What exacctly would be the script I would put in before the dialog trigger to have it play the sound file?

iirc, there should be a way to add it in module_dialogs.py as an optional parameter after the usual elements in a dialog entry.

I didn't even consider module_dialogs, I thought for sure it would be triggers. I was readin through module_dialogs, and I seen what you were saying, it says a voiceover string can be added at the end of the line, but the game has no voiceovers to begin with and nothing to reference as an example. Does anyone know what the string would have to be to add voiceovers?
 
Code:
  [anyone,"bandit_introduce", [
      (store_random_in_range, ":intro", "str_bandit_intro_1", "str_bandit_outro_1"),
      (str_store_string, s5, ":intro"),
    ], "{s5}", "bandit_talk",[[b](play_sound,"snd_encounter_bandits")[/b]]],
A sound reference (snd_x) can actually consist of many clips. They are played at random.
 
So would it just be adding

[ b](play_sound,"snd_xxx")[/ b]

to the end of the text, something like this

[anyone,"bandit_attack", [
      (store_random_in_range, ":rand", 11, 15),
        (str_store_string, s11, "@Another fool come to throw {him/her}self on my weapon, eh? Fine, let's fight!"),
        (str_store_string, s12, "@We're not afraid of you, {sirrah/wench}. Time to bust some heads!"),
        (str_store_string, s13, "@That was a mistake. Now I'm going to have to make your death long and painful."),
        (str_store_string, s14, "@Brave words. Let's see you back them up with deeds, cur!"),
        (str_store_string_reg, s5, ":rand"),
      ], "{s5}", "close_window",[[ b](play_sound,"snd_xxx")[/ b]]],

or can it be done like this to have a different sound for each option

[anyone,"bandit_attack", [
      (store_random_in_range, ":rand", 11, 15),
        (str_store_string, s11, "@Another fool come to throw {him/her}self on my weapon, eh? Fine, let's fight!"),[[ b](play_sound,"snd_xxx1")[/ b]]],
        (str_store_string, s12, "@We're not afraid of you, {sirrah/wench}. Time to bust some heads!"),[[ b](play_sound,"snd_xxx2")[/ b]]],
        (str_store_string, s13, "@That was a mistake. Now I'm going to have to make your death long and painful."),[[ b](play_sound,"snd_xxx3")[/ b]]],
        (str_store_string, s14, "@Brave words. Let's see you back them up with deeds, cur!"),[[ b]
(play_sound,"snd_xxx4")[/ b]]],
        (str_store_string_reg, s5, ":rand"),
      ], "{s5}", "close_window",[]],



of course without the spaces before the b's
 
Moshein_Gunn said:
But can I do it like that for each option or can you only put the script at the end and use it for all options?

You can do as you wish and voice each response tuple, more than one call to sounds(within the same tuple) will cause them to play at the same time I haven't figured nor found a fix as of yet.  But then, I'm trying to learn too much too soon...I blame it on OCD and ADD.  :mrgreen:  I'd wager that if your voiced responses are very long, then you'll get overlapping sounds if someone rushes through the dialog.  Maybe you could start with low priority and increase it every other tuple.

For example, I'll give you what I've used for learning this, it is very simple and based on tutorials - so no complex scripting.  Plus, it was fun for me at least.  This is for specific troops that I made as tavern strumpets...

[anyone, "start", [(is_between, "$g_talk_troop", madame_begin, madame_end),],
  "{My lord/My lady}. What can I, a humble servant of the flesh do for ye?", "madame_talk",[(play_sound, "snd_mmm"),]],

  [anyone, "madame_pretalk", [],"{playername}, I am at ye service anyway ye like.", "madame_talk",[]],
 
  [anyone, "madame_angry", [],
  "Oh? Everyone! {playername} is an impotent flounder!  And ye expect to rule when ye are not virile enough for me?\
  The people will hear of this!", "close_window",
        [(call_script, "script_change_player_relation_with_faction_ex", "$g_talk_troop_faction", -5),]],
 
  [anyone|plyr, "madame_talk", [],"We work hard, now we need play. On the to bedrolls, come what may this day!", "madame_ans1",[]],

  [anyone|plyr, "madame_talk", [],"Just ye and me, strumpet.", "madame_ans2",[]],

  [anyone|plyr, "madame_talk", [(neg|main_party_has_troop, "$g_talk_troop")],"Filthy whore, I love war!", "madame_angry",[]],

  [anyone|plyr, "madame_talk", [],"Naw, I smell something fishy.", "close_window",[(play_sound, "snd_sigh"),]],

  [anyone, "madame_ans1", [], "To the gods and goddesses we shall dedicate our orgy! However, {playername},\
  the machine needs grease, 5000 coins should suffice for our trife.", "madame_ans1a",[]],

  [anyone, "madame_ans2", [],"{playername} is selfish I see, 300 will suffice for ye and me.", "madame_ans2a",[]],

  [anyone|plyr, "madame_ans2a", [],"Then ye and me it shall be, here are your 300 coins.", "madame_pretalk",
      [(troop_remove_gold, "trp_player", 300),(call_script, "script_change_player_party_morale", -10),
      (call_script, "script_change_player_honor", -1),
      (add_xp_as_reward, 100),]],

  [anyone|plyr, "madame_ans2a", [],"*sniff* Are ye selling rotten meat?!", "madame_angry",[]],

  [anyone|plyr, "madame_ans2a", [],"Actually, I'm not feeling it.", "madame_pretalk",[]],
 
  [anyone|plyr, "madame_ans1a", [],"To the higher powers! Here are yer 5000 coins.", "madame_pretalk",
      [(troop_remove_gold, "trp_player", 5000),
      (call_script, "script_change_player_relation_with_faction_ex", "$g_talk_troop_faction", 5),
      (call_script, "script_change_player_party_morale", 20),
      (call_script, "script_change_player_honor", 5),
      (call_script, "script_change_player_relation_with_center", "$current_town",5),
      (add_xp_as_reward, 1000),]],

  [anyone|plyr, "madame_ans1a", [],"*sniff* Are ye selling rotten meat?!", "madame_angry",[]],

  [anyone|plyr, "madame_ans1a", [],"Actually, I'm not feeling it.", "madame_pretalk",[]],

You'll need to add your sound files to the sounds folder (I suggest Vorbis '.ogg' files, search for videolan and make use of a free converter) and declare them as such:

Code:
("mmm",sf_priority_9|sf_vol_9, ["mmm.ogg"]),
("sigh",sf_priority_9|sf_vol_9, ["sigh.ogg"]),
You can change the volume, priority and other stuff, see the sound module for examples.

And now I'm off to learn about making/adding cutscenes! :lol:  If that's even possible for endusers, dunno.

xenoargh said:
Module_strings is basically just a giant data dump; it's no sweat.  Calling a sound right before you call a string isn't a big deal- if it's for a Menu / Dialog that will show next, just add a quarter-second delay to the sound so that it seems to happen simultaneously with the action.

Okay, so where would I call the sound for npc intro conversation?  Haven't been successful in finding reference anywhere that would tie it together.  And I had in mind sounds for nearly every response.  Aside, the strings module is actually a very large operation block, isn't it?
 
This will definately help me get me going tin the right direction, much appreciated. I'm suppose to have my PA system back in a day or two, so I can finally start testing stuff. Maybe theres a way to cut the sound short before it's done playing (so theres no overlapping if skipping through too fast). Or maybe I'll just be limited to voicing the first response in the conversation only, to prevent overlapping. I'm not to sure about the function of setting priority, what will giving another sound lower priority do? The dialog with your new character looks hilarious, awesome job, I'd like to see how that turns out. I'm already rockin VLC Player, I hate all other players.
 
Glad to be of what little service I can.

Cutting the sound on each dialog click would be great.  I have no idea if that is possible, but perhaps someone with the knowledge will chime in...

Otherwise I'd assume that each file with higher priority would cut the lessor priority sounds.  Or, perhaps they merely get higher priority among all sounds that are called from within a scene as it first loads. 

If you really want to see a sample of the tavern strumpets, you can check my first draft here.  Click the "muwahahaha" spoiler there to see pics.  I was really proud of them, it was my second day of playing with the module system.

VLC, rock on!  I always give them a plug whenever possible.

 
Okay, now I'm understanding a little more about how the strings are utilized.  No thanks to you bunch of knowledge hoarders.  :shock:
Well, xeno did say to think of it as a data dump....makes sense now.

Can anyone advise how to call (play_sound|agent_play_sound - I see no difference in this case) varying sound files according to individual companions?  From within the companion intro dialog, it is very generic plus usage of slots confuse me so that is a huge obsticle.  I assume "slot_troop_intro" comes into play but I simply fail at finding a solution. 

Who doesn't want the ability to personalize the default companions, or add personality to their newly created friends with sound?  Heck, why not a big manly grunt from the more barbaric mercenary troops when you enter hire dialog?

A sample of what I've found shows that calling sound can be very simple.  Sadly, there aren't many examples and there certainly aren't any complex examples of sound usage.

Code:
[party_tpl|pt_village_farmers,"start", [(eq,"$talk_context",tc_party_encounter),
                                          (agent_play_sound, "$g_talk_agent", "snd_encounter_farmers"),
  ],
Short, sweet and simple.

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"),
   ],
   "{s5}", "companion_recruit_intro_response", [
                    (troop_set_slot, "$g_talk_troop", slot_troop_first_encountered, "$g_encountered_party"),
       ]],
[anyone|plyr, "companion_recruit_intro_response", [
                     (troop_get_slot, ":intro_response", "$g_talk_troop", slot_troop_intro_response_1),
                     (str_store_string, 6, ":intro_response")
      ], "{s6}", "companion_recruit_backstory_a", []],

So how am I supposed to incorporate individualized sound into that pile of steaming goo?  Say you want npc3 to squeal with joy because you chose to speak to it for the first time...

 
play_sound just plays the sound. agent_play_sound plays it from the agent, which is of course distance dependent. The latter is probably more processor intensive - but it's just one sound. You probably can't hear the difference anyways since the encountered agent is always less than a meter away or something.

As to playing the sound, you could either make a new slot and define a reference to a sound in, or just get the offset and play a sound.
Code:
   "{s5}", "companion_recruit_intro_response", [
                    (troop_set_slot, "$g_talk_troop", slot_troop_first_encountered, "$g_encountered_party"),
                    (store_sub, ":offset", "$g_talk_troop", companions_begin),
                    (val_add, ":offset", "snd_npc1_squeal"),
                    (agent_play_sound, "$g_talk_agent", ":offset"),
       ]],
Just define a bunch of sounds in order of npc.
 
Ashmond, that's a nice little addition to the game, she kinda has the princess leia look when she has her arms crossed. Very nice work, exactly what every tavern is missing, lol.

As far as the priority goes, if you were to start the first response in a dialog set with a 1 and made the next response priority 2, and so on, shouldn't that solve the problem of overlapping sounds? I really gotta start testing some of this stuff, but I haven't had alot of time.

Would agent play be more for sounds when your walking through a village or something, to make the sound actually come from who ever is producing it? So you could probably leave it out of dialog right?

So being new at this, I might have some stupid questions, but whats the point off offset, and I'm not familiar with valu_add either?
 
Say you want npc3 to squeal with joy because you chose to speak to it for the first time...

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"),
                     (try_begin),
                       (eq, "$g_talk_troop", "trp_npc3"),
                       (play_sound, "snd_squeal_like_a_little_girl"),
                    (try_end),
   ],
   "{s5}", "companion_recruit_intro_response", [
                    (troop_set_slot, "$g_talk_troop", slot_troop_first_encountered, "$g_encountered_party"),
       ]],
[anyone|plyr, "companion_recruit_intro_response", [
                     (troop_get_slot, ":intro_response", "$g_talk_troop", slot_troop_intro_response_1),
                     (str_store_string, 6, ":intro_response")
      ], "{s6}", "companion_recruit_backstory_a", []],

The only real issue with that is not technical, really- it's getting decent-enough voice work that it's not embarrassing, without ripping off somebody's IP.
 
Much thanks xeno, works great.
Code:
"companion_recruit_intro_response", [
                    (troop_set_slot, "$g_talk_troop", slot_troop_first_encountered, "$g_encountered_party"),
					(try_begin),                       
					  (eq,"$g_talk_troop","trp_npc3"),
					  (play_sound,"snd_screamofjoy"),
					 (else_try),
					  (eq,"$g_talk_troop","trp_npc7"),
					  (play_sound,"snd_sigh"),
					 (try_end),
       ]],

Somebody, I'd hoped your code would allow using the same file with (snd_->npc3<-_mmm) an added argument of who to apply the sound to.  It appears that individual file identifiers are required, as in ("npc3_mmm",["mmm.ogg"]) was required in sound module.  Still, I got it to work your way as well.  So thanks!  Sigh, is it me, or does this "meta-language" module system insist on going around its own crotch to scratch its head?

Code:
"companion_recruit_backstory_a", [(troop_get_slot, ":backstory_a", "$g_talk_troop", slot_troop_backstory_a),
                     (str_store_string, 5, ":backstory_a"),
                     (str_store_string, 19, "str_here_plus_space"),
                     (str_store_party_name, 20, "$g_encountered_party"),
					 (store_sub, ":offset", "$g_talk_troop", "trp_npc3"),
					 (val_add, ":offset", "snd_npc3_mmm"),
					 (agent_play_sound, "$g_talk_agent", ":offset"),
   ],


Moshein, I still have no answer for the priority question.  If that comes into play for me, I'll post results.  Likewise, if you find a definate answer, post it to the thread if you would.  As for agent_play_sound, I'm not going to use it for this application.  This isn't a battlefield type thing, and as somebody stated, being that the subject is ~1m away, it wouldn't make a difference.

Perhaps now I'll invest in a voice pack or some such, I respect other's IP. 
 
Back
Top Bottom