sound_source clarification

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
User avatar
Spannerbag
Posts: 540
Joined: December 18th, 2016, 6:14 pm
Location: Yes

sound_source clarification

Post by Spannerbag »

Hi,
I've never used this and thought I'd ask here before totally messing it up experimenting myself.

Am I right in believing that [sound_source] sounds come and go depending on which area of the map the player is viewing?
So if the player scrolls/clicks further away from a sound source the volume will fall accordingly?

If so, what I want to do is have the sound determined by the nearest player unit(s) by using (one of those) unit(s) x,y as a location filter?

Something like this:

Code: Select all

    [sound_source]
      id=as_heard_by_nearest_player_unit
      x,y=$nearest_unit.x,$nearest_unit.y
      sounds=some_sound.ogg
      delay=0
      chance=100
      full_range=4
      fade_range=4
      loop=-1             # Not sure if this is needed yet
   [/sound_source]
The effect I want (if possible) is for the sound to wax and wane depending upon the proximity of the nearest player unit.
I suspect this won't work because the wiki states: For now, only sound sources tied to locations are supported so I presume the location filter, once set, doesn't change?

Any clarification or suggestions gratefully received.

Thanks in advance,
cheers!
-- Spannerbag
SP Campaigns: After EI (v1.14) Leafsea Burning (v1.17, v1.16)
I suspect the universe is simpler than we think and stranger than we can know.
Also, I fear that beyond a certain point more intelligence does not necessarily benefit a species...
User avatar
Celtic_Minstrel
Developer
Posts: 2252
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: sound_source clarification

Post by Celtic_Minstrel »

I think that's correct. You could try resetting the sound source whenever a unit moves. I would expect that to restart the sound from the beginning, but maybe if you're lucky it won't.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
Spannerbag
Posts: 540
Joined: December 18th, 2016, 6:14 pm
Location: Yes

Re: sound_source clarification

Post by Spannerbag »

Celtic_Minstrel wrote: April 25th, 2024, 1:38 pm ...You could try resetting the sound source whenever a unit moves. I would expect that to restart the sound from the beginning...
Thanks for the reply, I think when I get to a point where I can actually test this, I'll do some experimenting (now I know there's a chance).
Be awhile tho', have to get plenty of other stuff working first...

As an aside I've also learned from what little testing I have done that [remove_sound_source] with a non-existent id doesn't produce any errors on-screen or in the log. This helps simplify the code in my case. :)

As ever, many thanks for taking the trouble to reply, much appreciated.

Cheers!
-- Spannerbag
SP Campaigns: After EI (v1.14) Leafsea Burning (v1.17, v1.16)
I suspect the universe is simpler than we think and stranger than we can know.
Also, I fear that beyond a certain point more intelligence does not necessarily benefit a species...
Post Reply