From ace195080076b2ac924a0c818f3c78c64209f7d1 Mon Sep 17 00:00:00 2001 From: Poojawa Date: Wed, 22 Jan 2020 00:07:39 -0600 Subject: [PATCH] Makes listen checks a tad cheaper. Improves external sounds with falloff --- code/modules/vore/eating/belly_obj.dm | 21 ++--- code/modules/vore/eating/bellymodes.dm | 110 ++++++++----------------- 2 files changed, 46 insertions(+), 85 deletions(-) diff --git a/code/modules/vore/eating/belly_obj.dm b/code/modules/vore/eating/belly_obj.dm index 61031c0a0d..e2b2b33ba7 100644 --- a/code/modules/vore/eating/belly_obj.dm +++ b/code/modules/vore/eating/belly_obj.dm @@ -1,4 +1,5 @@ -//#define VORE_SOUND_FALLOFF 0.05 +#define VORE_SOUND_FALLOFF 0.1 +#define VORE_SOUND_RANGE 3 // // Belly system 2.0, now using objects instead of datums because EH at datums. @@ -175,7 +176,7 @@ if(vore_sound && !recent_sound) if((world.time + NORMIE_HEARCHECK) > last_hearcheck) LAZYCLEARLIST(hearing_mobs) - for(var/mob/living/H in get_hearers_in_view(3, owner)) + for(var/mob/living/H in get_hearers_in_view(VORE_SOUND_RANGE, owner)) if(!H.client || !(H.client.prefs.cit_toggles & EATING_NOISES)) continue LAZYADD(hearing_mobs, H) @@ -229,7 +230,7 @@ if(release_sound && !recent_sound) if((world.time + NORMIE_HEARCHECK) > last_hearcheck) LAZYCLEARLIST(hearing_mobs) - for(var/mob/living/H in get_hearers_in_view(3, owner)) + for(var/mob/living/H in get_hearers_in_view(VORE_SOUND_RANGE, owner)) if(!H.client || !(H.client.prefs.cit_toggles & EATING_NOISES)) continue LAZYADD(hearing_mobs, H) @@ -237,7 +238,7 @@ for(var/mob/living/H in hearing_mobs) if(H && H.client && (isturf(H.loc) || (H.loc != src.contents))) var/sound/releasement = GLOB.pred_release_sounds[release_sound] - SEND_SOUND(H,releasement) + H.playsound_local(owner.loc, releasement, vol = 75, vary = 1, falloff = VORE_SOUND_FALLOFF) else if(H && H in contents && H.client) var/sound/releasement = GLOB.prey_release_sounds[release_sound] SEND_SOUND(H,releasement) @@ -294,7 +295,7 @@ for(var/mob/living/H in hearing_mobs) if(H && H.client && (isturf(H.loc) || (H.loc != src.contents))) var/sound/releasement = GLOB.pred_release_sounds[release_sound] - SEND_SOUND(H,releasement) + H.playsound_local(owner.loc, releasement, vol = 75, vary = 1, falloff = VORE_SOUND_FALLOFF) else if(H && H in contents && H.client) var/sound/releasement = GLOB.prey_release_sounds[release_sound] SEND_SOUND(H,releasement) @@ -352,7 +353,7 @@ if(vore_sound && !recent_sound && !silent) if((world.time + NORMIE_HEARCHECK) > last_hearcheck) LAZYCLEARLIST(hearing_mobs) - for(var/mob/living/H in get_hearers_in_view(3, owner)) + for(var/mob/living/H in get_hearers_in_view(VORE_SOUND_RANGE, owner)) if(!H.client || !(H.client.prefs.cit_toggles & EATING_NOISES)) continue LAZYADD(hearing_mobs, H) @@ -360,7 +361,7 @@ for(var/mob/living/H in hearing_mobs) if(H && H.client && (isturf(H.loc) || (H.loc != src.contents))) var/sound/eating = GLOB.pred_vore_sounds[vore_sound] - SEND_SOUND(H,eating) + H.playsound_local(owner.loc, eating, vol = 75, vary = 1, falloff = VORE_SOUND_FALLOFF) else if(H && H in contents && H.client) var/sound/eating = GLOB.prey_vore_sounds[vore_sound] SEND_SOUND(H,eating) @@ -578,7 +579,7 @@ var/sound/struggle_rustle = sound(get_sfx("rustle")) LAZYCLEARLIST(hearing_mobs) - for(var/mob/living/H in get_hearers_in_view(3, owner)) + for(var/mob/living/H in get_hearers_in_view(VORE_SOUND_RANGE, owner)) if(!H.client || !(H.client.prefs.cit_toggles & EATING_NOISES)) continue LAZYADD(hearing_mobs, H) @@ -586,14 +587,14 @@ if(is_wet) for(var/mob/living/H in hearing_mobs) if(H && H.client && (isturf(H.loc) || (H.loc != src.contents))) - SEND_SOUND(H,pred_struggle_snuggle) + H.playsound_local(owner.loc, pred_struggle_snuggle, vol = 75, vary = 1, falloff = VORE_SOUND_FALLOFF) else if(H && H in contents && H.client) SEND_SOUND(H,prey_struggle_snuggle) else for(var/mob/living/H in hearing_mobs) if(H && H.client) - SEND_SOUND(H, struggle_rustle) + H.playsound_local(owner.loc, struggle_rustle, vol = 75, vary = 1, falloff = VORE_SOUND_FALLOFF) for(var/mob/living/H in hearing_mobs) if(H && H.client && (isturf(H.loc))) diff --git a/code/modules/vore/eating/bellymodes.dm b/code/modules/vore/eating/bellymodes.dm index 0ecaf49abc..6942a2d5a9 100644 --- a/code/modules/vore/eating/bellymodes.dm +++ b/code/modules/vore/eating/bellymodes.dm @@ -18,7 +18,8 @@ return SSBELLIES_PROCESSED next_process = times_fired + (6 SECONDS/wait) //Set up our next process time. - var/to_update = FALSE + var/play_sound //Potential sound to play at the end to avoid code duplication. + var/to_update = FALSE //Did anything update worthy happen? /////////////////////////// Auto-Emotes /////////////////////////// if(contents.len && next_emote <= times_fired) @@ -40,7 +41,7 @@ if(M.client.prefs.cit_toggles & DIGESTION_NOISES) var/sound/preyloop = sound('sound/vore/prey/loop.ogg') M.playsound_local(get_turf(src),preyloop, 80,0, channel = CHANNEL_PREYLOOP) - M.next_preyloop = (world.time + 51 SECONDS) + M.next_preyloop = (world.time + 52 SECONDS) /////////////////////////// Exit Early //////////////////////////// @@ -71,18 +72,9 @@ for (var/mob/living/M in contents) if(prob(25)) - if((world.time + NORMIE_HEARCHECK) > last_hearcheck) - LAZYCLEARLIST(hearing_mobs) - for(var/mob/living/H in get_hearers_in_view(3, owner)) - if(!H.client || !(H.client.prefs.cit_toggles & DIGESTION_NOISES)) - continue - LAZYADD(hearing_mobs, H) - last_hearcheck = world.time - for(var/mob/living/H in hearing_mobs) - if(H && H.client && (isturf(H.loc) || (H.loc != src.contents))) - SEND_SOUND(H,pred_digest) - else if(H && H in contents && H.client) - SEND_SOUND(H,prey_digest) + if(M && M.client && M.client.prefs.cit_toggles & DIGESTION_NOISES) + SEND_SOUND(M,prey_digest) + play_sound = pick(pred_digest) //Pref protection! if (!M.digestable || M.absorbed) @@ -108,18 +100,9 @@ M.visible_message("You watch as [owner]'s form loses its additions.") owner.nutrition += 400 // so eating dead mobs gives you *something*. - if((world.time + NORMIE_HEARCHECK) > last_hearcheck) - LAZYCLEARLIST(hearing_mobs) - for(var/mob/living/H in get_hearers_in_view(3, owner)) - if(!H.client || !(H.client.prefs.cit_toggles & DIGESTION_NOISES)) - continue - LAZYADD(hearing_mobs, H) - last_hearcheck = world.time - for(var/mob/living/H in hearing_mobs) - if(H && H.client && (isturf(H.loc) || (H.loc != src.contents))) - SEND_SOUND(H,pred_death) - else if(H && H in contents && H.client) - SEND_SOUND(H,prey_death) + play_sound = pick(pred_death) + if(M && M.client && M.client.prefs.cit_toggles & DIGESTION_NOISES) + SEND_SOUND(M,prey_death) M.stop_sound_channel(CHANNEL_PREYLOOP) digestion_death(M) owner.update_icons() @@ -142,19 +125,9 @@ if(digest_mode == DM_HEAL) for (var/mob/living/M in contents) if(prob(25)) - if((world.time + NORMIE_HEARCHECK) > last_hearcheck) - LAZYCLEARLIST(hearing_mobs) - for(var/mob/living/H in get_hearers_in_view(3, owner)) - if(!H.client || !(H.client.prefs.cit_toggles & DIGESTION_NOISES)) - continue - LAZYADD(hearing_mobs, H) - last_hearcheck = world.time - for(var/mob/living/H in hearing_mobs) - if(H && H.client && (isturf(H.loc) || (H.loc != src.contents))) - SEND_SOUND(H,pred_digest) - else if(H && H in contents && H.client) - SEND_SOUND(H,prey_digest) - + if(M && M.client && M.client.prefs.cit_toggles & DIGESTION_NOISES) + SEND_SOUND(M,prey_digest) + play_sound = pick(pred_digest) if(M.stat != DEAD) if(owner.nutrition >= NUTRITION_LEVEL_STARVING && (M.health < M.maxHealth)) M.adjustBruteLoss(-3) @@ -165,18 +138,10 @@ //for when you just want people to squelch around if(digest_mode == DM_NOISY) if(prob(35)) - if((world.time + NORMIE_HEARCHECK) > last_hearcheck) - LAZYCLEARLIST(hearing_mobs) - for(var/mob/living/H in get_hearers_in_view(3, owner)) - if(!H.client || !(H.client.prefs.cit_toggles & DIGESTION_NOISES)) - continue - LAZYADD(hearing_mobs, H) - last_hearcheck = world.time - for(var/mob/living/H in hearing_mobs) - if(H && H.client && (isturf(H.loc) || (H.loc != src.contents))) - SEND_SOUND(H,pred_digest) - else if(H && H in contents && H.client) - SEND_SOUND(H,prey_digest) + for(var/mob/M in contents) + if(M && M.client && M.client.prefs.cit_toggles & DIGESTION_NOISES) + SEND_SOUND(M,prey_digest) + play_sound = pick(pred_digest) //////////////////////////// DM_ABSORB //////////////////////////// @@ -185,18 +150,9 @@ for (var/mob/living/M in contents) if(prob(10))//Less often than gurgles. People might leave this on forever. - if((world.time + NORMIE_HEARCHECK) > last_hearcheck) - LAZYCLEARLIST(hearing_mobs) - for(var/mob/living/H in get_hearers_in_view(3, owner)) - if(!H.client || !(H.client.prefs.cit_toggles & DIGESTION_NOISES)) - continue - LAZYADD(hearing_mobs, H) - last_hearcheck = world.time - for(var/mob/living/H in hearing_mobs) - if(H && H.client && (isturf(H.loc) || (H.loc != src.contents))) - SEND_SOUND(H,pred_digest) - else if(H && H in contents && H.client) - SEND_SOUND(H,prey_digest) + if(M && M.client && M.client.prefs.cit_toggles & DIGESTION_NOISES) + SEND_SOUND(M,prey_digest) + play_sound = pick(pred_digest) if(M.absorbed) continue @@ -262,18 +218,9 @@ to_chat(owner, "[digest_alert_owner]") to_chat(M, "[digest_alert_prey]") M.visible_message("You watch as [owner]'s guts loudly rumble as it finishes off a meal.") - if((world.time + NORMIE_HEARCHECK) > last_hearcheck) - LAZYCLEARLIST(hearing_mobs) - for(var/mob/living/H in get_hearers_in_view(3, owner)) - if(!H.client || !(H.client.prefs.cit_toggles & DIGESTION_NOISES)) - continue - LAZYADD(hearing_mobs, H) - last_hearcheck = world.time - for(var/mob/living/H in hearing_mobs) - if(H && H.client && (isturf(H.loc) || (H.loc != src.contents))) - SEND_SOUND(H,pred_death) - else if(H && H in contents && H.client) - SEND_SOUND(H,prey_death) + play_sound = pick(pred_death) + if(M && M.client && M.client.prefs.cit_toggles & DIGESTION_NOISES) + SEND_SOUND(M,prey_death) M.spill_organs(FALSE,TRUE,TRUE) M.stop_sound_channel(CHANNEL_PREYLOOP) digestion_death(M) @@ -293,6 +240,19 @@ if(istype(T,/obj/item/reagent_containers/food) || istype(T,/obj/item/organ)) digest_item(T) +/////////////////////////// Make any noise /////////////////////////// + if(play_sound) + if((world.time + NORMIE_HEARCHECK) > last_hearcheck) + LAZYCLEARLIST(hearing_mobs) + for(var/mob/M in hearers(VORE_SOUND_RANGE, owner)) + if(!M.client || !(M.client.prefs.cit_toggles & DIGESTION_NOISES)) + continue + LAZYADD(hearing_mobs, M) + last_hearcheck = world.time + for(var/mob/M in hearing_mobs) //so we don't fill the whole room with the sound effect + if(M && M.client && (isturf(M.loc) || (M.loc != src.contents))) //to avoid people on the inside getting the outside sounds and their direct sounds + built in sound pref check + M.playsound_local(owner.loc, play_sound, vol = 75, vary = 1, falloff = VORE_SOUND_FALLOFF) + //these are all external sound triggers now, so it's ok. if(to_update) for(var/mob/living/M in contents) if(M.client)