mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-26 22:50:26 +01:00
Adds "surround" arg to playsound, which enables 3D sound
Defaulted to on Also changes the toy nuke to use it
This commit is contained in:
@@ -862,14 +862,13 @@ obj/item/toy/singlecard/attack_self(mob/user)
|
||||
/obj/item/toy/nuke/attack_self(mob/user)
|
||||
if (cooldown < world.time)
|
||||
cooldown = world.time + 3000 //5 minutes
|
||||
user.visible_message("<span class='warning'>[user] presses a button on [src]</span>", "<span class='notice'>You activate [src], it plays a loud noise!</span>", "<span class='notice'>You hear the click of a button.</span>")
|
||||
sleep(5)
|
||||
icon_state = "nuketoy"
|
||||
for (var/mob/M in hearers(world.view, user)) //I'm doing this because playsound's dampening/stereo ruins the effect
|
||||
if (M.client && !M.ear_deaf)
|
||||
M << 'sound/machines/Alarm.ogg'
|
||||
sleep(135)
|
||||
icon_state = "nuketoyidle"
|
||||
spawn() //gia said so
|
||||
user.visible_message("<span class='warning'>[user] presses a button on [src]</span>", "<span class='notice'>You activate [src], it plays a loud noise!</span>", "<span class='notice'>You hear the click of a button.</span>")
|
||||
sleep(5)
|
||||
icon_state = "nuketoy"
|
||||
playsound(src, 'sound/machines/Alarm.ogg', 100, 0, surround = 0)
|
||||
sleep(135)
|
||||
icon_state = "nuketoyidle"
|
||||
|
||||
|
||||
|
||||
|
||||
+8
-8
@@ -1,4 +1,4 @@
|
||||
/proc/playsound(var/atom/source, soundin, vol as num, vary, extrarange as num, falloff)
|
||||
/proc/playsound(var/atom/source, soundin, vol as num, vary, extrarange as num, falloff, surround = 1)
|
||||
|
||||
soundin = get_sfx(soundin) // same sound for everyone
|
||||
|
||||
@@ -17,12 +17,12 @@
|
||||
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)
|
||||
M.playsound_local(turf_source, soundin, vol, vary, frequency, falloff, surround)
|
||||
|
||||
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)
|
||||
/mob/proc/playsound_local(var/turf/turf_source, soundin, vol as num, vary, frequency, falloff, surround = 1)
|
||||
if(!src.client || ear_deaf > 0) return
|
||||
soundin = get_sfx(soundin)
|
||||
|
||||
@@ -40,12 +40,12 @@ var/const/SURROUND_CAP = 7
|
||||
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
|
||||
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)
|
||||
|
||||
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)
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user