Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MRE automatic trashing and nade box trashing #6285

Merged
merged 2 commits into from
May 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 28 additions & 10 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 @@ -728,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()
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
Loading