From 4a2ad46515f7b8446633218bdd4729532a324b00 Mon Sep 17 00:00:00 2001
From: silicons <2003111+silicons@users.noreply.github.com>
Date: Tue, 26 Nov 2024 06:57:32 -0500
Subject: [PATCH 01/18] fix
---
code/__DEFINES/matrices.dm | 6 +++---
code/game/machinery/{colormate.dm => gear_painter.dm} | 0
.../actor_huds/huds/inventory-screen_object.dm | 2 +-
code/modules/clothing/clothing_accessories.dm | 2 +-
code/modules/mob/inventory/inventory-hands-put.dm | 5 +++--
code/modules/mob/mob-inventory.dm | 2 +-
code/modules/mob/movement.dm | 10 ----------
7 files changed, 9 insertions(+), 18 deletions(-)
rename code/game/machinery/{colormate.dm => gear_painter.dm} (100%)
diff --git a/code/__DEFINES/matrices.dm b/code/__DEFINES/matrices.dm
index 26ff5a7232a2..15f73b7ca85d 100644
--- a/code/__DEFINES/matrices.dm
+++ b/code/__DEFINES/matrices.dm
@@ -5,11 +5,11 @@
#define COLOR_MATRIX_IDENTITY list(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0,0)
/// Color inversion
#define COLOR_MATRIX_INVERT list(-1,0,0,0, 0,-1,0,0, 0,0,-1,0, 0,0,0,1, 1,1,1,0)
-///Sepiatone
+/// Sepiatone
#define COLOR_MATRIX_SEPIATONE list(0.393,0.349,0.272,0, 0.769,0.686,0.534,0, 0.189,0.168,0.131,0, 0,0,0,1, 0,0,0,0)
-///Grayscale
+/// Grayscale
#define COLOR_MATRIX_GRAYSCALE list(0.33,0.33,0.33,0, 0.59,0.59,0.59,0, 0.11,0.11,0.11,0, 0,0,0,1, 0,0,0,0)
-///Polaroid colors
+/// Polaroid colors
#define COLOR_MATRIX_POLAROID list(1.438,-0.062,-0.062,0, -0.122,1.378,-0.122,0, -0.016,-0.016,1.483,0, 0,0,0,1, 0,0,0,0)
/// Converts reds to blue, green to red and blue to green.
#define COLOR_MATRIX_BRG list(0,0,1,0, 0,1,0,0, 1,0,0,0, 0,0,0,1, 0,0,0,0)
diff --git a/code/game/machinery/colormate.dm b/code/game/machinery/gear_painter.dm
similarity index 100%
rename from code/game/machinery/colormate.dm
rename to code/game/machinery/gear_painter.dm
diff --git a/code/game/rendering/actor_huds/huds/inventory-screen_object.dm b/code/game/rendering/actor_huds/huds/inventory-screen_object.dm
index 9e49286cff76..341e64053a97 100644
--- a/code/game/rendering/actor_huds/huds/inventory-screen_object.dm
+++ b/code/game/rendering/actor_huds/huds/inventory-screen_object.dm
@@ -139,7 +139,7 @@
..()
/atom/movable/screen/actor_hud/inventory/plate/hand/handle_inventory_click(mob/user, obj/item/with_item)
- hud.owner.swap_hand(hand_index)
+ hud.owner.mob.swap_hand(hand_index)
/atom/movable/screen/actor_hud/inventory/plate/hand/proc/sync_index(index = hand_index)
screen_loc = SCREEN_LOC_MOB_HUD_INVENTORY_HAND(index)
diff --git a/code/modules/clothing/clothing_accessories.dm b/code/modules/clothing/clothing_accessories.dm
index 4667527d1384..8ff46e36b00b 100644
--- a/code/modules/clothing/clothing_accessories.dm
+++ b/code/modules/clothing/clothing_accessories.dm
@@ -273,7 +273,7 @@
var/list/choices = list()
for(var/i in accessories)
choices[i] = i
- A = show_radial_menu(usr, src, choices)
+ A = show_radial_menu(usr, usr.is_in_inventory(src) ? usr : src, choices)
if(!usr || usr.stat || !(src in usr))
return
if(A)
diff --git a/code/modules/mob/inventory/inventory-hands-put.dm b/code/modules/mob/inventory/inventory-hands-put.dm
index b5799ca1698f..a129e3454a34 100644
--- a/code/modules/mob/inventory/inventory-hands-put.dm
+++ b/code/modules/mob/inventory/inventory-hands-put.dm
@@ -33,8 +33,9 @@
var/obj/item/stack/S = I
for(var/obj/item/stack/held_stack in get_held_items())
if(S.can_merge(held_stack) && S.merge(held_stack))
- to_chat(src, SPAN_NOTICE("Your [held_stack] stack now contains [held_stack.get_amount()] [held_stack.singular_name]\s."))
- return INV_RETURN_SUCCESS
+ to_chat(owner, SPAN_NOTICE("Your [held_stack] stack now contains [held_stack.get_amount()] [held_stack.singular_name]\s."))
+ if(QDELETED(S))
+ return INV_RETURN_SUCCESS
if(prioritize_index)
var/priority_result = put_in_hand(I, prioritize_index, inv_op_flags)
diff --git a/code/modules/mob/mob-inventory.dm b/code/modules/mob/mob-inventory.dm
index a5c6fc71c5bc..1cf64daf0880 100644
--- a/code/modules/mob/mob-inventory.dm
+++ b/code/modules/mob/mob-inventory.dm
@@ -50,7 +50,7 @@
* SLOT_ID_HANDS if in hands
*/
/mob/proc/is_in_inventory(obj/item/I)
- return (I?.worn_mob() == src) && I.worn_slot
+ return (I?.worn_mob() == src) ? I.worn_slot : null
// we use entirely cached vars for speed.
// if this returns bad data well fuck you, don't break equipped()/unequipped().
diff --git a/code/modules/mob/movement.dm b/code/modules/mob/movement.dm
index 2a083fe284fc..94a139bb449d 100644
--- a/code/modules/mob/movement.dm
+++ b/code/modules/mob/movement.dm
@@ -13,16 +13,6 @@
/client/proc/client_dir(input, direction=-1)
return turn(input, direction*dir2angle(dir))
-/client/verb/swap_hand()
- set hidden = 1
- if(istype(mob, /mob/living))
- var/mob/living/L = mob
- L.swap_hand()
- if(istype(mob,/mob/living/silicon/robot))
- var/mob/living/silicon/robot/R = mob
- R.cycle_modules()
- return
-
/client/verb/drop_item()
set hidden = 1
From 8e356cda3943ba89a293e635f8e3b825b0e941a9 Mon Sep 17 00:00:00 2001
From: silicons <2003111+silicons@users.noreply.github.com>
Date: Tue, 26 Nov 2024 07:00:41 -0500
Subject: [PATCH 02/18] oops
---
citadel.dme | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/citadel.dme b/citadel.dme
index f2fa8475ae1d..08643fd36569 100644
--- a/citadel.dme
+++ b/citadel.dme
@@ -1331,7 +1331,6 @@
#include "code\game\machinery\CableLayer.dm"
#include "code\game\machinery\cell_charger.dm"
#include "code\game\machinery\cloning.dm"
-#include "code\game\machinery\colormate.dm"
#include "code\game\machinery\cryo.dm"
#include "code\game\machinery\cryopod.dm"
#include "code\game\machinery\deployable.dm"
@@ -1347,6 +1346,7 @@
#include "code\game\machinery\floor_light.dm"
#include "code\game\machinery\floorlayer.dm"
#include "code\game\machinery\fossilrevive.dm"
+#include "code\game\machinery\gear_painter.dm"
#include "code\game\machinery\holopad.dm"
#include "code\game\machinery\holoposter.dm"
#include "code\game\machinery\holosign.dm"
From 3e75e13390534c0c70415f4398816eba6607f266 Mon Sep 17 00:00:00 2001
From: silicons <2003111+silicons@users.noreply.github.com>
Date: Tue, 26 Nov 2024 07:24:21 -0500
Subject: [PATCH 03/18] no auto-merge
---
code/game/objects/items-interaction.dm | 2 +-
code/modules/mob/inventory/inventory-hands-put.dm | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/code/game/objects/items-interaction.dm b/code/game/objects/items-interaction.dm
index f5a298b4ed1e..e9fa3c3ea3ed 100644
--- a/code/game/objects/items-interaction.dm
+++ b/code/game/objects/items-interaction.dm
@@ -89,7 +89,7 @@
if(isnull(actually_picked_up))
to_chat(user, SPAN_WARNING("[src] somehow slips through your grasp. What just happened?"))
return
- if(!user.put_in_hands(actually_picked_up, user.active_hand))
+ if(!user.put_in_hands(actually_picked_up, INV_OP_NO_MERGE_STACKS, user.active_hand))
if(has_to_drop_to_ground_on_fail)
actually_picked_up.forceMove(user.drop_location())
return
diff --git a/code/modules/mob/inventory/inventory-hands-put.dm b/code/modules/mob/inventory/inventory-hands-put.dm
index a129e3454a34..2aabea67031d 100644
--- a/code/modules/mob/inventory/inventory-hands-put.dm
+++ b/code/modules/mob/inventory/inventory-hands-put.dm
@@ -33,7 +33,7 @@
var/obj/item/stack/S = I
for(var/obj/item/stack/held_stack in get_held_items())
if(S.can_merge(held_stack) && S.merge(held_stack))
- to_chat(owner, SPAN_NOTICE("Your [held_stack] stack now contains [held_stack.get_amount()] [held_stack.singular_name]\s."))
+ to_chat(owner, SPAN_NOTICE("The [held_stack.name] in your hands now contains [held_stack.get_amount()] [held_stack.singular_name]\s."))
if(QDELETED(S))
return INV_RETURN_SUCCESS
From eefffd8db2b57d40eb2226e9aa6066e696ac5c00 Mon Sep 17 00:00:00 2001
From: silicons <2003111+silicons@users.noreply.github.com>
Date: Wed, 27 Nov 2024 19:53:27 -0500
Subject: [PATCH 04/18] api
---
citadel.dme | 2 +
.../mob/inventory/inventory-hands-get.dm | 37 ++++++++++++------
code/modules/mob/inventory/inventory-query.dm | 23 +++++++++++
.../mob/inventory/inventory-slot-get.dm | 38 +++++++++++++++++++
code/modules/mob/mob-inventory-abstraction.dm | 2 +-
5 files changed, 90 insertions(+), 12 deletions(-)
create mode 100644 code/modules/mob/inventory/inventory-query.dm
create mode 100644 code/modules/mob/inventory/inventory-slot-get.dm
diff --git a/citadel.dme b/citadel.dme
index af1acdb6dc8f..1985fdce0681 100644
--- a/citadel.dme
+++ b/citadel.dme
@@ -3648,7 +3648,9 @@
#include "code\modules\mob\inventory\inventory-hands-put.dm"
#include "code\modules\mob\inventory\inventory-hands.dm"
#include "code\modules\mob\inventory\inventory-hooks.dm"
+#include "code\modules\mob\inventory\inventory-query.dm"
#include "code\modules\mob\inventory\inventory-rendering.dm"
+#include "code\modules\mob\inventory\inventory-slot-get.dm"
#include "code\modules\mob\inventory\inventory.dm"
#include "code\modules\mob\inventory\inventory_slot.dm"
#include "code\modules\mob\living\autohiss.dm"
diff --git a/code/modules/mob/inventory/inventory-hands-get.dm b/code/modules/mob/inventory/inventory-hands-get.dm
index e85a1f3029aa..16fe0bef0b16 100644
--- a/code/modules/mob/inventory/inventory-hands-get.dm
+++ b/code/modules/mob/inventory/inventory-hands-get.dm
@@ -1,14 +1,6 @@
//* This file is explicitly licensed under the MIT license. *//
//* Copyright (c) 2024 Citadel Station Developers *//
-//* Procs in this file are mirrored to the /mob level for ease of use. *//
-//* *//
-//* In the future, there should likely be a separation of concerns *//
-//* and the enforcement of 'mob.inventory' access, but given the overhead of *//
-//* a proc-call, this is currently not done. *//
-
-//* Basic *//
-
/**
* Gets the item held in a given hand index
*
@@ -16,10 +8,33 @@
*
* @return /obj/item or null.
*/
-/datum/inventory/proc/get_held_item(index)
- RETURN_TYPE(/obj/item)
+/datum/inventory/proc/get_item_in_hand(index) as /obj/item
return held_items[index]
+/**
+ * Gets the item held in a given hand index
+ *
+ * * This expects a valid index.
+ * * This returns a list, and includes all items in compound items.
+ *
+ * @return /obj/item or null.
+ */
+/datum/inventory/proc/get_items_in_hand(index) as /obj/item
+ var/obj/item/held = held_items[index]
+ if(!held)
+ return
+ return held.inv_slot_attached()
+
+// todo: old below
+
+//* Procs in this file are mirrored to the /mob level for ease of use. *//
+//* *//
+//* In the future, there should likely be a separation of concerns *//
+//* and the enforcement of 'mob.inventory' access, but given the overhead of *//
+//* a proc-call, this is currently not done. *//
+
+//* Basic *//
+
/**
* Gets the item held in a given hand index
*
@@ -27,7 +42,7 @@
*
* @return /obj/item or null.
*/
-/mob/proc/get_held_item(index)
+/mob/proc/get_item_in_hand(index)
RETURN_TYPE(/obj/item)
return inventory?.held_items[index]
diff --git a/code/modules/mob/inventory/inventory-query.dm b/code/modules/mob/inventory/inventory-query.dm
new file mode 100644
index 000000000000..924865f92fa9
--- /dev/null
+++ b/code/modules/mob/inventory/inventory-query.dm
@@ -0,0 +1,23 @@
+//* This file is explicitly licensed under the MIT license. *//
+//* Copyright (c) 2024 Citadel Station Developers *//
+
+/datum/inventory
+
+/datum/inventory
+
+/datum/inventory
+
+/datum/inventory
+
+/datum/inventory
+
+/datum/inventory
+
+/datum/inventory
+
+/datum/inventory
+
+/datum/inventory
+
+
+#warn impl
diff --git a/code/modules/mob/inventory/inventory-slot-get.dm b/code/modules/mob/inventory/inventory-slot-get.dm
new file mode 100644
index 000000000000..a3263035e9cc
--- /dev/null
+++ b/code/modules/mob/inventory/inventory-slot-get.dm
@@ -0,0 +1,38 @@
+//* This file is explicitly licensed under the MIT license. *//
+//* Copyright (c) 2024 Citadel Station Developers *//
+
+/**
+ * Gets the item in a slot.
+ *
+ * * If multiple items are worn over each other in a slot, this gets the topmost.
+ * * For compound items, this only returns the outermost / host / root.
+ *
+ * @params
+ * * slot_id - slot ID
+ *
+ * @return /obj/item or null
+ */
+/datum/inventory/proc/get_item_in_slot(slot_id) as /obj/item
+ . = owner._item_by_slot(slot_id)
+ if(. == INVENTORY_SLOT_DOES_NOT_EXIST)
+ return null
+
+/**
+ * Gets all items in a slot.
+ *
+ * * If multiple items are worn over each other in a slot, this gets all of them.
+ * * If multiple items are compounded on one item (e.g. clothing accessories), this gets all of them.
+ *
+ * @params
+ * * slot_id - slot ID
+ *
+ * @return /obj/item or null
+ */
+/datum/inventory/proc/get_items_in_slot(slot_id) as /list
+ var/obj/item/in_slot = owner._item_by_slot(slot_id)
+ if(in_slot == INVENTORY_SLOT_DOES_NOT_EXIST)
+ return
+ if(in_slot)
+ . = in_slot.inv_slot_attached()
+ if(!islist(.))
+ . = . ? list(.) : list()
diff --git a/code/modules/mob/mob-inventory-abstraction.dm b/code/modules/mob/mob-inventory-abstraction.dm
index b9f6ee115cf1..693aaacd0221 100644
--- a/code/modules/mob/mob-inventory-abstraction.dm
+++ b/code/modules/mob/mob-inventory-abstraction.dm
@@ -56,7 +56,7 @@
* returns -1 if no slot
* YES, MAGIC VALUE BUT SOLE USER IS 20 LINES ABOVE, SUE ME.
*/
-/mob/proc/_item_by_slot(slot)
+/mob/proc/_item_by_slot(slot) as /obj/item
PROTECTED_PROC(TRUE)
return INVENTORY_SLOT_DOES_NOT_EXIST
From abafe89eb98a115052c7cce1611c921eec61c494 Mon Sep 17 00:00:00 2001
From: silicons <2003111+silicons@users.noreply.github.com>
Date: Thu, 28 Nov 2024 09:44:28 -0500
Subject: [PATCH 05/18] rid of that
---
citadel.dme | 1 +
code/__DEFINES/inventory/procs.dm | 2 +-
code/modules/detectivework/forensics.dm | 6 +-
.../detectivework/tools/sample_kits.dm | 5 +-
code/modules/hydroponics/grown.dm | 2 +-
code/modules/materials/material_sheets.dm | 2 +-
.../mob/inventory/inventory-hands-get.dm | 14 +-
.../mob/inventory/inventory-slot-equip.dm | 45 +++++
code/modules/mob/living/carbon/human/dummy.dm | 178 ------------------
code/modules/mob/mob-inventory-abstraction.dm | 6 -
10 files changed, 63 insertions(+), 198 deletions(-)
create mode 100644 code/modules/mob/inventory/inventory-slot-equip.dm
diff --git a/citadel.dme b/citadel.dme
index 1985fdce0681..2967d86c098f 100644
--- a/citadel.dme
+++ b/citadel.dme
@@ -3650,6 +3650,7 @@
#include "code\modules\mob\inventory\inventory-hooks.dm"
#include "code\modules\mob\inventory\inventory-query.dm"
#include "code\modules\mob\inventory\inventory-rendering.dm"
+#include "code\modules\mob\inventory\inventory-slot-equip.dm"
#include "code\modules\mob\inventory\inventory-slot-get.dm"
#include "code\modules\mob\inventory\inventory.dm"
#include "code\modules\mob\inventory\inventory_slot.dm"
diff --git a/code/__DEFINES/inventory/procs.dm b/code/__DEFINES/inventory/procs.dm
index a49a6ff2253d..8e246783737c 100644
--- a/code/__DEFINES/inventory/procs.dm
+++ b/code/__DEFINES/inventory/procs.dm
@@ -51,7 +51,7 @@
// todo: INV_OP_RECURSE for nested / worn-over pieces
-//* Inventory Return Flags *//
+//* Inventory Returns *//
/// Failed
///
diff --git a/code/modules/detectivework/forensics.dm b/code/modules/detectivework/forensics.dm
index 5945787ff6d0..59b7aa88503e 100644
--- a/code/modules/detectivework/forensics.dm
+++ b/code/modules/detectivework/forensics.dm
@@ -24,20 +24,20 @@ var/const/FINGERPRINT_COMPLETE = 6
var/fibertext
var/item_multiplier = istype(src,/obj/item)?1.2:1
var/suit_coverage = 0
- if(istype(M.wear_suit, /obj/item/clothing))
+ if(istype(M.inventory.get_item_in_slot(/datum/inventory_slot/inventory/suit::id), /obj/item/clothing))
var/obj/item/clothing/C = M.wear_suit
fibertext = C.get_fibers()
if(fibertext && prob(10*item_multiplier))
suit_fibers |= fibertext
suit_coverage = C.body_cover_flags
- if(istype(M.w_uniform, /obj/item/clothing) && (M.w_uniform.body_cover_flags & ~suit_coverage))
+ if(istype(M.inventory.get_item_in_slot(/datum/inventory_slot/inventory/uniform::id), /obj/item/clothing) && (M.w_uniform.body_cover_flags & ~suit_coverage))
var/obj/item/clothing/C = M.w_uniform
fibertext = C.get_fibers()
if(fibertext && prob(15*item_multiplier))
suit_fibers |= fibertext
- if(istype(M.gloves, /obj/item/clothing) && (M.gloves.body_cover_flags & ~suit_coverage))
+ if(istype(M.inventory.get_item_in_slot(/datum/inventory_slot/inventory/gloves::id), /obj/item/clothing) && (M.gloves.body_cover_flags & ~suit_coverage))
var/obj/item/clothing/C = M.gloves
fibertext = C.get_fibers()
if(fibertext && prob(20*item_multiplier))
diff --git a/code/modules/detectivework/tools/sample_kits.dm b/code/modules/detectivework/tools/sample_kits.dm
index ab1601b1610a..ceab3010b679 100644
--- a/code/modules/detectivework/tools/sample_kits.dm
+++ b/code/modules/detectivework/tools/sample_kits.dm
@@ -69,8 +69,9 @@
if(!ishuman(user))
return
var/mob/living/carbon/human/H = user
- if(H.gloves)
- to_chat(user, "Take \the [H.gloves] off first.")
+ var/obj/item/wearing_gloves = H.inventory.get_item_in_slot(/datum/inventory_slot/inventory/gloves::id)
+ if(wearing_gloves)
+ to_chat(user, "Take \the [wearing_gloves] off first.")
return
to_chat(user, "You firmly press your fingertips onto the card.")
diff --git a/code/modules/hydroponics/grown.dm b/code/modules/hydroponics/grown.dm
index 48206ed05c1e..eca52835d049 100644
--- a/code/modules/hydroponics/grown.dm
+++ b/code/modules/hydroponics/grown.dm
@@ -316,7 +316,7 @@
return
if(seed.get_trait(TRAIT_STINGS))
var/mob/living/carbon/human/H = user
- if(istype(H) && H.gloves)
+ if(H.inventory.get_item_in_slot(/datum/inventory_slot/inventory/gloves::id))
return
if(!reagents || reagents.total_volume <= 0)
return
diff --git a/code/modules/materials/material_sheets.dm b/code/modules/materials/material_sheets.dm
index a5f2786d45fa..32c9e5ac4a42 100644
--- a/code/modules/materials/material_sheets.dm
+++ b/code/modules/materials/material_sheets.dm
@@ -311,7 +311,7 @@
var/burn_user = TRUE
if(istype(M, /mob/living/carbon/human))
var/mob/living/carbon/human/H = user
- var/obj/item/clothing/gloves/G = H.gloves
+ var/obj/item/clothing/gloves/G = H.inventory.get_item_in_slot(/datum/inventory_slot/inventory/gloves::id)
if(istype(G) && ((G.clothing_flags & CLOTHING_THICK_MATERIAL && prob(70)) || istype(G, /obj/item/clothing/gloves/gauntlets)))
burn_user = FALSE
diff --git a/code/modules/mob/inventory/inventory-hands-get.dm b/code/modules/mob/inventory/inventory-hands-get.dm
index 16fe0bef0b16..b66aa653c723 100644
--- a/code/modules/mob/inventory/inventory-hands-get.dm
+++ b/code/modules/mob/inventory/inventory-hands-get.dm
@@ -1,6 +1,12 @@
//* This file is explicitly licensed under the MIT license. *//
//* Copyright (c) 2024 Citadel Station Developers *//
+//* Procs in this file are mirrored to the /mob level for ease of use. *//
+//* *//
+//* In the future, there should likely be a separation of concerns *//
+//* and the enforcement of 'mob.inventory' access, but given the overhead of *//
+//* a proc-call, this is currently not done. *//
+
/**
* Gets the item held in a given hand index
*
@@ -11,6 +17,8 @@
/datum/inventory/proc/get_item_in_hand(index) as /obj/item
return held_items[index]
+
+
/**
* Gets the item held in a given hand index
*
@@ -27,12 +35,6 @@
// todo: old below
-//* Procs in this file are mirrored to the /mob level for ease of use. *//
-//* *//
-//* In the future, there should likely be a separation of concerns *//
-//* and the enforcement of 'mob.inventory' access, but given the overhead of *//
-//* a proc-call, this is currently not done. *//
-
//* Basic *//
/**
diff --git a/code/modules/mob/inventory/inventory-slot-equip.dm b/code/modules/mob/inventory/inventory-slot-equip.dm
new file mode 100644
index 000000000000..efd2549cf353
--- /dev/null
+++ b/code/modules/mob/inventory/inventory-slot-equip.dm
@@ -0,0 +1,45 @@
+//* This file is explicitly licensed under the MIT license. *//
+//* Copyright (c) 2024 Citadel Station Developers *//
+
+/**
+ * Equips an item to a slot or deletes it.
+ *
+ * @return TRUE / FALSE
+ */
+/datum/inventory/proc/equip_to_slot_or_del(obj/item/entity, datum/inventory_slot/slot_or_id, inv_op_flags, datum/event_args/actor/actor)
+ return owner.equip_to_slot_or_del(entity, slot_or_id, inv_op_flags, actor?.performer)
+
+/**
+ * Equips an item to a slot or drops it beneath our owner.
+ *
+ * @return TRUE / FALSE
+ */
+/datum/inventory/proc/equip_to_slot_or_drop(obj/item/entity, datum/inventory_slot/slot_or_id, inv_op_flags, datum/event_args/actor/actor)
+ if(!owner.equip_to_slot_if_possible(entity, slot_or_id, inv_op_flags, actor?.performer))
+ entity.forceMove(owner.drop_location())
+ return FALSE
+ return TRUE
+
+/**
+ * Equips an item to a slot if possible
+ *
+ * @return TRUE / FALSE
+ */
+/datum/inventory/proc/equip_to_slot_if_possible(obj/item/entity, datum/inventory_slot/slot_or_id, inv_op_flags, datum/event_args/actor/actor)
+ return owner.equip_to_slot_if_possible(entity, slot_or_id, inv_op_flags, actor?.performer)
+
+/**
+ * Equips an item to a slot forcefully, trampling anything in the way.
+ *
+ * @return TRUE / FALSE
+ */
+/datum/inventory/proc/equip_to_slot_forcefully(obj/item/entity, datum/inventory_slot/slot_or_id, inv_op_flags, datum/event_args/actor/actor)
+ return owner._equip_item(entity, inv_op_flags | INV_OP_FORCE, slot_or_id, actor?.performer)
+
+/**
+ * Equips an item to a slot. This is the advanced version of the proc that returns an INV_RETURN_* result.
+ *
+ * @return INV_RETURN_*
+ */
+/datum/inventory/proc/equip_to_slot(obj/item/entity, datum/inventory_slot/slot_or_id, inv_op_flags, datum/event_args/actor/actor)
+ return owner._equip_item(entity, inv_op_flags, slot_or_id, actor?.performer) ? INV_RETURN_SUCCESS : INV_RETURN_FAILED
diff --git a/code/modules/mob/living/carbon/human/dummy.dm b/code/modules/mob/living/carbon/human/dummy.dm
index 771d8a2d8384..6ae7557e14aa 100644
--- a/code/modules/mob/living/carbon/human/dummy.dm
+++ b/code/modules/mob/living/carbon/human/dummy.dm
@@ -89,181 +89,3 @@ GLOBAL_LIST_EMPTY(dummy_mob_list)
if(istype(dummy))
GLOB.dummy_mob_list -= dummy
qdel(dummy)
-
-//? old/legacy stuff below, do not use
-
-/mob/living/carbon/human/dummy/mannequin/default/Initialize(mapload)
- . = ..()
- name = "Wooden Mannequin"
- real_name = "Wooden Mannequin"
- weight = rand(100,175)
- gender = pick(MALE,FEMALE,NEUTER)
-
- // whoever wrote this, wow, you are bad at codde
- // we'll deal with this later, jfc ~silicons
- for(var/mob/living/carbon/human/dummy/mannequin/H in src.loc)
- for(var/i = 1, i <= 2, i++)
- if(!w_uniform)
- var/list/options = typesof(/obj/item/clothing/under)
- var/PICK= options[rand(1,options.len)]
- H.equip_to_slot_or_del(new PICK(H), SLOT_ID_UNIFORM)
- H.update_inv_w_uniform()
- if(!glasses)
- var/list/options = typesof(/obj/item/clothing/glasses)
- var/PICK= options[rand(1,options.len)]
- H.equip_to_slot_or_del(new PICK(H), SLOT_ID_GLASSES)
- H.update_inv_glasses()
- if(!shoes)
- var/list/options = typesof(/obj/item/clothing/shoes)
- var/PICK= options[rand(1,options.len)]
- H.equip_to_slot_or_del(new PICK(H), SLOT_ID_SHOES)
- H.update_inv_shoes()
-
-/mob/living/carbon/human/dummy/mannequin/plastic/Initialize(mapload)
- . = ..()
- name = "Plastic Mannequin"
- real_name = "Plastic Mannequin"
- GLOB.mob_list -= src
- living_mob_list -= src
- dead_mob_list -= src
- weight = rand(76,175)
- gender = pick(MALE,FEMALE,NEUTER)
- change_skin_color(255, 255, 255)
- delete_inventory()
-
- for(var/mob/living/carbon/human/dummy/mannequin/plastic/H in src.loc)
- for(var/i = 1, i <= 2, i++)
- if(!w_uniform)
- var/list/options = typesof(/obj/item/clothing/under)
- var/PICK= options[rand(1,options.len)]
- H.equip_to_slot_or_del(new PICK(H), SLOT_ID_UNIFORM)
- H.update_inv_w_uniform()
- if(!glasses)
- var/list/options = typesof(/obj/item/clothing/glasses)
- var/PICK= options[rand(1,options.len)]
- H.equip_to_slot_or_del(new PICK(H), SLOT_ID_GLASSES)
- H.update_inv_glasses()
- if(!shoes)
- var/list/options = typesof(/obj/item/clothing/shoes)
- var/PICK= options[rand(1,options.len)]
- H.equip_to_slot_or_del(new PICK(H), SLOT_ID_SHOES)
- H.update_inv_shoes()
-
-/mob/living/carbon/human/dummy/mannequin/samurai/Initialize(mapload)
- . = ..()
- name = "Wooden Mannequin"
- real_name = "Wooden Mannequin"
- GLOB.mob_list -= src
- living_mob_list -= src
- dead_mob_list -= src
- weight = rand(76,175)
- gender = pick(MALE,NEUTER)
- delete_inventory()
-
- for(var/mob/living/carbon/human/dummy/mannequin/samurai/H in src.loc)
- for(var/i = 1, i <= 2, i++)
- if(!w_uniform)
- H.equip_to_slot_or_del(new /obj/item/clothing/under/color/black, SLOT_ID_UNIFORM)
- H.update_inv_w_uniform()
- if(!shoes)
- H.equip_to_slot_or_del(new /obj/item/clothing/shoes/boots/duty, SLOT_ID_SHOES)
- H.update_inv_shoes()
- if(!gloves)
- H.equip_to_slot_or_del(new /obj/item/clothing/gloves/black, SLOT_ID_GLOVES)
- H.update_inv_gloves()
- if(!wear_mask)
- H.equip_to_slot_or_del(new /obj/item/clothing/mask/samurai, SLOT_ID_MASK)
- H.update_inv_wear_mask()
- if(!head)
- H.equip_to_slot_or_del(new /obj/item/clothing/head/helmet/samurai, SLOT_ID_HEAD)
- H.update_inv_head()
- if(!wear_suit)
- H.equip_to_slot_or_del(new /obj/item/clothing/suit/armor/samurai, SLOT_ID_SUIT)
- H.update_inv_wear_suit()
-
-/mob/living/carbon/human/dummy/mannequin/animegirl/Initialize(mapload)
- . = ..()
- name = "Wooden Mannequin"
- real_name = "Wooden Mannequin"
- GLOB.mob_list -= src
- living_mob_list -= src
- dead_mob_list -= src
- weight = rand(76,175)
- gender = pick(FEMALE,NEUTER)
- delete_inventory()
-
- for(var/mob/living/carbon/human/dummy/mannequin/animegirl/H in src.loc)
- for(var/i = 1, i <= 2, i++)
- if(!w_uniform)
- H.equip_to_slot_or_del(new /obj/item/clothing/under/schoolgirl, SLOT_ID_UNIFORM)
- H.update_inv_w_uniform()
- if(!shoes)
- H.equip_to_slot_or_del(new /obj/item/clothing/shoes/hitops/black, SLOT_ID_SHOES)
- H.update_inv_shoes()
- if(!wear_mask)
- H.equip_to_slot_or_del(new /obj/item/clothing/mask/breath/medical, SLOT_ID_MASK)
- H.update_inv_wear_mask()
- if(!head)
- H.equip_to_slot_or_del(new /obj/item/clothing/head/bunny, SLOT_ID_HEAD)
- H.update_inv_head()
- if(!glasses)
- H.equip_to_slot_or_del(new /obj/item/clothing/glasses/thermal/plain/eyepatch, SLOT_ID_SUIT)
- H.update_inv_glasses()
-
-/mob/living/carbon/human/dummy/mannequin/mummy/Initialize(mapload)
- . = ..()
- name = "Wooden Mannequin"
- real_name = "Wooden Mannequin"
- GLOB.mob_list -= src
- living_mob_list -= src
- dead_mob_list -= src
- weight = rand(76,175)
- gender = pick(MALE,FEMALE,NEUTER)
- delete_inventory()
-
- for(var/mob/living/carbon/human/dummy/mannequin/mummy/H in src.loc)
- for(var/i = 1, i <= 2, i++)
- if(!w_uniform)
- H.equip_to_slot_or_del(new /obj/item/clothing/under/mummy, SLOT_ID_UNIFORM)
- H.update_inv_w_uniform()
- if(!shoes)
- H.equip_to_slot_or_del(new /obj/item/clothing/shoes/sandal, SLOT_ID_SHOES)
- H.update_inv_shoes()
- if(!wear_mask)
- H.equip_to_slot_or_del(new /obj/item/clothing/mask/gas/mummy, SLOT_ID_MASK)
- H.update_inv_wear_mask()
- if(!head)
- H.equip_to_slot_or_del(new /obj/item/clothing/head/nemes, SLOT_ID_HEAD)
- H.update_inv_head()
- if(!wear_suit)
- H.equip_to_slot_or_del(new /obj/item/clothing/suit/pharaoh, SLOT_ID_SUIT)
- H.update_inv_wear_suit()
-
-/mob/living/carbon/human/dummy/mannequin/scarecrow/Initialize(mapload)
- . = ..()
- name = "Wooden Mannequin"
- real_name = "Wooden Mannequin"
- GLOB.mob_list -= src
- living_mob_list -= src
- dead_mob_list -= src
- weight = rand(76,175)
- gender = pick(MALE,FEMALE,NEUTER)
- delete_inventory()
-
- for(var/mob/living/carbon/human/dummy/mannequin/scarecrow/H in src.loc)
- for(var/i = 1, i <= 2, i++)
- if(!w_uniform)
- H.equip_to_slot_or_del(new /obj/item/clothing/under/scarecrow, SLOT_ID_UNIFORM)
- H.update_inv_w_uniform()
- if(!shoes)
- H.equip_to_slot_or_del(new /obj/item/clothing/shoes/boots/workboots, SLOT_ID_SHOES)
- H.update_inv_shoes()
- if(!wear_mask)
- H.equip_to_slot_or_del(new /obj/item/clothing/mask/gas/scarecrow, SLOT_ID_MASK)
- H.update_inv_wear_mask()
- if(!head)
- H.equip_to_slot_or_del(new /obj/item/clothing/head/scarecrow, SLOT_ID_HEAD)
- H.update_inv_head()
- if(!gloves)
- H.equip_to_slot_or_del(new /obj/item/clothing/gloves/botanic_leather, SLOT_ID_SUIT)
- H.update_inv_gloves()
diff --git a/code/modules/mob/mob-inventory-abstraction.dm b/code/modules/mob/mob-inventory-abstraction.dm
index 693aaacd0221..bf81bf9eecbf 100644
--- a/code/modules/mob/mob-inventory-abstraction.dm
+++ b/code/modules/mob/mob-inventory-abstraction.dm
@@ -40,7 +40,6 @@
* logic - apply logic like dropping stuff from pockets when unequippiing a jumpsuit imemdiately?
*/
/mob/proc/_set_inv_slot(slot, obj/item/I, flags)
- PROTECTED_PROC(TRUE)
. = INVENTORY_SLOT_DOES_NOT_EXIST
CRASH("Attempting to set inv slot of [slot] to [I] went to base /mob. You probably had someone assigning to a nonexistant slot!")
@@ -49,7 +48,6 @@
* usually used when safety checks detect something is amiss
*/
/mob/proc/_slot_by_item(obj/item/I)
- PROTECTED_PROC(TRUE)
/**
* doubles as slot detection
@@ -57,18 +55,15 @@
* YES, MAGIC VALUE BUT SOLE USER IS 20 LINES ABOVE, SUE ME.
*/
/mob/proc/_item_by_slot(slot) as /obj/item
- PROTECTED_PROC(TRUE)
return INVENTORY_SLOT_DOES_NOT_EXIST
/mob/proc/_get_all_slots(include_restraints)
- PROTECTED_PROC(TRUE)
return list()
/**
* return all slot ids we implement
*/
/mob/proc/_get_inventory_slot_ids()
- PROTECTED_PROC(TRUE)
return list()
/**
@@ -76,7 +71,6 @@
* useful for other species that don't have a slot so you don't have jumpsuit requirements apply
*/
/mob/proc/_semantic_slot_id_check(id)
- PROTECTED_PROC(TRUE)
return TRUE
//* Optional Behaviors *//
From 9074b95032222d060a95dcada4a410d45192e63a Mon Sep 17 00:00:00 2001
From: silicons <2003111+silicons@users.noreply.github.com>
Date: Thu, 28 Nov 2024 10:38:17 -0500
Subject: [PATCH 06/18] That
---
citadel.dme | 1 +
code/__DEFINES/inventory/slots.dm | 14 ++++++-
code/game/objects/items-inventory.dm | 3 ++
code/modules/mob/inventory/inventory-get.dm | 39 +++++++++++++++++++
.../mob/inventory/inventory-hands-get.dm | 8 ----
.../mob/inventory/inventory-slot-get.dm | 2 +-
code/modules/mob/inventory/inventory_slot.dm | 4 ++
7 files changed, 61 insertions(+), 10 deletions(-)
create mode 100644 code/modules/mob/inventory/inventory-get.dm
diff --git a/citadel.dme b/citadel.dme
index 2967d86c098f..0e7b4f269a25 100644
--- a/citadel.dme
+++ b/citadel.dme
@@ -3641,6 +3641,7 @@
#include "code\modules\mob\freelook\mask\cultnet.dm"
#include "code\modules\mob\freelook\mask\eye.dm"
#include "code\modules\mob\freelook\mask\update_triggers.dm"
+#include "code\modules\mob\inventory\inventory-get.dm"
#include "code\modules\mob\inventory\inventory-hands-check.dm"
#include "code\modules\mob\inventory\inventory-hands-drop.dm"
#include "code\modules\mob\inventory\inventory-hands-get.dm"
diff --git a/code/__DEFINES/inventory/slots.dm b/code/__DEFINES/inventory/slots.dm
index 682ea7ec1cf1..056cce5bbb07 100644
--- a/code/__DEFINES/inventory/slots.dm
+++ b/code/__DEFINES/inventory/slots.dm
@@ -34,7 +34,8 @@ DEFINE_BITFIELD(slot_equip_checks, list(
BITFIELD(SLOT_EQUIP_CHECK_USE_PROC),
))
-//! slot meta inventory_slot_flags flags
+//* /datum/inventory_slot inventory_slot_flags *//
+
/// render on mob
#define INV_SLOT_IS_RENDERED (1<<0)
/// considered worn equipment
@@ -66,6 +67,17 @@ DEFINE_BITFIELD(inventory_slot_flags, list(
BITFIELD(INV_SLOT_STRIP_ONLY_REMOVES),
))
+//* /datum/inventory_slot inventory_slot_filter *//
+
+#define INV_SLOT_FILTER_UNKNOWN (1<<1)
+#define INV_SLOT_FILTER_EQUIPMENT (1<<2)
+#define INV_SLOT_FILTER_RESTRAINTS (1<<3)
+
+/// specially handled value
+#define INV_SLOT_FILTER_HANDS (1<<23)
+
+#warn DEFINE_BITFIELD_NEW
+
//! slot flags
// Item inventory slot bitmasks.
#define SLOT_OCLOTHING (1<<0)
diff --git a/code/game/objects/items-inventory.dm b/code/game/objects/items-inventory.dm
index fb41848ddf32..bbf84855b729 100644
--- a/code/game/objects/items-inventory.dm
+++ b/code/game/objects/items-inventory.dm
@@ -346,6 +346,9 @@
* returns either an item or a list
* get_equipped_items() uses this so accessories are included
* anything this returns is considered to be in the same slot.
+ *
+ * * You must never return anything that would be returned when this is called on any other item!
+ * Things can only be in one slot at a time, even with this compound-item system.
*/
/obj/item/proc/inv_slot_attached()
if(worn_over)
diff --git a/code/modules/mob/inventory/inventory-get.dm b/code/modules/mob/inventory/inventory-get.dm
new file mode 100644
index 000000000000..6d9b57925e02
--- /dev/null
+++ b/code/modules/mob/inventory/inventory-get.dm
@@ -0,0 +1,39 @@
+//* This file is explicitly licensed under the MIT license. *//
+//* Copyright (c) 2024 Citadel Station Developers *//
+
+/**
+ * Gets all equipped items.
+ *
+ * In non-compound mode:
+ * * If multiple items are worn over each other in a slot, this gets the topmost.
+ * * For compound items, this only returns the outermost / host / root.
+ *
+ * In compound mode:
+ * * If multiple items are worn over each other in a slot, this gets all of them.
+ * * If multiple items are compounded on one item (e.g. clothing accessories), this gets all of them.
+ *
+ * @params
+ * * filter_exclude - INV_SLOT_FILTER to exclude.
+ * * compound - Enable compound mode.
+ *
+ * @return list() of items
+ */
+/datum/inventory/proc/get_equipped_items(filter_exclude, compound) as /list
+ . = list()
+ if(compound)
+ for(var/slot_id in base_inventory_slots)
+ var/datum/inventory_slot/slot_meta = resolve_inventory_slot(slot_id)
+ if(slot_meta.inventory_slot_filter & filter_exclude)
+ continue
+ var/obj/item/in_slot = owner._item_by_slot(slot_id)
+ if(in_slot)
+ . += in_slot.inv_slot_attached()
+ else
+ for(var/slot_id in base_inventory_slots)
+ var/datum/inventory_slot/slot_meta = resolve_inventory_slot(slot_id)
+ if(slot_meta.inventory_slot_filter & filter_exclude)
+ continue
+ if(in_slot)
+ . += in_slot
+ if(!(filter_exclude & INV_SLOT_FILTER_HANDS))
+ . += get_held_items()
diff --git a/code/modules/mob/inventory/inventory-hands-get.dm b/code/modules/mob/inventory/inventory-hands-get.dm
index b66aa653c723..4a9a80ec96b3 100644
--- a/code/modules/mob/inventory/inventory-hands-get.dm
+++ b/code/modules/mob/inventory/inventory-hands-get.dm
@@ -1,12 +1,6 @@
//* This file is explicitly licensed under the MIT license. *//
//* Copyright (c) 2024 Citadel Station Developers *//
-//* Procs in this file are mirrored to the /mob level for ease of use. *//
-//* *//
-//* In the future, there should likely be a separation of concerns *//
-//* and the enforcement of 'mob.inventory' access, but given the overhead of *//
-//* a proc-call, this is currently not done. *//
-
/**
* Gets the item held in a given hand index
*
@@ -17,8 +11,6 @@
/datum/inventory/proc/get_item_in_hand(index) as /obj/item
return held_items[index]
-
-
/**
* Gets the item held in a given hand index
*
diff --git a/code/modules/mob/inventory/inventory-slot-get.dm b/code/modules/mob/inventory/inventory-slot-get.dm
index a3263035e9cc..9978d7dddaee 100644
--- a/code/modules/mob/inventory/inventory-slot-get.dm
+++ b/code/modules/mob/inventory/inventory-slot-get.dm
@@ -26,7 +26,7 @@
* @params
* * slot_id - slot ID
*
- * @return /obj/item or null
+ * @return list() of items
*/
/datum/inventory/proc/get_items_in_slot(slot_id) as /list
var/obj/item/in_slot = owner._item_by_slot(slot_id)
diff --git a/code/modules/mob/inventory/inventory_slot.dm b/code/modules/mob/inventory/inventory_slot.dm
index 5b5df236dec9..0c2e7fec3eae 100644
--- a/code/modules/mob/inventory/inventory_slot.dm
+++ b/code/modules/mob/inventory/inventory_slot.dm
@@ -93,6 +93,8 @@ GLOBAL_LIST_EMPTY(inventory_slot_type_cache)
var/static/id_next = 0
/// flags
var/inventory_slot_flags = INV_SLOT_IS_RENDERED
+ /// filter flags
+ var/inventory_slot_filter = INVENTORY_SLOT_FILTER_UNKNOWN
/// display order - higher is upper. a
is applied on 0.
var/sort_order = 0
@@ -268,6 +270,7 @@ GLOBAL_LIST_EMPTY(inventory_slot_type_cache)
/datum/inventory_slot/inventory
abstract_type = /datum/inventory_slot/inventory
inventory_slot_flags = INV_SLOT_IS_RENDERED | INV_SLOT_IS_INVENTORY | INV_SLOT_IS_STRIPPABLE | INV_SLOT_HUD_REQUIRES_EXPAND | INV_SLOT_CONSIDERED_WORN
+ inventory_slot_filter = INV_SLOT_FILTER_EQUIPMENT
inventory_hud_rendered = TRUE
/datum/inventory_slot/inventory/back
@@ -874,6 +877,7 @@ GLOBAL_LIST_EMPTY(inventory_slot_type_cache)
always_show_on_strip_menu = FALSE
abstract_type = /datum/inventory_slot/restraints
inventory_slot_flags = INV_SLOT_IS_RENDERED | INV_SLOT_IS_STRIPPABLE | INV_SLOT_STRIP_ONLY_REMOVES | INV_SLOT_STRIP_SIMPLE_LINK
+ inventory_slot_filter = INV_SLOT_FILTER_RESTRAINTS
/datum/inventory_slot/restraints/handcuffs
name = "handcuffed"
From e1dac7caf4f6b7019bd0ac11f85fa180b323497a Mon Sep 17 00:00:00 2001
From: silicons <2003111+silicons@users.noreply.github.com>
Date: Thu, 28 Nov 2024 11:16:27 -0500
Subject: [PATCH 07/18] api
---
citadel.dme | 2 +
code/game/objects/items-inventory-old.dm | 334 +++++++++++++++++
code/game/objects/items-inventory.dm | 350 +++---------------
code/modules/clothing/clothing-inventory.dm | 14 +
.../clothing/under/accessories/accessory.dm | 1 +
code/modules/hardsuits/rig_pieces.dm | 4 +
.../mob/living/carbon/human/human_defines.dm | 2 -
code/modules/mob/living/living-inventory.dm | 2 +-
.../mob/living/silicon/robot/inventory.dm | 6 +
code/modules/mob/mob-inventory-abstraction.dm | 1 +
code/modules/mob/mob-inventory-internal.dm | 7 +-
11 files changed, 410 insertions(+), 313 deletions(-)
create mode 100644 code/game/objects/items-inventory-old.dm
create mode 100644 code/modules/clothing/clothing-inventory.dm
diff --git a/citadel.dme b/citadel.dme
index 0e7b4f269a25..c3a750e27863 100644
--- a/citadel.dme
+++ b/citadel.dme
@@ -1515,6 +1515,7 @@
#include "code\game\objects\items-defense.dm"
#include "code\game\objects\items-interaction.dm"
#include "code\game\objects\items-inventory-hooks.dm"
+#include "code\game\objects\items-inventory-old.dm"
#include "code\game\objects\items-inventory-rendering.dm"
#include "code\game\objects\items-inventory.dm"
#include "code\game\objects\items.dm"
@@ -2543,6 +2544,7 @@
#include "code\modules\client\verbs\system.dm"
#include "code\modules\client\verbs\view.dm"
#include "code\modules\clothing\chameleon.dm"
+#include "code\modules\clothing\clothing-inventory.dm"
#include "code\modules\clothing\clothing.dm"
#include "code\modules\clothing\clothing_accessories.dm"
#include "code\modules\clothing\clothing_icons.dm"
diff --git a/code/game/objects/items-inventory-old.dm b/code/game/objects/items-inventory-old.dm
new file mode 100644
index 000000000000..5637c54478af
--- /dev/null
+++ b/code/game/objects/items-inventory-old.dm
@@ -0,0 +1,334 @@
+//* This file is explicitly licensed under the MIT license. *//
+//* Copyright (c) 2024 Citadel Station Developers *//
+
+//* Hooks - Old *//
+
+/**
+ * called when an item is equipped to inventory or picked up
+ *
+ * @params
+ * user - person equipping us
+ * slot - slot id we're equipped to
+ * flags - inventory operation flags, see defines
+ */
+/obj/item/proc/equipped(mob/user, slot, flags)
+ SHOULD_CALL_PARENT(TRUE)
+
+ // set slot
+ worn_slot = slot
+ // register carry
+ if(isliving(user))
+ var/mob/living/L = user
+ if((slot == SLOT_ID_HANDS)? (item_flags & ITEM_ENCUMBERS_WHILE_HELD) : !(item_flags & ITEM_ENCUMBERS_ONLY_HELD))
+ if(flat_encumbrance)
+ L.recalculate_carry()
+ else
+ encumbrance_registered = get_encumbrance()
+ L.adjust_current_carry_encumbrance(encumbrance_registered)
+ // fire signals
+ SEND_SIGNAL(src, COMSIG_ITEM_EQUIPPED, user, slot, flags)
+ SEND_SIGNAL(user, COMSIG_MOB_ITEM_EQUIPPED, src, slot, flags)
+
+ if((slot != SLOT_ID_HANDS) && equip_sound)
+ playsound(src, equip_sound, 30, ignore_walls = FALSE)
+
+ on_equipped(user, slot == SLOT_ID_HANDS? user.get_held_index(src) : slot, flags)
+
+
+/**
+ * called when an item is unequipped from inventory or moved around in inventory
+ *
+ * @params
+ * user - person unequipping us
+ * slot - slot id we're unequipping from
+ * flags - inventory operation flags, see defines
+ */
+/obj/item/proc/unequipped(mob/user, slot, flags)
+ SHOULD_CALL_PARENT(TRUE)
+ // clear slot
+ worn_slot = null
+ // clear carry
+ if(isliving(user))
+ var/mob/living/L = user
+ if(flat_encumbrance)
+ L.recalculate_carry()
+ else if(!isnull(encumbrance_registered))
+ L.adjust_current_carry_encumbrance(-encumbrance_registered)
+ encumbrance_registered = null
+ // fire signals
+ SEND_SIGNAL(src, COMSIG_ITEM_UNEQUIPPED, user, slot, flags)
+ SEND_SIGNAL(user, COMSIG_MOB_ITEM_UNEQUIPPED, src, slot, flags)
+
+ if(!(flags & INV_OP_DIRECTLY_DROPPING) && (slot != SLOT_ID_HANDS) && unequip_sound)
+ playsound(src, unequip_sound, 30, ignore_walls = FALSE)
+
+/**
+ * called when a mob drops an item
+ *
+ * ! WARNING: You CANNOT assume we are post or pre-move on dropped.
+ * ! If unequipped() deletes the item, loc will be null. Sometimes, loc won't change at all!
+ *
+ * dropping is defined as moving out of both equipment slots and hand slots
+ */
+/obj/item/proc/dropped(mob/user, flags, atom/newLoc)
+ SHOULD_CALL_PARENT(TRUE)
+
+ // unset things
+ item_flags &= ~ITEM_IN_INVENTORY
+ vis_flags &= ~(VIS_INHERIT_LAYER | VIS_INHERIT_PLANE)
+ // clear carry
+ if(isliving(user))
+ var/mob/living/L = user
+ L.adjust_current_carry_weight(-weight_registered)
+ weight_registered = null
+ // unload actions
+ unregister_item_actions(user)
+ // close context menus
+ context_close()
+ // storage stuff
+ obj_storage?.on_dropped(user)
+ // get rid of shieldcalls
+ for(var/datum/shieldcall/shieldcall as anything in shieldcalls)
+ if(!shieldcall.shields_in_inventory)
+ continue
+ user.unregister_shieldcall(shieldcall)
+
+ //! LEGACY
+ if(!(flags & INV_OP_SUPPRESS_SOUND) && isturf(newLoc) && !(. & COMPONENT_ITEM_DROPPED_SUPPRESS_SOUND))
+ playsound(src, drop_sound, 30, ignore_walls = FALSE)
+ // user?.update_equipment_speed_mods()
+ if(zoom)
+ zoom() //binoculars, scope, etc
+ //! END
+
+ // fire signals
+ . = SEND_SIGNAL(src, COMSIG_ITEM_DROPPED, user, flags, newLoc)
+ SEND_SIGNAL(user, COMSIG_MOB_ITEM_DROPPED, src, flags, newLoc)
+
+ if((item_flags & ITEM_DROPDEL) && !(flags & INV_OP_DELETING))
+ qdel(src)
+ . |= ITEM_RELOCATED_BY_DROPPED
+
+ return ((. & COMPONENT_ITEM_DROPPED_RELOCATE)? ITEM_RELOCATED_BY_DROPPED : NONE)
+
+/**
+ * called when a mob picks up an item
+ *
+ * picking up is defined as moving into either an equipment slot, or hand slots
+ */
+/obj/item/proc/pickup(mob/user, flags, atom/oldLoc)
+ SHOULD_CALL_PARENT(TRUE)
+
+ // set things
+ item_flags |= ITEM_IN_INVENTORY
+ vis_flags |= (VIS_INHERIT_LAYER | VIS_INHERIT_PLANE)
+ // we load the component here as it hooks equipped,
+ // so loading it here means it can still handle the equipped signal.
+ if(passive_parry)
+ LoadComponent(/datum/component/passive_parry, passive_parry)
+
+ // load action buttons
+ register_item_actions(user)
+ // register carry
+ weight_registered = get_weight()
+ if(isliving(user))
+ var/mob/living/L = user
+ L.adjust_current_carry_weight(weight_registered)
+ // register shieldcalls
+ for(var/datum/shieldcall/shieldcall as anything in shieldcalls)
+ if(!shieldcall.shields_in_inventory)
+ continue
+ user.register_shieldcall(shieldcall)
+ // storage stuff
+ obj_storage?.on_pickup(user)
+
+ //! LEGACY
+ reset_pixel_offsets()
+ // todo: should this be here
+ transform = null
+ if(isturf(oldLoc) && !(flags & (INV_OP_SILENT | INV_OP_DIRECTLY_EQUIPPING)))
+ playsound(src, pickup_sound, 20, ignore_walls = FALSE)
+ //! END
+
+ // fire signals
+ SEND_SIGNAL(src, COMSIG_ITEM_PICKUP, user, flags, oldLoc)
+ SEND_SIGNAL(user, COMSIG_MOB_ITEM_PICKUP, src, flags, oldLoc)
+
+//* Access *//
+
+/**
+ * get the mob we're equipped on
+ */
+/obj/item/proc/worn_mob()
+ RETURN_TYPE(/mob)
+ return worn_inside?.worn_mob() || (worn_slot? loc : null)
+
+
+//* Stripping *//
+
+/**
+ * get strip menu options by href key associated to name.
+ */
+/obj/item/proc/strip_menu_options(mob/user)
+ RETURN_TYPE(/list)
+ return list()
+
+/**
+ * strip menu act
+ *
+ * adjacency is pre-checked.
+ * return TRUE to refresh
+ */
+/obj/item/proc/strip_menu_act(mob/user, action)
+ return FALSE
+
+/**
+ * standard do after for interacting from strip menu
+ */
+/obj/item/proc/strip_menu_standard_do_after(mob/user, delay)
+ . = FALSE
+ var/slot = worn_slot
+ if(!slot)
+ CRASH("no worn slot")
+ var/mob/M = worn_mob()
+ if(!M)
+ CRASH("no worn mob")
+ if(!M.strip_interaction_prechecks(user))
+ return
+ if(!do_after(user, delay, M, DO_AFTER_IGNORE_ACTIVE_ITEM))
+ return
+ if(slot != worn_slot || M != worn_mob())
+ return
+ return TRUE
+
+//* Checks *//
+// todo: item should get final say for "soft" aka not-literal-var-overwrite conflicts.
+
+/**
+ * checks if a mob can equip us to a slot
+ * mob gets final say
+ * if you return false, feedback to the user, as the main proc doesn't do this.
+ *
+ * todo: non-singular-letter proc args
+ */
+/obj/item/proc/can_equip(mob/M, slot, mob/user, flags)
+ if(!equip_check_beltlink(M, slot, user, flags))
+ return FALSE
+ return TRUE
+
+/**
+ * checks if a mob can unequip us from a slot
+ * mob gets final say
+ * if you return false, feedback to the user, as the main proc doesn't do this.
+ *
+ * todo: non-singular-letter proc args
+ */
+/obj/item/proc/can_unequip(mob/M, slot, mob/user, flags)
+ return TRUE
+
+/**
+ * allow an item in suit storage slot?
+ */
+/obj/item/proc/can_suit_storage(obj/item/I)
+ // todo: this is awful
+ return is_type_in_list(I, allowed)
+
+/**
+ * checks if we need something to attach to in a certain slot
+ *
+ * todo: non-singular-letter proc args
+ */
+/obj/item/proc/equip_check_beltlink(mob/M, slot, mob/user, flags)
+ if(clothing_flags & CLOTHING_IGNORE_BELTLINK)
+ return TRUE
+
+ if(!ishuman(M))
+ return TRUE
+
+ var/mob/living/carbon/human/H = M
+
+ switch(slot)
+ if(SLOT_ID_LEFT_POCKET, SLOT_ID_RIGHT_POCKET)
+ if(H.semantically_has_slot(SLOT_ID_UNIFORM) && !H.item_by_slot_id(SLOT_ID_UNIFORM))
+ if(!(flags & INV_OP_SUPPRESS_WARNING))
+ to_chat(H, SPAN_WARNING("You need a jumpsuit before you can attach [src]."))
+ return FALSE
+ if(SLOT_ID_WORN_ID)
+ if(H.semantically_has_slot(SLOT_ID_UNIFORM) && !H.item_by_slot_id(SLOT_ID_UNIFORM))
+ if(!(flags & INV_OP_SUPPRESS_WARNING))
+ to_chat(H, SPAN_WARNING("You need a jumpsuit before you can attach [src]."))
+ return FALSE
+ if(SLOT_ID_BELT)
+ if(H.semantically_has_slot(SLOT_ID_UNIFORM) && !H.item_by_slot_id(SLOT_ID_UNIFORM))
+ if(!(flags & INV_OP_SUPPRESS_WARNING))
+ to_chat(H, SPAN_WARNING("You need a jumpsuit before you can attach [src]."))
+ return FALSE
+ if(SLOT_ID_SUIT_STORAGE)
+ if(H.semantically_has_slot(SLOT_ID_SUIT) && !H.item_by_slot_id(SLOT_ID_SUIT))
+ if(!(flags & INV_OP_SUPPRESS_WARNING))
+ to_chat(H, SPAN_WARNING("You need a suit before you can attach [src]."))
+ return FALSE
+ return TRUE
+
+/**
+ * automatically unequip if we're missing beltlink
+ */
+/obj/item/proc/reconsider_beltlink()
+ var/mob/M = loc
+ if(!istype(M))
+ return
+ if(!worn_slot)
+ return
+ if(!equip_check_beltlink(M, worn_slot, null, INV_OP_SILENT))
+ M.drop_item_to_ground(src, INV_OP_SILENT)
+ return
+
+//* Speed / Carry Weight *//
+
+/**
+ * get the slowdown we incur when we're worn
+ */
+/obj/item/proc/get_equipment_speed_mod()
+ return slowdown
+
+//* ADVANCED: Wear-Over System *//
+
+/**
+ * checks if we can fit over something
+ *
+ * todo: non-singular-letter proc args
+ */
+/obj/item/proc/equip_worn_over_check(mob/M, slot, mob/user, obj/item/I, flags)
+ return FALSE
+
+/**
+ * call when we fit us over something - item should be already in us
+ *
+ * todo: non-singular-letter proc args
+ */
+/obj/item/proc/equip_on_worn_over_insert(mob/M, slot, mob/user, obj/item/I, flags)
+ if(!(flags & INV_OP_SUPPRESS_WARNING))
+ to_chat(M, SPAN_NOTICE("You slip [src] over [I]."))
+
+/**
+ * call when we unfit us over something - item should already be out of us
+ *
+ * todo: non-singular-letter proc args
+ */
+/obj/item/proc/equip_on_worn_over_remove(mob/M, slot, mob/user, obj/item/I, flags)
+
+//* ADVANCED: Compound Objects *//
+
+/**
+ * returns either an item or a list
+ * get_equipped_items() uses this so accessories are included
+ * anything this returns is considered to be in the same slot.
+ *
+ * * You must never return anything that would be returned when this is called on any other item!
+ * Things can only be in one slot at a time, even with this compound-item system.
+ */
+/obj/item/proc/inv_slot_attached()
+ if(worn_over)
+ return list(src) + worn_over.inv_slot_attached()
+ else
+ return src
diff --git a/code/game/objects/items-inventory.dm b/code/game/objects/items-inventory.dm
index bbf84855b729..7a431de35f1c 100644
--- a/code/game/objects/items-inventory.dm
+++ b/code/game/objects/items-inventory.dm
@@ -4,176 +4,79 @@
//* Hooks *//
/**
- * called when an item is equipped to inventory or picked up
+ * Called when we enter a new inventory slot, or hand index.
+ *
+ * * Called after on_unequipped in a swap
+ * * Called after on_pickup on a pickup
*
* @params
- * user - person equipping us
- * slot - slot id we're equipped to
- * flags - inventory operation flags, see defines
+ * * wearer - The person whose inventory we are in
+ * * slot_id_or_index - Text slot ID or numerical hand index
+ * * inv_op_flags - INV_OP_* bits.
+ * * actor - (optional) Actor data of who's putting it on us.
*/
-/obj/item/proc/equipped(mob/user, slot, flags)
+/obj/item/proc/on_equipped(mob/wearer, slot_id_or_index, inv_op_flags, datum/event_args/actor/actor)
SHOULD_CALL_PARENT(TRUE)
-
- // set slot
- worn_slot = slot
- // register carry
- if(isliving(user))
- var/mob/living/L = user
- if((slot == SLOT_ID_HANDS)? (item_flags & ITEM_ENCUMBERS_WHILE_HELD) : !(item_flags & ITEM_ENCUMBERS_ONLY_HELD))
- if(flat_encumbrance)
- L.recalculate_carry()
- else
- encumbrance_registered = get_encumbrance()
- L.adjust_current_carry_encumbrance(encumbrance_registered)
- // fire signals
- SEND_SIGNAL(src, COMSIG_ITEM_EQUIPPED, user, slot, flags)
- SEND_SIGNAL(user, COMSIG_MOB_ITEM_EQUIPPED, src, slot, flags)
-
- if((slot != SLOT_ID_HANDS) && equip_sound)
- playsound(src, equip_sound, 30, ignore_walls = FALSE)
-
+ SHOULD_NOT_SLEEP(TRUE)
/**
- * called when an item is unequipped from inventory or moved around in inventory
+ * Called when we exit an inventory slot, or hand index.
+ *
+ * * Called after on_unequipped in a swap
+ * * Called before on_dropped on a drop
*
* @params
- * user - person unequipping us
- * slot - slot id we're unequipping from
- * flags - inventory operation flags, see defines
+ * * wearer - The person whose inventory we are in
+ * * slot_id_or_index - Text slot ID or numerical hand index
+ * * inv_op_flags - INV_OP_* bits.
+ * * actor - (optional) Actor data of who's putting it on us.
*/
-/obj/item/proc/unequipped(mob/user, slot, flags)
+/obj/item/proc/on_unequipped(mob/wearer, slot_id_or_index, inv_op_flags, datum/event_args/actor/actor)
SHOULD_CALL_PARENT(TRUE)
- // clear slot
- worn_slot = null
- // clear carry
- if(isliving(user))
- var/mob/living/L = user
- if(flat_encumbrance)
- L.recalculate_carry()
- else if(!isnull(encumbrance_registered))
- L.adjust_current_carry_encumbrance(-encumbrance_registered)
- encumbrance_registered = null
- // fire signals
- SEND_SIGNAL(src, COMSIG_ITEM_UNEQUIPPED, user, slot, flags)
- SEND_SIGNAL(user, COMSIG_MOB_ITEM_UNEQUIPPED, src, slot, flags)
-
- if(!(flags & INV_OP_DIRECTLY_DROPPING) && (slot != SLOT_ID_HANDS) && unequip_sound)
- playsound(src, unequip_sound, 30, ignore_walls = FALSE)
+ SHOULD_NOT_SLEEP(TRUE)
/**
- * called when a mob drops an item
+ * Called when we are picked up
*
- * ! WARNING: You CANNOT assume we are post or pre-move on dropped.
- * ! If unequipped() deletes the item, loc will be null. Sometimes, loc won't change at all!
+ * * Called before on_equipped
*
- * dropping is defined as moving out of both equipment slots and hand slots
+ * @params
+ * * wearer - The person whose inventory we are in
+ * * inv_op_flags - INV_OP_* bits.
+ * * actor - (optional) Actor data of who's putting it on us.
*/
-/obj/item/proc/dropped(mob/user, flags, atom/newLoc)
+/obj/item/proc/on_pickup(mob/wearer, slot_id_or_index, inv_op_flags, datum/event_args/actor/actor)
SHOULD_CALL_PARENT(TRUE)
-
- // unset things
- item_flags &= ~ITEM_IN_INVENTORY
- vis_flags &= ~(VIS_INHERIT_LAYER | VIS_INHERIT_PLANE)
- // clear carry
- if(isliving(user))
- var/mob/living/L = user
- L.adjust_current_carry_weight(-weight_registered)
- weight_registered = null
- // unload actions
- unregister_item_actions(user)
- // close context menus
- context_close()
- // storage stuff
- obj_storage?.on_dropped(user)
- // get rid of shieldcalls
- for(var/datum/shieldcall/shieldcall as anything in shieldcalls)
- if(!shieldcall.shields_in_inventory)
- continue
- user.unregister_shieldcall(shieldcall)
-
- //! LEGACY
- if(!(flags & INV_OP_SUPPRESS_SOUND) && isturf(newLoc) && !(. & COMPONENT_ITEM_DROPPED_SUPPRESS_SOUND))
- playsound(src, drop_sound, 30, ignore_walls = FALSE)
- // user?.update_equipment_speed_mods()
- if(zoom)
- zoom() //binoculars, scope, etc
- //! END
-
- // fire signals
- . = SEND_SIGNAL(src, COMSIG_ITEM_DROPPED, user, flags, newLoc)
- SEND_SIGNAL(user, COMSIG_MOB_ITEM_DROPPED, src, flags, newLoc)
-
- if((item_flags & ITEM_DROPDEL) && !(flags & INV_OP_DELETING))
- qdel(src)
- . |= ITEM_RELOCATED_BY_DROPPED
-
- return ((. & COMPONENT_ITEM_DROPPED_RELOCATE)? ITEM_RELOCATED_BY_DROPPED : NONE)
+ SHOULD_NOT_SLEEP(TRUE)
/**
- * called when a mob picks up an item
+ * Called when we are dropped
+ *
+ * * Called after on_unequipped
*
- * picking up is defined as moving into either an equipment slot, or hand slots
+ * @params
+ * * wearer - The person whose inventory we are in
+ * * inv_op_flags - INV_OP_* bits.
+ * * actor - (optional) Actor data of who's putting it on us.
*/
-/obj/item/proc/pickup(mob/user, flags, atom/oldLoc)
+/obj/item/proc/on_dropped(mob/wearer, slot_id_or_index, inv_op_flags, datum/event_args/actor/actor)
SHOULD_CALL_PARENT(TRUE)
+ SHOULD_NOT_SLEEP(TRUE)
- // set things
- item_flags |= ITEM_IN_INVENTORY
- vis_flags |= (VIS_INHERIT_LAYER | VIS_INHERIT_PLANE)
- // we load the component here as it hooks equipped,
- // so loading it here means it can still handle the equipped signal.
- if(passive_parry)
- LoadComponent(/datum/component/passive_parry, passive_parry)
-
- // load action buttons
- register_item_actions(user)
- // register carry
- weight_registered = get_weight()
- if(isliving(user))
- var/mob/living/L = user
- L.adjust_current_carry_weight(weight_registered)
- // register shieldcalls
- for(var/datum/shieldcall/shieldcall as anything in shieldcalls)
- if(!shieldcall.shields_in_inventory)
- continue
- user.register_shieldcall(shieldcall)
- // storage stuff
- obj_storage?.on_pickup(user)
-
- //! LEGACY
- reset_pixel_offsets()
- // todo: should this be here
- transform = null
- if(isturf(oldLoc) && !(flags & (INV_OP_SILENT | INV_OP_DIRECTLY_EQUIPPING)))
- playsound(src, pickup_sound, 20, ignore_walls = FALSE)
- //! END
-
- // fire signals
- SEND_SIGNAL(src, COMSIG_ITEM_PICKUP, user, flags, oldLoc)
- SEND_SIGNAL(user, COMSIG_MOB_ITEM_PICKUP, src, flags, oldLoc)
-
-//* Access *//
-
-/**
- * get the mob we're equipped on
- */
-/obj/item/proc/worn_mob()
- RETURN_TYPE(/mob)
- return worn_inside?.worn_mob() || (worn_slot? loc : null)
+//* Checks *//
/**
* checks if we're in inventory. if so, returns mob we're in
- * **hands count**
*/
-/obj/item/proc/is_in_inventory(include_hands)
- return (worn_slot && ((worn_slot != SLOT_ID_HANDS) || include_hands)) && worn_mob()
+/obj/item/proc/is_in_inventory()
+ return worn_slot && worn_mob()
/**
* checks if we're held in hand
*
* if so, returns mob we're in
*/
-/obj/item/proc/is_held()
+/obj/item/proc/is_being_held() as /mob
return (worn_slot == SLOT_ID_HANDS)? worn_mob() : null
/**
@@ -181,181 +84,12 @@
*
* note: this is not the same as is_in_inventory, we check if it's a clothing/worn slot in this case!
*/
-/obj/item/proc/is_being_worn()
+/obj/item/proc/is_being_worn() as /mob
if(!worn_slot)
return FALSE
var/datum/inventory_slot/slot_meta = resolve_inventory_slot(worn_slot)
return slot_meta.inventory_slot_flags & INV_SLOT_CONSIDERED_WORN
-//* Stripping *//
-
-/**
- * get strip menu options by href key associated to name.
- */
-/obj/item/proc/strip_menu_options(mob/user)
- RETURN_TYPE(/list)
- return list()
-
-/**
- * strip menu act
- *
- * adjacency is pre-checked.
- * return TRUE to refresh
- */
-/obj/item/proc/strip_menu_act(mob/user, action)
- return FALSE
-
-/**
- * standard do after for interacting from strip menu
- */
-/obj/item/proc/strip_menu_standard_do_after(mob/user, delay)
- . = FALSE
- var/slot = worn_slot
- if(!slot)
- CRASH("no worn slot")
- var/mob/M = worn_mob()
- if(!M)
- CRASH("no worn mob")
- if(!M.strip_interaction_prechecks(user))
- return
- if(!do_after(user, delay, M, DO_AFTER_IGNORE_ACTIVE_ITEM))
- return
- if(slot != worn_slot || M != worn_mob())
- return
- return TRUE
-
-//* Checks *//
-// todo: item should get final say for "soft" aka not-literal-var-overwrite conflicts.
-
-/**
- * checks if a mob can equip us to a slot
- * mob gets final say
- * if you return false, feedback to the user, as the main proc doesn't do this.
- *
- * todo: non-singular-letter proc args
- */
-/obj/item/proc/can_equip(mob/M, slot, mob/user, flags)
- if(!equip_check_beltlink(M, slot, user, flags))
- return FALSE
- return TRUE
-
-/**
- * checks if a mob can unequip us from a slot
- * mob gets final say
- * if you return false, feedback to the user, as the main proc doesn't do this.
- *
- * todo: non-singular-letter proc args
- */
-/obj/item/proc/can_unequip(mob/M, slot, mob/user, flags)
- return TRUE
-
-/**
- * allow an item in suit storage slot?
- */
-/obj/item/proc/can_suit_storage(obj/item/I)
- // todo: this is awful
- return is_type_in_list(I, allowed)
-
-/**
- * checks if we need something to attach to in a certain slot
- *
- * todo: non-singular-letter proc args
- */
-/obj/item/proc/equip_check_beltlink(mob/M, slot, mob/user, flags)
- if(clothing_flags & CLOTHING_IGNORE_BELTLINK)
- return TRUE
-
- if(!ishuman(M))
- return TRUE
-
- var/mob/living/carbon/human/H = M
-
- switch(slot)
- if(SLOT_ID_LEFT_POCKET, SLOT_ID_RIGHT_POCKET)
- if(H.semantically_has_slot(SLOT_ID_UNIFORM) && !H.item_by_slot_id(SLOT_ID_UNIFORM))
- if(!(flags & INV_OP_SUPPRESS_WARNING))
- to_chat(H, SPAN_WARNING("You need a jumpsuit before you can attach [src]."))
- return FALSE
- if(SLOT_ID_WORN_ID)
- if(H.semantically_has_slot(SLOT_ID_UNIFORM) && !H.item_by_slot_id(SLOT_ID_UNIFORM))
- if(!(flags & INV_OP_SUPPRESS_WARNING))
- to_chat(H, SPAN_WARNING("You need a jumpsuit before you can attach [src]."))
- return FALSE
- if(SLOT_ID_BELT)
- if(H.semantically_has_slot(SLOT_ID_UNIFORM) && !H.item_by_slot_id(SLOT_ID_UNIFORM))
- if(!(flags & INV_OP_SUPPRESS_WARNING))
- to_chat(H, SPAN_WARNING("You need a jumpsuit before you can attach [src]."))
- return FALSE
- if(SLOT_ID_SUIT_STORAGE)
- if(H.semantically_has_slot(SLOT_ID_SUIT) && !H.item_by_slot_id(SLOT_ID_SUIT))
- if(!(flags & INV_OP_SUPPRESS_WARNING))
- to_chat(H, SPAN_WARNING("You need a suit before you can attach [src]."))
- return FALSE
- return TRUE
-
-/**
- * automatically unequip if we're missing beltlink
- */
-/obj/item/proc/reconsider_beltlink()
- var/mob/M = loc
- if(!istype(M))
- return
- if(!worn_slot)
- return
- if(!equip_check_beltlink(M, worn_slot, null, INV_OP_SILENT))
- M.drop_item_to_ground(src, INV_OP_SILENT)
- return
-
-//* Speed / Carry Weight *//
-
-/**
- * get the slowdown we incur when we're worn
- */
-/obj/item/proc/get_equipment_speed_mod()
- return slowdown
-
-//* ADVANCED: Wear-Over System *//
-
-/**
- * checks if we can fit over something
- *
- * todo: non-singular-letter proc args
- */
-/obj/item/proc/equip_worn_over_check(mob/M, slot, mob/user, obj/item/I, flags)
- return FALSE
-
-/**
- * call when we fit us over something - item should be already in us
- *
- * todo: non-singular-letter proc args
- */
-/obj/item/proc/equip_on_worn_over_insert(mob/M, slot, mob/user, obj/item/I, flags)
- if(!(flags & INV_OP_SUPPRESS_WARNING))
- to_chat(M, SPAN_NOTICE("You slip [src] over [I]."))
-
-/**
- * call when we unfit us over something - item should already be out of us
- *
- * todo: non-singular-letter proc args
- */
-/obj/item/proc/equip_on_worn_over_remove(mob/M, slot, mob/user, obj/item/I, flags)
-
-//* ADVANCED: Compound Objects *//
-
-/**
- * returns either an item or a list
- * get_equipped_items() uses this so accessories are included
- * anything this returns is considered to be in the same slot.
- *
- * * You must never return anything that would be returned when this is called on any other item!
- * Things can only be in one slot at a time, even with this compound-item system.
- */
-/obj/item/proc/inv_slot_attached()
- if(worn_over)
- return list(src) + worn_over.inv_slot_attached()
- else
- return src
-
//* Shieldcall registration
/obj/item/register_shieldcall(datum/shieldcall/delegate)
diff --git a/code/modules/clothing/clothing-inventory.dm b/code/modules/clothing/clothing-inventory.dm
new file mode 100644
index 000000000000..2e4e1bfaa75c
--- /dev/null
+++ b/code/modules/clothing/clothing-inventory.dm
@@ -0,0 +1,14 @@
+//* This file is explicitly licensed under the MIT license. *//
+//* Copyright (c) 2024 Citadel Station Developers *//
+
+// todo: relay on_equipped() normally; it's currently relay'd by equipped()
+
+/obj/item/clothing/on_unequipped(mob/wearer, slot_id_or_index, inv_op_flags, datum/event_args/actor/actor)
+ . = ..()
+ // Do not allow nested propagation.
+ if(!(inv_op_flags & INV_OP_IS_ACCESSORY) && length(accessories))
+ for(var/obj/item/acc as anything in accessories)
+ acc.on_unequipped(wearer, slot_id_or_index, inv_op_flags | INV_OP_IS_ACCESSORY, actor)
+
+// todo: relay on_pickup() normally; it's currently relay'd by pickup()
+// todo: relay on_dropped() normally; it's currently relay'd by dropped()
diff --git a/code/modules/clothing/under/accessories/accessory.dm b/code/modules/clothing/under/accessories/accessory.dm
index 393ead9c4f5f..cb59abd1bfaa 100644
--- a/code/modules/clothing/under/accessories/accessory.dm
+++ b/code/modules/clothing/under/accessories/accessory.dm
@@ -113,6 +113,7 @@
// todo: don't call dropped/pickup if going to same person
if(accessory_host.worn_slot)
unequipped(accessory_host.worn_mob(), accessory_host.worn_slot, INV_OP_IS_ACCESSORY)
+ module_state_1.on_unequipped(accessory_host.worn_mob(), accessory_host.worn_slot == SLOT_ID_HANDS ? accessory_host.worn_mob().get_held_index(accessory_host) : accessory_host.worn_slot , INV_OP_IS_ACCESSORY)
dropped(accessory_host.worn_mob(), INV_OP_IS_ACCESSORY)
// inventory handling stop
diff --git a/code/modules/hardsuits/rig_pieces.dm b/code/modules/hardsuits/rig_pieces.dm
index 471a9793cdc9..2d42ccb8919f 100644
--- a/code/modules/hardsuits/rig_pieces.dm
+++ b/code/modules/hardsuits/rig_pieces.dm
@@ -84,6 +84,10 @@
SPECIES_ZORREN_HIGH,
)
+/obj/item/clothing/gloves/gauntlets/hardsuit/equipped
+
+/obj/item/clothing/gloves/gauntlets/hardsuit
+
/obj/item/clothing/shoes/magboots/hardsuit
name = "boots"
atom_flags = PHORONGUARD
diff --git a/code/modules/mob/living/carbon/human/human_defines.dm b/code/modules/mob/living/carbon/human/human_defines.dm
index b87a9859e57f..13e8421ce890 100644
--- a/code/modules/mob/living/carbon/human/human_defines.dm
+++ b/code/modules/mob/living/carbon/human/human_defines.dm
@@ -217,8 +217,6 @@
/// Instead of new say code calling GetVoice() over and over and over, we're just going to ask this variable, which gets updated in Life()
var/voice = ""
- /// Toggle for the mime's abilities. //TODO Readd mime stuff :(
- //var/miming = null
/// For changing our voice. Used by a symptom.
var/special_voice = ""
diff --git a/code/modules/mob/living/living-inventory.dm b/code/modules/mob/living/living-inventory.dm
index f9462d1af51d..a2468b6c1769 100644
--- a/code/modules/mob/living/living-inventory.dm
+++ b/code/modules/mob/living/living-inventory.dm
@@ -67,7 +67,7 @@
var/flat_encumbrance = 0
for(var/obj/item/I as anything in get_equipped_items())
tally_weight += (I.weight_registered = I.get_weight())
- if(I.is_held())
+ if(I.is_being_held())
if(!(I.item_flags & ITEM_ENCUMBERS_WHILE_HELD))
I.encumbrance_registered = null
continue
diff --git a/code/modules/mob/living/silicon/robot/inventory.dm b/code/modules/mob/living/silicon/robot/inventory.dm
index f08ddfd06dc4..abb3dd94c120 100644
--- a/code/modules/mob/living/silicon/robot/inventory.dm
+++ b/code/modules/mob/living/silicon/robot/inventory.dm
@@ -30,6 +30,7 @@
client.screen -= module_state_1
contents -= module_state_1
module_state_1.unequipped(src, SLOT_ID_HANDS, NONE)
+ module_state_1.on_unequipped(src, 1, NONE)
module_active = null
module_state_1:loc = module //So it can be used again later
module_state_1 = null
@@ -41,6 +42,7 @@
client.screen -= module_state_2
contents -= module_state_2
module_state_2.unequipped(src, SLOT_ID_HANDS, NONE)
+ module_state_1.on_unequipped(src, 2, NONE)
module_active = null
module_state_2:loc = module
module_state_2 = null
@@ -52,6 +54,7 @@
client.screen -= module_state_3
contents -= module_state_3
module_state_3.unequipped(src, SLOT_ID_HANDS, NONE)
+ module_state_1.on_unequipped(src, 3, NONE)
module_active = null
module_state_3:loc = module
module_state_3 = null
@@ -69,6 +72,7 @@
contents -= module_state_1
module_state_1:loc = module
module_state_1.unequipped(src, SLOT_ID_HANDS, NONE)
+ module_state_1.on_unequipped(src, 1, NONE)
module_state_1 = null
inv1.icon_state = "inv1"
if(module_state_2)
@@ -79,6 +83,7 @@
contents -= module_state_2
module_state_2:loc = module
module_state_2.unequipped(src, SLOT_ID_HANDS, NONE)
+ module_state_1.on_unequipped(src, 2, NONE)
module_state_2 = null
inv2.icon_state = "inv2"
if(module_state_3)
@@ -89,6 +94,7 @@
contents -= module_state_3
module_state_3:loc = module
module_state_3.unequipped(src, SLOT_ID_HANDS, NONE)
+ module_state_1.on_unequipped(src, 3, NONE)
module_state_3 = null
inv3.icon_state = "inv3"
updateicon()
diff --git a/code/modules/mob/mob-inventory-abstraction.dm b/code/modules/mob/mob-inventory-abstraction.dm
index bf81bf9eecbf..22cfe5f3bc85 100644
--- a/code/modules/mob/mob-inventory-abstraction.dm
+++ b/code/modules/mob/mob-inventory-abstraction.dm
@@ -218,6 +218,7 @@
I.held_index = null
I.unequipped(src, SLOT_ID_HANDS, flags)
+ I.on_unequipped(src, index, flags)
if(!(flags & INV_OP_NO_UPDATE_ICONS))
update_inv_hand(index)
diff --git a/code/modules/mob/mob-inventory-internal.dm b/code/modules/mob/mob-inventory-internal.dm
index b3421051cdb8..b5c344b06b13 100644
--- a/code/modules/mob/mob-inventory-internal.dm
+++ b/code/modules/mob/mob-inventory-internal.dm
@@ -104,8 +104,9 @@
if(!can_unequip(I, I.worn_slot, flags, user))
return FALSE
old = I.worn_slot
- _unequip_slot(I.worn_slot, flags)
- I.unequipped(src, I.worn_slot, flags)
+ _unequip_slot(old, flags)
+ I.on_unequipped(src, old, flags)
+ I.unequipped(src, old, flags)
handle_item_denesting(I, old, flags, user)
// this qdeleted catches unequipped() deleting the item.
@@ -257,6 +258,7 @@
unequip_hand_impl(I, get_held_index(I), flags)
else
_unequip_slot(old_slot, flags)
+ I.on_unequipped(src, old_slot, flags)
I.unequipped(src, old_slot, flags)
// sigh
handle_item_denesting(I, old_slot, flags, user)
@@ -280,6 +282,7 @@
else
_unequip_slot(old_slot, flags)
I.unequipped(src, old_slot, flags)
+ I.on_unequipped(src, old_slot, flags)
// TODO: HANDLE DELETIONS ON EQUIPPED PROPERLY
// sigh
_equip_slot(I, slot, flags)
From c8bd2c905a3357e5518314594aa325ab1dd0830e Mon Sep 17 00:00:00 2001
From: silicons <2003111+silicons@users.noreply.github.com>
Date: Thu, 28 Nov 2024 13:35:00 -0500
Subject: [PATCH 08/18] fixes
---
code/datums/outfits/costumes/halloween.dm | 4 +-
code/game/objects/items/defib/shockpaddles.dm | 5 +-
code/game/objects/items/stacks/medical.dm | 2 +-
.../objects/items/weapons/gift_wrappaper.dm | 2 +-
code/modules/detectivework/forensics.dm | 6 +--
.../detectivework/tools/sample_kits.dm | 2 +-
code/modules/hydroponics/grown.dm | 2 +-
.../jobs/job_types/station/command/captain.dm | 2 +-
code/modules/materials/material_sheets.dm | 2 +-
code/modules/mob/inventory/inventory-get.dm | 3 +-
.../mob/inventory/inventory-hands-get.dm | 47 ++++++++++++++---
code/modules/mob/inventory/inventory-hooks.dm | 4 +-
.../mob/inventory/inventory-slot-equip.dm | 50 +++++++++++++++----
.../mob/inventory/inventory-slot-get.dm | 40 +++++++++++++--
code/modules/mob/inventory/inventory.dm | 14 +++---
code/modules/mob/inventory/inventory_slot.dm | 23 ++++++++-
code/modules/mob/mob-inventory-internal.dm | 2 -
17 files changed, 165 insertions(+), 45 deletions(-)
diff --git a/code/datums/outfits/costumes/halloween.dm b/code/datums/outfits/costumes/halloween.dm
index bf0a942d6779..abbf6f82085c 100644
--- a/code/datums/outfits/costumes/halloween.dm
+++ b/code/datums/outfits/costumes/halloween.dm
@@ -41,7 +41,7 @@
r_hand = /obj/item/gun/ballistic/revolver/capgun
/datum/outfit/costume/horrorcop/post_equip(var/mob/living/carbon/human/H)
- var/obj/item/clothing/under/U = H.w_uniform
+ var/obj/item/clothing/under/U = H.inventory.get_slot(/datum/inventory_slot/inventory/uniform)
if(LAZYLEN(U.accessories))
for(var/obj/item/clothing/accessory/A in U.accessories)
if(istype(A, /obj/item/clothing/accessory/holster))
@@ -58,7 +58,7 @@
r_hand = /obj/item/gun/ballistic/revolver/capgun
/datum/outfit/costume/cowboy/post_equip(var/mob/living/carbon/human/H)
- var/obj/item/clothing/under/U = H.w_uniform
+ var/obj/item/clothing/under/U = H.inventory.get_slot(/datum/inventory_slot/inventory/uniform)
if(LAZYLEN(U.accessories))
for(var/obj/item/clothing/accessory/A in U.accessories)
if(istype(A, /obj/item/clothing/accessory/holster))
diff --git a/code/game/objects/items/defib/shockpaddles.dm b/code/game/objects/items/defib/shockpaddles.dm
index 80ea15055a58..5e9a0a94563d 100644
--- a/code/game/objects/items/defib/shockpaddles.dm
+++ b/code/game/objects/items/defib/shockpaddles.dm
@@ -105,7 +105,10 @@
/obj/item/shockpaddles/proc/check_contact(mob/living/carbon/human/H)
if(!combat)
- for(var/obj/item/clothing/cloth in list(H.wear_suit, H.w_uniform))
+ for(var/obj/item/clothing/cloth in H.get_slots(
+ /datum/inventory_slot/inventory/uniform,
+ /datum/inventory_slot/inventory/suit,
+ ))
if((cloth.body_cover_flags & UPPER_TORSO) && (cloth.clothing_flags & CLOTHING_THICK_MATERIAL))
return FALSE
return TRUE
diff --git a/code/game/objects/items/stacks/medical.dm b/code/game/objects/items/stacks/medical.dm
index abd4f53a4475..051fd0ccf74e 100644
--- a/code/game/objects/items/stacks/medical.dm
+++ b/code/game/objects/items/stacks/medical.dm
@@ -44,7 +44,7 @@
to_chat(user, "You can't apply [src] through [H.head]!")
return FALSE
else
- if(H.wear_suit && istype(H.wear_suit,/obj/item/clothing/suit/space))
+ if(istype(H.inventory.get_slot(/datum/inventory_slot/inventory/suit), /obj/item/clothing/suit/space))
to_chat(user, "You can't apply [src] through [H.wear_suit]!")
return FALSE
diff --git a/code/game/objects/items/weapons/gift_wrappaper.dm b/code/game/objects/items/weapons/gift_wrappaper.dm
index 5d3212747275..e7597e27e03f 100644
--- a/code/game/objects/items/weapons/gift_wrappaper.dm
+++ b/code/game/objects/items/weapons/gift_wrappaper.dm
@@ -276,7 +276,7 @@
return
var/mob/living/carbon/human/H = target
- if (istype(H.wear_suit, /obj/item/clothing/suit/straight_jacket) || H.stat)
+ if (istype(H.inventory.get_slot(/datum/inventory_slot/inventory/suit), /obj/item/clothing/suit/straight_jacket) || H.stat)
if (src.amount > 2)
var/obj/effect/spresent/present = new /obj/effect/spresent (H.loc)
src.amount -= 2
diff --git a/code/modules/detectivework/forensics.dm b/code/modules/detectivework/forensics.dm
index 59b7aa88503e..a9aea73a6154 100644
--- a/code/modules/detectivework/forensics.dm
+++ b/code/modules/detectivework/forensics.dm
@@ -24,20 +24,20 @@ var/const/FINGERPRINT_COMPLETE = 6
var/fibertext
var/item_multiplier = istype(src,/obj/item)?1.2:1
var/suit_coverage = 0
- if(istype(M.inventory.get_item_in_slot(/datum/inventory_slot/inventory/suit::id), /obj/item/clothing))
+ if(istype(M.inventory.get_slot(/datum/inventory_slot/inventory/suit::id), /obj/item/clothing))
var/obj/item/clothing/C = M.wear_suit
fibertext = C.get_fibers()
if(fibertext && prob(10*item_multiplier))
suit_fibers |= fibertext
suit_coverage = C.body_cover_flags
- if(istype(M.inventory.get_item_in_slot(/datum/inventory_slot/inventory/uniform::id), /obj/item/clothing) && (M.w_uniform.body_cover_flags & ~suit_coverage))
+ if(istype(M.inventory.get_slot(/datum/inventory_slot/inventory/uniform::id), /obj/item/clothing) && (M.w_uniform.body_cover_flags & ~suit_coverage))
var/obj/item/clothing/C = M.w_uniform
fibertext = C.get_fibers()
if(fibertext && prob(15*item_multiplier))
suit_fibers |= fibertext
- if(istype(M.inventory.get_item_in_slot(/datum/inventory_slot/inventory/gloves::id), /obj/item/clothing) && (M.gloves.body_cover_flags & ~suit_coverage))
+ if(istype(M.inventory.get_slot(/datum/inventory_slot/inventory/gloves::id), /obj/item/clothing) && (M.gloves.body_cover_flags & ~suit_coverage))
var/obj/item/clothing/C = M.gloves
fibertext = C.get_fibers()
if(fibertext && prob(20*item_multiplier))
diff --git a/code/modules/detectivework/tools/sample_kits.dm b/code/modules/detectivework/tools/sample_kits.dm
index ceab3010b679..e53b3b06217b 100644
--- a/code/modules/detectivework/tools/sample_kits.dm
+++ b/code/modules/detectivework/tools/sample_kits.dm
@@ -69,7 +69,7 @@
if(!ishuman(user))
return
var/mob/living/carbon/human/H = user
- var/obj/item/wearing_gloves = H.inventory.get_item_in_slot(/datum/inventory_slot/inventory/gloves::id)
+ var/obj/item/wearing_gloves = H.inventory.get_slot(/datum/inventory_slot/inventory/gloves::id)
if(wearing_gloves)
to_chat(user, "Take \the [wearing_gloves] off first.")
return
diff --git a/code/modules/hydroponics/grown.dm b/code/modules/hydroponics/grown.dm
index eca52835d049..e1807a7ddab0 100644
--- a/code/modules/hydroponics/grown.dm
+++ b/code/modules/hydroponics/grown.dm
@@ -316,7 +316,7 @@
return
if(seed.get_trait(TRAIT_STINGS))
var/mob/living/carbon/human/H = user
- if(H.inventory.get_item_in_slot(/datum/inventory_slot/inventory/gloves::id))
+ if(H.inventory.get_slot(/datum/inventory_slot/inventory/gloves::id))
return
if(!reagents || reagents.total_volume <= 0)
return
diff --git a/code/modules/jobs/job_types/station/command/captain.dm b/code/modules/jobs/job_types/station/command/captain.dm
index 87dd8c513ac4..661e5f4e6515 100644
--- a/code/modules/jobs/job_types/station/command/captain.dm
+++ b/code/modules/jobs/job_types/station/command/captain.dm
@@ -70,7 +70,7 @@ var/datum/legacy_announcement/minor/captain_announcement = new(do_newscast = 1)
if(H.age>49)
// Since we can have something other than the default uniform at this
// point, check if we can actually attach the medal
- var/obj/item/clothing/uniform = H.w_uniform
+ var/obj/item/clothing/uniform = H.inventory.get_slot(/datum/inventory_slot/inventory/uniform::id)
if(uniform)
var/obj/item/clothing/accessory/medal/gold/captain/medal = new()
if(uniform.can_attach_accessory(medal))
diff --git a/code/modules/materials/material_sheets.dm b/code/modules/materials/material_sheets.dm
index 32c9e5ac4a42..34efdd2da5ff 100644
--- a/code/modules/materials/material_sheets.dm
+++ b/code/modules/materials/material_sheets.dm
@@ -311,7 +311,7 @@
var/burn_user = TRUE
if(istype(M, /mob/living/carbon/human))
var/mob/living/carbon/human/H = user
- var/obj/item/clothing/gloves/G = H.inventory.get_item_in_slot(/datum/inventory_slot/inventory/gloves::id)
+ var/obj/item/clothing/gloves/G = H.inventory.get_slot(/datum/inventory_slot/inventory/gloves::id)
if(istype(G) && ((G.clothing_flags & CLOTHING_THICK_MATERIAL && prob(70)) || istype(G, /obj/item/clothing/gloves/gauntlets)))
burn_user = FALSE
diff --git a/code/modules/mob/inventory/inventory-get.dm b/code/modules/mob/inventory/inventory-get.dm
index 6d9b57925e02..b6791df8be98 100644
--- a/code/modules/mob/inventory/inventory-get.dm
+++ b/code/modules/mob/inventory/inventory-get.dm
@@ -18,7 +18,7 @@
*
* @return list() of items
*/
-/datum/inventory/proc/get_equipped_items(filter_exclude, compound) as /list
+/datum/inventory/proc/get_everything(filter_exclude, compound) as /list
. = list()
if(compound)
for(var/slot_id in base_inventory_slots)
@@ -33,6 +33,7 @@
var/datum/inventory_slot/slot_meta = resolve_inventory_slot(slot_id)
if(slot_meta.inventory_slot_filter & filter_exclude)
continue
+ var/obj/item/in_slot = owner._item_by_slot(slot_id)
if(in_slot)
. += in_slot
if(!(filter_exclude & INV_SLOT_FILTER_HANDS))
diff --git a/code/modules/mob/inventory/inventory-hands-get.dm b/code/modules/mob/inventory/inventory-hands-get.dm
index 4a9a80ec96b3..3b50e18022a6 100644
--- a/code/modules/mob/inventory/inventory-hands-get.dm
+++ b/code/modules/mob/inventory/inventory-hands-get.dm
@@ -4,27 +4,60 @@
/**
* Gets the item held in a given hand index
*
- * * This expects a valid index.
+ * * This only includes the topmost item in a slot, and ignores compound / attached items.
*
- * @return /obj/item or null.
+ * @return /obj/item or null
*/
-/datum/inventory/proc/get_item_in_hand(index) as /obj/item
+/datum/inventory/proc/get_hand(index) as /obj/item
+ if(index < 1 || index > length(held_items))
+ return
return held_items[index]
/**
* Gets the item held in a given hand index
*
- * * This expects a valid index.
- * * This returns a list, and includes all items in compound items.
+ * * This includes all items in a hand slot including nested and compound/attached items.
*
- * @return /obj/item or null.
+ * @return list() of items
*/
-/datum/inventory/proc/get_items_in_hand(index) as /obj/item
+/datum/inventory/proc/get_hand_multi(index) as /list
+ if(index < 1 || index > length(held_items))
+ return
var/obj/item/held = held_items[index]
if(!held)
return
return held.inv_slot_attached()
+/**
+ * Gets items in given hand indices.
+ *
+ * * This does not check that 'indices' list is deduped, or that the hands exist.
+ *
+ * Non-compound mode:
+ * * This returns a list, and includes only the topmost item in a slot.
+ *
+ * Compound mode:
+ * * This returns a list, and includes all items in compound items.
+ *
+ * @params
+ * * indices - List of indices, or null for all hands. This list must be deduped, or the resulting list will be duped.
+ * * compound - Compound mode?
+ *
+ * @return list() of items
+ */
+/datum/inventory/proc/get_hands_unsafe(list/indices, compound) as /list
+ . = list()
+ if(indices)
+ for(var/index in indices)
+ if(index < 1 || index > length(held_items))
+ continue
+ var/obj/item/maybe_held = held_items[index]
+ if(maybe_held)
+ . += compound ? maybe_held.inv_slot_attached() : maybe_held
+ else
+ for(var/obj/item/held in held_items)
+ . += compound ? held.inv_slot_attached() : maybe_held
+
// todo: old below
//* Basic *//
diff --git a/code/modules/mob/inventory/inventory-hooks.dm b/code/modules/mob/inventory/inventory-hooks.dm
index a52382909040..ecc5d06d67f0 100644
--- a/code/modules/mob/inventory/inventory-hooks.dm
+++ b/code/modules/mob/inventory/inventory-hooks.dm
@@ -1,7 +1,7 @@
//* This file is explicitly licensed under the MIT license. *//
//* Copyright (c) 2024 Citadel Station Developers *//
-//* Item enter / exit *//
+//* Internal Calls *//
/**
* Should be called when an item is added to inventory.
@@ -48,6 +48,8 @@
for(var/datum/actor_hud/inventory/hud in huds_using)
hud.move_item(item, from_slot_or_index, to_slot_or_index)
+//* External Calls *//
+
/**
* Should be called when the mob's mobility flags change.
*/
diff --git a/code/modules/mob/inventory/inventory-slot-equip.dm b/code/modules/mob/inventory/inventory-slot-equip.dm
index efd2549cf353..21cbe837e1e4 100644
--- a/code/modules/mob/inventory/inventory-slot-equip.dm
+++ b/code/modules/mob/inventory/inventory-slot-equip.dm
@@ -4,18 +4,30 @@
/**
* Equips an item to a slot or deletes it.
*
+ * @params
+ * * Entity - Item being equipped.
+ * * type_or_id - A typepath, or string ID.
+ * * inv_op_flags - INV_OP_* bits.
+ * * actors - Actor data of who did it.
+ *
* @return TRUE / FALSE
*/
-/datum/inventory/proc/equip_to_slot_or_del(obj/item/entity, datum/inventory_slot/slot_or_id, inv_op_flags, datum/event_args/actor/actor)
- return owner.equip_to_slot_or_del(entity, slot_or_id, inv_op_flags, actor?.performer)
+/datum/inventory/proc/equip_to_slot_or_del(obj/item/entity, datum/inventory_slot/type_or_id, inv_op_flags, datum/event_args/actor/actor)
+ return owner.equip_to_slot_or_del(entity, type_or_id, inv_op_flags, actor?.performer)
/**
* Equips an item to a slot or drops it beneath our owner.
*
+ * @params
+ * * Entity - Item being equipped.
+ * * type_or_id - A typepath, or string ID.
+ * * inv_op_flags - INV_OP_* bits.
+ * * actors - Actor data of who did it.
+ *
* @return TRUE / FALSE
*/
-/datum/inventory/proc/equip_to_slot_or_drop(obj/item/entity, datum/inventory_slot/slot_or_id, inv_op_flags, datum/event_args/actor/actor)
- if(!owner.equip_to_slot_if_possible(entity, slot_or_id, inv_op_flags, actor?.performer))
+/datum/inventory/proc/equip_to_slot_or_drop(obj/item/entity, datum/inventory_slot/type_or_id, inv_op_flags, datum/event_args/actor/actor)
+ if(!owner.equip_to_slot_if_possible(entity, type_or_id, inv_op_flags, actor?.performer))
entity.forceMove(owner.drop_location())
return FALSE
return TRUE
@@ -23,23 +35,41 @@
/**
* Equips an item to a slot if possible
*
+ * @params
+ * * Entity - Item being equipped.
+ * * type_or_id - A typepath, or string ID.
+ * * inv_op_flags - INV_OP_* bits.
+ * * actors - Actor data of who did it.
+ *
* @return TRUE / FALSE
*/
-/datum/inventory/proc/equip_to_slot_if_possible(obj/item/entity, datum/inventory_slot/slot_or_id, inv_op_flags, datum/event_args/actor/actor)
- return owner.equip_to_slot_if_possible(entity, slot_or_id, inv_op_flags, actor?.performer)
+/datum/inventory/proc/equip_to_slot_if_possible(obj/item/entity, datum/inventory_slot/type_or_id, inv_op_flags, datum/event_args/actor/actor)
+ return owner.equip_to_slot_if_possible(entity, type_or_id, inv_op_flags, actor?.performer)
/**
* Equips an item to a slot forcefully, trampling anything in the way.
*
+ * @params
+ * * Entity - Item being equipped.
+ * * type_or_id - A typepath, or string ID.
+ * * inv_op_flags - INV_OP_* bits.
+ * * actors - Actor data of who did it.
+ *
* @return TRUE / FALSE
*/
-/datum/inventory/proc/equip_to_slot_forcefully(obj/item/entity, datum/inventory_slot/slot_or_id, inv_op_flags, datum/event_args/actor/actor)
- return owner._equip_item(entity, inv_op_flags | INV_OP_FORCE, slot_or_id, actor?.performer)
+/datum/inventory/proc/equip_to_slot_forcefully(obj/item/entity, datum/inventory_slot/type_or_id, inv_op_flags, datum/event_args/actor/actor)
+ return owner._equip_item(entity, inv_op_flags | INV_OP_FORCE, type_or_id, actor?.performer)
/**
* Equips an item to a slot. This is the advanced version of the proc that returns an INV_RETURN_* result.
*
+ * @params
+ * * Entity - Item being equipped.
+ * * type_or_id - A typepath, or string ID.
+ * * inv_op_flags - INV_OP_* bits.
+ * * actors - Actor data of who did it.
+ *
* @return INV_RETURN_*
*/
-/datum/inventory/proc/equip_to_slot(obj/item/entity, datum/inventory_slot/slot_or_id, inv_op_flags, datum/event_args/actor/actor)
- return owner._equip_item(entity, inv_op_flags, slot_or_id, actor?.performer) ? INV_RETURN_SUCCESS : INV_RETURN_FAILED
+/datum/inventory/proc/equip_to_slot(obj/item/entity, datum/inventory_slot/type_or_id, inv_op_flags, datum/event_args/actor/actor)
+ return owner._equip_item(entity, inv_op_flags, type_or_id, actor?.performer) ? INV_RETURN_SUCCESS : INV_RETURN_FAILED
diff --git a/code/modules/mob/inventory/inventory-slot-get.dm b/code/modules/mob/inventory/inventory-slot-get.dm
index 9978d7dddaee..1aafc2093f97 100644
--- a/code/modules/mob/inventory/inventory-slot-get.dm
+++ b/code/modules/mob/inventory/inventory-slot-get.dm
@@ -8,11 +8,13 @@
* * For compound items, this only returns the outermost / host / root.
*
* @params
- * * slot_id - slot ID
+ * * type_or_id - slot typepath or id
*
* @return /obj/item or null
*/
-/datum/inventory/proc/get_item_in_slot(slot_id) as /obj/item
+/datum/inventory/proc/get_slot(datum/inventory_slot/type_or_id) as /obj/item
+ if(ispath(type_or_id))
+ type_or_id = initial(type_or_id.id)
. = owner._item_by_slot(slot_id)
if(. == INVENTORY_SLOT_DOES_NOT_EXIST)
return null
@@ -24,11 +26,13 @@
* * If multiple items are compounded on one item (e.g. clothing accessories), this gets all of them.
*
* @params
- * * slot_id - slot ID
+ * * type_or_id - slot typepath or id
*
* @return list() of items
*/
-/datum/inventory/proc/get_items_in_slot(slot_id) as /list
+/datum/inventory/proc/get_slot_multi(datum/inventory_slot/type_or_id) as /list
+ if(ispath(type_or_id))
+ type_or_id = initial(type_or_id.id)
var/obj/item/in_slot = owner._item_by_slot(slot_id)
if(in_slot == INVENTORY_SLOT_DOES_NOT_EXIST)
return
@@ -36,3 +40,31 @@
. = in_slot.inv_slot_attached()
if(!islist(.))
. = . ? list(.) : list()
+
+/**
+ * Gets the item in a list of slots.
+ *
+ * * This does not check that the provided slot list is deduped.
+ *
+ * Non-compound mode:
+ * * If multiple items are worn over each other in a slot, this gets the topmost.
+ * * For compound items, this only returns the outermost / host / root.
+ *
+ * Compound mode:
+ * * If multiple items are worn over each other in a slot, this gets all of them.
+ * * If multiple items are compounded on one item (e.g. clothing accessories), this gets all of them.
+ *
+ * @params
+ * * types_or_ids - slot types / IDs. Defaults to all slots if not provided. This dupe must be deduped, or the resulting list will be duped.
+ * * compound - Compound mode?
+ *
+ * @return list() of items
+ */
+/datum/inventory/proc/get_slots_unsafe(list/types_or_ids, compound) as /list
+ . = list()
+ for(var/datum/inventory_slot/slot_id as anything in slot_ids || base_inventory_slots)
+ if(ispath(slot_id))
+ slot_id = initial(slot_id.id)
+ var/obj/item/fetched = owner._item_by_slot(slot_id)
+ if(istype(fetched))
+ . += compound ? fetched.inv_slot_attached() : fetched
diff --git a/code/modules/mob/inventory/inventory.dm b/code/modules/mob/inventory/inventory.dm
index 197ac691ea81..388eb15ee8ee 100644
--- a/code/modules/mob/inventory/inventory.dm
+++ b/code/modules/mob/inventory/inventory.dm
@@ -16,13 +16,6 @@
/// our action holder
var/datum/action_holder/actions
- //* Caches *//
- /// cached overlays by slot id or hand index
- var/list/rendered_normal_overlays = list()
- /// cached overlays by slot id
- // todo: emissives
- // var/list/rendered_emissive_overlays = list()
-
//* HUDs *//
/// Actor HUDs using us
var/list/datum/actor_hud/inventory/huds_using
@@ -36,6 +29,13 @@
/// * 2, 4, 6, ... are right
var/list/obj/item/held_items = list()
+ //* Rendering *//
+ /// cached overlays by slot id or hand index
+ var/list/rendered_normal_overlays = list()
+ /// cached overlays by slot id
+ // todo: emissives
+ // var/list/rendered_emissive_overlays = list()
+
//* Slots *//
/// our base slot ids associated to remappings
///
diff --git a/code/modules/mob/inventory/inventory_slot.dm b/code/modules/mob/inventory/inventory_slot.dm
index 0c2e7fec3eae..8d915f171839 100644
--- a/code/modules/mob/inventory/inventory_slot.dm
+++ b/code/modules/mob/inventory/inventory_slot.dm
@@ -94,7 +94,12 @@ GLOBAL_LIST_EMPTY(inventory_slot_type_cache)
/// flags
var/inventory_slot_flags = INV_SLOT_IS_RENDERED
/// filter flags
- var/inventory_slot_filter = INVENTORY_SLOT_FILTER_UNKNOWN
+ var/inventory_slot_filter = INV_SLOT_FILTER_UNKNOWN
+ /// semantic layer
+ ///
+ /// * higher = outer, lower = inner
+ /// * outer ones intercept hits/whatnot first
+ var/semantic_layer = 0
/// display order - higher is upper. a
is applied on 0.
var/sort_order = 0
@@ -277,6 +282,7 @@ GLOBAL_LIST_EMPTY(inventory_slot_type_cache)
name = "back"
render_key = "back"
id = SLOT_ID_BACK
+ semantic_layer = 100
sort_order = 2000
display_name = "back"
display_preposition = "on"
@@ -304,6 +310,7 @@ GLOBAL_LIST_EMPTY(inventory_slot_type_cache)
name = "uniform"
render_key = "under"
id = SLOT_ID_UNIFORM
+ semantic_layer = 0
sort_order = 5000
display_name = "body"
display_preposition = "on"
@@ -433,6 +440,7 @@ GLOBAL_LIST_EMPTY(inventory_slot_type_cache)
name = "head"
render_key = "head"
id = SLOT_ID_HEAD
+ semantic_layer = /datum/inventory_slot/inventory/uniform::semantic_layer + 1
sort_order = 10000
display_name = "head"
display_preposition = "on"
@@ -474,6 +482,7 @@ GLOBAL_LIST_EMPTY(inventory_slot_type_cache)
name = "outerwear"
render_key = "suit"
id = SLOT_ID_SUIT
+ semantic_layer = /datum/inventory_slot/inventory/uniform::semantic_layer + 10
sort_order = 7000
display_name = "suit"
display_preposition = "over"
@@ -548,6 +557,7 @@ GLOBAL_LIST_EMPTY(inventory_slot_type_cache)
name = "belt"
render_key = "belt"
id = SLOT_ID_BELT
+ semantic_layer = /datum/inventory_slot/inventory/uniform::semantic_layer + 15
sort_order = 6000
display_name = "waist"
display_preposition = "on"
@@ -588,6 +598,7 @@ GLOBAL_LIST_EMPTY(inventory_slot_type_cache)
id = SLOT_ID_LEFT_POCKET
display_name = "left pocket"
display_preposition = "in"
+ semantic_layer = /datum/inventory_slot/inventory/uniform::semantic_layer + 1
inventory_hud_anchor = INVENTORY_HUD_ANCHOR_TO_HANDS
inventory_hud_main_axis = 1
@@ -599,6 +610,7 @@ GLOBAL_LIST_EMPTY(inventory_slot_type_cache)
id = SLOT_ID_RIGHT_POCKET
display_name = "right pocket"
display_preposition = "in"
+ semantic_layer = /datum/inventory_slot/inventory/uniform::semantic_layer + 1
inventory_hud_anchor = INVENTORY_HUD_ANCHOR_TO_HANDS
inventory_hud_main_axis = 2
@@ -612,6 +624,7 @@ GLOBAL_LIST_EMPTY(inventory_slot_type_cache)
sort_order = 3000
display_name = "badge"
display_preposition = "as"
+ semantic_layer = /datum/inventory_slot/inventory/uniform::semantic_layer + 1
inventory_hud_anchor = INVENTORY_HUD_ANCHOR_TO_HANDS
inventory_hud_main_axis = -3
@@ -645,6 +658,7 @@ GLOBAL_LIST_EMPTY(inventory_slot_type_cache)
name = "shoes"
render_key = "shoes"
id = SLOT_ID_SHOES
+ semantic_layer = /datum/inventory_slot/inventory/uniform::semantic_layer + 3
sort_order = 4000
display_name = "feet"
display_preposition = "on"
@@ -686,6 +700,7 @@ GLOBAL_LIST_EMPTY(inventory_slot_type_cache)
name = "gloves"
render_key = "gloves"
id = SLOT_ID_GLOVES
+ semantic_layer = /datum/inventory_slot/inventory/uniform::semantic_layer + 3
sort_order = 6500
display_name = "hands"
display_preposition = "on"
@@ -715,6 +730,7 @@ GLOBAL_LIST_EMPTY(inventory_slot_type_cache)
name = "glasses"
render_key = "glasses"
id = SLOT_ID_GLASSES
+ semantic_layer = /datum/inventory_slot/inventory/uniform::semantic_layer + 3
sort_order = 7500
display_name = "eyes"
display_preposition = "over"
@@ -744,6 +760,7 @@ GLOBAL_LIST_EMPTY(inventory_slot_type_cache)
name = "suit storage"
render_key = "suit-store"
id = SLOT_ID_SUIT_STORAGE
+ semantic_layer = /datum/inventory_slot/inventory/uniform::semantic_layer + 20
sort_order = 500
display_name = "suit"
display_preposition = "on"
@@ -782,6 +799,7 @@ GLOBAL_LIST_EMPTY(inventory_slot_type_cache)
sort_order = 9500
abstract_type = /datum/inventory_slot/inventory/ears
inventory_slot_flags = INV_SLOT_IS_RENDERED | INV_SLOT_IS_INVENTORY | INV_SLOT_IS_STRIPPABLE | INV_SLOT_CONSIDERED_WORN | INV_SLOT_HUD_REQUIRES_EXPAND
+ semantic_layer = /datum/inventory_slot/inventory/uniform::semantic_layer + 3
render_default_icons = list(
BODYTYPE_STRING_DEFAULT = 'icons/mob/clothing/ears.dmi',
BODYTYPE_STRING_TESHARI = 'icons/mob/clothing/species/teshari/ears.dmi',
@@ -832,6 +850,7 @@ GLOBAL_LIST_EMPTY(inventory_slot_type_cache)
name = "mask"
render_key = "mask"
id = SLOT_ID_MASK
+ semantic_layer = /datum/inventory_slot/inventory/uniform::semantic_layer + 3
sort_order = 9250
display_name = "face"
display_preposition = "on"
@@ -886,6 +905,7 @@ GLOBAL_LIST_EMPTY(inventory_slot_type_cache)
display_name = "hands"
display_preposition = "around"
slot_equip_checks = SLOT_EQUIP_CHECK_USE_PROC
+ semantic_layer = /datum/inventory_slot/inventory/uniform::semantic_layer + 30
render_default_icons = list(
BODYTYPE_STRING_DEFAULT = 'icons/mob/mob.dmi',
BODYTYPE_STRING_TESHARI = 'icons/mob/clothing/species/teshari/handcuffs.dmi',
@@ -903,6 +923,7 @@ GLOBAL_LIST_EMPTY(inventory_slot_type_cache)
display_name = "legs"
display_preposition = "around"
slot_equip_checks = SLOT_EQUIP_CHECK_USE_PROC
+ semantic_layer = /datum/inventory_slot/inventory/uniform::semantic_layer + 30
render_default_icons = list(
BODYTYPE_STRING_DEFAULT = 'icons/mob/mob.dmi',
BODYTYPE_STRING_TESHARI = 'icons/mob/clothing/species/teshari/handcuffs.dmi',
diff --git a/code/modules/mob/mob-inventory-internal.dm b/code/modules/mob/mob-inventory-internal.dm
index b5c344b06b13..8a4e0bbe2b8c 100644
--- a/code/modules/mob/mob-inventory-internal.dm
+++ b/code/modules/mob/mob-inventory-internal.dm
@@ -165,8 +165,6 @@
* @return TRUE/FALSE on success
*/
/mob/proc/_equip_item(obj/item/I, flags, slot, mob/user = src)
- PROTECTED_PROC(TRUE)
-
if(!I) // how tf would we put on "null"?
return FALSE
From 8e9bda1ef9aaecb713ae380cbf93938aea231c43 Mon Sep 17 00:00:00 2001
From: silicons <2003111+silicons@users.noreply.github.com>
Date: Thu, 28 Nov 2024 13:35:06 -0500
Subject: [PATCH 09/18] fixes
---
code/__DEFINES/inventory/slots.dm | 11 ++++++++++-
code/datums/outfits/costumes/halloween.dm | 4 ++--
code/game/objects/items/defib/shockpaddles.dm | 2 +-
code/game/objects/items/stacks/medical.dm | 2 +-
code/game/objects/items/weapons/gift_wrappaper.dm | 2 +-
code/modules/clothing/under/accessories/accessory.dm | 2 +-
code/modules/detectivework/forensics.dm | 6 +++---
code/modules/detectivework/tools/sample_kits.dm | 2 +-
code/modules/hydroponics/grown.dm | 2 +-
.../modules/jobs/job_types/station/command/captain.dm | 2 +-
code/modules/materials/material_sheets.dm | 2 +-
code/modules/mob/inventory/inventory-hands-get.dm | 6 +++---
code/modules/mob/inventory/inventory-slot-get.dm | 10 +++++-----
code/modules/projectiles/guns/attachments/harness.dm | 8 ++++----
14 files changed, 35 insertions(+), 26 deletions(-)
diff --git a/code/__DEFINES/inventory/slots.dm b/code/__DEFINES/inventory/slots.dm
index 056cce5bbb07..0e996c5be660 100644
--- a/code/__DEFINES/inventory/slots.dm
+++ b/code/__DEFINES/inventory/slots.dm
@@ -76,7 +76,16 @@ DEFINE_BITFIELD(inventory_slot_flags, list(
/// specially handled value
#define INV_SLOT_FILTER_HANDS (1<<23)
-#warn DEFINE_BITFIELD_NEW
+DEFINE_BITFIELD_NEW(inv_slot_filter, list(
+ /datum/inventory_slot = list(
+ NAMEOF_STATIC(/datum/inventory_slot, inventory_slot_filter),
+ ),
+), list(
+ BITFIELD_NEW("Unknown", INV_SLOT_FILTER_UNKNOWN),
+ BITFIELD_NEW("Equipment", INV_SLOT_FILTER_EQUIPMENT),
+ BITFIELD_NEW("Restraints", INV_SLOT_FILTER_RESTRAINTS),
+ BITFIELD_NEW("Hands", INV_SLOT_FILTER_HANDS),
+))
//! slot flags
// Item inventory slot bitmasks.
diff --git a/code/datums/outfits/costumes/halloween.dm b/code/datums/outfits/costumes/halloween.dm
index abbf6f82085c..4ad364388739 100644
--- a/code/datums/outfits/costumes/halloween.dm
+++ b/code/datums/outfits/costumes/halloween.dm
@@ -41,7 +41,7 @@
r_hand = /obj/item/gun/ballistic/revolver/capgun
/datum/outfit/costume/horrorcop/post_equip(var/mob/living/carbon/human/H)
- var/obj/item/clothing/under/U = H.inventory.get_slot(/datum/inventory_slot/inventory/uniform)
+ var/obj/item/clothing/under/U = H.inventory.get_slot_single(/datum/inventory_slot/inventory/uniform)
if(LAZYLEN(U.accessories))
for(var/obj/item/clothing/accessory/A in U.accessories)
if(istype(A, /obj/item/clothing/accessory/holster))
@@ -58,7 +58,7 @@
r_hand = /obj/item/gun/ballistic/revolver/capgun
/datum/outfit/costume/cowboy/post_equip(var/mob/living/carbon/human/H)
- var/obj/item/clothing/under/U = H.inventory.get_slot(/datum/inventory_slot/inventory/uniform)
+ var/obj/item/clothing/under/U = H.inventory.get_slot_single(/datum/inventory_slot/inventory/uniform)
if(LAZYLEN(U.accessories))
for(var/obj/item/clothing/accessory/A in U.accessories)
if(istype(A, /obj/item/clothing/accessory/holster))
diff --git a/code/game/objects/items/defib/shockpaddles.dm b/code/game/objects/items/defib/shockpaddles.dm
index 5e9a0a94563d..02f6a9041130 100644
--- a/code/game/objects/items/defib/shockpaddles.dm
+++ b/code/game/objects/items/defib/shockpaddles.dm
@@ -105,7 +105,7 @@
/obj/item/shockpaddles/proc/check_contact(mob/living/carbon/human/H)
if(!combat)
- for(var/obj/item/clothing/cloth in H.get_slots(
+ for(var/obj/item/clothing/cloth in H.get_slots_unsafe(
/datum/inventory_slot/inventory/uniform,
/datum/inventory_slot/inventory/suit,
))
diff --git a/code/game/objects/items/stacks/medical.dm b/code/game/objects/items/stacks/medical.dm
index 051fd0ccf74e..748b839080cb 100644
--- a/code/game/objects/items/stacks/medical.dm
+++ b/code/game/objects/items/stacks/medical.dm
@@ -44,7 +44,7 @@
to_chat(user, "You can't apply [src] through [H.head]!")
return FALSE
else
- if(istype(H.inventory.get_slot(/datum/inventory_slot/inventory/suit), /obj/item/clothing/suit/space))
+ if(istype(H.inventory.get_slot_single(/datum/inventory_slot/inventory/suit), /obj/item/clothing/suit/space))
to_chat(user, "You can't apply [src] through [H.wear_suit]!")
return FALSE
diff --git a/code/game/objects/items/weapons/gift_wrappaper.dm b/code/game/objects/items/weapons/gift_wrappaper.dm
index e7597e27e03f..92d2edd2da17 100644
--- a/code/game/objects/items/weapons/gift_wrappaper.dm
+++ b/code/game/objects/items/weapons/gift_wrappaper.dm
@@ -276,7 +276,7 @@
return
var/mob/living/carbon/human/H = target
- if (istype(H.inventory.get_slot(/datum/inventory_slot/inventory/suit), /obj/item/clothing/suit/straight_jacket) || H.stat)
+ if (istype(H.inventory.get_slot_single(/datum/inventory_slot/inventory/suit), /obj/item/clothing/suit/straight_jacket) || H.stat)
if (src.amount > 2)
var/obj/effect/spresent/present = new /obj/effect/spresent (H.loc)
src.amount -= 2
diff --git a/code/modules/clothing/under/accessories/accessory.dm b/code/modules/clothing/under/accessories/accessory.dm
index cb59abd1bfaa..2eaffff0e6a2 100644
--- a/code/modules/clothing/under/accessories/accessory.dm
+++ b/code/modules/clothing/under/accessories/accessory.dm
@@ -113,7 +113,7 @@
// todo: don't call dropped/pickup if going to same person
if(accessory_host.worn_slot)
unequipped(accessory_host.worn_mob(), accessory_host.worn_slot, INV_OP_IS_ACCESSORY)
- module_state_1.on_unequipped(accessory_host.worn_mob(), accessory_host.worn_slot == SLOT_ID_HANDS ? accessory_host.worn_mob().get_held_index(accessory_host) : accessory_host.worn_slot , INV_OP_IS_ACCESSORY)
+ on_unequipped(accessory_host.worn_mob(), accessory_host.worn_slot == SLOT_ID_HANDS ? accessory_host.worn_mob().get_held_index(accessory_host) : accessory_host.worn_slot , INV_OP_IS_ACCESSORY)
dropped(accessory_host.worn_mob(), INV_OP_IS_ACCESSORY)
// inventory handling stop
diff --git a/code/modules/detectivework/forensics.dm b/code/modules/detectivework/forensics.dm
index a9aea73a6154..a10ec626a545 100644
--- a/code/modules/detectivework/forensics.dm
+++ b/code/modules/detectivework/forensics.dm
@@ -24,20 +24,20 @@ var/const/FINGERPRINT_COMPLETE = 6
var/fibertext
var/item_multiplier = istype(src,/obj/item)?1.2:1
var/suit_coverage = 0
- if(istype(M.inventory.get_slot(/datum/inventory_slot/inventory/suit::id), /obj/item/clothing))
+ if(istype(M.inventory.get_slot_single(/datum/inventory_slot/inventory/suit::id), /obj/item/clothing))
var/obj/item/clothing/C = M.wear_suit
fibertext = C.get_fibers()
if(fibertext && prob(10*item_multiplier))
suit_fibers |= fibertext
suit_coverage = C.body_cover_flags
- if(istype(M.inventory.get_slot(/datum/inventory_slot/inventory/uniform::id), /obj/item/clothing) && (M.w_uniform.body_cover_flags & ~suit_coverage))
+ if(istype(M.inventory.get_slot_single(/datum/inventory_slot/inventory/uniform::id), /obj/item/clothing) && (M.w_uniform.body_cover_flags & ~suit_coverage))
var/obj/item/clothing/C = M.w_uniform
fibertext = C.get_fibers()
if(fibertext && prob(15*item_multiplier))
suit_fibers |= fibertext
- if(istype(M.inventory.get_slot(/datum/inventory_slot/inventory/gloves::id), /obj/item/clothing) && (M.gloves.body_cover_flags & ~suit_coverage))
+ if(istype(M.inventory.get_slot_single(/datum/inventory_slot/inventory/gloves::id), /obj/item/clothing) && (M.gloves.body_cover_flags & ~suit_coverage))
var/obj/item/clothing/C = M.gloves
fibertext = C.get_fibers()
if(fibertext && prob(20*item_multiplier))
diff --git a/code/modules/detectivework/tools/sample_kits.dm b/code/modules/detectivework/tools/sample_kits.dm
index e53b3b06217b..5deb83bfa2e6 100644
--- a/code/modules/detectivework/tools/sample_kits.dm
+++ b/code/modules/detectivework/tools/sample_kits.dm
@@ -69,7 +69,7 @@
if(!ishuman(user))
return
var/mob/living/carbon/human/H = user
- var/obj/item/wearing_gloves = H.inventory.get_slot(/datum/inventory_slot/inventory/gloves::id)
+ var/obj/item/wearing_gloves = H.inventory.get_slot_single(/datum/inventory_slot/inventory/gloves::id)
if(wearing_gloves)
to_chat(user, "Take \the [wearing_gloves] off first.")
return
diff --git a/code/modules/hydroponics/grown.dm b/code/modules/hydroponics/grown.dm
index e1807a7ddab0..c65968cf1dd3 100644
--- a/code/modules/hydroponics/grown.dm
+++ b/code/modules/hydroponics/grown.dm
@@ -316,7 +316,7 @@
return
if(seed.get_trait(TRAIT_STINGS))
var/mob/living/carbon/human/H = user
- if(H.inventory.get_slot(/datum/inventory_slot/inventory/gloves::id))
+ if(H.inventory.get_slot_single(/datum/inventory_slot/inventory/gloves::id))
return
if(!reagents || reagents.total_volume <= 0)
return
diff --git a/code/modules/jobs/job_types/station/command/captain.dm b/code/modules/jobs/job_types/station/command/captain.dm
index 661e5f4e6515..6da364b0d134 100644
--- a/code/modules/jobs/job_types/station/command/captain.dm
+++ b/code/modules/jobs/job_types/station/command/captain.dm
@@ -70,7 +70,7 @@ var/datum/legacy_announcement/minor/captain_announcement = new(do_newscast = 1)
if(H.age>49)
// Since we can have something other than the default uniform at this
// point, check if we can actually attach the medal
- var/obj/item/clothing/uniform = H.inventory.get_slot(/datum/inventory_slot/inventory/uniform::id)
+ var/obj/item/clothing/uniform = H.inventory.get_slot_single(/datum/inventory_slot/inventory/uniform::id)
if(uniform)
var/obj/item/clothing/accessory/medal/gold/captain/medal = new()
if(uniform.can_attach_accessory(medal))
diff --git a/code/modules/materials/material_sheets.dm b/code/modules/materials/material_sheets.dm
index 34efdd2da5ff..4995dab8f054 100644
--- a/code/modules/materials/material_sheets.dm
+++ b/code/modules/materials/material_sheets.dm
@@ -311,7 +311,7 @@
var/burn_user = TRUE
if(istype(M, /mob/living/carbon/human))
var/mob/living/carbon/human/H = user
- var/obj/item/clothing/gloves/G = H.inventory.get_slot(/datum/inventory_slot/inventory/gloves::id)
+ var/obj/item/clothing/gloves/G = H.inventory.get_slot_single(/datum/inventory_slot/inventory/gloves::id)
if(istype(G) && ((G.clothing_flags & CLOTHING_THICK_MATERIAL && prob(70)) || istype(G, /obj/item/clothing/gloves/gauntlets)))
burn_user = FALSE
diff --git a/code/modules/mob/inventory/inventory-hands-get.dm b/code/modules/mob/inventory/inventory-hands-get.dm
index 3b50e18022a6..112ee8aa114c 100644
--- a/code/modules/mob/inventory/inventory-hands-get.dm
+++ b/code/modules/mob/inventory/inventory-hands-get.dm
@@ -8,7 +8,7 @@
*
* @return /obj/item or null
*/
-/datum/inventory/proc/get_hand(index) as /obj/item
+/datum/inventory/proc/get_hand_single(index) as /obj/item
if(index < 1 || index > length(held_items))
return
return held_items[index]
@@ -20,7 +20,7 @@
*
* @return list() of items
*/
-/datum/inventory/proc/get_hand_multi(index) as /list
+/datum/inventory/proc/get_hand(index) as /list
if(index < 1 || index > length(held_items))
return
var/obj/item/held = held_items[index]
@@ -56,7 +56,7 @@
. += compound ? maybe_held.inv_slot_attached() : maybe_held
else
for(var/obj/item/held in held_items)
- . += compound ? held.inv_slot_attached() : maybe_held
+ . += compound ? held.inv_slot_attached() : held
// todo: old below
diff --git a/code/modules/mob/inventory/inventory-slot-get.dm b/code/modules/mob/inventory/inventory-slot-get.dm
index 1aafc2093f97..5352e9ae5b4a 100644
--- a/code/modules/mob/inventory/inventory-slot-get.dm
+++ b/code/modules/mob/inventory/inventory-slot-get.dm
@@ -12,10 +12,10 @@
*
* @return /obj/item or null
*/
-/datum/inventory/proc/get_slot(datum/inventory_slot/type_or_id) as /obj/item
+/datum/inventory/proc/get_slot_single(datum/inventory_slot/type_or_id) as /obj/item
if(ispath(type_or_id))
type_or_id = initial(type_or_id.id)
- . = owner._item_by_slot(slot_id)
+ . = owner._item_by_slot(type_or_id)
if(. == INVENTORY_SLOT_DOES_NOT_EXIST)
return null
@@ -30,10 +30,10 @@
*
* @return list() of items
*/
-/datum/inventory/proc/get_slot_multi(datum/inventory_slot/type_or_id) as /list
+/datum/inventory/proc/get_slot(datum/inventory_slot/type_or_id) as /list
if(ispath(type_or_id))
type_or_id = initial(type_or_id.id)
- var/obj/item/in_slot = owner._item_by_slot(slot_id)
+ var/obj/item/in_slot = owner._item_by_slot(type_or_id)
if(in_slot == INVENTORY_SLOT_DOES_NOT_EXIST)
return
if(in_slot)
@@ -62,7 +62,7 @@
*/
/datum/inventory/proc/get_slots_unsafe(list/types_or_ids, compound) as /list
. = list()
- for(var/datum/inventory_slot/slot_id as anything in slot_ids || base_inventory_slots)
+ for(var/datum/inventory_slot/slot_id as anything in types_or_ids || base_inventory_slots)
if(ispath(slot_id))
slot_id = initial(slot_id.id)
var/obj/item/fetched = owner._item_by_slot(slot_id)
diff --git a/code/modules/projectiles/guns/attachments/harness.dm b/code/modules/projectiles/guns/attachments/harness.dm
index 96fa43da8859..9bb5b02b1917 100644
--- a/code/modules/projectiles/guns/attachments/harness.dm
+++ b/code/modules/projectiles/guns/attachments/harness.dm
@@ -29,8 +29,8 @@
/obj/item/gun_attachment/harness/magnetic/on_attach(obj/item/gun/gun)
..()
- RegisterSignal(gun, COMSIG_ITEM_DROPPED, PROC_REF(on_drop))
- RegisterSignal(gun, COMSIG_ITEM_PICKUP, PROC_REF(on_pickup))
+ RegisterSignal(gun, COMSIG_ITEM_DROPPED, PROC_REF(on_gun_drop))
+ RegisterSignal(gun, COMSIG_ITEM_PICKUP, PROC_REF(on_gun_pickup))
/obj/item/gun_attachment/harness/magnetic/on_detach(obj/item/gun/gun)
..()
@@ -42,7 +42,7 @@
/obj/item/gun_attachment/harness/magnetic/ui_action_click(datum/action/action, datum/event_args/actor/actor)
set_active(!active, actor)
-/obj/item/gun_attachment/harness/magnetic/proc/on_drop(datum/source, mob/user, inv_op_flags, atom/new_loc)
+/obj/item/gun_attachment/harness/magnetic/proc/on_gun_drop(datum/source, mob/user, inv_op_flags, atom/new_loc)
SIGNAL_HANDLER
if(!active)
return NONE
@@ -58,7 +58,7 @@
return NONE
return COMPONENT_ITEM_DROPPED_RELOCATE | COMPONENT_ITEM_DROPPED_SUPPRESS_SOUND
-/obj/item/gun_attachment/harness/magnetic/proc/on_pickup(datum/source, mob/user, inv_op_flags, atom/old_loc)
+/obj/item/gun_attachment/harness/magnetic/proc/on_gun_pickup(datum/source, mob/user, inv_op_flags, atom/old_loc)
SIGNAL_HANDLER
if(active)
return
From 398a4471db9f5d657dbaac75942065c5916bd010 Mon Sep 17 00:00:00 2001
From: silicons <2003111+silicons@users.noreply.github.com>
Date: Thu, 28 Nov 2024 14:16:13 -0500
Subject: [PATCH 10/18] coverage flag audit
---
citadel.dme | 1 +
code/__DEFINES/_flags/item_flags.dm | 10 ++++-
.../dcs/signals/datums/signals_inventory.dm | 8 ++--
code/__DEFINES/inventory/slots.dm | 20 ++++-----
code/game/objects/items-carry_weight.dm | 2 +-
code/game/objects/items-interaction.dm | 2 +-
code/game/objects/items-inventory-old.dm | 2 +
code/game/objects/items.dm | 18 ++++++--
code/game/objects/items/devices/flashlight.dm | 7 ++-
code/modules/clothing/chameleon.dm | 2 +-
code/modules/clothing/glasses/_glasses.dm | 8 ++--
code/modules/clothing/head/misc/cakehat.dm | 30 +++++++++++++
code/modules/clothing/head/misc_special.dm | 45 +------------------
code/modules/clothing/masks/breath.dm | 4 +-
code/modules/clothing/masks/gasmask.dm | 8 ++--
code/modules/clothing/masks/miscellaneous.dm | 8 ++--
code/modules/clothing/suits/miscellaneous.dm | 4 +-
code/modules/clothing/under/_under.dm | 6 +--
code/modules/mob/inventory/inventory-get.dm | 6 +--
code/modules/mob/inventory/inventory-hooks.dm | 13 ++++--
code/modules/mob/inventory/inventory-query.dm | 28 +++++++++---
code/modules/mob/inventory/inventory.dm | 9 +++-
code/modules/mob/inventory/inventory_slot.dm | 6 +--
23 files changed, 144 insertions(+), 103 deletions(-)
create mode 100644 code/modules/clothing/head/misc/cakehat.dm
diff --git a/citadel.dme b/citadel.dme
index c3a750e27863..91ddc776a7ad 100644
--- a/citadel.dme
+++ b/citadel.dme
@@ -2579,6 +2579,7 @@
#include "code\modules\clothing\head\oricon.dm"
#include "code\modules\clothing\head\pilot_helmet.dm"
#include "code\modules\clothing\head\soft_caps.dm"
+#include "code\modules\clothing\head\misc\cakehat.dm"
#include "code\modules\clothing\head\xeno\tajara.dm"
#include "code\modules\clothing\masks\_mask.dm"
#include "code\modules\clothing\masks\boxing.dm"
diff --git a/code/__DEFINES/_flags/item_flags.dm b/code/__DEFINES/_flags/item_flags.dm
index 9feebe4d2d4f..3be7599323d1 100644
--- a/code/__DEFINES/_flags/item_flags.dm
+++ b/code/__DEFINES/_flags/item_flags.dm
@@ -1,5 +1,6 @@
//! Flags for the item_flags var on /obj/item
/// is this item equipped into an inventory slot or hand of a mob? used for tooltips
+/// todo: is this still needed? `inv_slot_or_index` on `/obj/item` is a good check already
#define ITEM_IN_INVENTORY (1<<0)
/// When dropped, it calls qdel on itself
#define ITEM_DROPDEL (1<<1)
@@ -128,7 +129,14 @@ DEFINE_BITFIELD(inv_hide_flags, list(
BITFIELD(BLOCKHAIR),
))
-//!# bitflags for /obj/item/var/body_cover_flags
+//* Body Cover Flags / Body Part Flags *//
+//* *//
+//* These are used in many places, despite only being used commonly on *//
+//* /item's and /item/organ/external's. *//
+//* *//
+//* These should be used any time you need to store coverage or parts *//
+//* of a standard humanoid body. *//
+
#define HEAD (1<<0)
#define FACE (1<<1)
#define EYES (1<<2)
diff --git a/code/__DEFINES/dcs/signals/datums/signals_inventory.dm b/code/__DEFINES/dcs/signals/datums/signals_inventory.dm
index 3f232a7913a1..84ad64496e43 100644
--- a/code/__DEFINES/dcs/signals/datums/signals_inventory.dm
+++ b/code/__DEFINES/dcs/signals/datums/signals_inventory.dm
@@ -5,12 +5,12 @@
/// raised with (obj/item/item, datum/inventory_slot/slot_or_index)
///
-/// * raised after COMSIG_INVENTORY_ITEM_EXITED_SLOT during swaps
-#define COMSIG_INVENTORY_ITEM_ENTERED_SLOT "inventory-item-entered-slot"
+/// * raised after COMSIG_INVENTORY_ITEM_EXITED during swaps
+#define COMSIG_INVENTORY_ITEM_ENTERED "inventory-item-entered-slot"
/// raised with (obj/item/item, datum/inventory_slot/slot_or_index)
///
-/// * raised before COMSIG_INVENTORY_ITEM_ENTERED_SLOT during swaps
-#define COMSIG_INVENTORY_ITEM_EXITED_SLOT "inventory-item-exited-slot"
+/// * raised before COMSIG_INVENTORY_ITEM_ENTERED during swaps
+#define COMSIG_INVENTORY_ITEM_EXITED "inventory-item-exited-slot"
/// raised with ()
///
/// * raised on any inventory slot mutation
diff --git a/code/__DEFINES/inventory/slots.dm b/code/__DEFINES/inventory/slots.dm
index 0e996c5be660..f2a983bd8dcf 100644
--- a/code/__DEFINES/inventory/slots.dm
+++ b/code/__DEFINES/inventory/slots.dm
@@ -67,24 +67,24 @@ DEFINE_BITFIELD(inventory_slot_flags, list(
BITFIELD(INV_SLOT_STRIP_ONLY_REMOVES),
))
-//* /datum/inventory_slot inventory_slot_filter *//
+//* /datum/inventory_slot inventory_filter_flags *//
-#define INV_SLOT_FILTER_UNKNOWN (1<<1)
-#define INV_SLOT_FILTER_EQUIPMENT (1<<2)
-#define INV_SLOT_FILTER_RESTRAINTS (1<<3)
+#define INV_FILTER_UNKNOWN (1<<1)
+#define INV_FILTER_EQUIPMENT (1<<2)
+#define INV_FILTER_RESTRAINTS (1<<3)
/// specially handled value
-#define INV_SLOT_FILTER_HANDS (1<<23)
+#define INV_FILTER_HANDS (1<<23)
DEFINE_BITFIELD_NEW(inv_slot_filter, list(
/datum/inventory_slot = list(
- NAMEOF_STATIC(/datum/inventory_slot, inventory_slot_filter),
+ NAMEOF_STATIC(/datum/inventory_slot, inventory_filter_flags),
),
), list(
- BITFIELD_NEW("Unknown", INV_SLOT_FILTER_UNKNOWN),
- BITFIELD_NEW("Equipment", INV_SLOT_FILTER_EQUIPMENT),
- BITFIELD_NEW("Restraints", INV_SLOT_FILTER_RESTRAINTS),
- BITFIELD_NEW("Hands", INV_SLOT_FILTER_HANDS),
+ BITFIELD_NEW("Unknown", INV_FILTER_UNKNOWN),
+ BITFIELD_NEW("Equipment", INV_FILTER_EQUIPMENT),
+ BITFIELD_NEW("Restraints", INV_FILTER_RESTRAINTS),
+ BITFIELD_NEW("Hands", INV_FILTER_HANDS),
))
//! slot flags
diff --git a/code/game/objects/items-carry_weight.dm b/code/game/objects/items-carry_weight.dm
index f26b7114f7f3..4cdcdebb2999 100644
--- a/code/game/objects/items-carry_weight.dm
+++ b/code/game/objects/items-carry_weight.dm
@@ -1,5 +1,5 @@
//* This file is explicitly licensed under the MIT license. *//
-//* Copyright (c) 2024 silicons *//
+//* Copyright (c) 2024 Citadel Station Developers *//
//* Carry Weight *//
//* The carry weight system is a modular system used to discourage *//
diff --git a/code/game/objects/items-interaction.dm b/code/game/objects/items-interaction.dm
index f5a298b4ed1e..217e2aae0ee2 100644
--- a/code/game/objects/items-interaction.dm
+++ b/code/game/objects/items-interaction.dm
@@ -1,5 +1,5 @@
//* This file is explicitly licensed under the MIT license. *//
-//* Copyright (c) 2024 silicons *//
+//* Copyright (c) 2024 Citadel Station Developers *//
//* ----- Click Triggers ----- */
diff --git a/code/game/objects/items-inventory-old.dm b/code/game/objects/items-inventory-old.dm
index 5637c54478af..ee2f92d25c66 100644
--- a/code/game/objects/items-inventory-old.dm
+++ b/code/game/objects/items-inventory-old.dm
@@ -16,6 +16,7 @@
// set slot
worn_slot = slot
+ inv_slot_or_index = slot == SLOT_ID_HANDS ? user.get_held_index(src) : slot
// register carry
if(isliving(user))
var/mob/living/L = user
@@ -47,6 +48,7 @@
SHOULD_CALL_PARENT(TRUE)
// clear slot
worn_slot = null
+ inv_slot_or_index = null
// clear carry
if(isliving(user))
var/mob/living/L = user
diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm
index e4a3ed586c63..77c2eb3ea3a6 100644
--- a/code/game/objects/items.dm
+++ b/code/game/objects/items.dm
@@ -9,7 +9,6 @@
climb_allowed = FALSE
//* Actions *//
-
/// cached action descriptors
///
/// this can be:
@@ -65,8 +64,10 @@
/// As of right now, some flags only work in some slots.
/// These flags are listed in [code/__DEFINES/inventory/item_flags.dm].
var/inv_hide_flags = NONE
- /// flags for the bodyparts this item covers when worn.
+ /// Flags for the bodyparts this item covers when worn.
/// These flags are listed in [code/__DEFINES/inventory/item_flags.dm].
+ ///
+ /// * Do not set these directly, use set_body_cover_flags()!
var/body_cover_flags = NONE
/// Flags which determine which body parts are protected from heat. Use the HEAD, UPPER_TORSO, LOWER_TORSO, etc. flags. See setup.dm
/// These flags are listed in [code/__DEFINES/inventory/item_flags.dm].
@@ -85,6 +86,12 @@
var/interaction_flags_item = INTERACT_ITEM_ATTACK_SELF
//* Inventory *//
+ /// Currently equipped slot ID or hand index if held in hand
+ var/inv_slot_or_index
+ /// The inventory datum we're in.
+ ///
+ /// * This also doubles as an 'is in inventory' check, as this will always be set if we are in inventory.
+ var/datum/inventory/inv_inside
/// currently equipped slot id
///
/// todo: `worn_slot_or_index`
@@ -117,7 +124,7 @@
/// Set this variable if the item protects its wearer against low pressures above a lower bound. Keep at null to disable protection. 0 represents protection against hard vacuum.
var/min_pressure_protection
- //? Carry Weight
+ //* Carry Weight *//
/// encumberance.
/// calculated as max() of all encumbrance
/// result is calculated into slowdown value
@@ -837,6 +844,11 @@ modules/mob/living/carbon/human/life.dm if you die, you will be zoomed out.
/obj/item/proc/reload_passive_parry()
load_passive_parry()
+//* Flags *//
+
+/obj/item/proc/set_body_cover_flags()
+ inv_inside.invalidate_coverage_cache()
+
//* Interactions *//
/obj/item/attackby(obj/item/I, mob/user, list/params, clickchain_flags, damage_multiplier)
diff --git a/code/game/objects/items/devices/flashlight.dm b/code/game/objects/items/devices/flashlight.dm
index d5d7056ccf20..5e4f88d287b6 100644
--- a/code/game/objects/items/devices/flashlight.dm
+++ b/code/game/objects/items/devices/flashlight.dm
@@ -150,10 +150,9 @@
var/mob/living/carbon/human/H = L //mob has protective eyewear
if(istype(H))
- for(var/obj/item/clothing/C in list(H.head,H.wear_mask,H.glasses))
- if(istype(C) && (C.body_cover_flags & EYES))
- to_chat(user, SPAN_WARNING("You're going to need to remove [C.name] first."))
- return
+ for(var/obj/item/C in H.inventory.query_coverage(EYES))
+ to_chat(user, SPAN_WARNING("You're going to need to remove [C.name] first."))
+ return
var/obj/item/organ/vision
if(H.species.vision_organ)
diff --git a/code/modules/clothing/chameleon.dm b/code/modules/clothing/chameleon.dm
index a0ae42c236c8..7b2cb0c6f4d1 100644
--- a/code/modules/clothing/chameleon.dm
+++ b/code/modules/clothing/chameleon.dm
@@ -13,7 +13,7 @@
icon_state = copy.icon_state
color = copy.color
item_state = copy.item_state
- body_cover_flags = copy.body_cover_flags
+ set_body_cover_flags(copy.body_cover_flags)
inv_hide_flags = copy.inv_hide_flags
gender = copy.gender
diff --git a/code/modules/clothing/glasses/_glasses.dm b/code/modules/clothing/glasses/_glasses.dm
index 7766e0a6fa25..b44e788cc9d6 100644
--- a/code/modules/clothing/glasses/_glasses.dm
+++ b/code/modules/clothing/glasses/_glasses.dm
@@ -453,14 +453,14 @@ BLIND // can't see anything
if(src.up)
src.up = !src.up
inv_hide_flags |= HIDEEYES
- body_cover_flags |= EYES
+ set_body_cover_flags(body_cover_flags | EYES)
flash_protection = initial(flash_protection)
tint = initial(tint)
to_chat(usr, "You flip \the [src] down to protect your eyes.")
else
src.up = !src.up
inv_hide_flags &= ~HIDEEYES
- body_cover_flags &= ~EYES
+ set_body_cover_flags(body_cover_flags & ~EYES)
flash_protection = FLASH_PROTECTION_NONE
tint = TINT_NONE
to_chat(usr, "You push \the [src] up out of your face.")
@@ -697,13 +697,13 @@ BLIND // can't see anything
if(src.up)
src.up = !src.up
inv_hide_flags |= HIDEEYES
- body_cover_flags |= EYES
+ set_body_cover_flags(body_cover_flags | EYES)
icon_state = initial(icon_state)
to_chat(usr, "You flip \the [src] down to protect your eyes.")
else
src.up = !src.up
inv_hide_flags &= ~HIDEEYES
- body_cover_flags &= ~EYES
+ set_body_cover_flags(body_cover_flags & ~EYES)
icon_state = "[initial(icon_state)]up"
to_chat(usr, "You push \the [src] up from in front of your eyes.")
update_worn_icon()
diff --git a/code/modules/clothing/head/misc/cakehat.dm b/code/modules/clothing/head/misc/cakehat.dm
new file mode 100644
index 000000000000..297d45835658
--- /dev/null
+++ b/code/modules/clothing/head/misc/cakehat.dm
@@ -0,0 +1,30 @@
+/obj/item/clothing/head/cakehat
+ name = "cake-hat"
+ desc = "It's tasty looking!"
+ icon_state = "cake0"
+ body_cover_flags = HEAD
+ var/onfire = 0
+
+/obj/item/clothing/head/cakehat/process(delta_time)
+ if(!onfire)
+ STOP_PROCESSING(SSobj, src)
+ return
+
+ var/turf/maybe_turf_location = inv_slot_or_index ? get_turf(worn_mob()) : loc
+ if(isturf(maybe_turf_location))
+ maybe_turf_location.hotspot_expose(700, 1)
+
+/obj/item/clothing/head/cakehat/attack_self(mob/user, datum/event_args/actor/actor)
+ . = ..()
+ if(.)
+ return
+ onfire = !(onfire)
+ if (onfire)
+ damage_force = 3
+ damage_type = DAMAGE_TYPE_BURN
+ icon_state = "cake1"
+ START_PROCESSING(SSobj, src)
+ else
+ damage_force = 0
+ damage_type = DAMAGE_TYPE_BRUTE
+ icon_state = "cake0"
diff --git a/code/modules/clothing/head/misc_special.dm b/code/modules/clothing/head/misc_special.dm
index b685c459f629..72e1b85c5596 100644
--- a/code/modules/clothing/head/misc_special.dm
+++ b/code/modules/clothing/head/misc_special.dm
@@ -54,7 +54,7 @@
if(src.up)
src.up = !src.up
- body_cover_flags |= (EYES|FACE)
+ set_body_cover_flags(body_cover_flags | (EYES|FACE))
inv_hide_flags |= (HIDEMASK|HIDEEARS|HIDEEYES|HIDEFACE)
icon_state = base_state
flash_protection = FLASH_PROTECTION_MAJOR
@@ -62,7 +62,7 @@
to_chat(usr, "You flip the [src] down to protect your eyes.")
else
src.up = !src.up
- body_cover_flags &= ~(EYES|FACE)
+ set_body_cover_flags(body_cover_flags & ~(EYES|FACE))
inv_hide_flags &= ~(HIDEMASK|HIDEEARS|HIDEEYES|HIDEFACE)
icon_state = "[base_state]up"
flash_protection = FLASH_PROTECTION_NONE
@@ -119,47 +119,6 @@
SLOT_ID_RIGHT_HAND = "ararwelding",
)
-/*
- * Cakehat
- */
-/obj/item/clothing/head/cakehat
- name = "cake-hat"
- desc = "It's tasty looking!"
- icon_state = "cake0"
- var/onfire = 0
- body_cover_flags = HEAD
-
-/obj/item/clothing/head/cakehat/process(delta_time)
- if(!onfire)
- STOP_PROCESSING(SSobj, src)
- return
-
- var/turf/location = src.loc
- if(istype(location, /mob/))
- var/mob/living/carbon/human/M = location
- if(M.is_holding(src) || M.head == src)
- location = M.loc
-
- if (istype(location, /turf))
- location.hotspot_expose(700, 1)
-
-/obj/item/clothing/head/cakehat/attack_self(mob/user, datum/event_args/actor/actor)
- . = ..()
- if(.)
- return
- onfire = !(onfire)
- if (onfire)
- damage_force = 3
- damage_type = DAMAGE_TYPE_BURN
- icon_state = "cake1"
- START_PROCESSING(SSobj, src)
- else
- damage_force = 0
- damage_type = DAMAGE_TYPE_BRUTE
- icon_state = "cake0"
- return
-
-
/*
* Ushanka
*/
diff --git a/code/modules/clothing/masks/breath.dm b/code/modules/clothing/masks/breath.dm
index bea597d452fb..2c4bcb4317ca 100644
--- a/code/modules/clothing/masks/breath.dm
+++ b/code/modules/clothing/masks/breath.dm
@@ -17,13 +17,13 @@
hanging = !hanging
if (hanging)
gas_transfer_coefficient = 1
- body_cover_flags = body_cover_flags & ~FACE
+ set_body_cover_flags(body_cover_flags & ~FACE)
clothing_flags = clothing_flags & ~ALLOWINTERNALS
icon_state = "breathdown"
to_chat(user, "Your mask is now hanging on your neck.")
else
gas_transfer_coefficient = initial(gas_transfer_coefficient)
- body_cover_flags = initial(body_cover_flags)
+ set_body_cover_flags(initial(body_cover_flags))
clothing_flags = initial(clothing_flags)
icon_state = initial(icon_state)
to_chat(user, "You pull the mask up to cover your face.")
diff --git a/code/modules/clothing/masks/gasmask.dm b/code/modules/clothing/masks/gasmask.dm
index 09530c6f6b4b..482f6a7e5b49 100644
--- a/code/modules/clothing/masks/gasmask.dm
+++ b/code/modules/clothing/masks/gasmask.dm
@@ -57,7 +57,7 @@
if (src.hanging)
gas_transfer_coefficient = 1
gas_filter_strength = 0
- body_cover_flags = body_cover_flags & ~FACE
+ set_body_cover_flags(body_cover_flags & ~FACE)
clothing_flags &= ~(BLOCK_GAS_SMOKE_EFFECT | ALLOWINTERNALS)
inv_hide_flags = 0
set_armor(/datum/armor/none)
@@ -66,7 +66,7 @@
else
gas_transfer_coefficient = initial(gas_transfer_coefficient)
gas_filter_strength = initial(gas_filter_strength)
- body_cover_flags = initial(body_cover_flags)
+ set_body_cover_flags(initial(body_cover_flags))
clothing_flags = initial(clothing_flags)
inv_hide_flags = initial(inv_hide_flags)
reset_armor()
@@ -116,10 +116,10 @@
if(!CHECK_MOBILITY(user, MOBILITY_CAN_USE))
mask_open = !mask_open
if(mask_open)
- body_cover_flags = EYES
+ set_body_cover_flags(EYES)
to_chat(user, "Your mask moves to allow you to eat.")
else
- body_cover_flags = FACE|EYES
+ set_body_cover_flags(FACE|EYES)
to_chat(user, "Your mask moves to cover your mouth.")
return
diff --git a/code/modules/clothing/masks/miscellaneous.dm b/code/modules/clothing/masks/miscellaneous.dm
index 543815ad4fe3..7185c59a354f 100644
--- a/code/modules/clothing/masks/miscellaneous.dm
+++ b/code/modules/clothing/masks/miscellaneous.dm
@@ -44,13 +44,13 @@
src.hanging = !src.hanging
if (src.hanging)
gas_transfer_coefficient = 1
- body_cover_flags = body_cover_flags & ~FACE
+ set_body_cover_flags(body_cover_flags & ~FACE)
set_armor(/datum/armor/none)
icon_state = "steriledown"
to_chat(usr, "You pull the mask below your chin.")
else
gas_transfer_coefficient = initial(gas_transfer_coefficient)
- body_cover_flags = initial(body_cover_flags)
+ set_body_cover_flags(initial(body_cover_flags))
icon_state = initial(icon_state)
reset_armor()
to_chat(usr, "You pull the mask up to cover your face.")
@@ -216,12 +216,12 @@
if(src.icon_state == initial(icon_state))
src.icon_state = "[icon_state]_up"
to_chat(user, "You fold the bandana into a cap.")
- body_cover_flags = HEAD
+ set_body_cover_flags(HEAD)
else
src.icon_state = initial(icon_state)
to_chat(user, "You untie the bandana and spread it out.")
slot_flags = initial(slot_flags)
- body_cover_flags = initial(body_cover_flags)
+ set_body_cover_flags(initial(body_cover_flags))
update_worn_icon() //so our mob-overlays update
/*
diff --git a/code/modules/clothing/suits/miscellaneous.dm b/code/modules/clothing/suits/miscellaneous.dm
index 5793fc0b4e91..211c7f874254 100644
--- a/code/modules/clothing/suits/miscellaneous.dm
+++ b/code/modules/clothing/suits/miscellaneous.dm
@@ -1134,11 +1134,11 @@
if(rolled == 0)
rolled = 1
- body_cover_flags &= ~(ARMS)
+ set_body_cover_flags(body_cover_flags & ~(ARMS))
to_chat(usr, "You roll up the sleeves of your [src].")
else
rolled = 0
- body_cover_flags = initial(body_cover_flags)
+ set_body_cover_flags(initial(body_cover_flags))
to_chat(usr, "You roll down the sleeves of your [src].")
update_icon()
diff --git a/code/modules/clothing/under/_under.dm b/code/modules/clothing/under/_under.dm
index 72aae1fd7516..f7ce6de2bdfd 100644
--- a/code/modules/clothing/under/_under.dm
+++ b/code/modules/clothing/under/_under.dm
@@ -122,21 +122,21 @@
if("normal")
worn_rolled_down = UNIFORM_ROLL_FALSE
worn_rolled_sleeves = UNIFORM_ROLL_FALSE
- body_cover_flags = initial(body_cover_flags)
+ set_body_cover_flags(initial(body_cover_flags))
update_worn_icon()
to_chat(user, SPAN_NOTICE("You roll [src] back to normal."))
return TRUE
if("rolled down")
worn_rolled_down = UNIFORM_ROLL_TRUE
worn_rolled_sleeves = UNIFORM_ROLL_FALSE
- body_cover_flags = (initial(body_cover_flags) & ~(UPPER_TORSO | ARMS | HANDS))
+ set_body_cover_flags(initial(body_cover_flags) & ~(UPPER_TORSO | ARMS | HANDS))
update_worn_icon()
to_chat(user, SPAN_NOTICE("You roll [src] down."))
return TRUE
if("rolled sleeves")
worn_rolled_down = UNIFORM_ROLL_FALSE
worn_rolled_sleeves = UNIFORM_ROLL_TRUE
- body_cover_flags = (initial(body_cover_flags) & ~(ARMS | HANDS))
+ set_body_cover_flags(initial(body_cover_flags) & ~(ARMS | HANDS))
update_worn_icon()
to_chat(user, SPAN_NOTICE("You roll [src]'s sleeves."))
return TRUE
diff --git a/code/modules/mob/inventory/inventory-get.dm b/code/modules/mob/inventory/inventory-get.dm
index b6791df8be98..0641acb48ef5 100644
--- a/code/modules/mob/inventory/inventory-get.dm
+++ b/code/modules/mob/inventory/inventory-get.dm
@@ -23,7 +23,7 @@
if(compound)
for(var/slot_id in base_inventory_slots)
var/datum/inventory_slot/slot_meta = resolve_inventory_slot(slot_id)
- if(slot_meta.inventory_slot_filter & filter_exclude)
+ if(slot_meta.inventory_filter_flags & filter_exclude)
continue
var/obj/item/in_slot = owner._item_by_slot(slot_id)
if(in_slot)
@@ -31,10 +31,10 @@
else
for(var/slot_id in base_inventory_slots)
var/datum/inventory_slot/slot_meta = resolve_inventory_slot(slot_id)
- if(slot_meta.inventory_slot_filter & filter_exclude)
+ if(slot_meta.inventory_filter_flags & filter_exclude)
continue
var/obj/item/in_slot = owner._item_by_slot(slot_id)
if(in_slot)
. += in_slot
- if(!(filter_exclude & INV_SLOT_FILTER_HANDS))
+ if(!(filter_exclude & INV_FILTER_HANDS))
. += get_held_items()
diff --git a/code/modules/mob/inventory/inventory-hooks.dm b/code/modules/mob/inventory/inventory-hooks.dm
index ecc5d06d67f0..5db35f5f9405 100644
--- a/code/modules/mob/inventory/inventory-hooks.dm
+++ b/code/modules/mob/inventory/inventory-hooks.dm
@@ -12,7 +12,9 @@
* * It is not required for on_item_swapped to be called instead of this proc if it's a swap.
*/
/datum/inventory/proc/on_item_entered(obj/item/item, datum/inventory_slot/slot_or_index)
- SEND_SIGNAL(src, COMSIG_INVENTORY_ITEM_ENTERED_SLOT, slot_or_index)
+ SEND_SIGNAL(src, COMSIG_INVENTORY_ITEM_ENTERED, slot_or_index)
+ item.inv_inside = src
+ invalidate_cache()
for(var/datum/actor_hud/inventory/hud in huds_using)
hud.add_item(item, slot_or_index)
@@ -25,7 +27,9 @@
* * It is not required for on_item_swapped to be called instead of this proc if it's a swap.
*/
/datum/inventory/proc/on_item_exited(obj/item/item, datum/inventory_slot/slot_or_index)
- SEND_SIGNAL(src, COMSIG_INVENTORY_ITEM_EXITED_SLOT, slot_or_index)
+ SEND_SIGNAL(src, COMSIG_INVENTORY_ITEM_EXITED, slot_or_index)
+ item.inv_inside = null
+ invalidate_cache()
for(var/datum/actor_hud/inventory/hud in huds_using)
hud.remove_item(item, slot_or_index)
@@ -43,8 +47,9 @@
* As of right now, the functionality is equivalent; on_item_swapped() is just more efficient.
*/
/datum/inventory/proc/on_item_swapped(obj/item/item, datum/inventory_slot/from_slot_or_index, datum/inventory_slot/to_slot_or_index)
- SEND_SIGNAL(src, COMSIG_INVENTORY_ITEM_EXITED_SLOT, from_slot_or_index)
- SEND_SIGNAL(src, COMSIG_INVENTORY_ITEM_ENTERED_SLOT, to_slot_or_index)
+ SEND_SIGNAL(src, COMSIG_INVENTORY_ITEM_EXITED, from_slot_or_index)
+ SEND_SIGNAL(src, COMSIG_INVENTORY_ITEM_ENTERED, to_slot_or_index)
+ invalidate_cache()
for(var/datum/actor_hud/inventory/hud in huds_using)
hud.move_item(item, from_slot_or_index, to_slot_or_index)
diff --git a/code/modules/mob/inventory/inventory-query.dm b/code/modules/mob/inventory/inventory-query.dm
index 924865f92fa9..aa8bbef4cb22 100644
--- a/code/modules/mob/inventory/inventory-query.dm
+++ b/code/modules/mob/inventory/inventory-query.dm
@@ -1,11 +1,29 @@
//* This file is explicitly licensed under the MIT license. *//
//* Copyright (c) 2024 Citadel Station Developers *//
-/datum/inventory
-
-/datum/inventory
-
-/datum/inventory
+//* This file contains expensive, cached queries. *//
+
+/**
+ * todo: better coverage checks, coverage levels / flags
+ *
+ * @return null or list() of covering items
+ */
+/datum/inventory/proc/query_coverage(body_cover_flags) as /list
+ if((. = cache["coverage-[body_cover_flags]"]))
+ return (.):Copy()
+ trim_cache()
+ . = cache["coverage-[body_cover_flags]"] = list()
+ for(var/obj/item/worn as anything in get_everything(~INV_FILTER_EQUIPMENT, TRUE))
+ if(worn.body_cover_flags & body_cover_flags)
+ . += worn
+ . = (.):Copy()
+
+/datum/inventory/proc/trim_coverage_cache()
+ if(length(cache) > 100)
+ cache.len = 100
+
+/datum/inventory/proc/invalidate_coverage_cache()
+ cache = list()
/datum/inventory
diff --git a/code/modules/mob/inventory/inventory.dm b/code/modules/mob/inventory/inventory.dm
index 388eb15ee8ee..34e23ec66402 100644
--- a/code/modules/mob/inventory/inventory.dm
+++ b/code/modules/mob/inventory/inventory.dm
@@ -16,8 +16,14 @@
/// our action holder
var/datum/action_holder/actions
+ //* Caches *//
+ /// Cache holder
+ var/list/cache = list()
+
//* HUDs *//
/// Actor HUDs using us
+ ///
+ /// * Lazy list
var/list/datum/actor_hud/inventory/huds_using
//* Inventory *//
@@ -39,8 +45,9 @@
//* Slots *//
/// our base slot ids associated to remappings
///
+ /// * Lazy list
/// * key: string id; value: remapping list with keys of INVENTORY_SLOT_REMAP_*
- /// * never ever modify this list in-place, this is why it's private; this may be shared lists in species!
+ /// * Never ever modify this list in-place, this is why it's private; this may be shared lists in species!
VAR_PRIVATE/list/base_inventory_slots
/datum/inventory/New(mob/M)
diff --git a/code/modules/mob/inventory/inventory_slot.dm b/code/modules/mob/inventory/inventory_slot.dm
index 8d915f171839..a4afb326839e 100644
--- a/code/modules/mob/inventory/inventory_slot.dm
+++ b/code/modules/mob/inventory/inventory_slot.dm
@@ -94,7 +94,7 @@ GLOBAL_LIST_EMPTY(inventory_slot_type_cache)
/// flags
var/inventory_slot_flags = INV_SLOT_IS_RENDERED
/// filter flags
- var/inventory_slot_filter = INV_SLOT_FILTER_UNKNOWN
+ var/inventory_filter_flags = INV_FILTER_UNKNOWN
/// semantic layer
///
/// * higher = outer, lower = inner
@@ -275,7 +275,7 @@ GLOBAL_LIST_EMPTY(inventory_slot_type_cache)
/datum/inventory_slot/inventory
abstract_type = /datum/inventory_slot/inventory
inventory_slot_flags = INV_SLOT_IS_RENDERED | INV_SLOT_IS_INVENTORY | INV_SLOT_IS_STRIPPABLE | INV_SLOT_HUD_REQUIRES_EXPAND | INV_SLOT_CONSIDERED_WORN
- inventory_slot_filter = INV_SLOT_FILTER_EQUIPMENT
+ inventory_filter_flags = INV_FILTER_EQUIPMENT
inventory_hud_rendered = TRUE
/datum/inventory_slot/inventory/back
@@ -896,7 +896,7 @@ GLOBAL_LIST_EMPTY(inventory_slot_type_cache)
always_show_on_strip_menu = FALSE
abstract_type = /datum/inventory_slot/restraints
inventory_slot_flags = INV_SLOT_IS_RENDERED | INV_SLOT_IS_STRIPPABLE | INV_SLOT_STRIP_ONLY_REMOVES | INV_SLOT_STRIP_SIMPLE_LINK
- inventory_slot_filter = INV_SLOT_FILTER_RESTRAINTS
+ inventory_filter_flags = INV_FILTER_RESTRAINTS
/datum/inventory_slot/restraints/handcuffs
name = "handcuffed"
From cdc63f2e694d668b9538f20767a95f2491a2c065 Mon Sep 17 00:00:00 2001
From: silicons <2003111+silicons@users.noreply.github.com>
Date: Thu, 28 Nov 2024 14:22:52 -0500
Subject: [PATCH 11/18] that
---
code/game/objects/items/weapons/handcuffs.dm | 2 +-
code/game/objects/items/weapons/material/shards.dm | 2 +-
code/game/objects/structures/cliff.dm | 4 ++--
code/modules/mob/living/carbon/human/human-defense.dm | 10 +++-------
4 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/code/game/objects/items/weapons/handcuffs.dm b/code/game/objects/items/weapons/handcuffs.dm
index 2779b2e35027..b0c4e6aad1d1 100644
--- a/code/game/objects/items/weapons/handcuffs.dm
+++ b/code/game/objects/items/weapons/handcuffs.dm
@@ -265,7 +265,7 @@ var/last_chew = 0
if(!H.can_equip(src, SLOT_ID_LEGCUFFED, user = user))
return FALSE
- if(istype(H.shoes,/obj/item/clothing/shoes/magboots/hardsuit) && !elastic) // Can't cuff someone who's in a deployed hardsuit.
+ if(istype(H.inventory.get_slot(/datum/inventory_slot/inventory/shoes), /obj/item/clothing/shoes/magboots/hardsuit) && !elastic) // Can't cuff someone who's in a deployed hardsuit.
to_chat(user, "\The [src] won't fit around \the [H.shoes]!")
return 0
diff --git a/code/game/objects/items/weapons/material/shards.dm b/code/game/objects/items/weapons/material/shards.dm
index 0400482f45b7..abfa96fbda4b 100644
--- a/code/game/objects/items/weapons/material/shards.dm
+++ b/code/game/objects/items/weapons/material/shards.dm
@@ -118,7 +118,7 @@
if(H.species.siemens_coefficient<0.5) //Thick skin.
return
- if( H.shoes || ( H.wear_suit && (H.wear_suit.body_cover_flags & FEET) ) )
+ if(length(H.query_coverage(FEET)))
return
if(H.species.species_flags & NO_MINOR_CUT)
diff --git a/code/game/objects/structures/cliff.dm b/code/game/objects/structures/cliff.dm
index 74b08f80cc4e..010651aad073 100644
--- a/code/game/objects/structures/cliff.dm
+++ b/code/game/objects/structures/cliff.dm
@@ -229,8 +229,8 @@ two tiles on initialization, and which way a cliff is facing may change during m
// Cliff climbing requires climbing gear.
if(ishuman(user))
var/mob/living/carbon/human/H = user
- var/obj/item/clothing/shoes/shoes = H.shoes
- if(shoes && shoes.rock_climbing)
+ var/obj/item/clothing/shoes/shoes = H.inventory.get_slot(/datum/inventory_slot/inventory/shoes)
+ if(istype(shoes) && shoes.rock_climbing)
return TRUE
var/obj/item/held = H.get_active_held_item()
if(held && istype(held, /obj/item/pickaxe/icepick))
diff --git a/code/modules/mob/living/carbon/human/human-defense.dm b/code/modules/mob/living/carbon/human/human-defense.dm
index a605de256ebe..dd8ec5289309 100644
--- a/code/modules/mob/living/carbon/human/human-defense.dm
+++ b/code/modules/mob/living/carbon/human/human-defense.dm
@@ -32,12 +32,8 @@
//* Misc Effects *//
/mob/living/carbon/human/slip_act(slip_class, source, hard_strength, soft_strength, suppressed)
- var/list/equipment = list(src.w_uniform,src.wear_suit,src.shoes)
- var/footcoverage_check = FALSE
- for(var/obj/item/clothing/C in equipment)
- if(C.body_cover_flags & FEET)
- footcoverage_check = TRUE
- break
- if((species.species_flags & NO_SLIP && !footcoverage_check) || (shoes && (shoes.clothing_flags & NOSLIP))) //Footwear negates a species' natural traction.
+ var/footcoverage_check = length(inventory.query_coverage(FEET))
+ var/obj/item/shoes = inventory.get_slot(/datum/inventory_slot/inventory/shoes)
+ if(((species.species_flags & NO_SLIP) && !footcoverage_check) || (shoes && (shoes.clothing_flags & NOSLIP))) //Footwear negates a species' natural traction.
return 0
return ..()
From 997aedab4346245cc1656ce2f4895d97b9fd19f6 Mon Sep 17 00:00:00 2001
From: silicons <2003111+silicons@users.noreply.github.com>
Date: Thu, 28 Nov 2024 14:23:02 -0500
Subject: [PATCH 12/18] enough for now, time to move onto fixes
---
code/modules/mob/inventory/inventory-query.dm | 15 ---------------
1 file changed, 15 deletions(-)
diff --git a/code/modules/mob/inventory/inventory-query.dm b/code/modules/mob/inventory/inventory-query.dm
index aa8bbef4cb22..c8e15ba7f5f4 100644
--- a/code/modules/mob/inventory/inventory-query.dm
+++ b/code/modules/mob/inventory/inventory-query.dm
@@ -24,18 +24,3 @@
/datum/inventory/proc/invalidate_coverage_cache()
cache = list()
-
-/datum/inventory
-
-/datum/inventory
-
-/datum/inventory
-
-/datum/inventory
-
-/datum/inventory
-
-/datum/inventory
-
-
-#warn impl
From 53cf049a01903d91164d272d627dada15d0ef740 Mon Sep 17 00:00:00 2001
From: silicons <2003111+silicons@users.noreply.github.com>
Date: Thu, 28 Nov 2024 14:30:05 -0500
Subject: [PATCH 13/18] fix
---
code/game/objects/items/defib/shockpaddles.dm | 2 +-
code/game/objects/items/weapons/material/shards.dm | 2 +-
code/modules/clothing/clothing_accessories.dm | 2 +-
code/modules/mob/inventory/inventory-query.dm | 2 +-
code/modules/mob/inventory/inventory.dm | 8 ++++++++
5 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/code/game/objects/items/defib/shockpaddles.dm b/code/game/objects/items/defib/shockpaddles.dm
index 02f6a9041130..6194487dc220 100644
--- a/code/game/objects/items/defib/shockpaddles.dm
+++ b/code/game/objects/items/defib/shockpaddles.dm
@@ -105,7 +105,7 @@
/obj/item/shockpaddles/proc/check_contact(mob/living/carbon/human/H)
if(!combat)
- for(var/obj/item/clothing/cloth in H.get_slots_unsafe(
+ for(var/obj/item/clothing/cloth in H.inventory.get_slots_unsafe(
/datum/inventory_slot/inventory/uniform,
/datum/inventory_slot/inventory/suit,
))
diff --git a/code/game/objects/items/weapons/material/shards.dm b/code/game/objects/items/weapons/material/shards.dm
index abfa96fbda4b..3341973c4be0 100644
--- a/code/game/objects/items/weapons/material/shards.dm
+++ b/code/game/objects/items/weapons/material/shards.dm
@@ -118,7 +118,7 @@
if(H.species.siemens_coefficient<0.5) //Thick skin.
return
- if(length(H.query_coverage(FEET)))
+ if(length(H.inventory.query_coverage(FEET)))
return
if(H.species.species_flags & NO_MINOR_CUT)
diff --git a/code/modules/clothing/clothing_accessories.dm b/code/modules/clothing/clothing_accessories.dm
index 4667527d1384..99fcc383ba41 100644
--- a/code/modules/clothing/clothing_accessories.dm
+++ b/code/modules/clothing/clothing_accessories.dm
@@ -38,7 +38,7 @@
return TRUE
return FALSE
-/obj/item/clothing/worn_mob()
+/obj/item/clothing/worn_mob() as /mob
return isnull(accessory_host)? ..() : accessory_host.worn_mob()
/obj/item/clothing/update_worn_icon()
diff --git a/code/modules/mob/inventory/inventory-query.dm b/code/modules/mob/inventory/inventory-query.dm
index c8e15ba7f5f4..d94b3c40c918 100644
--- a/code/modules/mob/inventory/inventory-query.dm
+++ b/code/modules/mob/inventory/inventory-query.dm
@@ -11,7 +11,7 @@
/datum/inventory/proc/query_coverage(body_cover_flags) as /list
if((. = cache["coverage-[body_cover_flags]"]))
return (.):Copy()
- trim_cache()
+ trim_coverage_cache()
. = cache["coverage-[body_cover_flags]"] = list()
for(var/obj/item/worn as anything in get_everything(~INV_FILTER_EQUIPMENT, TRUE))
if(worn.body_cover_flags & body_cover_flags)
diff --git a/code/modules/mob/inventory/inventory.dm b/code/modules/mob/inventory/inventory.dm
index 34e23ec66402..5deab05f8151 100644
--- a/code/modules/mob/inventory/inventory.dm
+++ b/code/modules/mob/inventory/inventory.dm
@@ -65,6 +65,14 @@
hud.unbind_from_inventory(src)
return ..()
+//* Cache *//
+
+/**
+ * Invalidate all caches.
+ */
+/datum/inventory/proc/invalidate_cache()
+ cache = list()
+
//* Queries *//
/**
From 5622c6dbc72ae46c2b8452b1bfb0e92024a6515c Mon Sep 17 00:00:00 2001
From: silicons <2003111+silicons@users.noreply.github.com>
Date: Thu, 28 Nov 2024 14:33:27 -0500
Subject: [PATCH 14/18] fix
---
code/game/objects/items-inventory-old.dm | 2 +-
code/modules/clothing/clothing_accessories.dm | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/code/game/objects/items-inventory-old.dm b/code/game/objects/items-inventory-old.dm
index ee2f92d25c66..25ee42b2f0fb 100644
--- a/code/game/objects/items-inventory-old.dm
+++ b/code/game/objects/items-inventory-old.dm
@@ -161,7 +161,7 @@
/**
* get the mob we're equipped on
*/
-/obj/item/proc/worn_mob()
+/obj/item/proc/worn_mob() as /mob
RETURN_TYPE(/mob)
return worn_inside?.worn_mob() || (worn_slot? loc : null)
diff --git a/code/modules/clothing/clothing_accessories.dm b/code/modules/clothing/clothing_accessories.dm
index 99fcc383ba41..4667527d1384 100644
--- a/code/modules/clothing/clothing_accessories.dm
+++ b/code/modules/clothing/clothing_accessories.dm
@@ -38,7 +38,7 @@
return TRUE
return FALSE
-/obj/item/clothing/worn_mob() as /mob
+/obj/item/clothing/worn_mob()
return isnull(accessory_host)? ..() : accessory_host.worn_mob()
/obj/item/clothing/update_worn_icon()
From 2adfae9b09e1b409449451b8e2763437ef6244e3 Mon Sep 17 00:00:00 2001
From: silicons <2003111+silicons@users.noreply.github.com>
Date: Thu, 28 Nov 2024 15:27:11 -0500
Subject: [PATCH 15/18] Fix
---
citadel.dme | 1 +
code/controllers/subsystem/materials.dm | 4 ----
code/game/click/mobs.dm | 1 +
code/game/objects/systems/storage/storage.dm | 16 +++++-----------
.../clothing/under/accessories/holster.dm | 2 ++
code/modules/mob/inventory/inventory.dm | 4 ++++
code/modules/mob/living/carbon/brain/brain.dm | 3 +++
code/modules/mob/mob-inventory-internal.dm | 10 ++++++----
code/modules/mob/mob-inventory.dm | 4 +++-
.../reagents/chemistry/reagent_holder.dm | 4 ++--
icons/screen/hud/hologram/inventory.dmi | Bin 1665 -> 1665 bytes
11 files changed, 27 insertions(+), 22 deletions(-)
diff --git a/citadel.dme b/citadel.dme
index 91ddc776a7ad..5b19d9954e8a 100644
--- a/citadel.dme
+++ b/citadel.dme
@@ -2015,6 +2015,7 @@
#include "code\game\objects\systems\_system.dm"
#include "code\game\objects\systems\cell_slot.dm"
#include "code\game\objects\systems\storage\storage-screen_object.dm"
+#include "code\game\objects\systems\storage\storage-ui.dm"
#include "code\game\objects\systems\storage\storage.dm"
#include "code\game\objects\systems\storage\subtypes\stack.dm"
#include "code\game\objects\systems\storage\subtypes\stock_parts.dm"
diff --git a/code/controllers/subsystem/materials.dm b/code/controllers/subsystem/materials.dm
index 877dcbe0bd1e..4cd8fae04146 100644
--- a/code/controllers/subsystem/materials.dm
+++ b/code/controllers/subsystem/materials.dm
@@ -7,10 +7,6 @@ SUBSYSTEM_DEF(materials)
/// material recipes
var/list/datum/stack_recipe/material/material_stack_recipes
- // todo: Recover() should keep procedural materials
- // however, i can't be assed to write Recover() until we do procedural materials
- // thus, dealing with it later :^)
-
/// ticked atoms
var/list/ticking = list()
/// currentrun
diff --git a/code/game/click/mobs.dm b/code/game/click/mobs.dm
index ab66aae11d88..656b62c6baf1 100644
--- a/code/game/click/mobs.dm
+++ b/code/game/click/mobs.dm
@@ -139,3 +139,4 @@
constructed.hand_index = active_hand
if(!unarmed)
constructed.using = get_active_held_item()
+ return constructed
diff --git a/code/game/objects/systems/storage/storage.dm b/code/game/objects/systems/storage/storage.dm
index f76db1c7d1f0..b921ced493b1 100644
--- a/code/game/objects/systems/storage/storage.dm
+++ b/code/game/objects/systems/storage/storage.dm
@@ -450,6 +450,9 @@
* @return TRUE / FALSE; if true, caller should stop clickchain.
*/
/datum/object_system/storage/proc/auto_handle_interacted_insertion(obj/item/inserting, datum/event_args/actor/actor, silent, suppressed)
+ if(!actor.performer.is_holding(inserting))
+ // something probably yanked it, don't bother
+ return FALSE
if(is_locked(actor.performer))
actor.chat_feedback(
msg = SPAN_WARNING("[parent] is locked."),
@@ -1431,6 +1434,8 @@
LEFT+[STORAGE_UI_START_TILE_X]:[STORAGE_UI_START_PIXEL_X + middle_width - WORLD_ICON_SIZE + VOLUMETRIC_STORAGE_BOX_BORDER_SIZE],\
BOTTOM+[STORAGE_UI_START_TILE_Y + current_row - 1]:[STORAGE_UI_START_PIXEL_Y]"
+//* Indirection *//
+
/**
* **USE AT YOUR OWN PERIL**
*/
@@ -1461,17 +1466,6 @@
//? Numerical Display Helper
-/datum/storage_numerical_display
- var/obj/item/rendered_object
- var/amount
-
-/datum/storage_numerical_display/New(obj/item/sample, amount = 0)
- src.rendered_object = sample
- src.amount = amount
-
-/proc/cmp_storage_numerical_displays_name_asc(datum/storage_numerical_display/A, datum/storage_numerical_display/B)
- return sorttext(B.rendered_object.name, A.rendered_object.name) || sorttext(B.rendered_object.type, A.rendered_object.type)
-
//? Action
/datum/action/storage_gather_mode
diff --git a/code/modules/clothing/under/accessories/holster.dm b/code/modules/clothing/under/accessories/holster.dm
index 339fda618d4a..5e4af9e315a2 100644
--- a/code/modules/clothing/under/accessories/holster.dm
+++ b/code/modules/clothing/under/accessories/holster.dm
@@ -74,6 +74,8 @@
..(user)
/obj/item/clothing/accessory/holster/attackby(obj/item/W as obj, mob/user as mob)
+ if(!user.is_holding(W))
+ return
holster(W, user)
/obj/item/clothing/accessory/holster/emp_act(severity)
diff --git a/code/modules/mob/inventory/inventory.dm b/code/modules/mob/inventory/inventory.dm
index 5deab05f8151..e0642d94d5a5 100644
--- a/code/modules/mob/inventory/inventory.dm
+++ b/code/modules/mob/inventory/inventory.dm
@@ -117,6 +117,10 @@
over.worn_inside = inside
I.worn_over = null
I.worn_inside = null
+ // make sure it's inside us, and not the other item
+ I.worn_hook_suppressed = TRUE
+ I.forceMove(src)
+ I.worn_hook_suppressed = FALSE
// call procs to inform things
inside.equip_on_worn_over_remove(src, old_slot, user, I, flags)
if(over)
diff --git a/code/modules/mob/living/carbon/brain/brain.dm b/code/modules/mob/living/carbon/brain/brain.dm
index d6d873a15811..7faf1550b053 100644
--- a/code/modules/mob/living/carbon/brain/brain.dm
+++ b/code/modules/mob/living/carbon/brain/brain.dm
@@ -58,6 +58,9 @@
ghostize() //Ghostize checks for key so nothing else is necessary.
return ..()
+/mob/living/carbon/brain/init_inventory()
+ return
+
/mob/living/carbon/brain/update_mobility(blocked, forced)
if(in_contents_of(/obj/vehicle/sealed/mecha) || istype(loc, /obj/item/mmi))
. = ..(blocked, forced)
diff --git a/code/modules/mob/mob-inventory-internal.dm b/code/modules/mob/mob-inventory-internal.dm
index 8a4e0bbe2b8c..b080bc7ca19d 100644
--- a/code/modules/mob/mob-inventory-internal.dm
+++ b/code/modules/mob/mob-inventory-internal.dm
@@ -104,7 +104,7 @@
if(!can_unequip(I, I.worn_slot, flags, user))
return FALSE
old = I.worn_slot
- _unequip_slot(old, flags)
+ _unequip_slot(old, flags, I)
I.on_unequipped(src, old, flags)
I.unequipped(src, old, flags)
handle_item_denesting(I, old, flags, user)
@@ -134,9 +134,11 @@
log_inventory("[key_name(src)] unequipped [I] from [old].")
-/mob/proc/_unequip_slot(slot, flags)
+/mob/proc/_unequip_slot(slot, flags, obj/item/yanking)
SHOULD_NOT_OVERRIDE(TRUE)
var/obj/item/old = _item_by_slot(slot)
+ if(old != yanking)
+ return FALSE
. = _set_inv_slot(slot, null, flags) != INVENTORY_SLOT_DOES_NOT_EXIST
if(.)
inventory.on_item_exited(old, resolve_inventory_slot(slot))
@@ -255,7 +257,7 @@
if(old_slot == SLOT_ID_HANDS)
unequip_hand_impl(I, get_held_index(I), flags)
else
- _unequip_slot(old_slot, flags)
+ _unequip_slot(old_slot, flags, I)
I.on_unequipped(src, old_slot, flags)
I.unequipped(src, old_slot, flags)
// sigh
@@ -278,7 +280,7 @@
if(old_slot == SLOT_ID_HANDS)
unequip_hand_impl(I, get_held_index(I), flags)
else
- _unequip_slot(old_slot, flags)
+ _unequip_slot(old_slot, flags, I)
I.unequipped(src, old_slot, flags)
I.on_unequipped(src, old_slot, flags)
// TODO: HANDLE DELETIONS ON EQUIPPED PROPERLY
diff --git a/code/modules/mob/mob-inventory.dm b/code/modules/mob/mob-inventory.dm
index a5c6fc71c5bc..177a3173dd4b 100644
--- a/code/modules/mob/mob-inventory.dm
+++ b/code/modules/mob/mob-inventory.dm
@@ -164,7 +164,7 @@
to_wear_over = conflicting
// ! DANGER: snowflake time
// take it out of the slot
- _unequip_slot(slot, flags | INV_OP_NO_LOGIC | INV_OP_NO_UPDATE_ICONS)
+ _unequip_slot(slot, flags | INV_OP_NO_LOGIC | INV_OP_NO_UPDATE_ICONS, conflicting)
// recheck
conflict_result = inventory_slot_conflict_check(I, slot)
// put it back in incase something else breaks
@@ -204,6 +204,8 @@
to_wear_over.worn_inside = I
// setting worn inside first disallows equip/unequip from triggering
to_wear_over.forceMove(I)
+ for(var/datum/actor_hud/inventory/hud in inventory?.huds_using)
+ hud.remove_item(to_wear_over, slot)
// check we don't have something already (wtf)
if(I.worn_over)
handle_item_denesting(I, denest_to, flags, user)
diff --git a/code/modules/reagents/chemistry/reagent_holder.dm b/code/modules/reagents/chemistry/reagent_holder.dm
index 7ee0d420823b..45505ac908c1 100644
--- a/code/modules/reagents/chemistry/reagent_holder.dm
+++ b/code/modules/reagents/chemistry/reagent_holder.dm
@@ -365,9 +365,9 @@
if (!target || !target.reagents)
return
- amount = min(amount, get_reagent_amount(id))
+ amount = min(amount, get_reagent_amount(id), target.reagents.maximum_volume - target.reagents.total_volume)
- if(!amount)
+ if(amount <= 0)
return
var/datum/reagent_holder/F = new /datum/reagent_holder(amount)
diff --git a/icons/screen/hud/hologram/inventory.dmi b/icons/screen/hud/hologram/inventory.dmi
index 50673be6fae825a64071539560bcd44b4c5d17b8..c7e63170ebfd94aa026e23d6452c1d9bee18498d 100644
GIT binary patch
delta 158
zcmV;P0Ac@u4S@}iIDd`KJr08~3rkKR|r_h4s+ograEHaG-zcYPyabUk97Zb9b4{B(72d-=N51&yyP!-w^x)unI9juEPyz>+vo(YqNw+eoR|E$c`92iFku
Date: Thu, 28 Nov 2024 15:36:07 -0500
Subject: [PATCH 16/18] hell
---
code/game/objects/systems/storage/storage-ui.dm | 13 +++++++++++++
code/modules/mob/inventory/inventory.dm | 4 ++++
code/modules/mob/mob-inventory.dm | 2 +-
3 files changed, 18 insertions(+), 1 deletion(-)
create mode 100644 code/game/objects/systems/storage/storage-ui.dm
diff --git a/code/game/objects/systems/storage/storage-ui.dm b/code/game/objects/systems/storage/storage-ui.dm
new file mode 100644
index 000000000000..76d987239ff9
--- /dev/null
+++ b/code/game/objects/systems/storage/storage-ui.dm
@@ -0,0 +1,13 @@
+//* This file is explicitly licensed under the MIT license. *//
+//* Copyright (c) 2024 Citadel Station Developers *//
+
+/datum/storage_numerical_display
+ var/obj/item/rendered_object
+ var/amount
+
+/datum/storage_numerical_display/New(obj/item/sample, amount = 0)
+ src.rendered_object = sample
+ src.amount = amount
+
+/proc/cmp_storage_numerical_displays_name_asc(datum/storage_numerical_display/A, datum/storage_numerical_display/B)
+ return sorttext(B.rendered_object.name, A.rendered_object.name) || sorttext(B.rendered_object.type, A.rendered_object.type)
diff --git a/code/modules/mob/inventory/inventory.dm b/code/modules/mob/inventory/inventory.dm
index e0642d94d5a5..e6f2c80548d4 100644
--- a/code/modules/mob/inventory/inventory.dm
+++ b/code/modules/mob/inventory/inventory.dm
@@ -138,6 +138,10 @@
over.worn_hook_suppressed = FALSE
// put it back in the slot
_equip_slot(over, old_slot, flags)
+ var/datum/inventory_slot/old_slot_meta = resolve_inventory_slot(old_slot)
+ for(var/datum/actor_hud/inventory/hud in inventory?.huds_using)
+ hud.remove_item(I, old_slot_meta)
+ hud.add_item(over, old_slot_meta)
/**
* drop items if a bodypart is missing
diff --git a/code/modules/mob/mob-inventory.dm b/code/modules/mob/mob-inventory.dm
index 177a3173dd4b..834455bb13f2 100644
--- a/code/modules/mob/mob-inventory.dm
+++ b/code/modules/mob/mob-inventory.dm
@@ -205,7 +205,7 @@
// setting worn inside first disallows equip/unequip from triggering
to_wear_over.forceMove(I)
for(var/datum/actor_hud/inventory/hud in inventory?.huds_using)
- hud.remove_item(to_wear_over, slot)
+ hud.remove_item(to_wear_over, slot_meta)
// check we don't have something already (wtf)
if(I.worn_over)
handle_item_denesting(I, denest_to, flags, user)
From d68c409baa72e4db22c451781799d55986c1bb85 Mon Sep 17 00:00:00 2001
From: silicons <2003111+silicons@users.noreply.github.com>
Date: Thu, 28 Nov 2024 15:46:32 -0500
Subject: [PATCH 17/18] Fix
---
code/game/objects/items-interaction.dm | 2 +-
code/modules/hardsuits/_rig.dm | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/code/game/objects/items-interaction.dm b/code/game/objects/items-interaction.dm
index 217e2aae0ee2..90c483a942be 100644
--- a/code/game/objects/items-interaction.dm
+++ b/code/game/objects/items-interaction.dm
@@ -89,7 +89,7 @@
if(isnull(actually_picked_up))
to_chat(user, SPAN_WARNING("[src] somehow slips through your grasp. What just happened?"))
return
- if(!user.put_in_hands(actually_picked_up, user.active_hand))
+ if(!user.put_in_hands(actually_picked_up, null, user.active_hand))
if(has_to_drop_to_ground_on_fail)
actually_picked_up.forceMove(user.drop_location())
return
diff --git a/code/modules/hardsuits/_rig.dm b/code/modules/hardsuits/_rig.dm
index a0283f4234a3..55f51f8b0877 100644
--- a/code/modules/hardsuits/_rig.dm
+++ b/code/modules/hardsuits/_rig.dm
@@ -957,7 +957,7 @@
if(check_slot && check_slot == use_obj)
return
use_obj.copy_atom_colour(src)
- if(!H.equip_to_slot_if_possible(use_obj, equip_to, null, INV_OP_FORCE))
+ if(!H.equip_to_slot_if_possible(use_obj, equip_to, INV_OP_FORCE))
if(check_slot && warn == 1)
to_chat(H, "You are unable to deploy \the [piece] as \the [check_slot] [check_slot.gender == PLURAL ? "are" : "is"] in the way.")
return
From d732f26f28f0389fcc629fbd62fdb38eea5b2bc7 Mon Sep 17 00:00:00 2001
From: silicons <2003111+silicons@users.noreply.github.com>
Date: Thu, 28 Nov 2024 15:53:56 -0500
Subject: [PATCH 18/18] it shoudl recognize new annotations
---
dependencies.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dependencies.sh b/dependencies.sh
index d8af558c6f38..e41225a27381 100755
--- a/dependencies.sh
+++ b/dependencies.sh
@@ -19,7 +19,7 @@ export NODE_VERSION_LTS=20.13.0
export NODE_VERSION_COMPAT=20.2.0
# SpacemanDMM git tag
-export SPACEMAN_DMM_VERSION=suite-1.8
+export SPACEMAN_DMM_VERSION=suite-1.9
# Python version for mapmerge and other tools
export PYTHON_VERSION=3.9.0