diff --git a/code/datums/action.dm b/code/datums/action.dm index 85899857516..36f9c9455c4 100644 --- a/code/datums/action.dm +++ b/code/datums/action.dm @@ -555,8 +555,8 @@ return FALSE if(istype(owner.loc, /obj/structure/closet/cardboard/agent)) var/obj/structure/closet/cardboard/agent/box = owner.loc - owner.playsound_local(box, 'sound/misc/box_deploy.ogg', 50, TRUE) - box.open() + if(box.open()) + owner.playsound_local(box, 'sound/misc/box_deploy.ogg', 50, TRUE) return //Box closing from here on out. if(!isturf(owner.loc)) //Don't let the player use this to escape mechs/welded closets. diff --git a/code/game/objects/items/implants/implant_stealth.dm b/code/game/objects/items/implants/implant_stealth.dm index 7ef672e63c7..514db174d9e 100644 --- a/code/game/objects/items/implants/implant_stealth.dm +++ b/code/game/objects/items/implants/implant_stealth.dm @@ -26,6 +26,10 @@ /obj/structure/closet/cardboard/agent/open(mob/living/user, force = FALSE) . = ..() + + if(!.) + return + qdel(src) /obj/structure/closet/cardboard/agent/process() diff --git a/code/game/objects/structures/crates_lockers/closets.dm b/code/game/objects/structures/crates_lockers/closets.dm index 8c5695d6185..3614936bb4f 100644 --- a/code/game/objects/structures/crates_lockers/closets.dm +++ b/code/game/objects/structures/crates_lockers/closets.dm @@ -251,11 +251,11 @@ /obj/structure/closet/proc/open(mob/living/user, force = FALSE) if(!can_open(user, force)) - return + return FALSE if(opened) - return + return FALSE if(SEND_SIGNAL(src, COMSIG_CLOSET_PRE_OPEN, user, force) & BLOCK_OPEN) - return + return FALSE welded = FALSE locked = FALSE playsound(loc, open_sound, open_sound_volume, TRUE, -3) diff --git a/code/game/objects/structures/crates_lockers/closets/cardboardbox.dm b/code/game/objects/structures/crates_lockers/closets/cardboardbox.dm index 058665c4437..467bf426fdc 100644 --- a/code/game/objects/structures/crates_lockers/closets/cardboardbox.dm +++ b/code/game/objects/structures/crates_lockers/closets/cardboardbox.dm @@ -1,4 +1,3 @@ -#define SNAKE_SPAM_TICKS 600 //how long between cardboard box openings that trigger the '!' /obj/structure/closet/cardboard name = "large cardboard box" desc = "Just a box..." @@ -20,9 +19,14 @@ door_anim_time = 0 // no animation var/move_speed_multiplier = 1 var/move_delay = FALSE - var/egged = 0 can_install_electronics = FALSE + /// Cooldown controlling when the box can trigger the Metal Gear Solid-style '!' alert. + COOLDOWN_DECLARE(alert_cooldown) + + /// How much time must pass before the box can trigger the next Metal Gear Solid-style '!' alert. + var/time_between_alerts = 60 SECONDS + /obj/structure/closet/cardboard/relaymove(mob/living/user, direction) if(opened || move_delay || user.incapacitated() || !isturf(loc) || !has_gravity(loc)) return @@ -38,25 +42,33 @@ move_delay = FALSE /obj/structure/closet/cardboard/open(mob/living/user, force = FALSE) - if(opened || !can_open(user, force)) - return FALSE - var/list/alerted = null - if(egged < world.time) - var/mob/living/Snake = null - for(var/mob/living/L in src.contents) - Snake = L - break - if(Snake) - alerted = viewers(7,src) - ..() - if(LAZYLEN(alerted)) - egged = world.time + SNAKE_SPAM_TICKS - for(var/mob/living/L in alerted) - if(!L.stat) - if(!L.incapacitated(IGNORE_RESTRAINTS)) - L.face_atom(src) - L.do_alert_animation() - playsound(loc, 'sound/machines/chime.ogg', 50, FALSE, -5) + var/do_alert = (COOLDOWN_FINISHED(src, alert_cooldown) && (locate(/mob/living) in contents)) + + if(!do_alert) + return ..() + + // Cache the list before we open the box. + var/list/alerted = viewers(7, src) + + // There are no mobs to alert? + if(!(locate(/mob/living) in alerted)) + return ..() + + . = ..() + + // Box didn't open? + if(!.) + return + + COOLDOWN_START(src, alert_cooldown, time_between_alerts) + + for(var/mob/living/alerted_mob in alerted) + if(alerted_mob.stat == CONSCIOUS) + if(!alerted_mob.incapacitated(IGNORE_RESTRAINTS)) + alerted_mob.face_atom(src) + alerted_mob.do_alert_animation() + + playsound(loc, 'sound/machines/chime.ogg', 50, FALSE, -5) /// Does the MGS ! animation /atom/proc/do_alert_animation() @@ -66,7 +78,6 @@ alert_image.alpha = 0 animate(alert_image, pixel_z = 32, alpha = 255, time = 5, easing = ELASTIC_EASING) - /obj/structure/closet/cardboard/metal name = "large metal box" desc = "THE COWARDS! THE FOOLS!" @@ -81,4 +92,3 @@ open_sound_volume = 35 close_sound_volume = 50 material_drop = /obj/item/stack/sheet/plasteel -#undef SNAKE_SPAM_TICKS