mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 10:21:11 +00:00
88 lines
3.8 KiB
Plaintext
88 lines
3.8 KiB
Plaintext
var/list/shatter_sound = list('sound/effects/Glassbr1.ogg','sound/effects/Glassbr2.ogg','sound/effects/Glassbr3.ogg')
|
|
var/list/explosion_sound = list('sound/effects/Explosion1.ogg','sound/effects/Explosion2.ogg')
|
|
var/list/spark_sound = list('sound/effects/sparks1.ogg','sound/effects/sparks2.ogg','sound/effects/sparks3.ogg','sound/effects/sparks4.ogg')
|
|
var/list/rustle_sound = list('sound/effects/rustle1.ogg','sound/effects/rustle2.ogg','sound/effects/rustle3.ogg','sound/effects/rustle4.ogg','sound/effects/rustle5.ogg')
|
|
var/list/punch_sound = list('sound/weapons/punch1.ogg','sound/weapons/punch2.ogg','sound/weapons/punch3.ogg','sound/weapons/punch4.ogg')
|
|
var/list/clown_sound = list('sound/effects/clownstep1.ogg','sound/effects/clownstep2.ogg')
|
|
var/list/swing_hit_sound = list('sound/weapons/genhit1.ogg', 'sound/weapons/genhit2.ogg', 'sound/weapons/genhit3.ogg')
|
|
var/list/hiss_sound = list('sound/voice/hiss1.ogg','sound/voice/hiss2.ogg','sound/voice/hiss3.ogg','sound/voice/hiss4.ogg')
|
|
var/list/page_sound = list('sound/effects/pageturn1.ogg', 'sound/effects/pageturn2.ogg','sound/effects/pageturn3.ogg')
|
|
//var/list/gun_sound = list('sound/weapons/Gunshot.ogg', 'sound/weapons/Gunshot2.ogg','sound/weapons/Gunshot3.ogg','sound/weapons/Gunshot4.ogg')
|
|
|
|
/proc/playsound(var/atom/source, soundin, vol as num, vary, extrarange as num, falloff)
|
|
|
|
soundin = get_sfx(soundin) // same sound for everyone
|
|
|
|
if(isarea(source))
|
|
error("[source] is an area and is trying to make the sound: [soundin]")
|
|
return
|
|
|
|
var/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)
|
|
|
|
var/const/FALLOFF_SOUNDS = 1
|
|
var/const/SURROUND_CAP = 7
|
|
|
|
/mob/proc/playsound_local(var/turf/turf_source, soundin, vol as num, vary, frequency, falloff)
|
|
if(!src.client || ear_deaf > 0) return
|
|
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))
|
|
// 3D sounds, the technology is here!
|
|
var/turf/T = get_turf(src)
|
|
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
|
|
|
|
/client/proc/playtitlemusic()
|
|
if(!ticker || !ticker.login_music) return
|
|
if(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(shatter_sound)
|
|
if ("explosion") soundin = pick(explosion_sound)
|
|
if ("sparks") soundin = pick(spark_sound)
|
|
if ("rustle") soundin = pick(rustle_sound)
|
|
if ("punch") soundin = pick(punch_sound)
|
|
if ("clownstep") soundin = pick(clown_sound)
|
|
if ("swing_hit") soundin = pick(swing_hit_sound)
|
|
if ("hiss") soundin = pick(hiss_sound)
|
|
if ("pageturn") soundin = pick(page_sound)
|
|
//if ("gunshot") soundin = pick(gun_sound)
|
|
return soundin |