From 620fee8afdaf271055a458a85dd6c4e958930e46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Barou=C5=A1?= Date: Sat, 17 Oct 2020 12:17:07 +0200 Subject: [PATCH] Bugfixes and improvements for "fancy" storages (#10271) --- .../objects/items/weapons/storage/fancy.dm | 37 +++++++++++++++---- html/changelogs/amunak-fancy-fixes.yml | 7 ++++ 2 files changed, 36 insertions(+), 8 deletions(-) create mode 100755 html/changelogs/amunak-fancy-fixes.yml diff --git a/code/game/objects/items/weapons/storage/fancy.dm b/code/game/objects/items/weapons/storage/fancy.dm index ae721e0ad39..9d1cf7a40b7 100644 --- a/code/game/objects/items/weapons/storage/fancy.dm +++ b/code/game/objects/items/weapons/storage/fancy.dm @@ -35,14 +35,17 @@ desc_info += "Alt-click to open and close the box. " //aka force override icon state. for you know, style. /obj/item/storage/box/fancy/AltClick(mob/user) + if(opened && !closable) // opened, non-closable items do nothing + return + if(!Adjacent(user)) + return + opened = !opened playsound(src.loc, src.use_sound, 50, 0, -5) - if(closable && !opened) - icon_state = "[initial(icon_state)]" // closed - cut_overlays() + update_icon() + if(!opened) close(user) return 1 - update_icon() /obj/item/storage/box/fancy/update_icon(var/itemremoved = 0) if(opened) //use the open icon. @@ -50,6 +53,15 @@ src.icon_state = "[src.icon_type][src.storage_type][contents.len - itemremoved]" else icon_state = "[initial(icon_state)][src.opened]" + else + cut_overlays() + icon_state = "[initial(icon_state)]" // closed + +/obj/item/storage/box/fancy/handle_item_insertion() + if(!opened) // makes sure boxes are opened before inserting anything + opened = TRUE + update_icon() + . = ..() /obj/item/storage/box/fancy/examine(mob/user) ..() @@ -77,7 +89,7 @@ foldable = /obj/item/stack/material/cardboard /obj/item/storage/box/fancy/donut/update_icon() // One of the few unique update_icon()s, due to having to store both regular and sprinkled donuts. - .=..() + . = ..() if(opened) cut_overlays() var/i = 0 @@ -163,6 +175,7 @@ starts_with = null /obj/item/storage/box/fancy/crayons/update_icon() + . = ..() cut_overlays() add_overlay("crayonbox") for(var/obj/item/pen/crayon/crayon in contents) @@ -210,7 +223,7 @@ return /obj/item/storage/box/fancy/matches/update_icon() - .=..() + . = ..() if(opened) if(contents.len == 0) icon_state = "matchbox_e" @@ -255,7 +268,9 @@ new cigarette_to_spawn(src) /obj/item/storage/box/fancy/cigarettes/update_icon() - icon_state = "[initial(icon_state)][contents.len]" + . = ..() + if(opened) + icon_state = "[initial(icon_state)][contents.len]" /obj/item/storage/box/fancy/cigarettes/remove_from_storage(obj/item/W as obj, atom/new_location) var/obj/item/clothing/mask/smokable/cigarette/C = W @@ -263,9 +278,12 @@ reagents.trans_to_obj(C, (reagents.total_volume/contents.len)) ..() -/obj/item/storage/box/fancy/cigarettes/attack(mob/living/carbon/M as mob, mob/living/carbon/user as mob,var/target_zone) +/obj/item/storage/box/fancy/cigarettes/attack(mob/living/carbon/M as mob, mob/living/carbon/user as mob, target_zone) if(!istype(M, /mob)) return + if(!opened) + to_chat(user, SPAN_NOTICE("The [src] is closed.")) + return if(M == user && target_zone == BP_MOUTH && contents.len > 0 && !user.wear_mask) var/obj/item/clothing/mask/smokable/cigarette/W = new cigarette_to_spawn(user) @@ -357,6 +375,8 @@ can_hold = list(/obj/item/reagent_containers/glass/beaker/vial) starts_with = list(/obj/item/reagent_containers/glass/beaker/vial = 6) chewable = FALSE + opened = TRUE + closable = FALSE /obj/item/storage/lockbox/vials name = "secure vial storage box" @@ -378,6 +398,7 @@ queue_icon_update() /obj/item/storage/lockbox/vials/update_icon(var/itemremoved = 0) + . = ..() var/total_contents = src.contents.len - itemremoved src.icon_state = "vialbox[total_contents]" cut_overlays() diff --git a/html/changelogs/amunak-fancy-fixes.yml b/html/changelogs/amunak-fancy-fixes.yml new file mode 100755 index 00000000000..02932193ab0 --- /dev/null +++ b/html/changelogs/amunak-fancy-fixes.yml @@ -0,0 +1,7 @@ +author: Amunak +delete-after: True +changes: + - tweak: "Cigarette packs can now be opened and closed; they behave more like matchboxes and they spawn in closed. You cannot pull a cigarette out of a closed pack." + - tweak: "Fancy storage boxes will open before inserting anything." + - bugfix: "Fancy storage boxes (donuts, matchboxes, ...) can no longer be opened/closed from anywhere - they require adjacency." + - bugfix: "Other minor fixes to fancy storage boxes: sprites should behave better, stuff that shouldn't close doesn't close, etc."