From 1310a841481ec43f64b54213351b43b4b42b8815 Mon Sep 17 00:00:00 2001 From: Spy <31124786+SpypigDev@users.noreply.github.com> Date: Wed, 20 Nov 2024 21:46:13 +1100 Subject: [PATCH] Pill bottle emptying bugfix (#7357) # About the pull request Fixes an annoying bug introduced in #7265 which caused pill bottles to run through two simultaneous emptying processes whenever used in the hand. First trying to empty their contents, then moving to their own pill drawing code, and trying to draw a single pill from the empty bottle. This PR bypasses the typical emptying system, for pill bottles and packets, allowing a single pill to be drawn from a pill bottle in hand with Z, but still leaves the empty verb functional, so bottles can be emptied by selecting the option after right clicking. # Explain why it's good for the game While I recognize I am in the vast minority, some HM players still prefer not to use the belt system of drawing directly from pill bottles when treating patients. Drawing a pill from a pill bottle held in the hand allows HMs to keep track of which medications have been given, and in what order. #7265 broke this system by forcing HMs to start emptying pill bottles in the hand on a click, rather than drawing a single pill, making it exceptionally annoying to medicate wounded without belt mode, and near impossible to do so without a belt. This PR allows both systems to co-exist, letting HMs draw a single pill from bottles held in the hand if they choose to do so, and still leaving the empty verb on pill bottles, so that their contents can be dumped through the right click menu # Testing Photographs and Procedure
Screenshots & Videos Put screenshots and videos here with an empty line between the screenshots and the `
` tags.
# Changelog :cl: fix: no longer forces pill bottles to begin emptying on a click /:cl: --- code/__DEFINES/equipment.dm | 39 ++++++++++++++------- code/_globalvars/bitfields.dm | 1 + code/game/objects/items/storage/firstaid.dm | 4 +-- code/game/objects/items/storage/storage.dm | 3 +- 4 files changed, 31 insertions(+), 16 deletions(-) diff --git a/code/__DEFINES/equipment.dm b/code/__DEFINES/equipment.dm index 88d59beae417..6f10e79ac061 100644 --- a/code/__DEFINES/equipment.dm +++ b/code/__DEFINES/equipment.dm @@ -530,19 +530,32 @@ GLOBAL_LIST_INIT(uniform_categories, list( // Storage flags -#define STORAGE_ALLOW_EMPTY (1<<0) // Whether the storage object has the 'empty' verb, which dumps all the contents on the floor -#define STORAGE_QUICK_EMPTY (1<<1) // Whether the storage object can quickly be emptied (no delay) -#define STORAGE_QUICK_GATHER (1<<2) // Whether the storage object can quickly collect all items from a tile via the 'toggle mode' verb -#define STORAGE_ALLOW_DRAWING_METHOD_TOGGLE (1<<3) // Whether this storage object can have its items drawn (pouches) -#define STORAGE_USING_DRAWING_METHOD (1<<4) // Whether this storage object has its items drawn (versus just opening it) -#define STORAGE_USING_FIFO_DRAWING (1<<5) // Wether the storage object can have items in it's leftmost slot be drawn -#define STORAGE_CLICK_EMPTY (1<<6) // Whether you can click to empty an item -#define STORAGE_CLICK_GATHER (1<<7) // Whether it is possible to use this storage object in an inverse way, - // so you can have the item in your hand and click items on the floor to pick them up -#define STORAGE_SHOW_FULLNESS (1<<8) // Whether our storage object on hud changes color when full -#define STORAGE_CONTENT_NUM_DISPLAY (1<<9) // Whether the storage object groups contents of the same type and displays them as a number. Only works for slot-based storage objects. -#define STORAGE_GATHER_SIMULTAENOUSLY (1<<10) // Whether the storage object can pick up all the items in a tile -#define STORAGE_ALLOW_QUICKDRAW (1<<11) // Whether the storage can be drawn with E or Holster verb +/// Whether the storage object has the 'empty' verb, which dumps all the contents on the floor +#define STORAGE_ALLOW_EMPTY (1<<0) +/// Whether the storage object can quickly be emptied (no delay) +#define STORAGE_QUICK_EMPTY (1<<1) +/// Whether the storage object can quickly collect all items from a tile via the 'toggle mode' verb +#define STORAGE_QUICK_GATHER (1<<2) +/// Whether this storage object can have its items drawn (pouches) +#define STORAGE_ALLOW_DRAWING_METHOD_TOGGLE (1<<3) +/// Whether this storage object has its items drawn (versus just opening it) +#define STORAGE_USING_DRAWING_METHOD (1<<4) +/// Wether the storage object can have items in it's leftmost slot be drawn +#define STORAGE_USING_FIFO_DRAWING (1<<5) +/// Whether you can click to empty an item +#define STORAGE_CLICK_EMPTY (1<<6) +/// Whether it is possible to use this storage object in an inverse way, so you can have the item in your hand and click items on the floor to pick them up +#define STORAGE_CLICK_GATHER (1<<7) +/// Whether our storage object on hud changes color when full +#define STORAGE_SHOW_FULLNESS (1<<8) +/// Whether the storage object groups contents of the same type and displays them as a number. Only works for slot-based storage objects. +#define STORAGE_CONTENT_NUM_DISPLAY (1<<9) +/// Whether the storage object can pick up all the items in a tile +#define STORAGE_GATHER_SIMULTAENOUSLY (1<<10) +/// Whether the storage can be drawn with E or Holster verb +#define STORAGE_ALLOW_QUICKDRAW (1<<11) +/// Whether using this item will try not to empty it if possible +#define STORAGE_DISABLE_USE_EMPTY (1<<12) #define STORAGE_FLAGS_DEFAULT (STORAGE_SHOW_FULLNESS|STORAGE_GATHER_SIMULTAENOUSLY|STORAGE_ALLOW_EMPTY) #define STORAGE_FLAGS_BOX (STORAGE_FLAGS_DEFAULT) diff --git a/code/_globalvars/bitfields.dm b/code/_globalvars/bitfields.dm index c90f970d4471..f08585846879 100644 --- a/code/_globalvars/bitfields.dm +++ b/code/_globalvars/bitfields.dm @@ -303,6 +303,7 @@ DEFINE_BITFIELD(storage_flags, list( "STORAGE_CONTENT_NUM_DISPLAY" = STORAGE_CONTENT_NUM_DISPLAY, "STORAGE_GATHER_SIMULTAENOUSLY" = STORAGE_GATHER_SIMULTAENOUSLY, "STORAGE_ALLOW_QUICKDRAW" = STORAGE_ALLOW_QUICKDRAW, + "STORAGE_DISABLE_USE_EMPTY" = STORAGE_DISABLE_USE_EMPTY, )) DEFINE_BITFIELD(datum_flags, list( diff --git a/code/game/objects/items/storage/firstaid.dm b/code/game/objects/items/storage/firstaid.dm index f4a5c22699e8..405dcefeff5f 100644 --- a/code/game/objects/items/storage/firstaid.dm +++ b/code/game/objects/items/storage/firstaid.dm @@ -348,7 +348,7 @@ /obj/item/toy/dice, /obj/item/paper, ) - storage_flags = STORAGE_FLAGS_BOX|STORAGE_CLICK_GATHER|STORAGE_QUICK_GATHER + storage_flags = STORAGE_FLAGS_BOX|STORAGE_CLICK_GATHER|STORAGE_QUICK_GATHER|STORAGE_DISABLE_USE_EMPTY storage_slots = null use_sound = "pillbottle" max_storage_space = 16 @@ -765,7 +765,7 @@ max_w_class = 0 max_storage_space = 4 skilllock = SKILL_MEDICAL_DEFAULT - storage_flags = STORAGE_FLAGS_BOX + storage_flags = STORAGE_FLAGS_BOX|STORAGE_DISABLE_USE_EMPTY display_maptext = FALSE /obj/item/storage/pill_bottle/packet/Initialize() diff --git a/code/game/objects/items/storage/storage.dm b/code/game/objects/items/storage/storage.dm index c04de364baf7..1e1d12760cab 100644 --- a/code/game/objects/items/storage/storage.dm +++ b/code/game/objects/items/storage/storage.dm @@ -857,7 +857,8 @@ W is always an item. stop_warning prevents messaging. user may be null.**/ //Clicking on itself will empty it, if it has contents and the verb to do that. Contents but no verb means nothing happens. if(length(contents)) - empty(user) + if (!(storage_flags & STORAGE_DISABLE_USE_EMPTY)) + empty(user) return //Otherwise we'll try to fold it.