From e99996c7255d72ad14bdd97b7935551ea54fc676 Mon Sep 17 00:00:00 2001 From: Twinmold Date: Sat, 26 Nov 2016 23:06:55 -0600 Subject: [PATCH] Changes Sound and Message Dup Codes to Procs By request of Crazylemon. Doing this also removed the need to have the check for passengers and pilots from the health checks of the pod, as they are no longer necessary and unified inside the new procs. --- code/modules/spacepods/spacepod.dm | 64 +++++++++++------------------- 1 file changed, 24 insertions(+), 40 deletions(-) diff --git a/code/modules/spacepods/spacepod.dm b/code/modules/spacepods/spacepod.dm index d3019f40e12..b8a9cc32b30 100644 --- a/code/modules/spacepods/spacepod.dm +++ b/code/modules/spacepods/spacepod.dm @@ -229,39 +229,15 @@ health = max(0, health - damage) var/percentage = (health / initial(health)) * 100 occupant_sanity_check() - if(passengers | pilot && oldhealth > health && percentage <= 25 && percentage > 0) - var/sound/S = sound('sound/effects/engine_alert2.ogg') - S.wait = 0 //No queue - S.channel = 0 //Any channel - S.volume = 50 - if(pilot) - pilot << S - if(passengers) - for(var/mob/M in passengers) - M << S - if(passengers | pilot && oldhealth > health && !health) - var/sound/S = sound('sound/effects/engine_alert1.ogg') - S.wait = 0 - S.channel = 0 - S.volume = 50 - if(pilot) - pilot << S - if(passengers) - for(var/mob/M in passengers) - M << S + if(oldhealth > health && percentage <= 25 && percentage > 0) + play_sound_to_riders('sound/effects/engine_alert2.ogg') + else if(oldhealth > health) + play_sound_to_riders('sound/effects/engine_alert1.ogg') if(!health) spawn(0) - if(pilot) - to_chat(pilot, "Critical damage to the vessel detected, core explosion imminent!") - if(passengers) - for(var/mob/M in passengers) - to_chat(M, "Critical damage to the vessel detected, core explosion imminent!") + message_to_riders("Critical damage to the vessel detected, core explosion imminent!") for(var/i = 10, i >= 0; --i) - if(pilot) - to_chat(pilot, "[i]") - if(passengers) - for(var/mob/M in passengers) - to_chat(M, "[i]") + message_to_riders("[i]") if(i == 0) explosion(loc, 2, 4, 8) qdel(src) @@ -307,17 +283,25 @@ switch(severity) if(1) - if(pilot) - to_chat(pilot, "The pod console flashes 'Heavy EMP WAVE DETECTED'.") - if(passengers) - for(var/mob/M in passengers) - to_chat(M, "The pod console flashes 'Heavy EMP WAVE DETECTED'.") + message_to_riders("The pod console flashes 'Heavy EMP WAVE DETECTED'.") if(2) - if(pilot) - to_chat(pilot, "The pod console flashes 'EMP WAVE DETECTED'.") - if(passengers) - for(var/mob/M in passengers) - to_chat(M, "The pod console flashes 'EMP WAVE DETECTED'.") + message_to_riders("The pod console flashes 'EMP WAVE DETECTED'.") + +/obj/spacepod/proc/play_sound_to_riders(mysound) + if(length(passengers | pilot) == 0) + return + var/sound/S = sound(mysound) + S.wait = 0 //No queue + S.channel = 0 //Any channel + S.volume = 50 + for(var/mob/M in passengers | pilot) + M << S + +/obj/spacepod/proc/message_to_riders(mymessage) + if(length(passengers | pilot) == 0) + return + for(var/mob/M in passengers | pilot) + to_chat(M, mymessage) /obj/spacepod/attackby(obj/item/W as obj, mob/user as mob, params) if(user.a_intent == I_HARM)