From 00a584184b294f91588b46fa49cba7bc9be37478 Mon Sep 17 00:00:00 2001
From: SkyratBot <59378654+SkyratBot@users.noreply.github.com>
Date: Sat, 26 Aug 2023 22:38:29 +0200
Subject: [PATCH] [MIRROR] Fixes greyscale colors not updating when changing
their colors via VV, and fixes some issues with accessories [MDB IGNORE]
(#23346)
* Fixes greyscale colors not updating when changing their colors via VV, and fixes some issues with accessories (#77806)
## About The Pull Request
Fixes https://github.com/Skyrat-SS13/Skyrat-tg/issues/23214
This fixes a few bugs and cleans up code a bit:
1) Greyscale colors that were changed via the VV modify greyscale menu
will now update the mob's worn clothing accordingly. It wasn't doing
this before. Accessories in particular needed a bit of extra work to
update in this way because it wasn't coded with this case in mind.
2) Accessories will call `equipped()` and `dropped()` when they get
added/removed. This will fix issues like item flags being incorrectly
set, action bars not being added, etc.
3) Accessories will now be returned by `get_all_gear()`. This will
probably fix a few issues I'm not aware of.
## Why It's Good For The Game
Works

get_all_gear()

get_equipped_items()

item_flags get set now, hopefully preventing future
issues related to that

