From 58a2385780e6de9c450fe26d87e2071673fe2d4c Mon Sep 17 00:00:00 2001 From: Git-Nivrak <59925169+Git-Nivrak@users.noreply.github.com> Date: Mon, 1 Jul 2024 15:07:03 +0300 Subject: [PATCH 01/18] a --- code/datums/diseases/black_goo.dm | 2 +- code/datums/soundOutput.dm | 78 ++++++++++++++----- code/game/machinery/bots/mulebot.dm | 18 ++--- code/game/sound.dm | 2 + .../living/carbon/human/human_abilities.dm | 2 +- code/modules/mob/living/carbon/human/say.dm | 2 +- .../mob/living/carbon/human/species/zombie.dm | 4 +- .../mob/living/carbon/xenomorph/Abilities.dm | 2 +- .../living/carbon/xenomorph/Facehuggers.dm | 6 +- .../mob/living/carbon/xenomorph/XenoProcs.dm | 2 +- .../abilities/ability_helper_procs.dm | 4 +- .../abilities/burrower/burrower_powers.dm | 2 +- .../xenomorph/abilities/general_powers.dm | 4 +- .../abilities/predalien/predalien_powers.dm | 2 +- .../abilities/runner/runner_powers.dm | 4 +- .../abilities/sentinel/sentinel_powers.dm | 4 +- .../carbon/xenomorph/castes/Facehugger.dm | 2 +- .../living/carbon/xenomorph/castes/Larva.dm | 2 +- .../living/carbon/xenomorph/castes/Queen.dm | 4 +- .../mob/living/carbon/xenomorph/life.dm | 2 +- .../mob/living/carbon/xenomorph/say.dm | 2 +- .../strains/castes/carrier/eggsac.dm | 4 +- .../mob/living/simple_animal/friendly/cat.dm | 2 +- .../mob/living/simple_animal/hostile/alien.dm | 2 +- code/modules/movement/movement.dm | 4 + 25 files changed, 102 insertions(+), 60 deletions(-) diff --git a/code/datums/diseases/black_goo.dm b/code/datums/diseases/black_goo.dm index 6fb74bc82bd4..056034d32fb2 100644 --- a/code/datums/diseases/black_goo.dm +++ b/code/datums/diseases/black_goo.dm @@ -155,7 +155,7 @@ human.remove_language(LANGUAGE_ENGLISH) // You lose the ability to understand english. Language processing is handled in the mind not the body. var/datum/species/zombie/zombie_species = GLOB.all_species[SPECIES_ZOMBIE] zombie_species.handle_alert_ghost(human) - playsound(human.loc, 'sound/hallucinations/wail.ogg', 25, 1) + playsound(human, 'sound/hallucinations/wail.ogg', 25, 1) human.jitteriness = 0 human.set_species(SPECIES_ZOMBIE) stage = 4 diff --git a/code/datums/soundOutput.dm b/code/datums/soundOutput.dm index 6ebc32c7e41f..5158b8f18424 100644 --- a/code/datums/soundOutput.dm +++ b/code/datums/soundOutput.dm @@ -24,7 +24,26 @@ owner = null return ..() -/datum/soundOutput/proc/process_sound(datum/sound_template/T) +#define SMOOTHING 1 // How much smoothing when moving between tiles, smaller is more smoothing + +/datum/soundOutput/proc/update_sounds(atom/user, direction) + SIGNAL_HANDLER + for(var/channel in current_sounds) + for(var/i in 0 to round(32/SMOOTHING)) + i = i * SMOOTHING + switch(direction) + if(1) + process_sound(current_sounds[channel], TRUE, 0, -1+i/32) + if(2) + process_sound(current_sounds[channel], TRUE, 0, 1-i/32) + if(4) + process_sound(current_sounds[channel], TRUE, -1+i/32) + if(8) + process_sound(current_sounds[channel], TRUE, 1-i/32, 0) +/datum/soundOutput/proc/remove_sound(channel) + current_sounds -= channel + +/datum/soundOutput/proc/process_sound(datum/sound_template/T, update=FALSE, offset_x = 0, offset_y = 0) var/sound/S = sound(T.file, T.wait, T.repeat) S.volume = owner.volume_preferences[T.volume_cat] * T.volume if(T.channel == 0) @@ -33,29 +52,46 @@ S.channel = T.channel S.frequency = T.frequency S.falloff = T.falloff - S.status = T.status - if(T.x && T.y && T.z) - var/turf/owner_turf = get_turf(owner.mob) - if(owner_turf) - // We're in an interior and sound came from outside - if(SSinterior.in_interior(owner_turf) && owner_turf.z != T.z) - var/datum/interior/VI = SSinterior.get_interior_by_coords(owner_turf.x, owner_turf.y, owner_turf.z) - if(VI && VI.exterior) - var/turf/candidate = get_turf(VI.exterior) - if(candidate.z != T.z) - return // Invalid location - S.falloff /= 2 - owner_turf = candidate - S.x = T.x - owner_turf.x - S.y = 0 - S.z = T.y - owner_turf.y - S.y += T.y_s_offset - S.x += T.x_s_offset - S.echo = SOUND_ECHO_REVERB_ON //enable environment reverb for positional sounds + S.status = update ? SOUND_UPDATE : T.status + if(!update) + S.params = list("on-end" = ".soundend [S.channel]") + + + var/turf/source_turf + if(!QDELETED(T.source)) + source_turf = get_turf(T.source) + else + source_turf = locate(T.x, T.y, T.z) + + var/turf/owner_turf = get_turf(owner.mob) + if(owner_turf) + // We're in an interior and sound came from outside + if(SSinterior.in_interior(owner_turf) && owner_turf.z != T.z) + var/datum/interior/VI = SSinterior.get_interior_by_coords(owner_turf.x, owner_turf.y, owner_turf.z) + if(VI && VI.exterior) + var/turf/candidate = get_turf(VI.exterior) + if(candidate.z != T.z) + return // Invalid location + S.falloff /= 2 + owner_turf = candidate + S.x = source_turf.x - owner_turf.x + offset_x + S.y = 0 + S.z = source_turf.y - owner_turf.y + offset_y + S.y += T.y_s_offset + S.x += T.x_s_offset + S.echo = SOUND_ECHO_REVERB_ON if(owner.mob.ear_deaf > 0) S.status |= SOUND_MUTE - sound_to(owner,S) + if(!update) + current_sounds[num2text(S.channel)] = T + sound_to(owner, S) + +/client/verb/sound_ended(channel as num) + set name = ".soundend" + + soundOutput.remove_sound(num2text(channel)) + /datum/soundOutput/proc/update_ambience(area/target_area, ambience_override, force_update = FALSE) var/status_flags = SOUND_STREAM diff --git a/code/game/machinery/bots/mulebot.dm b/code/game/machinery/bots/mulebot.dm index 563c4b89c590..a3a030470d18 100644 --- a/code/game/machinery/bots/mulebot.dm +++ b/code/game/machinery/bots/mulebot.dm @@ -452,7 +452,7 @@ /obj/structure/machinery/bot/mulebot/proc/load(atom/movable/C) if((wires & WIRE_LOADCHECK) && !istype(C,/obj/structure/closet/crate)) src.visible_message("[src] makes a sighing buzz.", "You hear an electronic buzzing sound.") - playsound(src.loc, 'sound/machines/buzz-sigh.ogg', 25, 0) + playsound(src, 'sound/machines/buzz-sigh.ogg', 25, 0) return // if not emagged, only allow crates to be loaded //I'm sure someone will come along and ask why this is here... well people were dragging screen items onto the mule, and that was not cool. @@ -636,25 +636,25 @@ mode = 4 if(blockcount == 3) src.visible_message("[src] makes an annoyed buzzing sound", "You hear an electronic buzzing sound.") - playsound(src.loc, 'sound/machines/buzz-two.ogg', 25, 0) + playsound(src, 'sound/machines/buzz-two.ogg', 25, 0) if(blockcount > 5) // attempt 5 times before recomputing // find new path excluding blocked turf src.visible_message("[src] makes a sighing buzz.", "You hear an electronic buzzing sound.") - playsound(src.loc, 'sound/machines/buzz-sigh.ogg', 25, 0) + playsound(src, 'sound/machines/buzz-sigh.ogg', 25, 0) spawn(2) calc_path(next) if(length(path) > 0) src.visible_message("[src] makes a delighted ping!", "You hear a ping.") - playsound(src.loc, 'sound/machines/ping.ogg', 25, 0) + playsound(src, 'sound/machines/ping.ogg', 25, 0) mode = 4 mode =6 return return else src.visible_message("[src] makes an annoyed buzzing sound", "You hear an electronic buzzing sound.") - playsound(src.loc, 'sound/machines/buzz-two.ogg', 25, 0) + playsound(src, 'sound/machines/buzz-two.ogg', 25, 0) mode = 5 return else @@ -671,11 +671,11 @@ blockcount = 0 mode = 4 src.visible_message("[src] makes a delighted ping!", "You hear a ping.") - playsound(src.loc, 'sound/machines/ping.ogg', 25, 0) + playsound(src, 'sound/machines/ping.ogg', 25, 0) else src.visible_message("[src] makes a sighing buzz.", "You hear an electronic buzzing sound.") - playsound(src.loc, 'sound/machines/buzz-sigh.ogg', 25, 0) + playsound(src, 'sound/machines/buzz-sigh.ogg', 25, 0) mode = 7 //if(6) @@ -720,7 +720,7 @@ /obj/structure/machinery/bot/mulebot/proc/at_target() if(!reached_target) src.visible_message("[src] makes a chiming sound!", "You hear a chime.") - playsound(src.loc, 'sound/machines/chime.ogg', 25, 0) + playsound(src, 'sound/machines/chime.ogg', 25, 0) reached_target = 1 if(load) // if loaded, unload at target @@ -770,7 +770,7 @@ // when mulebot is in the same loc /obj/structure/machinery/bot/mulebot/proc/RunOver(mob/living/carbon/human/H) src.visible_message(SPAN_DANGER("[src] drives over [H]!")) - playsound(src.loc, 'sound/effects/splat.ogg', 25, 1) + playsound(src, 'sound/effects/splat.ogg', 25, 1) var/damage = rand(5,15) H.apply_damage(2*damage, BRUTE, "head") diff --git a/code/game/sound.dm b/code/game/sound.dm index 1ab8fc42f41a..7f42837f8c7e 100644 --- a/code/game/sound.dm +++ b/code/game/sound.dm @@ -18,6 +18,7 @@ var/z var/y_s_offset // Vertical sound offset var/x_s_offset // Horizontal sound offset + var/atom/source /proc/get_free_channel() var/static/cur_chan = 1 @@ -72,6 +73,7 @@ S.x = turf_source.x S.y = turf_source.y S.z = turf_source.z + S.source = source if(!SSinterior) SSsound.queue(S) diff --git a/code/modules/mob/living/carbon/human/human_abilities.dm b/code/modules/mob/living/carbon/human/human_abilities.dm index 76ebbed06de6..32cb615bf0b1 100644 --- a/code/modules/mob/living/carbon/human/human_abilities.dm +++ b/code/modules/mob/living/carbon/human/human_abilities.dm @@ -347,7 +347,7 @@ CULT H.put_in_any_hand_if_possible(new /obj/item/device/flashlight, FALSE, TRUE) - playsound(H.loc, 'sound/voice/scream_horror1.ogg', 25) + playsound(H, 'sound/voice/scream_horror1.ogg', 25) H.visible_message(SPAN_HIGHDANGER("[H] puts on their robes."), SPAN_WARNING("You put on your robes.")) for(var/datum/action/human_action/activable/cult/obtain_equipment/O in H.actions) diff --git a/code/modules/mob/living/carbon/human/say.dm b/code/modules/mob/living/carbon/human/say.dm index c95efd8a2995..090a1672b518 100644 --- a/code/modules/mob/living/carbon/human/say.dm +++ b/code/modules/mob/living/carbon/human/say.dm @@ -160,7 +160,7 @@ if(M != src) M.show_message(SPAN_NOTICE("[src] talks into [length(used_radios) ? used_radios[1] : "the radio."]"), SHOW_MESSAGE_VISIBLE) if(ishumansynth_strict(src)) - playsound(src.loc, 'sound/effects/radiostatic.ogg', 15, 1) + playsound(src, 'sound/effects/radiostatic.ogg', 15, 1) italics = 1 message_range = 2 diff --git a/code/modules/mob/living/carbon/human/species/zombie.dm b/code/modules/mob/living/carbon/human/species/zombie.dm index 4e8a0b5e98e2..4823463240a5 100644 --- a/code/modules/mob/living/carbon/human/species/zombie.dm +++ b/code/modules/mob/living/carbon/human/species/zombie.dm @@ -80,9 +80,9 @@ /datum/species/zombie/handle_unique_behavior(mob/living/carbon/human/zombie) if(prob(5)) - playsound(zombie.loc, basic_moan, 15, basic_variance) + playsound(zombie, basic_moan, 15, basic_variance) else if(prob(5)) - playsound(zombie.loc, rare_moan, 15, rare_variance) + playsound(zombie, rare_moan, 15, rare_variance) /datum/species/zombie/handle_death(mob/living/carbon/human/zombie, gibbed) set waitfor = FALSE diff --git a/code/modules/mob/living/carbon/xenomorph/Abilities.dm b/code/modules/mob/living/carbon/xenomorph/Abilities.dm index 09b99871e936..2da22826273f 100644 --- a/code/modules/mob/living/carbon/xenomorph/Abilities.dm +++ b/code/modules/mob/living/carbon/xenomorph/Abilities.dm @@ -136,7 +136,7 @@ if(hugger.stat != DEAD) hugger.die() - playsound(xeno.loc, pick(xeno.screech_sound_effect_list), 75, 0, status = 0) + playsound(xeno, pick(xeno.screech_sound_effect_list), 75, 0, status = 0) xeno.visible_message(SPAN_XENOHIGHDANGER("[xeno] emits an ear-splitting guttural roar!")) xeno.create_shriekwave(14) //Adds the visual effect. Wom wom wom, 14 shriekwaves diff --git a/code/modules/mob/living/carbon/xenomorph/Facehuggers.dm b/code/modules/mob/living/carbon/xenomorph/Facehuggers.dm index 9a87f10d74a3..91fec9fcdb35 100644 --- a/code/modules/mob/living/carbon/xenomorph/Facehuggers.dm +++ b/code/modules/mob/living/carbon/xenomorph/Facehuggers.dm @@ -293,9 +293,9 @@ human.disable_lights() human.disable_special_items() if(ishuman_strict(human)) - playsound(loc, human.gender == "male" ? 'sound/misc/facehugged_male.ogg' : 'sound/misc/facehugged_female.ogg' , 25, 0) + playsound(human, human.gender == "male" ? 'sound/misc/facehugged_male.ogg' : 'sound/misc/facehugged_female.ogg' , 25, 0) else if(isyautja(human)) - playsound(loc, 'sound/voice/pred_facehugged.ogg', 65, FALSE) + playsound(human, 'sound/voice/pred_facehugged.ogg', 65, FALSE) if(!sterile) if(!human.species || !(human.species.flags & IS_SYNTHETIC)) //synthetics aren't paralyzed human.apply_effect(MIN_IMPREGNATION_TIME * 0.5 * knockout_mod, PARALYZE) //THIS MIGHT NEED TWEAKS @@ -435,7 +435,7 @@ stat = DEAD flags_inventory &= ~CANTSTRIP visible_message("[icon2html(src, viewers(src))] \The [src] curls up into a ball!") - playsound(src.loc, 'sound/voice/alien_facehugger_dies.ogg', 25, 1) + playsound(src, 'sound/voice/alien_facehugger_dies.ogg', 25, 1) if(ismob(loc)) //Make it fall off the person so we can update their icons. Won't update if they're in containers thou var/mob/holder_mob = loc diff --git a/code/modules/mob/living/carbon/xenomorph/XenoProcs.dm b/code/modules/mob/living/carbon/xenomorph/XenoProcs.dm index f0fd8a4d86a7..ffb3c9f87b11 100644 --- a/code/modules/mob/living/carbon/xenomorph/XenoProcs.dm +++ b/code/modules/mob/living/carbon/xenomorph/XenoProcs.dm @@ -319,7 +319,7 @@ if (pounceAction.freeze_self) if(pounceAction.freeze_play_sound) - playsound(loc, rand(0, 100) < 95 ? 'sound/voice/alien_pounce.ogg' : 'sound/voice/alien_pounce2.ogg', 25, 1) + playsound(src, rand(0, 100) < 95 ? 'sound/voice/alien_pounce.ogg' : 'sound/voice/alien_pounce2.ogg', 25, 1) ADD_TRAIT(src, TRAIT_IMMOBILIZED, TRAIT_SOURCE_ABILITY("Pounce")) pounceAction.freeze_timer_id = addtimer(CALLBACK(src, PROC_REF(unfreeze_pounce)), pounceAction.freeze_time, TIMER_STOPPABLE) pounceAction.additional_effects(M) diff --git a/code/modules/mob/living/carbon/xenomorph/abilities/ability_helper_procs.dm b/code/modules/mob/living/carbon/xenomorph/abilities/ability_helper_procs.dm index 87657af5ce7a..f370d5e7f8cc 100644 --- a/code/modules/mob/living/carbon/xenomorph/abilities/ability_helper_procs.dm +++ b/code/modules/mob/living/carbon/xenomorph/abilities/ability_helper_procs.dm @@ -138,7 +138,7 @@ R.take_damage_type(40 / A.acid_delay, "acid", src) visible_message(SPAN_XENOWARNING("[src] vomits globs of vile stuff at \the [O]. It sizzles under the bubbling mess of acid!"), \ SPAN_XENOWARNING("We vomit globs of vile stuff at [O]. It sizzles under the bubbling mess of acid!"), null, 5) - playsound(loc, "sound/bullets/acid_impact1.ogg", 25) + playsound(O, "sound/bullets/acid_impact1.ogg", 25) QDEL_IN(A, 20) return @@ -158,7 +158,7 @@ attack_log += text("\[[time_stamp()]\] Spat acid on [O]") visible_message(SPAN_XENOWARNING("[src] vomits globs of vile stuff all over [O]. It begins to sizzle and melt under the bubbling mess of acid!"), \ SPAN_XENOWARNING("We vomit globs of vile stuff all over [O]. It begins to sizzle and melt under the bubbling mess of acid!"), null, 5) - playsound(loc, "sound/bullets/acid_impact1.ogg", 25) + playsound(O, "sound/bullets/acid_impact1.ogg", 25) /proc/unroot_human(mob/living/carbon/H, trait_source) if (!isxeno_human(H)) diff --git a/code/modules/mob/living/carbon/xenomorph/abilities/burrower/burrower_powers.dm b/code/modules/mob/living/carbon/xenomorph/abilities/burrower/burrower_powers.dm index ee084e77a5a0..f5bca96fdca6 100644 --- a/code/modules/mob/living/carbon/xenomorph/abilities/burrower/burrower_powers.dm +++ b/code/modules/mob/living/carbon/xenomorph/abilities/burrower/burrower_powers.dm @@ -44,7 +44,7 @@ COMSIG_LIVING_FLAMER_FLAMED, ), PROC_REF(flamer_crossed_immune)) add_traits(list(TRAIT_ABILITY_BURROWED, TRAIT_UNDENSE, TRAIT_IMMOBILIZED), TRAIT_SOURCE_ABILITY("Burrow")) - playsound(src.loc, 'sound/effects/burrowing_b.ogg', 25) + playsound(src, 'sound/effects/burrowing_b.ogg', 25) update_icons() addtimer(CALLBACK(src, PROC_REF(do_burrow_cooldown)), (caste ? caste.burrow_cooldown : 5 SECONDS)) burrow_timer = world.time + 90 // How long we can be burrowed diff --git a/code/modules/mob/living/carbon/xenomorph/abilities/general_powers.dm b/code/modules/mob/living/carbon/xenomorph/abilities/general_powers.dm index 014cb3d2f24b..a446e11033fb 100644 --- a/code/modules/mob/living/carbon/xenomorph/abilities/general_powers.dm +++ b/code/modules/mob/living/carbon/xenomorph/abilities/general_powers.dm @@ -757,7 +757,7 @@ if(xeno.ammo.spit_windup) spitting = TRUE if(xeno.ammo.pre_spit_warn) - playsound(xeno.loc,"alien_drool", 55, 1) + playsound(xeno, "alien_drool", 55, 1) to_chat(xeno, SPAN_WARNING("We begin to prepare a large spit!")) xeno.visible_message(SPAN_WARNING("[xeno] prepares to spit a massive glob!"),\ SPAN_WARNING("We begin to spit [xeno.ammo.name]!")) @@ -775,7 +775,7 @@ xeno.visible_message(SPAN_XENOWARNING("[xeno] spits at [atom]!"), \ SPAN_XENOWARNING("We spit [xeno.ammo.name] at [atom]!") ) - playsound(xeno.loc, sound_to_play, 25, 1) + playsound(xeno, sound_to_play, 25, 1) var/obj/projectile/proj = new (current_turf, create_cause_data(xeno.ammo.name, xeno)) proj.generate_bullet(xeno.ammo) diff --git a/code/modules/mob/living/carbon/xenomorph/abilities/predalien/predalien_powers.dm b/code/modules/mob/living/carbon/xenomorph/abilities/predalien/predalien_powers.dm index 3ec4855f9c3a..13ef448bbeb5 100644 --- a/code/modules/mob/living/carbon/xenomorph/abilities/predalien/predalien_powers.dm +++ b/code/modules/mob/living/carbon/xenomorph/abilities/predalien/predalien_powers.dm @@ -10,7 +10,7 @@ if(!check_and_use_plasma_owner()) return - playsound(xeno.loc, pick(predalien_roar), 75, 0, status = 0) + playsound(xeno, pick(predalien_roar), 75, 0, status = 0) xeno.visible_message(SPAN_XENOHIGHDANGER("[xeno] emits a guttural roar!")) xeno.create_shriekwave(7) //Adds the visual effect. Wom wom wom, 7 shriekwaves for(var/mob/living/carbon/carbon in view(7, xeno)) diff --git a/code/modules/mob/living/carbon/xenomorph/abilities/runner/runner_powers.dm b/code/modules/mob/living/carbon/xenomorph/abilities/runner/runner_powers.dm index f5e090bc7e4b..aac597441fd9 100644 --- a/code/modules/mob/living/carbon/xenomorph/abilities/runner/runner_powers.dm +++ b/code/modules/mob/living/carbon/xenomorph/abilities/runner/runner_powers.dm @@ -126,7 +126,7 @@ multitile_vehicle.take_damage_type(20 / acid.acid_delay, "acid", src) visible_message(SPAN_XENOWARNING("[src] vomits globs of vile stuff at [multitile_vehicle]. It sizzles under the bubbling mess of acid!"), \ SPAN_XENOWARNING("We vomit globs of vile stuff at [multitile_vehicle]. It sizzles under the bubbling mess of acid!"), null, 5) - playsound(loc, "sound/bullets/acid_impact1.ogg", 25) + playsound(O, "sound/bullets/acid_impact1.ogg", 25) QDEL_IN(acid, 20) return @@ -135,7 +135,7 @@ visible_message(SPAN_XENOWARNING("[src] vomits globs of vile stuff all over [affected_atom]. It begins to sizzle and melt under the bubbling mess of acid!"), \ SPAN_XENOWARNING("We vomit globs of vile stuff all over [affected_atom]. It begins to sizzle and melt under the bubbling mess of acid!"), null, 5) - playsound(loc, "sound/bullets/acid_impact1.ogg", 25) + playsound(O, "sound/bullets/acid_impact1.ogg", 25) /datum/action/xeno_action/activable/acider_for_the_hive/use_ability(atom/affected_atom) diff --git a/code/modules/mob/living/carbon/xenomorph/abilities/sentinel/sentinel_powers.dm b/code/modules/mob/living/carbon/xenomorph/abilities/sentinel/sentinel_powers.dm index 1ed8863c231a..b966e7497beb 100644 --- a/code/modules/mob/living/carbon/xenomorph/abilities/sentinel/sentinel_powers.dm +++ b/code/modules/mob/living/carbon/xenomorph/abilities/sentinel/sentinel_powers.dm @@ -18,7 +18,7 @@ xeno.visible_message(SPAN_XENOWARNING("[xeno] spits at [target]!"), \ SPAN_XENOWARNING("You spit at [target]!") ) var/sound_to_play = pick(1, 2) == 1 ? 'sound/voice/alien_spitacid.ogg' : 'sound/voice/alien_spitacid2.ogg' - playsound(xeno.loc, sound_to_play, 25, 1) + playsound(xeno, sound_to_play, 25, 1) xeno.ammo = GLOB.ammo_list[/datum/ammo/xeno/toxin] var/obj/projectile/projectile = new /obj/projectile(current_turf, create_cause_data(initial(xeno.caste_type), xeno)) @@ -50,7 +50,7 @@ xeno.visible_message(SPAN_XENOWARNING("[xeno] spits at [target]!"), \ SPAN_XENOWARNING("You spit at [target]!") ) var/sound_to_play = pick(1, 2) == 1 ? 'sound/voice/alien_spitacid.ogg' : 'sound/voice/alien_spitacid2.ogg' - playsound(xeno.loc, sound_to_play, 25, 1) + playsound(xeno, sound_to_play, 25, 1) xeno.ammo = GLOB.ammo_list[/datum/ammo/xeno/toxin/shotgun] var/obj/projectile/projectile = new /obj/projectile(current_turf, create_cause_data(initial(xeno.caste_type), xeno)) diff --git a/code/modules/mob/living/carbon/xenomorph/castes/Facehugger.dm b/code/modules/mob/living/carbon/xenomorph/castes/Facehugger.dm index 9d42eb982d2e..aedb1a4c48df 100644 --- a/code/modules/mob/living/carbon/xenomorph/castes/Facehugger.dm +++ b/code/modules/mob/living/carbon/xenomorph/castes/Facehugger.dm @@ -237,7 +237,7 @@ return FALSE // Otherwise, ""roar""! - playsound(loc, "alien_roar_larva", 15) + playsound(src, "alien_roar_larva", 15) return TRUE /mob/living/carbon/xenomorph/facehugger/get_status_tab_items() diff --git a/code/modules/mob/living/carbon/xenomorph/castes/Larva.dm b/code/modules/mob/living/carbon/xenomorph/castes/Larva.dm index 8dc427e2c55e..b846bfd5b356 100644 --- a/code/modules/mob/living/carbon/xenomorph/castes/Larva.dm +++ b/code/modules/mob/living/carbon/xenomorph/castes/Larva.dm @@ -176,7 +176,7 @@ return FALSE // Otherwise, ""roar""! - playsound(loc, "alien_roar_larva", 15) + playsound(src, "alien_roar_larva", 15) return TRUE /mob/living/carbon/xenomorph/larva/is_xeno_grabbable() diff --git a/code/modules/mob/living/carbon/xenomorph/castes/Queen.dm b/code/modules/mob/living/carbon/xenomorph/castes/Queen.dm index a66903a938c5..47f2adb6e608 100644 --- a/code/modules/mob/living/carbon/xenomorph/castes/Queen.dm +++ b/code/modules/mob/living/carbon/xenomorph/castes/Queen.dm @@ -399,7 +399,7 @@ if(!should_block_game_interaction(src))//so admins can safely spawn Queens in Thunderdome for tests. xeno_message(SPAN_XENOANNOUNCE("A new Queen has risen to lead the Hive! Rejoice!"),3,hivenumber) notify_ghosts(header = "New Queen", message = "A new Queen has risen.", source = src, action = NOTIFY_ORBIT) - playsound(loc, 'sound/voice/alien_queen_command.ogg', 75, 0) + playsound(src, 'sound/voice/alien_queen_command.ogg', 75, 0) set_resin_build_order(GLOB.resin_build_order_drone) for(var/datum/action/xeno_action/action in actions) // Also update the choose_resin icon since it resets @@ -522,7 +522,7 @@ if(stat != DEAD) if(++breathing_counter >= rand(22, 27)) //Increase the breathing variable each tick. Play it at random intervals. - playsound(loc, pick('sound/voice/alien_queen_breath1.ogg', 'sound/voice/alien_queen_breath2.ogg'), 15, 1, 4) + playsound(src, pick('sound/voice/alien_queen_breath1.ogg', 'sound/voice/alien_queen_breath2.ogg'), 15, 1, 4) breathing_counter = 0 //Reset the counter if(observed_xeno) diff --git a/code/modules/mob/living/carbon/xenomorph/life.dm b/code/modules/mob/living/carbon/xenomorph/life.dm index 1657d078ffda..d3178ff4c203 100644 --- a/code/modules/mob/living/carbon/xenomorph/life.dm +++ b/code/modules/mob/living/carbon/xenomorph/life.dm @@ -225,7 +225,7 @@ if(ishuman(M)) if(world.time > devour_timer - 50 && world.time < devour_timer - 30) to_chat(src, SPAN_WARNING("We're about to regurgitate [M]...")) - playsound(loc, 'sound/voice/alien_drool1.ogg', 50, 1) + playsound(src, 'sound/voice/alien_drool1.ogg', 50, 1) var/mob/living/carbon/human/H = M if(world.time > devour_timer || (H.stat == DEAD && !H.chestburst)) regurgitate(H) diff --git a/code/modules/mob/living/carbon/xenomorph/say.dm b/code/modules/mob/living/carbon/xenomorph/say.dm index 9f99cdb45455..8c7457f55ee8 100644 --- a/code/modules/mob/living/carbon/xenomorph/say.dm +++ b/code/modules/mob/living/carbon/xenomorph/say.dm @@ -76,7 +76,7 @@ if(forced) if(speaking_noise) - playsound(loc, speaking_noise, 25, 1) + playsound(src, speaking_noise, 25, 1) ..(message, speaking, verb, null, null, message_range, null) else hivemind_talk(message) diff --git a/code/modules/mob/living/carbon/xenomorph/strains/castes/carrier/eggsac.dm b/code/modules/mob/living/carbon/xenomorph/strains/castes/carrier/eggsac.dm index 61c03803841b..67537a41a780 100644 --- a/code/modules/mob/living/carbon/xenomorph/strains/castes/carrier/eggsac.dm +++ b/code/modules/mob/living/carbon/xenomorph/strains/castes/carrier/eggsac.dm @@ -24,7 +24,7 @@ carrier.recalculate_pheromones() if(carrier.huggers_cur) - playsound(carrier.loc, 'sound/voice/alien_facehugger_dies.ogg', 25, TRUE) + playsound(carrier, 'sound/voice/alien_facehugger_dies.ogg', 25, TRUE) carrier.huggers_cur = 0 carrier.huggers_max = 0 carrier.update_hugger_overlays() @@ -80,7 +80,7 @@ my_egg.start_unstoppable_decay() M.visible_message(SPAN_XENOWARNING("[M] throes as its eggsac bursts into a mess of acid!")) - playsound(M.loc, 'sound/effects/alien_egg_burst.ogg', 25, TRUE) + playsound(M, 'sound/effects/alien_egg_burst.ogg', 25, TRUE) ///Remove all references to src in eggs_sustained /datum/behavior_delegate/carrier_eggsac/Destroy() diff --git a/code/modules/mob/living/simple_animal/friendly/cat.dm b/code/modules/mob/living/simple_animal/friendly/cat.dm index 272bc289b2ec..19fcea1c4bd6 100644 --- a/code/modules/mob/living/simple_animal/friendly/cat.dm +++ b/code/modules/mob/living/simple_animal/friendly/cat.dm @@ -62,7 +62,7 @@ if((src.loc) && isturf(src.loc)) if(stat != DEAD) if(++miaow_counter >= rand(20, 30)) //Increase the meow variable each tick. Play it at random intervals. - playsound(loc, "cat_meow", 15, 1, 4) + playsound(src, "cat_meow", 15, 1, 4) miaow_counter = 0 //Reset the counter if(!stat && !resting && !buckled) for(var/mob/prey in view(1,src)) diff --git a/code/modules/mob/living/simple_animal/hostile/alien.dm b/code/modules/mob/living/simple_animal/hostile/alien.dm index 3f9a51355292..38febcbfa9fc 100644 --- a/code/modules/mob/living/simple_animal/hostile/alien.dm +++ b/code/modules/mob/living/simple_animal/hostile/alien.dm @@ -137,7 +137,7 @@ /mob/living/simple_animal/hostile/alien/proc/roar_emote() visible_message("The [name] roars!") - playsound(loc, "alien_roar", 40) + playsound(src, "alien_roar", 40) /mob/living/simple_animal/hostile/alien/death(cause, gibbed, deathmessage = "lets out a waning guttural screech, green blood bubbling from its maw. The caustic acid starts melting the body away...") . = ..() diff --git a/code/modules/movement/movement.dm b/code/modules/movement/movement.dm index e12a5b439296..54dad26cb9db 100644 --- a/code/modules/movement/movement.dm +++ b/code/modules/movement/movement.dm @@ -92,6 +92,10 @@ /atom/movable/proc/Moved(atom/oldloc, direction, Forced = FALSE) SEND_SIGNAL(src, COMSIG_MOVABLE_MOVED, oldloc, direction, Forced) + if(ismob(src)) + var/mob/moved = src + if(moved.client) + SEND_SIGNAL(moved.client, COMSIG_MOVABLE_MOVED, direction) for(var/datum/dynamic_light_source/light as anything in hybrid_light_sources) light.source_atom.update_light() if(!isturf(loc)) From e87be88b3673fa985bbc626794717f6b76d7e537 Mon Sep 17 00:00:00 2001 From: Git-Nivrak <59925169+Git-Nivrak@users.noreply.github.com> Date: Mon, 1 Jul 2024 15:29:30 +0300 Subject: [PATCH 02/18] fix --- code/datums/soundOutput.dm | 33 +++++++++++++++++-- .../abilities/runner/runner_powers.dm | 4 +-- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/code/datums/soundOutput.dm b/code/datums/soundOutput.dm index 5158b8f18424..dbc5146a01a9 100644 --- a/code/datums/soundOutput.dm +++ b/code/datums/soundOutput.dm @@ -4,6 +4,9 @@ var/list/soundscape_playlist = list() //Updated on changing areas var/ambience = null //The file currently being played as ambience var/status_flags = 0 //For things like ear deafness, psychodelic effects, and other things that change how all sounds behave + var/list/echo + var/list/current_sounds = list() + var/list/source_sounds = list() /// Currently applied environmental reverb. VAR_PROTECTED/owner_environment = SOUND_ENVIRONMENT_NONE @@ -24,7 +27,7 @@ owner = null return ..() -#define SMOOTHING 1 // How much smoothing when moving between tiles, smaller is more smoothing +#define SMOOTHING 1 // How much smoothing when moving between tiles, smaller value means more smoothing /datum/soundOutput/proc/update_sounds(atom/user, direction) SIGNAL_HANDLER @@ -40,6 +43,22 @@ process_sound(current_sounds[channel], TRUE, -1+i/32) if(8) process_sound(current_sounds[channel], TRUE, 1-i/32, 0) + +/datum/soundOutput/proc/update_sounds_from_source(atom/source, direction) + SIGNAL_HANDLER + for(var/channel in source_sounds[source]) + for(var/i in 0 to round(32/SMOOTHING)) + i = i * SMOOTHING + switch(direction) + if(1) + process_sound(current_sounds[channel], TRUE, 0, 1+i/32) + if(2) + process_sound(current_sounds[channel], TRUE, 0, -1-i/32) + if(4) + process_sound(current_sounds[channel], TRUE, 1+i/32) + if(8) + process_sound(current_sounds[channel], TRUE, -1-i/32, 0) + /datum/soundOutput/proc/remove_sound(channel) current_sounds -= channel @@ -54,12 +73,16 @@ S.falloff = T.falloff S.status = update ? SOUND_UPDATE : T.status if(!update) - S.params = list("on-end" = ".soundend [S.channel]") + S.params = list("on-end" = ".soundend [S.channel] [T.source]") var/turf/source_turf if(!QDELETED(T.source)) source_turf = get_turf(T.source) + + if(!update && istype(T.source, /atom/movable)) + source_sounds[T.source] = T + RegisterSignal(T.source, COMSIG_MOVABLE_MOVED, PROC_REF(update_sounds)) else source_turf = locate(T.x, T.y, T.z) @@ -87,10 +110,14 @@ current_sounds[num2text(S.channel)] = T sound_to(owner, S) -/client/verb/sound_ended(channel as num) +/client/verb/sound_ended(channel as num, source as atom) set name = ".soundend" soundOutput.remove_sound(num2text(channel)) + + if(soundOutput.source_sounds[source]) + soundOutput.source_sounds -= source + UnregisterSignal(source, COMSIG_MOVABLE_MOVED) /datum/soundOutput/proc/update_ambience(area/target_area, ambience_override, force_update = FALSE) diff --git a/code/modules/mob/living/carbon/xenomorph/abilities/runner/runner_powers.dm b/code/modules/mob/living/carbon/xenomorph/abilities/runner/runner_powers.dm index aac597441fd9..37e5083ab924 100644 --- a/code/modules/mob/living/carbon/xenomorph/abilities/runner/runner_powers.dm +++ b/code/modules/mob/living/carbon/xenomorph/abilities/runner/runner_powers.dm @@ -126,7 +126,7 @@ multitile_vehicle.take_damage_type(20 / acid.acid_delay, "acid", src) visible_message(SPAN_XENOWARNING("[src] vomits globs of vile stuff at [multitile_vehicle]. It sizzles under the bubbling mess of acid!"), \ SPAN_XENOWARNING("We vomit globs of vile stuff at [multitile_vehicle]. It sizzles under the bubbling mess of acid!"), null, 5) - playsound(O, "sound/bullets/acid_impact1.ogg", 25) + playsound(affected_atom, "sound/bullets/acid_impact1.ogg", 25) QDEL_IN(acid, 20) return @@ -135,7 +135,7 @@ visible_message(SPAN_XENOWARNING("[src] vomits globs of vile stuff all over [affected_atom]. It begins to sizzle and melt under the bubbling mess of acid!"), \ SPAN_XENOWARNING("We vomit globs of vile stuff all over [affected_atom]. It begins to sizzle and melt under the bubbling mess of acid!"), null, 5) - playsound(O, "sound/bullets/acid_impact1.ogg", 25) + playsound(affected_atom, "sound/bullets/acid_impact1.ogg", 25) /datum/action/xeno_action/activable/acider_for_the_hive/use_ability(atom/affected_atom) From 4e2d7e2ba67527d807971f271da03a8c14e761ce Mon Sep 17 00:00:00 2001 From: Git-Nivrak <59925169+Git-Nivrak@users.noreply.github.com> Date: Mon, 1 Jul 2024 15:32:47 +0300 Subject: [PATCH 03/18] more fix --- code/datums/soundOutput.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/datums/soundOutput.dm b/code/datums/soundOutput.dm index dbc5146a01a9..101eba13794a 100644 --- a/code/datums/soundOutput.dm +++ b/code/datums/soundOutput.dm @@ -110,7 +110,7 @@ current_sounds[num2text(S.channel)] = T sound_to(owner, S) -/client/verb/sound_ended(channel as num, source as atom) +/client/verb/sound_ended(channel as num, source as mob|obj|turf) set name = ".soundend" soundOutput.remove_sound(num2text(channel)) From a19357ad3c9e25cbac5738872ef4d35c1040b82e Mon Sep 17 00:00:00 2001 From: Git-Nivrak <59925169+Git-Nivrak@users.noreply.github.com> Date: Mon, 1 Jul 2024 20:28:39 +0300 Subject: [PATCH 04/18] New signal type --- code/__DEFINES/dcs/signals/signals_client.dm | 3 +++ code/datums/soundOutput.dm | 2 ++ code/modules/movement/movement.dm | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/code/__DEFINES/dcs/signals/signals_client.dm b/code/__DEFINES/dcs/signals/signals_client.dm index 36a60c153d0f..e3da9d31ba97 100644 --- a/code/__DEFINES/dcs/signals/signals_client.dm +++ b/code/__DEFINES/dcs/signals/signals_client.dm @@ -27,3 +27,6 @@ /// Called when something is removed from a client's screen : /client/proc/remove_from_screen(screen_remove) #define COMSIG_CLIENT_SCREEN_REMOVE "client_screen_remove" + +/// From movement.dm: /atom/movable/proc/Moved(atom/oldloc, direction, Forced = FALSE) +#define COMSIG_CLIENT_MOB_MOVED "client_mob_moved" diff --git a/code/datums/soundOutput.dm b/code/datums/soundOutput.dm index 101eba13794a..77be2f1fe719 100644 --- a/code/datums/soundOutput.dm +++ b/code/datums/soundOutput.dm @@ -19,11 +19,13 @@ RegisterSignal(owner.mob, COMSIG_MOVABLE_MOVED, PROC_REF(on_mob_moved)) RegisterSignal(owner.mob, COMSIG_MOB_LOGOUT, PROC_REF(on_mob_logout)) RegisterSignal(owner, COMSIG_CLIENT_MOB_LOGGED_IN, PROC_REF(on_client_mob_logged_in)) + RegisterSignal(owner, COMSIG_CLIENT_MOB_MOVED, PROC_REF(update_sounds)) return ..() /datum/soundOutput/Destroy() UnregisterSignal(owner.mob, list(COMSIG_MOVABLE_MOVED, COMSIG_MOB_LOGOUT)) UnregisterSignal(owner, COMSIG_CLIENT_MOB_LOGGED_IN) + UnregisterSignal(owner, COMSIG_CLIENT_MOB_MOVED) owner = null return ..() diff --git a/code/modules/movement/movement.dm b/code/modules/movement/movement.dm index 54dad26cb9db..d889f6e342ba 100644 --- a/code/modules/movement/movement.dm +++ b/code/modules/movement/movement.dm @@ -95,7 +95,7 @@ if(ismob(src)) var/mob/moved = src if(moved.client) - SEND_SIGNAL(moved.client, COMSIG_MOVABLE_MOVED, direction) + SEND_SIGNAL(moved.client, COMSIG_CLIENT_MOB_MOVED, direction) for(var/datum/dynamic_light_source/light as anything in hybrid_light_sources) light.source_atom.update_light() if(!isturf(loc)) From dfb66b88e74bb88f078e5db2d9c699718c10a987 Mon Sep 17 00:00:00 2001 From: Git-Nivrak <59925169+Git-Nivrak@users.noreply.github.com> Date: Wed, 3 Jul 2024 15:46:23 +0300 Subject: [PATCH 05/18] Update soundOutput.dm --- code/datums/soundOutput.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/datums/soundOutput.dm b/code/datums/soundOutput.dm index 77be2f1fe719..fc3d27e1b5a4 100644 --- a/code/datums/soundOutput.dm +++ b/code/datums/soundOutput.dm @@ -29,7 +29,7 @@ owner = null return ..() -#define SMOOTHING 1 // How much smoothing when moving between tiles, smaller value means more smoothing +#define SMOOTHING 2 // [1, 32], 32 Means best sound most lag 1 Means worst sound least lag /datum/soundOutput/proc/update_sounds(atom/user, direction) SIGNAL_HANDLER From db07f68349c8901333430794b412c795dd446985 Mon Sep 17 00:00:00 2001 From: Git-Nivrak <59925169+Git-Nivrak@users.noreply.github.com> Date: Fri, 5 Jul 2024 16:58:34 +0300 Subject: [PATCH 06/18] Fixes sources --- code/datums/soundOutput.dm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/code/datums/soundOutput.dm b/code/datums/soundOutput.dm index fc3d27e1b5a4..0e00daec07e5 100644 --- a/code/datums/soundOutput.dm +++ b/code/datums/soundOutput.dm @@ -48,18 +48,18 @@ /datum/soundOutput/proc/update_sounds_from_source(atom/source, direction) SIGNAL_HANDLER - for(var/channel in source_sounds[source]) + for(var/datum/sound_template/template in source_sounds[source]) for(var/i in 0 to round(32/SMOOTHING)) i = i * SMOOTHING switch(direction) if(1) - process_sound(current_sounds[channel], TRUE, 0, 1+i/32) + process_sound(template, TRUE, 0, 1+i/32) if(2) - process_sound(current_sounds[channel], TRUE, 0, -1-i/32) + process_sound(template, TRUE, 0, -1-i/32) if(4) - process_sound(current_sounds[channel], TRUE, 1+i/32) + process_sound(template, TRUE, 1+i/32) if(8) - process_sound(current_sounds[channel], TRUE, -1-i/32, 0) + process_sound(template, TRUE, -1-i/32, 0) /datum/soundOutput/proc/remove_sound(channel) current_sounds -= channel From 6bc6634ae838dcc9a87a3d3871f1e23a485a79aa Mon Sep 17 00:00:00 2001 From: Git-Nivrak <59925169+Git-Nivrak@users.noreply.github.com> Date: Sat, 6 Jul 2024 11:19:50 +0300 Subject: [PATCH 07/18] Update soundOutput.dm --- code/datums/soundOutput.dm | 1 - 1 file changed, 1 deletion(-) diff --git a/code/datums/soundOutput.dm b/code/datums/soundOutput.dm index 0e00daec07e5..fb33f8dd28ea 100644 --- a/code/datums/soundOutput.dm +++ b/code/datums/soundOutput.dm @@ -4,7 +4,6 @@ var/list/soundscape_playlist = list() //Updated on changing areas var/ambience = null //The file currently being played as ambience var/status_flags = 0 //For things like ear deafness, psychodelic effects, and other things that change how all sounds behave - var/list/echo var/list/current_sounds = list() var/list/source_sounds = list() From f4927408261f0f65ba5daec55993201047811221 Mon Sep 17 00:00:00 2001 From: Git-Nivrak <59925169+Git-Nivrak@users.noreply.github.com> Date: Sat, 6 Jul 2024 22:29:35 +0300 Subject: [PATCH 08/18] Update soundOutput.dm --- code/datums/soundOutput.dm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/datums/soundOutput.dm b/code/datums/soundOutput.dm index fb33f8dd28ea..fd664721dd69 100644 --- a/code/datums/soundOutput.dm +++ b/code/datums/soundOutput.dm @@ -103,7 +103,8 @@ S.z = source_turf.y - owner_turf.y + offset_y S.y += T.y_s_offset S.x += T.x_s_offset - S.echo = SOUND_ECHO_REVERB_ON + if(source_turf.x && source_turf.y && source_turf.z) + S.echo = SOUND_ECHO_REVERB_ON if(owner.mob.ear_deaf > 0) S.status |= SOUND_MUTE From 3ee6e09f855c2ab7b37679c9d1a201e6908a9ef5 Mon Sep 17 00:00:00 2001 From: Git-Nivrak <59925169+Git-Nivrak@users.noreply.github.com> Date: Sat, 6 Jul 2024 22:35:30 +0300 Subject: [PATCH 09/18] Update soundOutput.dm --- code/datums/soundOutput.dm | 39 ++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/code/datums/soundOutput.dm b/code/datums/soundOutput.dm index fd664721dd69..d43ee1d39b79 100644 --- a/code/datums/soundOutput.dm +++ b/code/datums/soundOutput.dm @@ -77,6 +77,7 @@ S.params = list("on-end" = ".soundend [S.channel] [T.source]") + var/positonal_sound = FALSE var/turf/source_turf if(!QDELETED(T.source)) source_turf = get_turf(T.source) @@ -84,27 +85,29 @@ if(!update && istype(T.source, /atom/movable)) source_sounds[T.source] = T RegisterSignal(T.source, COMSIG_MOVABLE_MOVED, PROC_REF(update_sounds)) - else + else if (T.x && T.y && T.z) + positonal_sound = TRUE source_turf = locate(T.x, T.y, T.z) - var/turf/owner_turf = get_turf(owner.mob) - if(owner_turf) - // We're in an interior and sound came from outside - if(SSinterior.in_interior(owner_turf) && owner_turf.z != T.z) - var/datum/interior/VI = SSinterior.get_interior_by_coords(owner_turf.x, owner_turf.y, owner_turf.z) - if(VI && VI.exterior) - var/turf/candidate = get_turf(VI.exterior) - if(candidate.z != T.z) - return // Invalid location - S.falloff /= 2 - owner_turf = candidate - S.x = source_turf.x - owner_turf.x + offset_x - S.y = 0 - S.z = source_turf.y - owner_turf.y + offset_y - S.y += T.y_s_offset - S.x += T.x_s_offset - if(source_turf.x && source_turf.y && source_turf.z) + if(positonal_sound) + var/turf/owner_turf = get_turf(owner.mob) + if(owner_turf) + // We're in an interior and sound came from outside + if(SSinterior.in_interior(owner_turf) && owner_turf.z != T.z) + var/datum/interior/VI = SSinterior.get_interior_by_coords(owner_turf.x, owner_turf.y, owner_turf.z) + if(VI && VI.exterior) + var/turf/candidate = get_turf(VI.exterior) + if(candidate.z != T.z) + return // Invalid location + S.falloff /= 2 + owner_turf = candidate + S.x = source_turf.x - owner_turf.x + offset_x + S.y = 0 + S.z = source_turf.y - owner_turf.y + offset_y + S.y += T.y_s_offset + S.x += T.x_s_offset S.echo = SOUND_ECHO_REVERB_ON + if(owner.mob.ear_deaf > 0) S.status |= SOUND_MUTE From d0866f568901b766cf2ee130896f0b7b48520cd7 Mon Sep 17 00:00:00 2001 From: Git-Nivrak <59925169+Git-Nivrak@users.noreply.github.com> Date: Sat, 6 Jul 2024 22:38:13 +0300 Subject: [PATCH 10/18] Update soundOutput.dm --- code/datums/soundOutput.dm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/code/datums/soundOutput.dm b/code/datums/soundOutput.dm index d43ee1d39b79..06551a199e90 100644 --- a/code/datums/soundOutput.dm +++ b/code/datums/soundOutput.dm @@ -108,11 +108,12 @@ S.x += T.x_s_offset S.echo = SOUND_ECHO_REVERB_ON + if(!update) + current_sounds[num2text(S.channel)] = T + if(owner.mob.ear_deaf > 0) S.status |= SOUND_MUTE - - if(!update) - current_sounds[num2text(S.channel)] = T + sound_to(owner, S) /client/verb/sound_ended(channel as num, source as mob|obj|turf) From bf3f1f8e09201e11062a392a95f6b6fa774fce08 Mon Sep 17 00:00:00 2001 From: Git-Nivrak <59925169+Git-Nivrak@users.noreply.github.com> Date: Sat, 6 Jul 2024 23:26:13 +0300 Subject: [PATCH 11/18] Cleanup --- code/datums/soundOutput.dm | 73 ++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 43 deletions(-) diff --git a/code/datums/soundOutput.dm b/code/datums/soundOutput.dm index 06551a199e90..30a0fd8704aa 100644 --- a/code/datums/soundOutput.dm +++ b/code/datums/soundOutput.dm @@ -15,15 +15,10 @@ qdel(src) return owner = client - RegisterSignal(owner.mob, COMSIG_MOVABLE_MOVED, PROC_REF(on_mob_moved)) - RegisterSignal(owner.mob, COMSIG_MOB_LOGOUT, PROC_REF(on_mob_logout)) - RegisterSignal(owner, COMSIG_CLIENT_MOB_LOGGED_IN, PROC_REF(on_client_mob_logged_in)) - RegisterSignal(owner, COMSIG_CLIENT_MOB_MOVED, PROC_REF(update_sounds)) + RegisterSignal(owner, COMSIG_CLIENT_MOB_MOVED, PROC_REF(on_mob_moved)) return ..() /datum/soundOutput/Destroy() - UnregisterSignal(owner.mob, list(COMSIG_MOVABLE_MOVED, COMSIG_MOB_LOGOUT)) - UnregisterSignal(owner, COMSIG_CLIENT_MOB_LOGGED_IN) UnregisterSignal(owner, COMSIG_CLIENT_MOB_MOVED) owner = null return ..() @@ -47,21 +42,25 @@ /datum/soundOutput/proc/update_sounds_from_source(atom/source, direction) SIGNAL_HANDLER - for(var/datum/sound_template/template in source_sounds[source]) - for(var/i in 0 to round(32/SMOOTHING)) - i = i * SMOOTHING - switch(direction) - if(1) - process_sound(template, TRUE, 0, 1+i/32) - if(2) - process_sound(template, TRUE, 0, -1-i/32) - if(4) - process_sound(template, TRUE, 1+i/32) - if(8) - process_sound(template, TRUE, -1-i/32, 0) + for(var/channel in source_sounds) + if(source_sounds[channel] == source) + var/datum/sound_template/template = current_sounds[channel] + for(var/i in 0 to round(32/SMOOTHING)) + i = i * SMOOTHING + switch(direction) + if(1) + process_sound(template, TRUE, 0, 1+i/32) + if(2) + process_sound(template, TRUE, 0, -1-i/32) + if(4) + process_sound(template, TRUE, 1+i/32) + if(8) + process_sound(template, TRUE, -1-i/32, 0) + break /datum/soundOutput/proc/remove_sound(channel) current_sounds -= channel + source_sounds -= channel /datum/soundOutput/proc/process_sound(datum/sound_template/T, update=FALSE, offset_x = 0, offset_y = 0) var/sound/S = sound(T.file, T.wait, T.repeat) @@ -72,19 +71,21 @@ S.channel = T.channel S.frequency = T.frequency S.falloff = T.falloff - S.status = update ? SOUND_UPDATE : T.status - if(!update) - S.params = list("on-end" = ".soundend [S.channel] [T.source]") - + if(!update) + S.params = list("on-end" = ".soundend [S.channel]") + S.status = T.status + else + S.status = SOUND_UPDATE + var/positonal_sound = FALSE var/turf/source_turf - if(!QDELETED(T.source)) + if(T.source && !QDELETED(T.source)) source_turf = get_turf(T.source) if(!update && istype(T.source, /atom/movable)) - source_sounds[T.source] = T - RegisterSignal(T.source, COMSIG_MOVABLE_MOVED, PROC_REF(update_sounds)) + source_sounds[num2text(T.channel)] = T.source + RegisterSignal(T.source, COMSIG_MOVABLE_MOVED, PROC_REF(update_sounds_from_source)) else if (T.x && T.y && T.z) positonal_sound = TRUE source_turf = locate(T.x, T.y, T.z) @@ -112,20 +113,15 @@ current_sounds[num2text(S.channel)] = T if(owner.mob.ear_deaf > 0) - S.status |= SOUND_MUTE - + S.status |= SOUND_MUTE + sound_to(owner, S) -/client/verb/sound_ended(channel as num, source as mob|obj|turf) +/client/verb/sound_ended(channel as num) set name = ".soundend" soundOutput.remove_sound(num2text(channel)) - if(soundOutput.source_sounds[source]) - soundOutput.source_sounds -= source - UnregisterSignal(source, COMSIG_MOVABLE_MOVED) - - /datum/soundOutput/proc/update_ambience(area/target_area, ambience_override, force_update = FALSE) var/status_flags = SOUND_STREAM var/target_ambience = ambience_override @@ -236,18 +232,9 @@ /datum/soundOutput/proc/on_mob_moved(datum/source, atom/oldloc, direction, Forced) SIGNAL_HANDLER //COMSIG_MOVABLE_MOVED + update_sounds() update_area_environment() -/datum/soundOutput/proc/on_mob_logout(datum/source) - SIGNAL_HANDLER //COMSIG_MOB_LOGOUT - UnregisterSignal(owner.mob, list(COMSIG_MOVABLE_MOVED, COMSIG_MOB_LOGOUT)) - -/datum/soundOutput/proc/on_client_mob_logged_in(datum/source, mob/new_mob) - SIGNAL_HANDLER //COMSIG_CLIENT_MOB_LOGGED_IN - RegisterSignal(owner.mob, COMSIG_MOVABLE_MOVED, PROC_REF(on_mob_moved)) - RegisterSignal(owner.mob, COMSIG_MOB_LOGOUT, PROC_REF(on_mob_logout)) - update_mob_environment_override() - /client/proc/adjust_volume_prefs(volume_key, prompt = "", channel_update = 0) volume_preferences[volume_key] = (tgui_input_number(src, prompt, "Volume", volume_preferences[volume_key]*100)) / 100 if(volume_preferences[volume_key] > 1) From e0d38dd8bc0b6d5b9306f56cacbd7c6e891307a4 Mon Sep 17 00:00:00 2001 From: Git-Nivrak <59925169+Git-Nivrak@users.noreply.github.com> Date: Sun, 7 Jul 2024 14:02:22 +0300 Subject: [PATCH 12/18] Update soundOutput.dm --- code/datums/soundOutput.dm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/code/datums/soundOutput.dm b/code/datums/soundOutput.dm index 30a0fd8704aa..a049fd15c9cb 100644 --- a/code/datums/soundOutput.dm +++ b/code/datums/soundOutput.dm @@ -16,10 +16,12 @@ return owner = client RegisterSignal(owner, COMSIG_CLIENT_MOB_MOVED, PROC_REF(on_mob_moved)) + RegisterSignal(owner, COMSIG_CLIENT_MOB_LOGGED_IN, PROC_REF(on_client_mob_logged_in)) return ..() /datum/soundOutput/Destroy() UnregisterSignal(owner, COMSIG_CLIENT_MOB_MOVED) + UnregisterSignal(owner, COMSIG_CLIENT_MOB_LOGGED_IN) owner = null return ..() @@ -78,7 +80,7 @@ else S.status = SOUND_UPDATE - var/positonal_sound = FALSE + var/positional_sound = FALSE var/turf/source_turf if(T.source && !QDELETED(T.source)) source_turf = get_turf(T.source) @@ -87,10 +89,10 @@ source_sounds[num2text(T.channel)] = T.source RegisterSignal(T.source, COMSIG_MOVABLE_MOVED, PROC_REF(update_sounds_from_source)) else if (T.x && T.y && T.z) - positonal_sound = TRUE + positional_sound = TRUE source_turf = locate(T.x, T.y, T.z) - if(positonal_sound) + if(positional_sound) var/turf/owner_turf = get_turf(owner.mob) if(owner_turf) // We're in an interior and sound came from outside @@ -122,6 +124,10 @@ soundOutput.remove_sound(num2text(channel)) +/datum/soundOutput/proc/on_client_mob_logged_in(datum/source, mob/new_mob) + SIGNAL_HANDLER //COMSIG_CLIENT_MOB_LOGGED_IN + update_mob_environment_override() + /datum/soundOutput/proc/update_ambience(area/target_area, ambience_override, force_update = FALSE) var/status_flags = SOUND_STREAM var/target_ambience = ambience_override From f682e014dbb33d577d0c791fb0c7805b2551ef52 Mon Sep 17 00:00:00 2001 From: Git-Nivrak <59925169+Git-Nivrak@users.noreply.github.com> Date: Mon, 8 Jul 2024 15:36:28 +0300 Subject: [PATCH 13/18] Update soundOutput.dm --- code/datums/soundOutput.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/datums/soundOutput.dm b/code/datums/soundOutput.dm index a049fd15c9cb..e751a00bdbc8 100644 --- a/code/datums/soundOutput.dm +++ b/code/datums/soundOutput.dm @@ -85,7 +85,7 @@ if(T.source && !QDELETED(T.source)) source_turf = get_turf(T.source) - if(!update && istype(T.source, /atom/movable)) + if(!update && istype(T.source, /atom/movable) && T.source != owner.mob) source_sounds[num2text(T.channel)] = T.source RegisterSignal(T.source, COMSIG_MOVABLE_MOVED, PROC_REF(update_sounds_from_source)) else if (T.x && T.y && T.z) From db03735cd97f4fe943d2457d39db68fafdd581ca Mon Sep 17 00:00:00 2001 From: Git-Nivrak <59925169+Git-Nivrak@users.noreply.github.com> Date: Wed, 10 Jul 2024 23:18:32 +0300 Subject: [PATCH 14/18] fixes fixes every sound being place ontop of you --- code/datums/soundOutput.dm | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/code/datums/soundOutput.dm b/code/datums/soundOutput.dm index e751a00bdbc8..e30d36b65ddc 100644 --- a/code/datums/soundOutput.dm +++ b/code/datums/soundOutput.dm @@ -38,7 +38,7 @@ if(2) process_sound(current_sounds[channel], TRUE, 0, 1-i/32) if(4) - process_sound(current_sounds[channel], TRUE, -1+i/32) + process_sound(current_sounds[channel], TRUE, -1+i/32, 0) if(8) process_sound(current_sounds[channel], TRUE, 1-i/32, 0) @@ -55,7 +55,7 @@ if(2) process_sound(template, TRUE, 0, -1-i/32) if(4) - process_sound(template, TRUE, 1+i/32) + process_sound(template, TRUE, 1+i/32, 0) if(8) process_sound(template, TRUE, -1-i/32, 0) break @@ -80,7 +80,7 @@ else S.status = SOUND_UPDATE - var/positional_sound = FALSE + var/positional_sound = TRUE var/turf/source_turf if(T.source && !QDELETED(T.source)) source_turf = get_turf(T.source) @@ -89,8 +89,9 @@ source_sounds[num2text(T.channel)] = T.source RegisterSignal(T.source, COMSIG_MOVABLE_MOVED, PROC_REF(update_sounds_from_source)) else if (T.x && T.y && T.z) - positional_sound = TRUE source_turf = locate(T.x, T.y, T.z) + else + positional_sound = FALSE if(positional_sound) var/turf/owner_turf = get_turf(owner.mob) @@ -236,10 +237,10 @@ src.owner_environment = new_environment -/datum/soundOutput/proc/on_mob_moved(datum/source, atom/oldloc, direction, Forced) - SIGNAL_HANDLER //COMSIG_MOVABLE_MOVED - update_sounds() +/datum/soundOutput/proc/on_mob_moved(atom/source, direction) + SIGNAL_HANDLER //COMSIG_CLIENT_MOB_MOVED update_area_environment() + update_sounds(source, direction) /client/proc/adjust_volume_prefs(volume_key, prompt = "", channel_update = 0) volume_preferences[volume_key] = (tgui_input_number(src, prompt, "Volume", volume_preferences[volume_key]*100)) / 100 From 4293e2e73281ecaabab1dc6997806667c9f695d6 Mon Sep 17 00:00:00 2001 From: Git-Nivrak <59925169+Git-Nivrak@users.noreply.github.com> Date: Wed, 10 Jul 2024 23:21:57 +0300 Subject: [PATCH 15/18] reduces smoothing --- code/datums/soundOutput.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/datums/soundOutput.dm b/code/datums/soundOutput.dm index e30d36b65ddc..3b3e545e121f 100644 --- a/code/datums/soundOutput.dm +++ b/code/datums/soundOutput.dm @@ -25,7 +25,7 @@ owner = null return ..() -#define SMOOTHING 2 // [1, 32], 32 Means best sound most lag 1 Means worst sound least lag +#define SMOOTHING 8 // [1, 32], 32 Means best sound most lag 1 Means worst sound least lag /datum/soundOutput/proc/update_sounds(atom/user, direction) SIGNAL_HANDLER From 973ac7a84b638f8f815d659f523d1097724befaa Mon Sep 17 00:00:00 2001 From: Git-Nivrak <59925169+Git-Nivrak@users.noreply.github.com> Date: Thu, 11 Jul 2024 22:30:14 +0300 Subject: [PATCH 16/18] Update soundOutput.dm --- code/datums/soundOutput.dm | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/code/datums/soundOutput.dm b/code/datums/soundOutput.dm index 3b3e545e121f..ccbda3cc0a8f 100644 --- a/code/datums/soundOutput.dm +++ b/code/datums/soundOutput.dm @@ -42,7 +42,7 @@ if(8) process_sound(current_sounds[channel], TRUE, 1-i/32, 0) -/datum/soundOutput/proc/update_sounds_from_source(atom/source, direction) +/datum/soundOutput/proc/update_sounds_from_source(datum/source, atom/oldloc, direction, Forced) SIGNAL_HANDLER for(var/channel in source_sounds) if(source_sounds[channel] == source) @@ -51,13 +51,13 @@ i = i * SMOOTHING switch(direction) if(1) - process_sound(template, TRUE, 0, 1+i/32) + process_sound(template, TRUE, 0, 1-i/32) if(2) - process_sound(template, TRUE, 0, -1-i/32) + process_sound(template, TRUE, 0, -1+i/32) if(4) - process_sound(template, TRUE, 1+i/32, 0) + process_sound(template, TRUE, 1-i/32, 0) if(8) - process_sound(template, TRUE, -1-i/32, 0) + process_sound(template, TRUE, -1+i/32, 0) break /datum/soundOutput/proc/remove_sound(channel) @@ -73,9 +73,9 @@ S.channel = T.channel S.frequency = T.frequency S.falloff = T.falloff - + S.params = list("on-end" = ".soundend [S.channel]") + if(!update) - S.params = list("on-end" = ".soundend [S.channel]") S.status = T.status else S.status = SOUND_UPDATE @@ -112,7 +112,7 @@ S.x += T.x_s_offset S.echo = SOUND_ECHO_REVERB_ON - if(!update) + if(!update && T.source && T.source != owner.mob) current_sounds[num2text(S.channel)] = T if(owner.mob.ear_deaf > 0) From 4f829ac74d063bc87173f7cec1115fc353391519 Mon Sep 17 00:00:00 2001 From: Git-Nivrak <59925169+Git-Nivrak@users.noreply.github.com> Date: Fri, 12 Jul 2024 01:43:18 +0300 Subject: [PATCH 17/18] Disables smoothing for guns --- code/datums/soundOutput.dm | 4 ++-- code/game/sound.dm | 4 +++- code/modules/projectiles/gun.dm | 8 ++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/code/datums/soundOutput.dm b/code/datums/soundOutput.dm index ccbda3cc0a8f..f3f1b214c7bf 100644 --- a/code/datums/soundOutput.dm +++ b/code/datums/soundOutput.dm @@ -85,7 +85,7 @@ if(T.source && !QDELETED(T.source)) source_turf = get_turf(T.source) - if(!update && istype(T.source, /atom/movable) && T.source != owner.mob) + if(!update && istype(T.source, /atom/movable) && T.source != owner.mob && T.use_smoothing) source_sounds[num2text(T.channel)] = T.source RegisterSignal(T.source, COMSIG_MOVABLE_MOVED, PROC_REF(update_sounds_from_source)) else if (T.x && T.y && T.z) @@ -112,7 +112,7 @@ S.x += T.x_s_offset S.echo = SOUND_ECHO_REVERB_ON - if(!update && T.source && T.source != owner.mob) + if(!update && T.source && T.source != owner.mob && T.use_smoothing) current_sounds[num2text(S.channel)] = T if(owner.mob.ear_deaf > 0) diff --git a/code/game/sound.dm b/code/game/sound.dm index 7f42837f8c7e..6b830f4e8c8a 100644 --- a/code/game/sound.dm +++ b/code/game/sound.dm @@ -19,6 +19,7 @@ var/y_s_offset // Vertical sound offset var/x_s_offset // Horizontal sound offset var/atom/source + var/use_smoothing = TRUE /proc/get_free_channel() var/static/cur_chan = 1 @@ -37,7 +38,7 @@ //status: the regular 4 sound flags //falloff: max range till sound volume starts dropping as distance increases -/proc/playsound(atom/source, soundin, vol = 100, vary = FALSE, sound_range, vol_cat = VOLUME_SFX, channel = 0, status , falloff = 1, y_s_offset,x_s_offset) +/proc/playsound(atom/source, soundin, vol = 100, vary = FALSE, sound_range, vol_cat = VOLUME_SFX, channel = 0, status , falloff = 1, y_s_offset,x_s_offset, smoothing=TRUE) if(isarea(source)) error("[source] is an area and is trying to make the sound: [soundin]") return FALSE @@ -57,6 +58,7 @@ S.volume_cat = vol_cat S.y_s_offset = y_s_offset S.x_s_offset = x_s_offset + S.use_smoothing = smoothing if(vary != FALSE) if(vary > 1) S.frequency = vary diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm index f7ffbf2875e2..c3500c4ee61f 100644 --- a/code/modules/projectiles/gun.dm +++ b/code/modules/projectiles/gun.dm @@ -1684,15 +1684,15 @@ not all weapons use normal magazines etc. load_into_chamber() itself is designed //firing from an attachment if(active_attachable && active_attachable.flags_attach_features & ATTACH_PROJECTILE) if(active_attachable.fire_sound) //If we're firing from an attachment, use that noise instead. - playsound(user, active_attachable.fire_sound, 50) + playsound(user, active_attachable.fire_sound, 50, use_smoothing=FALSE) else if(!(flags_gun_features & GUN_SILENCED)) if (firing_sndfreq && fire_rattle) - playsound(user, fire_rattle, firesound_volume, FALSE)//if the gun has a unique 'mag rattle' SFX play that instead of pitch shifting. + playsound(user, fire_rattle, firesound_volume, FALSE, use_smoothing=FALSE)//if the gun has a unique 'mag rattle' SFX play that instead of pitch shifting. else - playsound(user, actual_sound, firesound_volume, firing_sndfreq) + playsound(user, actual_sound, firesound_volume, firing_sndfreq, use_smoothing=FALSE) else - playsound(user, actual_sound, 25, firing_sndfreq) + playsound(user, actual_sound, 25, firing_sndfreq, use_smoothing=FALSE) return 1 From 1ae0d181a9cfc90ee64f7a9006e1449266ad061a Mon Sep 17 00:00:00 2001 From: Git-Nivrak <59925169+Git-Nivrak@users.noreply.github.com> Date: Fri, 12 Jul 2024 01:43:51 +0300 Subject: [PATCH 18/18] Update soundOutput.dm --- code/datums/soundOutput.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/datums/soundOutput.dm b/code/datums/soundOutput.dm index f3f1b214c7bf..2c19ecb2d588 100644 --- a/code/datums/soundOutput.dm +++ b/code/datums/soundOutput.dm @@ -25,7 +25,7 @@ owner = null return ..() -#define SMOOTHING 8 // [1, 32], 32 Means best sound most lag 1 Means worst sound least lag +#define SMOOTHING 1 // [1, 32], 32 Means best sound most lag 1 Means worst sound least lag /datum/soundOutput/proc/update_sounds(atom/user, direction) SIGNAL_HANDLER