DC Admin Offline
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.