diff --git a/code/game/objects/items/toys.dm b/code/game/objects/items/toys.dm
index 6e1b222b691..e4f022c7057 100644
--- a/code/game/objects/items/toys.dm
+++ b/code/game/objects/items/toys.dm
@@ -544,14 +544,13 @@
/obj/item/toy/nuke/attack_self(mob/user)
if (cooldown < world.time)
cooldown = world.time + 3000 //5 minutes
- user.visible_message("[user] presses a button on [src]", "You activate [src], it plays a loud noise!", "You hear the click of a button.")
- 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("[user] presses a button on [src]", "You activate [src], it plays a loud noise!", "You hear the click of a button.")
+ sleep(5)
+ icon_state = "nuketoy"
+ playsound(src, 'sound/machines/Alarm.ogg', 100, 0, surround = 0)
+ sleep(135)
+ icon_state = "nuketoyidle"
/obj/item/weapon/toddler
icon_state = "toddler"
diff --git a/code/game/sound.dm b/code/game/sound.dm
index e84ace97a33..876f65d811c 100644
--- a/code/game/sound.dm
+++ b/code/game/sound.dm
@@ -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
@@ -7,21 +7,22 @@
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
- var/turf/T = get_turf(M)
- if(T && T.z && T.z == source.z)
- if(get_dist(T, source) <= world.view + extrarange)
- M.playsound_local(source, soundin, vol, vary, frequency, falloff)
+ 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)
var/const/FALLOFF_SOUNDS = 1
var/const/SURROUND_CAP = 7
-/mob/proc/playsound_local(var/atom/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)
@@ -36,16 +37,15 @@ var/const/SURROUND_CAP = 7
else
S.frequency = get_rand_frequency()
- var/turf/turf_source = get_turf(source)
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
@@ -75,4 +75,5 @@ var/const/SURROUND_CAP = 7
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')
- return soundin
\ No newline at end of file
+ return soundin
+