Skip to content

Commit

Permalink
Fix mre getting trashed if "dropped" into inventory
Browse files Browse the repository at this point in the history
Fix mre runtimes if spawned on mob but no space
Add same auto throwaway on dropped signal to grenade box
  • Loading branch information
Drulikar committed May 14, 2024
1 parent c83ab1e commit 4ee6f83
Showing 1 changed file with 27 additions and 9 deletions.
36 changes: 27 additions & 9 deletions code/game/objects/items/storage/boxes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 4ee6f83

Please sign in to comment.