English Range of sv_soundpos and Env_Sound

2 replies
Goto Page
To the start Previous 1 Next To the start
Up
Masea
Super User
Offline Off
So as you all know, we have an entity called cs2d entity env_sound which creates a sound at everywhere or at the position within a range (which scales by the volume setting, I think). cs2d cmd sv_soundpos is the almost same thing excluding the volume cannot be adjusted.

These are pretty cool features but I always mind that how much big is that range in pixels and how actually it scales (scaling is a thing for only the entity).

I thought user DC could be the only one who does know the answer but using the forum for this would make the information provided for everyone else.

Thanks.
Create and design your GUI easy and fast: file cs2d GUI Framework (12) | Go deep of the darkness and try your intrepidity: file cs2d Outlast 2 Modification (25)
08.08.18 08:14:04 pm
Up
DC
Admin
Offline Off
Hi,

the calculation for the distance is ultra simple (and a bit wrong*):
volume=baseVolume-(dx+dy)/1000


with dx/dy = horizontal/vertical distance (absolute delta) between player and sound position in pixels

(*This is not very accurate because for a fully correct distance calculation you would have to do power of 2 and square root stuff [sqr(dx²+dy²)]. Moreover it would be better to multiply the reduction with the base value instead of simply subtracting it. But whatever. That's how it.)

In other words: The max distance at which you can hear full volume sounds in theory (with game volume set to 100) is roughly 1000 pixels. 1000/32 = 31.25 tiles. In practice it will be way less of course because ultra silent sounds are not perceivable / only perceivable if you use an insanely high overall volume.

The volume decreases linearly over distance. So 500 distance pixels (~15 tiles) mean half of the original volume already.

The map structure does NOT have any impact on the calculation.

Hope that helps to give you an idea.
... and I probably really should improve that formula like explained above. Ooops.
www.UnrealSoftware.de | www.CS2D.com | www.CarnageContest.com | Use the forum & avoid PMs!
08.08.18 08:20:53 pm
Up
Masea
Super User
Offline Off
Thanks, this certainly answers the topic.

By the way, sorry about the PM.
Create and design your GUI easy and fast: file cs2d GUI Framework (12) | Go deep of the darkness and try your intrepidity: file cs2d Outlast 2 Modification (25)
To the start Previous 1 Next To the start