Skip to content

Commit

Permalink
Pill bottle emptying bugfix (cmss13-devs#7357)
Browse files Browse the repository at this point in the history
# About the pull request

Fixes an annoying bug introduced in cmss13-devs#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.

cmss13-devs#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
<details>
<summary>Screenshots & Videos</summary>

Put screenshots and videos here with an empty line between the
screenshots and the `<details>` tags.

</details>


# Changelog
:cl:
fix: no longer forces pill bottles to begin emptying on a click
/:cl:
  • Loading branch information
SpypigDev authored Nov 20, 2024
1 parent fc009b7 commit 1310a84
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 16 deletions.
39 changes: 26 additions & 13 deletions code/__DEFINES/equipment.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions code/_globalvars/bitfields.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/items/storage/firstaid.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion code/game/objects/items/storage/storage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 1310a84

Please sign in to comment.