Forum

> > CS2D > General > Range of sv_soundpos and Env_Sound
Forums overviewCS2D overviewGeneral overviewLog in to reply

English Range of sv_soundpos and Env_Sound

2 replies
To the start Previous 1 Next To the start

old Range of sv_soundpos and Env_Sound

Masea
Super User Off Offline

Quote
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.

old Re: Range of sv_soundpos and Env_Sound

DC
Admin Off Offline

Quote
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.
To the start Previous 1 Next To the start
Log in to replyGeneral overviewCS2D overviewForums overview