Jump to content
The Dark Mod Forums

Adjusting speaker volume from script - NOT just on/off


BlackMagic

Recommended Posts

I want to adjust the volume of a speaker from script. I have a pan with "beef links" cooking on a stove. as the player takes them away (one by one) I want the "sizzle" sound to decrease. When all have been taken, I turn off the speaker from script. Works fine EXCEPT the volume is not changed. I tried $speaker_sausages.setKey("s_volume", 2);  as well as negative values, but it does not change. The starting value on the speaker is s_volume 10. What am I doing wrong?

Link to comment
Share on other sites

You're right; changing the s_volume key during play seems to do nothing.

 

You can fake it by using multiple speakers though. Place one speaker for each beef link in the same place on the stove. Give one the volume you want when all the beef links are present, another the volume you want when one has been taken, and so on. Have only the loudest one playing on map start. Then when you take a chunk of meat, turn that speaker off and the next loudest one on, cycling through until all the meat is gone and the quietest speaker is off. You should be able to accomplish this fairly easily with two trigger_sequencers.

My missions:           Stand-alone                                                      Duncan Lynch series                              

                                      Down and Out on Newford Road              the Factory Heist

                                                                                                  A House Call

                                                                                                  The House of deLisle                                                                                                  

                              

Link to comment
Share on other sites

Actually, I worked it out by setting the speakers minDistance to 0.05, and then tweaked the maxDistance to shrink in the script. Thanks for responding thebigh. (does that mean The Big H?) have a virtual Fosters on me! 😀

  • Like 1
Link to comment
Share on other sites

Huh, that's interesting that min and maxDistance are dynamically updated in-game but s_volume isn't.

Your method will have the issue that the sizzling will become inaudible at a shorter distance from the stove- if two steaks are audible ten meters away, realistically one steak should also be audible ten meters away but half as loud- but nobody will notice that if all the actual changes in volume will happen when you're standing right by the stove. And it does mean fewer speakers and less scripting.

Looking forward to seeing your mission and eating some of that beef!

My missions:           Stand-alone                                                      Duncan Lynch series                              

                                      Down and Out on Newford Road              the Factory Heist

                                                                                                  A House Call

                                                                                                  The House of deLisle                                                                                                  

                              

Link to comment
Share on other sites

$speaker_sausages.setKey("s_volume", 2);    That is a spawn time script function meaning what it does, only happens when a entity spawns, so would need to restart the mission for it to make effect, if you want to change something during gameplay, you need to call other functions like

/**
 * Fades the sound on this entity to a new level over a period of time.  Use SND_CHANNEL_ANY for all currently playing sounds.
 */
scriptEvent void		fadeSound(float channel, float newLevel, float fadeTime);

or

/**
 * Set the volume of the sound to play, must be issued before startSoundShader.
 */
scriptEvent void		setSoundVolume(float newLevel);

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • Ansome

      Turns out my 15th anniversary mission idea has already been done once or twice before! I've been beaten to the punch once again, but I suppose that's to be expected when there's over 170 FMs out there, eh? I'm not complaining though, I love learning new tricks and taking inspiration from past FMs. Best of luck on your own fan missions!
      · 4 replies
    • The Black Arrow

      I wanna play Doom 3, but fhDoom has much better features than dhewm3, yet fhDoom is old, outdated and probably not supported. Damn!
      Makes me think that TDM engine for Doom 3 itself would actually be perfect.
      · 6 replies
    • Petike the Taffer

      Maybe a bit of advice ? In the FM series I'm preparing, the two main characters have the given names Toby and Agnes (it's the protagonist and deuteragonist, respectively), I've been toying with the idea of giving them family names as well, since many of the FM series have named protagonists who have surnames. Toby's from a family who were usually farriers, though he eventually wound up working as a cobbler (this serves as a daylight "front" for his night time thieving). Would it make sense if the man's popularly accepted family name was Farrier ? It's an existing, though less common English surname, and it directly refers to the profession practiced by his relatives. Your suggestions ?
      · 9 replies
    • nbohr1more

      Looks like the "Reverse April Fools" releases were too well hidden. Darkfate still hasn't acknowledge all the new releases. Did you play any of the new April Fools missions?
      · 5 replies
    • The Black Arrow

      Hope everyone has the blessing of undying motivation for "The Dark Mod 15th Anniversary Contest". Can't wait to see the many magnificent missions you all may have planned. Good luck, with an Ace!
      · 0 replies
×
×
  • Create New...