## Changelog
:cl:
fix: greyscale colors will now update on the mob when modifying them via
the VV menu
/:cl:
---------
Co-authored-by: Ghom <42542238+Ghommie@ users.noreply.github.com>
* Fixes greyscale colors not updating when changing their colors via VV, and fixes some issues with accessories
---------
Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com>
Co-authored-by: Ghom <42542238+Ghommie@ users.noreply.github.com>
---
code/datums/components/gags_recolorable.dm | 9 ---------
code/datums/diseases/transformation.dm | 2 +-
code/datums/elements/skill_reward.dm | 2 +-
code/modules/admin/verbs/ert.dm | 2 +-
code/modules/admin/verbs/selectequipment.dm | 2 +-
.../antagonists/disease/disease_abilities.dm | 2 +-
code/modules/antagonists/obsessed/obsessed.dm | 2 +-
code/modules/assembly/bomb.dm | 2 +-
code/modules/buildmode/submodes/outfit.dm | 4 ++--
code/modules/clothing/clothing.dm | 15 +++++++++++++--
code/modules/clothing/outfits/standard.dm | 2 +-
code/modules/clothing/under/_under.dm | 9 +++++++++
.../clothing/under/accessories/_accessories.dm | 18 ++++++++++++++++++
code/modules/mafia/outfits.dm | 2 +-
code/modules/mob/inventory.dm | 13 +++++++++----
code/modules/mob/transform_procs.dm | 2 +-
16 files changed, 61 insertions(+), 27 deletions(-)
diff --git a/code/datums/components/gags_recolorable.dm b/code/datums/components/gags_recolorable.dm
index f864ee5bd0c..96dceaf95d8 100644
--- a/code/datums/components/gags_recolorable.dm
+++ b/code/datums/components/gags_recolorable.dm
@@ -62,12 +62,3 @@
playsound(atom_parent.loc, 'sound/effects/spray.ogg', 5, TRUE, 5)
atom_parent.set_greyscale(menu.split_colors)
-
- // If the item is a piece of clothing and is being worn, make sure it updates on the player
- if(!isclothing(atom_parent))
- return
- if(!ishuman(atom_parent.loc))
- return
- var/obj/item/clothing/clothing_parent = atom_parent
- var/mob/living/carbon/human/wearer = atom_parent.loc
- wearer.update_clothing(clothing_parent.slot_flags)
diff --git a/code/datums/diseases/transformation.dm b/code/datums/diseases/transformation.dm
index dfe3b87040b..15f56f8ec2f 100644
--- a/code/datums/diseases/transformation.dm
+++ b/code/datums/diseases/transformation.dm
@@ -61,7 +61,7 @@
if(affected_mob.notransform)
return
affected_mob.notransform = 1
- for(var/obj/item/W in affected_mob.get_equipped_items(TRUE))
+ for(var/obj/item/W in affected_mob.get_equipped_items(include_pockets = TRUE))
affected_mob.dropItemToGround(W)
for(var/obj/item/I in affected_mob.held_items)
affected_mob.dropItemToGround(I)
diff --git a/code/datums/elements/skill_reward.dm b/code/datums/elements/skill_reward.dm
index ac80c53449d..0c0e04754f7 100644
--- a/code/datums/elements/skill_reward.dm
+++ b/code/datums/elements/skill_reward.dm
@@ -28,7 +28,7 @@
///We check if the item can be equipped, otherwise we drop it.
/datum/element/skill_reward/proc/drop_if_unworthy(datum/source, mob/living/user)
SIGNAL_HANDLER
- if(check_equippable(user) | !(source in user.get_equipped_items(TRUE)))
+ if(check_equippable(user) | !(source in user.get_equipped_items(include_pockets = TRUE, include_accessories = TRUE)))
return
to_chat(user, span_warning("You feel completely and utterly unworthy to even touch \the [source]."))
user.dropItemToGround(src, TRUE)
diff --git a/code/modules/admin/verbs/ert.dm b/code/modules/admin/verbs/ert.dm
index a3921fe1f30..7db4c7cccc5 100644
--- a/code/modules/admin/verbs/ert.dm
+++ b/code/modules/admin/verbs/ert.dm
@@ -25,7 +25,7 @@
/datum/admins/proc/equipAntagOnDummy(mob/living/carbon/human/dummy/mannequin, datum/antagonist/antag)
- for(var/I in mannequin.get_equipped_items(TRUE))
+ for(var/I in mannequin.get_equipped_items(include_pockets = TRUE))
qdel(I)
if (ispath(antag, /datum/antagonist/ert))
var/datum/antagonist/ert/ert = antag
diff --git a/code/modules/admin/verbs/selectequipment.dm b/code/modules/admin/verbs/selectequipment.dm
index d1530a76052..e88ca0bf233 100644
--- a/code/modules/admin/verbs/selectequipment.dm
+++ b/code/modules/admin/verbs/selectequipment.dm
@@ -213,7 +213,7 @@
delete_pocket = TRUE
SSblackbox.record_feedback("tally", "admin_verb", 1, "Select Equipment") // If you are copy-pasting this, ensure the 4th parameter is unique to the new proc!
- for(var/obj/item/item in human_target.get_equipped_items(delete_pocket))
+ for(var/obj/item/item in human_target.get_equipped_items(include_pockets = delete_pocket))
qdel(item)
var/obj/item/organ/internal/brain/human_brain = human_target.get_organ_slot(BRAIN)
diff --git a/code/modules/antagonists/disease/disease_abilities.dm b/code/modules/antagonists/disease/disease_abilities.dm
index 08d5160e141..3267944e05c 100644
--- a/code/modules/antagonists/disease/disease_abilities.dm
+++ b/code/modules/antagonists/disease/disease_abilities.dm
@@ -268,7 +268,7 @@ new /datum/disease_ability/symptom/powerful/youth
var/mob/living/carbon/human/host = our_disease.following_host
if(!host)
return FALSE
- for(var/obj/thing as anything in host.get_equipped_items(FALSE))
+ for(var/obj/thing as anything in host.get_equipped_items(include_accessories = TRUE))
thing.AddComponent(/datum/component/infective, our_disease.disease_template, 300)
//no shoes? infect the floor.
if(!host.shoes)
diff --git a/code/modules/antagonists/obsessed/obsessed.dm b/code/modules/antagonists/obsessed/obsessed.dm
index 749f6d0fde4..63adacca1e8 100644
--- a/code/modules/antagonists/obsessed/obsessed.dm
+++ b/code/modules/antagonists/obsessed/obsessed.dm
@@ -63,7 +63,7 @@
suit = /obj/item/clothing/suit/apron
/datum/outfit/obsessed/post_equip(mob/living/carbon/human/H)
- for(var/obj/item/carried_item in H.get_equipped_items(TRUE))
+ for(var/obj/item/carried_item in H.get_equipped_items(include_pockets = TRUE, include_accessories = TRUE))
carried_item.add_mob_blood(H)//Oh yes, there will be blood...
H.regenerate_icons()
diff --git a/code/modules/assembly/bomb.dm b/code/modules/assembly/bomb.dm
index 2a15d78063d..4ea085ca9a3 100644
--- a/code/modules/assembly/bomb.dm
+++ b/code/modules/assembly/bomb.dm
@@ -122,7 +122,7 @@
if(LAZYLEN(assembly.assemblies) == igniter_count)
return
- if((src in user.get_equipped_items(TRUE)) && !user.canUnEquip(src))
+ if((src in user.get_equipped_items(include_pockets = TRUE, include_accessories = TRUE)) && !user.canUnEquip(src))
to_chat(user, span_warning("[src] is stuck to you!"))
return
diff --git a/code/modules/buildmode/submodes/outfit.dm b/code/modules/buildmode/submodes/outfit.dm
index 8927e7be9fa..5f8e3319cb9 100644
--- a/code/modules/buildmode/submodes/outfit.dm
+++ b/code/modules/buildmode/submodes/outfit.dm
@@ -32,11 +32,11 @@
to_chat(c, span_warning("Pick an outfit first."))
return
- for (var/item in dollie.get_equipped_items(TRUE))
+ for (var/item in dollie.get_equipped_items(include_pockets = TRUE))
qdel(item)
if(dressuptime != "Naked")
dollie.equipOutfit(dressuptime)
if(LAZYACCESS(modifiers, RIGHT_CLICK))
- for (var/item in dollie.get_equipped_items(TRUE))
+ for (var/item in dollie.get_equipped_items(include_pockets = TRUE))
qdel(item)
diff --git a/code/modules/clothing/clothing.dm b/code/modules/clothing/clothing.dm
index ef1769bf029..26792014fff 100644
--- a/code/modules/clothing/clothing.dm
+++ b/code/modules/clothing/clothing.dm
@@ -254,6 +254,17 @@
LAZYSET(user_vars_remembered, variable, user.vars[variable])
user.vv_edit_var(variable, user_vars_to_edit[variable])
+// If the item is a piece of clothing and is being worn, make sure it updates on the player
+/obj/item/clothing/update_greyscale()
+ . = ..()
+
+ var/mob/living/carbon/human/wearer = loc
+
+ if(!istype(wearer))
+ return
+
+ wearer.update_clothing(slot_flags)
+
/**
* Inserts a trait (or multiple traits) into the clothing traits list
*
@@ -392,7 +403,7 @@
if(isliving(loc)) //It's not important enough to warrant a message if it's not on someone
var/mob/living/M = loc
- if(src in M.get_equipped_items(FALSE))
+ if(src in M.get_equipped_items())
to_chat(M, span_warning("Your [name] start[p_s()] to fall apart!"))
else
to_chat(M, span_warning("[src] start[p_s()] to fall apart!"))
@@ -515,7 +526,7 @@ BLIND // can't see anything
update_clothes_damaged_state(CLOTHING_SHREDDED)
if(isliving(loc))
var/mob/living/M = loc
- if(src in M.get_equipped_items(FALSE)) //make sure they were wearing it and not attacking the item in their hands
+ if(src in M.get_equipped_items()) //make sure they were wearing it and not attacking the item in their hands
M.visible_message(span_danger("[M]'s [src.name] fall[p_s()] off, [p_theyre()] completely shredded!"), span_warning("Your [src.name] fall[p_s()] off, [p_theyre()] completely shredded!"), vision_distance = COMBAT_MESSAGE_RANGE)
M.dropItemToGround(src)
else
diff --git a/code/modules/clothing/outfits/standard.dm b/code/modules/clothing/outfits/standard.dm
index 06503046d5c..061fbe3a1de 100644
--- a/code/modules/clothing/outfits/standard.dm
+++ b/code/modules/clothing/outfits/standard.dm
@@ -175,7 +175,7 @@
l_hand = /obj/item/fireaxe
/datum/outfit/psycho/post_equip(mob/living/carbon/human/H)
- for(var/obj/item/carried_item in H.get_equipped_items(TRUE))
+ for(var/obj/item/carried_item in H.get_equipped_items(include_pockets = TRUE, include_accessories = TRUE))
carried_item.add_mob_blood(H)//Oh yes, there will be blood...
for(var/obj/item/I in H.held_items)
I.add_mob_blood(H)
diff --git a/code/modules/clothing/under/_under.dm b/code/modules/clothing/under/_under.dm
index 374d48148cd..4f4111a0eb4 100644
--- a/code/modules/clothing/under/_under.dm
+++ b/code/modules/clothing/under/_under.dm
@@ -238,6 +238,15 @@
accessory_overlay.alpha = prime_accessory.alpha
accessory_overlay.color = prime_accessory.color
+/// Updates the accessory's worn overlay mutable appearance
+/obj/item/clothing/under/proc/update_accessory_overlay()
+ if(isnull(accessory_overlay))
+ return
+
+ cut_overlay(accessory_overlay)
+ create_accessory_overlay()
+ update_appearance() // so we update the suit inventory overlay too
+
/obj/item/clothing/under/Exited(atom/movable/gone, direction)
. = ..()
// If one of our accessories was moved out, handle it
diff --git a/code/modules/clothing/under/accessories/_accessories.dm b/code/modules/clothing/under/accessories/_accessories.dm
index 1792bff82bb..8ecc3962abd 100644
--- a/code/modules/clothing/under/accessories/_accessories.dm
+++ b/code/modules/clothing/under/accessories/_accessories.dm
@@ -54,6 +54,22 @@
return TRUE
+// If accessory is being worn, make sure it updates on the player
+/obj/item/clothing/accessory/update_greyscale()
+ . = ..()
+
+ var/obj/item/clothing/under/attached_to = loc
+
+ if(!istype(attached_to))
+ return
+
+ var/mob/living/carbon/human/wearer = attached_to.loc
+
+ if(!istype(wearer))
+ return
+
+ attached_to.update_accessory_overlay()
+
/**
* Actually attach this accessory to the passed clothing article.
*
@@ -145,10 +161,12 @@
/// Called when the uniform this accessory is pinned to is equipped in a valid slot
/obj/item/clothing/accessory/proc/accessory_equipped(obj/item/clothing/under/clothes, mob/living/user)
+ equipped(user, user.get_slot_by_item(clothes)) // so we get any actions, item_flags get set, etc
return
/// Called when the uniform this accessory is pinned to is dropped
/obj/item/clothing/accessory/proc/accessory_dropped(obj/item/clothing/under/clothes, mob/living/user)
+ dropped(user)
return
/// Signal proc for [COMSIG_CLOTHING_UNDER_ADJUSTED] on the uniform we're pinned to
diff --git a/code/modules/mafia/outfits.dm b/code/modules/mafia/outfits.dm
index 43ccfe73a1e..b962b4530f1 100644
--- a/code/modules/mafia/outfits.dm
+++ b/code/modules/mafia/outfits.dm
@@ -155,7 +155,7 @@
suit = /obj/item/clothing/suit/apron
/datum/outfit/mafia/obsessed/post_equip(mob/living/carbon/human/H)
- for(var/obj/item/carried_item in H.get_equipped_items(TRUE))
+ for(var/obj/item/carried_item in H.get_equipped_items(include_pockets = TRUE, include_accessories = TRUE))
carried_item.add_mob_blood(H)//Oh yes, there will be blood...
H.regenerate_icons()
diff --git a/code/modules/mob/inventory.dm b/code/modules/mob/inventory.dm
index f772c4756cf..7e288ebcee5 100644
--- a/code/modules/mob/inventory.dm
+++ b/code/modules/mob/inventory.dm
@@ -385,9 +385,10 @@
*
* Argument(s):
* * Optional - include_pockets (TRUE/FALSE), whether or not to include the pockets and suit storage in the returned list
+ * * Optional - include_accessories (TRUE/FALSE), whether or not to include the accessories in the returned list
*/
-/mob/living/proc/get_equipped_items(include_pockets = FALSE)
+/mob/living/proc/get_equipped_items(include_pockets = FALSE, include_accessories = FALSE)
var/list/items = list()
for(var/obj/item/item_contents in contents)
if(item_contents.item_flags & IN_INVENTORY)
@@ -400,17 +401,21 @@
*
* Argument(s):
* * Optional - include_pockets (TRUE/FALSE), whether or not to include the pockets and suit storage in the returned list
+ * * Optional - include_accessories (TRUE/FALSE), whether or not to include the accessories in the returned list
*/
-/mob/living/carbon/human/get_equipped_items(include_pockets = FALSE)
+/mob/living/carbon/human/get_equipped_items(include_pockets = FALSE, include_accessories = FALSE)
var/list/items = ..()
if(!include_pockets)
items -= list(l_store, r_store, s_store)
+ if(include_accessories && w_uniform)
+ var/obj/item/clothing/under/worn_under = w_uniform
+ items += worn_under.attached_accessories
return items
/mob/living/proc/unequip_everything()
var/list/items = list()
- items |= get_equipped_items(TRUE)
+ items |= get_equipped_items(include_pockets = TRUE)
for(var/I in items)
dropItemToGround(I)
drop_all_held_items()
@@ -536,7 +541,7 @@
//GetAllContents that is reasonable and not stupid
/mob/living/carbon/proc/get_all_gear()
- var/list/processing_list = get_equipped_items(include_pockets = TRUE) + held_items
+ var/list/processing_list = get_equipped_items(include_pockets = TRUE, include_accessories = TRUE) + held_items
list_clear_nulls(processing_list) // handles empty hands
var/i = 0
while(i < length(processing_list) )
diff --git a/code/modules/mob/transform_procs.dm b/code/modules/mob/transform_procs.dm
index 56ff1cfae2a..f02624449ba 100644
--- a/code/modules/mob/transform_procs.dm
+++ b/code/modules/mob/transform_procs.dm
@@ -288,7 +288,7 @@
SSblackbox.record_feedback("amount", "gorillas_created", 1)
- var/Itemlist = get_equipped_items(TRUE)
+ var/Itemlist = get_equipped_items(include_pockets = TRUE)
Itemlist += held_items
for(var/obj/item/W in Itemlist)
dropItemToGround(W, TRUE)