Files
Bubberstation/code/datums/elements/befriend_petting.dm
SkyratBot 98774c8580 [MIRROR] Fixes mind traits (Curator, Miner, Clown) [MDB IGNORE] (#21397)
* Fixes mind traits (Curator, Miner, Clown) (#75593)

## About The Pull Request

Tower of Babel (Curator), Naive (Clown), and Storm detector (Shaft
Miner), are all traits that are given to your mind upon taking these
jobs.
However, we have been checking the body for these traits, not the mind.
This meant that Shaft miners werent alerted of ice storms, Clowns didnt
have their unique examine text, and Curators were affected by Tower of
Babel.
This fixes all those issues.

Naive and Tower of Babel realistically should only be on the mind, so I
changed all instances to check the mind. Storm detection is something
you can get through analyzers, so I left it as a check for both your
body and mind traits.

Clown's Naive:

![image](https://github.com/tgstation/tgstation/assets/53777086/30e92026-5d1d-44a5-9969-206df99c5e8f)

Tower of Babel:

![image](https://github.com/tgstation/tgstation/assets/53777086/b1d41f9d-e020-495c-89de-0d4e2c953442)

## Why It's Good For The Game

Fixes several bugs for 3 jobs all at once. I don't see any issue reports
on any of these, but they existed.

## Changelog

🆑
fix: Shaft Miners are now alerted of Icemoon storms, Clowns are naive,
and Curators are immune to the Tower of Babel again.
/🆑

* Fixes mind traits (Curator, Miner, Clown)

---------

Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com>
2023-05-24 16:34:55 +02:00

56 lines
1.9 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_TRAIT(user.mind, TRAIT_NAIVE) ? "It looks like [owner.p_theyre()] sleeping." : "[owner.p_they(capitalized = TRUE)] 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