From 4ee6f83b37fcb4e76e20f27dfc8abf7bc8c7ee58 Mon Sep 17 00:00:00 2001 From: Drulikar Date: Tue, 14 May 2024 05:18:58 -0700 Subject: [PATCH 1/2] Fix mre getting trashed if "dropped" into inventory Fix mre runtimes if spawned on mob but no space Add same auto throwaway on dropped signal to grenade box --- code/game/objects/items/storage/boxes.dm | 36 ++++++++++++++++++------ 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/code/game/objects/items/storage/boxes.dm b/code/game/objects/items/storage/boxes.dm index 3f5e56f85517..2ac4fabf6e3d 100644 --- a/code/game/objects/items/storage/boxes.dm +++ b/code/game/objects/items/storage/boxes.dm @@ -574,7 +574,7 @@ new /obj/item/device/flashlight/flare(src) /obj/item/storage/box/m94/update_icon() - if(!contents.len) + if(!length(contents)) icon_state = "m94_e" else icon_state = "m94" @@ -590,7 +590,7 @@ new /obj/item/device/flashlight/flare/signal(src) /obj/item/storage/box/m94/signal/update_icon() - if(!contents.len) + if(!length(contents)) icon_state = "m89_e" else icon_state = "m89" @@ -608,6 +608,24 @@ var/grenade_type = /obj/item/explosive/grenade/high_explosive has_gamemode_skin = TRUE +/obj/item/storage/box/nade_box/Initialize() + . = ..() + RegisterSignal(src, COMSIG_ITEM_DROPPED, PROC_REF(try_forced_folding)) + +/obj/item/storage/box/nade_box/proc/try_forced_folding(datum/source, mob/user) + SIGNAL_HANDLER + + if(!isturf(loc)) + return + + if(length(contents)) + return + + UnregisterSignal(src, COMSIG_ITEM_DROPPED) + storage_close(user) + to_chat(user, SPAN_NOTICE("You throw away [src].")) + qdel(src) + /obj/item/storage/box/nade_box/post_skin_selection() base_icon = icon_state @@ -616,9 +634,8 @@ new grenade_type(src) /obj/item/storage/box/nade_box/update_icon() - if(!contents.len) + if(!length(contents)) icon_state = "[base_icon]_e" - qdel(src) //No reason to keep it - nobody will reuse it... else icon_state = base_icon @@ -766,13 +783,16 @@ /obj/item/storage/box/MRE/Initialize() . = ..() - isopened = 0 + isopened = FALSE icon_state = "mealpack" RegisterSignal(src, COMSIG_ITEM_DROPPED, PROC_REF(try_forced_folding)) /obj/item/storage/box/MRE/proc/try_forced_folding(datum/source, mob/user) SIGNAL_HANDLER + if(!isturf(loc)) + return + if(locate(/obj/item/reagent_container/food/snacks/packaged_meal) in src) return @@ -782,10 +802,8 @@ qdel(src) /obj/item/storage/box/MRE/update_icon() - if(!contents.len) - qdel(src) - else if(!isopened) - isopened = 1 + if(!isopened) + isopened = TRUE icon_state = "mealpackopened" //food boxes for storage in bulk From bcefecdc937e3895e6694957328effe4a6976611 Mon Sep 17 00:00:00 2001 From: Drulikar Date: Tue, 14 May 2024 05:30:40 -0700 Subject: [PATCH 2/2] boolean --- code/game/objects/items/storage/boxes.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/objects/items/storage/boxes.dm b/code/game/objects/items/storage/boxes.dm index 2ac4fabf6e3d..ab221b89bfe2 100644 --- a/code/game/objects/items/storage/boxes.dm +++ b/code/game/objects/items/storage/boxes.dm @@ -745,7 +745,7 @@ storage_slots = 7 max_w_class = 0 use_sound = "rip" - var/isopened = 0 + var/isopened = FALSE /obj/item/storage/box/MRE/fill_preset_inventory() pickflavor()