diff --git a/code/game/objects/structures/crates_lockers/closets.dm b/code/game/objects/structures/crates_lockers/closets.dm
index fc60729c4c..8b46abee49 100644
--- a/code/game/objects/structures/crates_lockers/closets.dm
+++ b/code/game/objects/structures/crates_lockers/closets.dm
@@ -10,7 +10,7 @@
var/welded = 0
var/wall_mounted = 0 //never solid (You can always pass over it)
var/health = 100
- var/lastbang
+ var/breakout = 0 //if someone is currently breaking out. mutex
var/storage_capacity = 30 //This is so that someone can't pack hundreds of items in a locker/crate
//then open it in a populated area to crash clients.
var/open_sound = 'sound/machines/click.ogg'
@@ -255,12 +255,6 @@
if(!src.open())
user << "It won't budge!"
- if(!lastbang)
- lastbang = 1
- for (var/mob/M in hearers(src, null))
- M << text("BANG, bang!", max(0, 5 - get_dist(src, M)))
- spawn(30)
- lastbang = 0
/obj/structure/closet/attack_hand(mob/user as mob)
src.add_fingerprint(user)
@@ -310,6 +304,8 @@
return 1
/obj/structure/closet/proc/req_breakout()
+ if(breakout)
+ return 0 //Already breaking out.
if(opened)
return 0 //Door's open... wait, why are you in it's contents then?
if(!welded)
@@ -328,22 +324,30 @@
escapee << "You lean on the back of \the [src] and start pushing the door open. (this will take about [breakout_time] minutes)"
visible_message("The [src] begins to shake violently!")
- playsound(src.loc, 'sound/effects/grillehit.ogg', 100, 1)
+ breakout = 1 //can't think of a better way to do this right now.
for(var/i in 1 to (6*breakout_time * 2)) //minutes * 6 * 5seconds * 2
+ playsound(src.loc, 'sound/effects/grillehit.ogg', 100, 1)
+ animate_shake()
+
if(!do_after(escapee, 50)) //5 seconds
+ breakout = 0
return
if(!escapee || escapee.stat || escapee.loc != src)
+ breakout = 0
return //closet/user destroyed OR user dead/unconcious OR user no longer in closet OR closet opened
//Perform the same set of checks as above for weld and lock status to determine if there is even still a point in 'resisting'...
if(!req_breakout())
+ breakout = 0
return
- playsound(src.loc, 'sound/effects/grillehit.ogg', 100, 1)
//Well then break it!
+ breakout = 0
escapee << "You successfully break out!"
visible_message("\the [escapee] successfully broke out of \the [src]!")
+ playsound(src.loc, 'sound/effects/grillehit.ogg', 100, 1)
break_open()
+ animate_shake()
/obj/structure/closet/proc/break_open()
welded = 0
@@ -353,3 +357,9 @@
var/obj/structure/bigDelivery/BD = loc
BD.unwrap()
open()
+
+/obj/structure/closet/proc/animate_shake()
+ var/init_px = pixel_x
+ var/shake_dir = pick(-1, 1)
+ animate(src, transform=turn(matrix(), 8*shake_dir), pixel_x=init_px + 2*shake_dir, time=1)
+ animate(transform=null, pixel_x=init_px, time=6, easing=ELASTIC_EASING)