Files
Bubberstation/code/datums/elements/befriend_petting.dm
T
dfd4801122 Adds p_They (and friends) for capitalized pronoun helpers (#76910)
## About The Pull Request

![image](https://github.com/tgstation/tgstation/assets/66640614/f8afe149-85cf-40d2-a5c1-4c96a3ccdfe4)

Basically replaces p_they(TRUE) with p_They

## Why It's Good For The Game
Fewer ambiguous parameters (what does TRUE mean when passed to p_they?)
More comprehensive helper functions.

## Changelog
🆑 Tattle
spellcheck: Fixed the grammar on a few revenant messages
/🆑

---------

Co-authored-by: tattle <article.disaster@gmail.com>
2023-07-17 22:55:58 -07:00

56 lines
1.8 KiB
Plaintext

#define BEFRIEND_REPLACE_KEY_SOURCE "%SOURCE%"
#define BEFRIEND_REPLACE_KEY_TARGET "%TARGET%"
/**
* # Befriend Petting
*
* Element which makes a mob befriend you if you pet it enough.
*/
/datum/element/befriend_petting
element_flags = ELEMENT_BESPOKE
argument_hash_start_idx = 2
/// Chance of success per interaction.
var/befriend_chance
/// Message to print if we gain a friend. String %SOURCE% and %TARGET% are replaced by names if present.
var/tamed_reaction
/datum/element/befriend_petting/Attach(datum/target, befriend_chance = AI_DOG_PET_FRIEND_PROB, tamed_reaction)
. = ..()
if (!isliving(target))
return ELEMENT_INCOMPATIBLE
src.befriend_chance = befriend_chance
src.tamed_reaction = tamed_reaction
RegisterSignal(target, COMSIG_ATOM_ATTACK_HAND, PROC_REF(on_click))
/datum/element/befriend_petting/Detach(datum/target)
. = ..()
UnregisterSignal(target, COMSIG_ATOM_ATTACK_HAND, COMSIG_ATOM_WAS_ATTACKED)
/// If it's a nice touch make friends
/datum/element/befriend_petting/proc/on_click(mob/living/owner, mob/living/user)
SIGNAL_HANDLER
if (!istype(user))
return
if (user.combat_mode)
return // We'll deal with this later
if (owner.stat == DEAD)
var/additional_text = HAS_MIND_TRAIT(user, TRAIT_NAIVE) ? "It looks like [owner.p_theyre()] sleeping." : "[owner.p_They()] seem[owner.p_s()] to be dead."
to_chat(user, span_warning("[owner] feels cold to the touch. [additional_text]"))
return
if (owner.stat != CONSCIOUS)
return
if (!prob(befriend_chance))
return
if (!owner.befriend(user))
return
if (!tamed_reaction)
return
var/display_message = replacetext(tamed_reaction, BEFRIEND_REPLACE_KEY_SOURCE, "[owner]")
display_message = replacetext(display_message, BEFRIEND_REPLACE_KEY_TARGET, "[user]")
owner.visible_message(span_notice(display_message))
#undef BEFRIEND_REPLACE_KEY_SOURCE
#undef BEFRIEND_REPLACE_KEY_TARGET