Files
Bubberstation/code/datums/elements/skill_reward.dm
Jacquerel e8157f4dfc Items in your hands can catch fire (#83867)
## About The Pull Request

Recently we allowed items held in your hands to catch fire if you catch
fire.
This makes sense but the code had a few oversights, then we reverted it.

This PR reintroduces the feature, but with a few refinements.
The basic feature is simple: If you are on fire then items you are
holding will also catch fire, in the same vein as items you are wearing
on your head or hands.

There are also a few caveats we forgot about the first time we added
this:

- If your gloves cannot catch fire, your held items will not catch fire
(because your hands aren't on fire).
- If you are extinguished, your held items will also be extinguished.
- Stopping, Dropping, and Rolling on top of any items will also
extinguish those items.

As part of this change, after an argument about whether or not this is
an oversight in coding-general, I've made the proc `get_equipped_items`
take a bitflag instead of a series of booleans as an argument and added
a new one for "include held items", so that we need no longer argue
about whether holding something counts as "equipping" it (in all other
parts of the game than this proc, it does). This is what gives the PR
most of its code footprint, don't be scared.

## Why It's Good For The Game

Items you are holding in your hands _should_ catch fire if everything
else on your person is on fire, and taking an item off of your body to
put it in your hands shouldn't protect it from fire, because those
things don't make intuitive sense.
If we want an item to be able to catch fire when worn, then it should do
so.

This might expose some issues where we were improperly setting the
flammability flags on items, but any weapon which will burn in your
hands now would also have burned if you were wearing it on your belt or
back, so making those issues more visible should be a bonus (we'll also
stop them from burning on your back or belt).

If you see someone holding a piece of paper that you really don't want
them to read you can now set them on fire to stop them from reading it,
whereas previously they would deftly hold the very flammable object out
of reach of their flaming body.

## Changelog

🆑
balance: Items held in your hands can catch fire.
balance: Items you are holding won't catch fire if your hands cannot
catch fire.
balance: When you stop being on fire so will items you are holding.
balance: If you roll around on your burning items they will stop being
on fire.
/🆑
2024-06-19 12:15:27 +12:00

50 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
return NONE
///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 | INCLUDE_ACCESSORIES)))
return NONE
to_chat(user, span_warning("You feel completely and utterly unworthy to even touch \the [source]."))
user.dropItemToGround(source, 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()