Files
Bubberstation/code/datums/elements/skill_reward.dm
Bloop 1bfee08d54 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

<details><summary>Works</summary>


![dreamseeker_xijzQB0ALa](https://github.com/tgstation/tgstation/assets/13398309/eccb35d5-e1ea-4e2c-9906-f5b8c2187d24)

</details>

<details><summary>get_all_gear()</summary>


![dreamseeker_WsG0Uu2tIe](https://github.com/tgstation/tgstation/assets/13398309/d5c272d4-1990-454c-b48f-4da7b6a5f859)

</details>

<details><summary>get_equipped_items()</summary>


![dreamseeker_qe4hMngAO3](https://github.com/tgstation/tgstation/assets/13398309/06469b93-2a58-49db-be7f-c748576bf481)

</details>


<details><summary>item_flags get set now, hopefully preventing future
issues related to that</summary>


![image](https://github.com/tgstation/tgstation/assets/13398309/29a0e25a-a88f-4547-99f8-888da6b85e4d)

</details>

## Changelog

🆑
fix: greyscale colors will now update on the mob when modifying them via
the VV menu
/🆑

---------

Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
2023-08-26 20:47:59 +02:00

49 lines
2.2 KiB
Plaintext

///An element that forbids mobs without a required skill level from equipping the item.
/datum/element/skill_reward
element_flags = ELEMENT_BESPOKE
argument_hash_start_idx = 2
///The required skill the user has to have to equip the item.
var/associated_skill
/datum/element/skill_reward/Attach(datum/target, associated_skill)
. = ..()
if(!isitem(target))
return ELEMENT_INCOMPATIBLE
src.associated_skill = associated_skill
RegisterSignal(target, COMSIG_ATOM_EXAMINE, PROC_REF(on_examine))
RegisterSignal(target, COMSIG_ATOM_ATTACK_HAND, PROC_REF(on_attack_hand))
RegisterSignal(target, COMSIG_ITEM_POST_EQUIPPED, PROC_REF(drop_if_unworthy))
/datum/element/skill_reward/proc/on_examine(datum/source, mob/user, list/examine_list)
SIGNAL_HANDLER
examine_list += span_notice("You notice a powerful aura about this item, suggesting that only the truly experienced may wield it.")
/datum/element/skill_reward/proc/on_attack_hand(datum/source, mob/living/user, list/modifiers)
SIGNAL_HANDLER
if(!LAZYACCESS(modifiers, CTRL_CLICK) && !check_equippable(user)) //Allows other players to drag it around at least.
to_chat(user, span_warning("You feel completely and utterly unworthy to even touch \the [source]."))
return COMPONENT_CANCEL_ATTACK_CHAIN
///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(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)
return COMPONENT_EQUIPPED_FAILED
/datum/element/skill_reward/proc/check_equippable(mob/living/user)
return user.mind?.get_skill_level(associated_skill) >= SKILL_LEVEL_LEGENDARY
/**
* Welp, the code is pretty much the same, except for one tiny detail, I suppose it's ok to make a subtype of this element.
* That tiny detail is that we don't check for skills, but if the player has played for thousands of hours.
*/
/datum/element/skill_reward/veteran
element_flags = NONE
/datum/element/skill_reward/veteran/check_equippable(mob/user)
return user.client?.is_veteran()