From a68ddb11164b83595a6e597a5489c101e9e9ee1e Mon Sep 17 00:00:00 2001 From: FalseIncarnate Date: Fri, 6 May 2016 03:20:00 -0400 Subject: [PATCH] Global Intercom list, minor code cleanup round 2 --- code/_globalvars/lists/objects.dm | 1 + .../objects/items/devices/radio/intercom.dm | 2 + .../objects/items/weapons/bee_briefcase.dm | 44 +++++++------------ code/modules/admin/verbs/playsound.dm | 26 +++++++---- 4 files changed, 37 insertions(+), 36 deletions(-) diff --git a/code/_globalvars/lists/objects.dm b/code/_globalvars/lists/objects.dm index 617a0af3d7d..ec3be384bad 100644 --- a/code/_globalvars/lists/objects.dm +++ b/code/_globalvars/lists/objects.dm @@ -30,3 +30,4 @@ var/global/list/beacons = list() var/global/list/shuttle_caller_list = list() //list of all communication consoles and AIs, for automatic shuttle calls when there are none. var/global/list/tracked_implants = list() //list of all current implants that are tracked to work out what sort of trek everyone is on. Sadly not on lavaworld not implemented... var/global/list/abductor_equipment = list() //list of all abductor equipment +var/global/list/global_intercoms = list() //list of all intercomms, across all z-levels \ No newline at end of file diff --git a/code/game/objects/items/devices/radio/intercom.dm b/code/game/objects/items/devices/radio/intercom.dm index fba22decc42..f1eb48e06d7 100644 --- a/code/game/objects/items/devices/radio/intercom.dm +++ b/code/game/objects/items/devices/radio/intercom.dm @@ -56,6 +56,7 @@ dir=ndir b_stat=1 on = 0 + global_intercoms.Add(src) update_icon() /obj/item/device/radio/intercom/department/medbay/New() @@ -104,6 +105,7 @@ /obj/item/device/radio/intercom/Destroy() processing_objects.Remove(src) + global_intercoms.Remove(src) return ..() /obj/item/device/radio/intercom/attack_ai(mob/user as mob) diff --git a/code/game/objects/items/weapons/bee_briefcase.dm b/code/game/objects/items/weapons/bee_briefcase.dm index 29a98f433cf..5c3e9afff5d 100644 --- a/code/game/objects/items/weapons/bee_briefcase.dm +++ b/code/game/objects/items/weapons/bee_briefcase.dm @@ -15,7 +15,7 @@ var/bees_left = 10 var/list/blood_list = list() var/sound_file = 'sound/misc/briefcase_bees.ogg' - var/sound_cooldown = 0 + var/next_sound = 0 /obj/item/weapon/bee_briefcase/examine(mob/user) ..() @@ -50,9 +50,7 @@ else if(istype(I, /obj/item/weapon/plantspray)) var/obj/item/weapon/plantspray/PS = I user.drop_item(PS) - bees_left -= PS.pest_kill_str - if(bees_left < 0) - bees_left = 0 + bees_left = max(0, (bees_left - PS.pest_kill_str)) to_chat(user, "You spray [PS] into \the [src].") playsound(loc, 'sound/effects/spray3.ogg', 50, 1, -6) qdel(PS) @@ -62,30 +60,20 @@ to_chat(user, "The lack of all and any bees at this event has been somewhat of a let-down...") return else - if(!sound_cooldown) //The cooldown doesn't prevent us from releasing bees, just stops the sound - sound_cooldown = 1 - spawn(90) - sound_cooldown = 0 + if(world.time >= next_sound) //This cooldown doesn't prevent us from releasing bees, just stops the sound + next_sound = world.time + 90 //Play sound through the station intercomms, so everyone knows the doom you have wrought. - var/list/intercomms = list() - for(var/obj/item/device/radio/intercom/I in world) - if(I.z != ZLEVEL_STATION) continue - intercomms += I - - if(intercomms.len) - for(var/obj/item/device/radio/intercom/I in intercomms) - playsound(I, sound_file, 35) + for(var/O in global_intercoms) + var/obj/item/device/radio/intercom/I = O + if(I.z != ZLEVEL_STATION) //Only broadcast to the station intercoms + continue + if(!I.on) //Only broadcast to active intercoms (powered, switched on) + continue + playsound(I, sound_file, 35) //Release up to 5 bees per use. Without using strange reagent, that means two uses. WITH strange reagent, you can get more if you don't release the last bee - if(bees_left >= 5) - for(var/bee = 5, bee > 0, bee--) - var/mob/living/simple_animal/hostile/poison/bees/syndi/B = new /mob/living/simple_animal/hostile/poison/bees/syndi(null) - B.master_and_friends = blood_list //Doesn't automatically add the person who opens the case, so the bees will attack the user unless they gave their blood - B.forceMove(get_turf(user)) //RELEASE THE BEES! - bees_left -= 5 - else - for(var/bee = bees_left, bee > 0, bee--) - var/mob/living/simple_animal/hostile/poison/bees/syndi/B = new /mob/living/simple_animal/hostile/poison/bees/syndi(null) - B.master_and_friends = blood_list //Doesn't automatically add the person who opens the case, so the bees will attack the user unless they gave their blood - B.forceMove(get_turf(user)) //RELEASE THE BEES! - bees_left = 0 \ No newline at end of file + for(var/bee = min(5, bees_left), bee > 0, bee--) + var/mob/living/simple_animal/hostile/poison/bees/syndi/B = new /mob/living/simple_animal/hostile/poison/bees/syndi(null) + B.master_and_friends = blood_list //Doesn't automatically add the person who opens the case, so the bees will attack the user unless they gave their blood + B.forceMove(get_turf(user)) //RELEASE THE BEES! + bees_left -= 5 \ No newline at end of file diff --git a/code/modules/admin/verbs/playsound.dm b/code/modules/admin/verbs/playsound.dm index 25b0ed54140..47c7da15724 100644 --- a/code/modules/admin/verbs/playsound.dm +++ b/code/modules/admin/verbs/playsound.dm @@ -52,7 +52,7 @@ var/list/sounds_cache = list() set desc = "Plays a sound at every intercomm on the station z level. Works best with small sounds." if(!check_rights(R_SOUNDS)) return - var/A = alert("This will play a sound at every intercomm on the station Z, are you sure you want to continue? This works best with short sounds, beware.","Warning","Yep","Nope") + var/A = alert("This will play a sound at every intercomm, are you sure you want to continue? This works best with short sounds, beware.","Warning","Yep","Nope") if(A != "Yep") return var/list/sounds = file2list("sound/serversound_list.txt"); @@ -67,15 +67,25 @@ var/list/sounds_cache = list() if(inputvol && inputvol >= 1 && inputvol <= 70) cvol = inputvol - var/list/intercomms = list() + //Allows for override to utilize intercomms on all z-levels + var/B = alert("Do you want to play through intercomms on ALL Z-levels, or just the station?", "Override", "All", "Station") + var/ignore_z = 0 + if(B == "All") + ignore_z = 1 - for(var/obj/item/device/radio/intercom/I in world) - if(I.z != ZLEVEL_STATION) continue - intercomms += I + //Allows for override to utilize incomplete and unpowered intercomms + var/C = alert("Do you want to play through unpowered / incomplete intercomms, so the crew can't silence it?", "Override", "Yep", "Nope") + var/ignore_power = 0 + if(C == "Yep") + ignore_power = 1 - if(intercomms.len) - for(var/obj/item/device/radio/intercom/I in intercomms) - playsound(I, melody, cvol) + for(var/O in global_intercoms) + var/obj/item/device/radio/intercom/I = O + if(I.z != ZLEVEL_STATION && !ignore_z) + continue + if(!I.on && !ignore_power) + continue + playsound(I, melody, cvol) /* /client/proc/cuban_pete()