Files
GS13NG/code/game/sound.dm
T
Poojawa 0bca862419 Overhauls and 2/28 sync (#244)
* map tweaks/shuttle engines

* helpers and defines

* global/onclick

* controllers and datums

* mapping

* game folder

* some other stuff

* some modules

* modules that aren't mobs

* some mob stuff

* new player stuff

* mob living

* silicon stuff

* simple animal things

* carbon/ayylmao

* update_icons

* carbon/human

* sounds and tools

* icons and stuff

* hippie grinder changes + tgui

* kitchen.dmi

* compile issues fixed

* mapfix

* Mapfixes 2.0

* mapedit2.0

* mapmerger pls

* Revert "mapedit2.0"

This reverts commit 74139a3cacea10df7aafca06c0a10bd3daf3a481.

* clean up vore folder + 2 hotfixes

* admin ticket refinement

* Blob tweaks and LAZYADD

* LAZYADD IS LAZY

* Magic strings purged

* DEFINES NEED HIGHER PRIORITIES

* Only a sleepless idiot deals in absolute TRUE|FALSE

* u h g

* progress bar fix

* reverts ticket logs

* there's always that one guy

* fixes and stuff

* 2/27 fixes

* game folder stuff

* stats

* some modules again

* clothing stuff

gets vg clothing out of the main files

* everything not mobs again

* mob stuff

* maps, tgui, sql stuff

* icons

* additional fixes and compile errors

* don't need this anymore

* Oh right this isn't needed anymore

* maint bar re-added

* that doesn't need to be here

* stupid events

* wtfeven

* probably makes Travis happy

* don't care to fix the grinder atm

* fixes vending sprites, changes turret

* lethal, not lethals

* overylays are finicky creatures

* lazy fix for bleeding edgy (#252)

* map tweaks/shuttle engines

* helpers and defines

* global/onclick

* controllers and datums

* mapping

* game folder

* some other stuff

* some modules

* modules that aren't mobs

* some mob stuff

* new player stuff

* mob living

* silicon stuff

* simple animal things

* carbon/ayylmao

* update_icons

* carbon/human

* sounds and tools

* icons and stuff

* hippie grinder changes + tgui

* kitchen.dmi

* compile issues fixed

* mapfix

* Mapfixes 2.0

* mapedit2.0

* mapmerger pls

* Revert "mapedit2.0"

This reverts commit 74139a3cacea10df7aafca06c0a10bd3daf3a481.

* clean up vore folder + 2 hotfixes

* admin ticket refinement

* Blob tweaks and LAZYADD

* LAZYADD IS LAZY

* Magic strings purged

* DEFINES NEED HIGHER PRIORITIES

* Only a sleepless idiot deals in absolute TRUE|FALSE

* u h g

* progress bar fix

* reverts ticket logs

* there's always that one guy

* fixes and stuff

* 2/27 fixes

* game folder stuff

* stats

* some modules again

* clothing stuff

gets vg clothing out of the main files

* everything not mobs again

* mob stuff

* maps, tgui, sql stuff

* icons

* additional fixes and compile errors

* don't need this anymore

* Oh right this isn't needed anymore

* maint bar re-added

* that doesn't need to be here

* stupid events

* wtfeven

* probably makes Travis happy

* don't care to fix the grinder atm

* fixes vending sprites, changes turret

* lethal, not lethals

* overylays are finicky creatures
2017-02-28 09:30:49 -06:00

155 lines
6.6 KiB
Plaintext

/proc/playsound(atom/source, soundin, vol as num, vary, extrarange as num, falloff, surround = 1, frequency = null)
soundin = get_sfx(soundin) // same sound for everyone
if(isarea(source))
throw EXCEPTION("playsound(): source is an area")
return
if(isnull(frequency))
frequency = get_rand_frequency() // Same frequency for everybody
var/turf/turf_source = get_turf(source)
// Looping through the player list has the added bonus of working for mobs inside containers
for (var/P in player_list)
var/mob/M = P
if(!M || !M.client)
continue
if(get_dist(M, turf_source) <= world.view + extrarange)
var/turf/T = get_turf(M)
if(T && T.z == turf_source.z)
M.playsound_local(turf_source, soundin, vol, vary, frequency, falloff, surround)
/atom/proc/playsound_local(turf/turf_source, soundin, vol as num, vary, frequency, falloff, surround = 1)
soundin = get_sfx(soundin)
var/sound/S = sound(soundin)
S.wait = 0 //No queue
S.channel = 0 //Any channel
S.volume = vol
if (vary)
if(frequency)
S.frequency = frequency
else
S.frequency = get_rand_frequency()
if(isturf(turf_source))
var/turf/T = get_turf(src)
//Atmosphere affects sound
var/pressure_factor = 1
var/datum/gas_mixture/hearer_env = T.return_air()
var/datum/gas_mixture/source_env = turf_source.return_air()
if(hearer_env && source_env)
var/pressure = min(hearer_env.return_pressure(), source_env.return_pressure())
if(pressure < ONE_ATMOSPHERE)
pressure_factor = max((pressure - SOUND_MINIMUM_PRESSURE)/(ONE_ATMOSPHERE - SOUND_MINIMUM_PRESSURE), 0)
else //space
pressure_factor = 0
var/distance = get_dist(T, turf_source)
if(distance <= 1)
pressure_factor = max(pressure_factor, 0.15) //touching the source of the sound
S.volume *= pressure_factor
//End Atmosphere affecting sound
if(S.volume <= 0)
return //No sound
// 3D sounds, the technology is here!
if (surround)
var/dx = turf_source.x - T.x // Hearing from the right/left
S.x = round(max(-SURROUND_CAP, min(SURROUND_CAP, dx)), 1)
var/dz = turf_source.y - T.y // Hearing from infront/behind
S.z = round(max(-SURROUND_CAP, min(SURROUND_CAP, dz)), 1)
// The y value is for above your head, but there is no ceiling in 2d spessmens.
S.y = 1
S.falloff = (falloff ? falloff : FALLOFF_SOUNDS)
src << S
/mob/playsound_local(turf/turf_source, soundin, vol as num, vary, frequency, falloff, surround = 1)
if(!client || ear_deaf > 0)
return
..()
/mob/proc/stopLobbySound()
src << sound(null, repeat = 0, wait = 0, volume = 85, channel = 1)
/client/proc/playtitlemusic()
while(!ticker.login_music) //wait for ticker init to set the login music
stoplag()
if(!ticker.login_music)
return
if(prefs && (prefs.toggles & SOUND_LOBBY))
src << sound(ticker.login_music, repeat = 0, wait = 0, volume = 85, channel = 1) // MAD JAMS
/proc/get_rand_frequency()
return rand(32000, 55000) //Frequency stuff only works with 45kbps oggs.
/proc/get_sfx(soundin)
if(istext(soundin))
switch(soundin)
if ("shatter")
soundin = pick('sound/effects/Glassbr1.ogg','sound/effects/Glassbr2.ogg','sound/effects/Glassbr3.ogg')
if ("explosion")
soundin = pick('sound/effects/Explosion1.ogg','sound/effects/Explosion2.ogg')
if ("sparks")
soundin = pick('sound/effects/sparks1.ogg','sound/effects/sparks2.ogg','sound/effects/sparks3.ogg','sound/effects/sparks4.ogg')
if ("rustle")
soundin = pick('sound/effects/rustle1.ogg','sound/effects/rustle2.ogg','sound/effects/rustle3.ogg','sound/effects/rustle4.ogg','sound/effects/rustle5.ogg')
if ("bodyfall")
soundin = pick('sound/effects/bodyfall1.ogg','sound/effects/bodyfall2.ogg','sound/effects/bodyfall3.ogg','sound/effects/bodyfall4.ogg')
if ("punch")
soundin = pick('sound/weapons/punch1.ogg','sound/weapons/punch2.ogg','sound/weapons/punch3.ogg','sound/weapons/punch4.ogg')
if ("clownstep")
soundin = pick('sound/effects/clownstep1.ogg','sound/effects/clownstep2.ogg')
if ("swing_hit")
soundin = pick('sound/weapons/genhit1.ogg', 'sound/weapons/genhit2.ogg', 'sound/weapons/genhit3.ogg')
if ("hiss")
soundin = pick('sound/voice/hiss1.ogg','sound/voice/hiss2.ogg','sound/voice/hiss3.ogg','sound/voice/hiss4.ogg')
if ("pageturn")
soundin = pick('sound/effects/pageturn1.ogg', 'sound/effects/pageturn2.ogg','sound/effects/pageturn3.ogg')
if ("gunshot")
soundin = pick('sound/weapons/Gunshot.ogg', 'sound/weapons/Gunshot2.ogg','sound/weapons/Gunshot3.ogg','sound/weapons/Gunshot4.ogg')
if ("ricochet")
soundin = pick( 'sound/weapons/effects/ric1.ogg', 'sound/weapons/effects/ric2.ogg','sound/weapons/effects/ric3.ogg','sound/weapons/effects/ric4.ogg','sound/weapons/effects/ric5.ogg')
if ("terminal_type")
soundin = pick('sound/machines/terminal_button01.ogg', 'sound/machines/terminal_button02.ogg', 'sound/machines/terminal_button03.ogg', \
'sound/machines/terminal_button04.ogg', 'sound/machines/terminal_button05.ogg', 'sound/machines/terminal_button06.ogg', \
'sound/machines/terminal_button07.ogg', 'sound/machines/terminal_button08.ogg')
/* //Scream emote sounds //when they get ported again
if ("malescream")
soundin = pick('sound/voice/scream/scream_m1.ogg', 'sound/voice/scream/scream_m2.ogg')
if ("femscream")
soundin = pick('sound/voice/scream/scream_f1.ogg', 'sound/voice/scream/scream_f2.ogg', 'sound/voice/scream/scream_f3.ogg')
if ("drakescream")
soundin = pick('sound/voice/scream/drake1.ogg', 'sound/voice/scream/drake2.ogg')
if ("birdscream")
soundin = pick('sound/voice/scream/bird1.ogg', 'sound/voice/scream/bird2.ogg')
if ("mothscream")
soundin = pick('sound/voice/scream/moth1.ogg')
*/
//Vore sounds
if ("digestion_sounds")
soundin = pick('sound/vore/digest1.ogg', 'sound/vore/digest2.ogg', 'sound/vore/digest3.ogg', \
'sound/vore/digest4.ogg', 'sound/vore/digest5.ogg', 'sound/vore/digest6.ogg', \
'sound/vore/digest7.ogg', 'sound/vore/digest8.ogg', 'sound/vore/digest9.ogg', \
'sound/vore/digest10.ogg','sound/vore/digest11.ogg', 'sound/vore/digest12.ogg')
if ("death_gurgles")
soundin = pick('sound/vore/death1.ogg', 'sound/vore/death2.ogg', 'sound/vore/death3.ogg', \
'sound/vore/death4.ogg', 'sound/vore/death5.ogg', 'sound/vore/death6.ogg', \
'sound/vore/death7.ogg', 'sound/vore/death8.ogg', 'sound/vore/death9.ogg', 'sound/vore/death10.ogg')
if ("struggle_sounds")
soundin = pick('sound/vore/squish1.ogg', 'sound/vore/squish2.ogg', 'sound/vore/squish3.ogg', 'sound/vore/squish4.ogg')
return soundin
/proc/playsound_global(file, repeat=0, wait, channel, volume)
for(var/V in clients)
V << sound(file, repeat, wait, channel, volume)