diff --git a/code/game/objects/items/bodybag.dm b/code/game/objects/items/bodybag.dm
index b72954eac9b..6df651a7467 100644
--- a/code/game/objects/items/bodybag.dm
+++ b/code/game/objects/items/bodybag.dm
@@ -77,8 +77,13 @@
user.last_special = world.time + CLICK_CD_BREAKOUT
to_chat(user, "You claw at the fabric of [src], trying to tear it open...")
to_chat(loc, "Someone starts trying to break free of [src]!")
- if(!do_after(user, 200, target = src))
- to_chat(loc, "The pressure subsides. It seems that they've stopped resisting...")
- return
- loc.visible_message("[user] suddenly appears in front of [loc]!", "[user] breaks free of [src]!")
- qdel(src)
+ if(do_after_mob(user, src, 12 SECONDS, TRUE))
+ if(user.loc != src)
+ return
+ // you are still in the bag? time to go unless you KO'd, honey!
+ // if they escape during this time and you rebag them the timer is still clocking down and does NOT reset so they can very easily get out.
+ if(user.incapacitated())
+ to_chat(loc, "The pressure subsides. It seems that they've stopped resisting...")
+ return
+ loc.visible_message("[user] suddenly appears in front of [loc]!", "[user] breaks free of [src]!")
+ qdel(src)
diff --git a/code/game/objects/structures/crates_lockers/closets/bodybag.dm b/code/game/objects/structures/crates_lockers/closets/bodybag.dm
index 2502d6eee8c..915f1088600 100644
--- a/code/game/objects/structures/crates_lockers/closets/bodybag.dm
+++ b/code/game/objects/structures/crates_lockers/closets/bodybag.dm
@@ -37,11 +37,11 @@
if(!user.canUseTopic(src, BE_CLOSE))
return
if(t)
- name = "body bag - [t]"
+ name = "[initial(name)] - [t]"
tagged = TRUE
update_icon()
else
- name = "body bag"
+ name = initial(name)
return
else if(I.tool_behaviour == TOOL_WIRECUTTER)
to_chat(user, "You cut the tag off [src].")
@@ -68,19 +68,40 @@
/obj/structure/closet/body_bag/MouseDrop(over_object, src_location, over_location)
. = ..()
if(over_object == usr && Adjacent(usr) && (in_range(src, usr) || usr.contents.Find(src)))
- if(!ishuman(usr))
+ if(!attempt_fold(usr))
return
- if(opened)
- to_chat(usr, "You wrestle with [src], but it won't fold while unzipped.")
- return
- if(contents.len)
- to_chat(usr, "There are too many things inside of [src] to fold it up!")
- return
- visible_message("[usr] folds up [src].")
- var/obj/item/bodybag/B = foldedbag_instance || new foldedbag_path
- usr.put_in_hands(B)
+ perform_fold(usr)
qdel(src)
+ /**
+ * Checks to see if we can fold. Return TRUE to actually perform the fold and delete.
+ *
+ * Arguments:
+ * * the_folder - over_object of MouseDrop aka usr
+ */
+/obj/structure/closet/body_bag/proc/attempt_fold(mob/living/carbon/human/the_folder)
+ . = FALSE
+ if(!istype(the_folder))
+ return
+ if(opened)
+ to_chat(the_folder, "You wrestle with [src], but it won't fold while unzipped.")
+ return
+ if(contents.len)
+ to_chat(the_folder, "There are too many things inside of [src] to fold it up!")
+ return
+ // toto we made it!
+ return TRUE
+
+ /**
+ * Performs the actual folding. Deleting is automatic, please do not include.
+ *
+ * Arguments:
+ * * the_folder - over_object of MouseDrop aka usr
+ */
+/obj/structure/closet/body_bag/proc/perform_fold(mob/living/carbon/human/the_folder)
+ visible_message("[usr] folds up [src].")
+ var/obj/item/bodybag/B = foldedbag_instance || new foldedbag_path
+ the_folder.put_in_hands(B)
/obj/structure/closet/body_bag/bluespace
name = "bluespace body bag"
@@ -91,25 +112,38 @@
mob_storage_capacity = 15
max_mob_size = MOB_SIZE_LARGE
-/obj/structure/closet/body_bag/bluespace/MouseDrop(over_object, src_location, over_location)
- . = ..()
- if(over_object == usr && Adjacent(usr) && (in_range(src, usr) || usr.contents.Find(src)))
- if(!ishuman(usr))
- return
- if(opened)
- to_chat(usr, "You wrestle with [src], but it won't fold while unzipped.")
- return
- if(contents.len >= mob_storage_capacity / 2)
- to_chat(usr, "There are too many things inside of [src] to fold it up!")
- return
- for(var/obj/item/bodybag/bluespace/B in src)
- to_chat(usr, "You can't recursively fold bluespace body bags!" )
- return
- visible_message("[usr] folds up [src].")
- var/obj/item/bodybag/B = foldedbag_instance || new foldedbag_path
- usr.put_in_hands(B)
- for(var/atom/movable/A in contents)
- A.forceMove(B)
- if(isliving(A))
- to_chat(A, "You're suddenly forced into a tiny, compressed space!")
- qdel(src)
+/obj/structure/closet/body_bag/bluespace/attempt_fold(mob/living/carbon/human/the_folder)
+ . = FALSE
+ //copypaste zone, we do not want the content check so we don't want inheritance
+ if(!istype(the_folder))
+ return
+ if(opened)
+ to_chat(the_folder, "You wrestle with [src], but it won't fold while unzipped.")
+ return
+ //end copypaste zone
+ if(contents.len >= mob_storage_capacity / 2)
+ to_chat(usr, "There are too many things inside of [src] to fold it up!")
+ return
+ for(var/obj/item/bodybag/bluespace/B in src)
+ to_chat(usr, "You can't recursively fold bluespace body bags!" )
+ return
+ return TRUE
+
+/obj/structure/closet/body_bag/bluespace/perform_fold(mob/living/carbon/human/the_folder)
+ visible_message("[usr] folds up [src].")
+ var/obj/item/bodybag/B = foldedbag_instance || new foldedbag_path
+ var/max_weight_of_contents = initial(B.w_class)
+ for(var/am in contents)
+ var/atom/movable/content = am
+ content.forceMove(B)
+ if(isliving(content))
+ to_chat(content, "You're suddenly forced into a tiny, compressed space!")
+ if(!isitem(content))
+ max_weight_of_contents = max(WEIGHT_CLASS_BULKY, max_weight_of_contents)
+ continue
+ var/obj/item/A_is_item = content
+ if(A_is_item.w_class < max_weight_of_contents)
+ continue
+ max_weight_of_contents = A_is_item.w_class
+ B.w_class = max_weight_of_contents
+ usr.put_in_hands(B)