mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-21 03:59:59 +01:00
## About The Pull Request Partial Revert of https://github.com/tgstation/tgstation/pull/80800 Assuming every num passed in the parameters of `add_mood_effect` is a `timeout_mod` is incorrect, because there can be mood events that take a numeric arg which is not meant to be multiplied against the timeout. This leads to the same issue as multiplying it with strings essentially (in one case, shown below, this results in a negative duration of a timer).   Plus having a keyword arg that may or may not actually be what the keyword arg claims to be is really confusing and bad. Instead here's what I propose: passing in an instantiated mood datum itself, which has been modified, and copying the timeout from it before discarding it. It is not as clean as I'd prefer either, but at least it's logically sound and the intent is clear, and it's the best I can think of short of a major refactor of the entire system for this one small thing which is only being used by food quality.  ## Why It's Good For The Game Clearer, less smelly code. ## Changelog 🆑 code: removed the timeout_mod arg from add_mood_event, which was only used for one thing and causes more issues than it's worth /🆑
40 lines
1.3 KiB
Plaintext
40 lines
1.3 KiB
Plaintext
/**
|
|
* # Pet bonus element!
|
|
*
|
|
* Bespoke element that plays a fun message, sends a heart out, and gives a stronger mood bonus when you pet this animal.
|
|
* I may have been able to make this work for carbons, but it would have been interjecting on some help mode interactions anyways.
|
|
*/
|
|
/datum/element/pet_bonus
|
|
element_flags = ELEMENT_BESPOKE
|
|
argument_hash_start_idx = 2
|
|
|
|
///optional cute message to send when you pet your pet!
|
|
var/emote_message
|
|
///actual moodlet given, defaults to the pet animal one
|
|
var/moodlet
|
|
|
|
/datum/element/pet_bonus/Attach(datum/target, emote_message, moodlet = /datum/mood_event/pet_animal)
|
|
. = ..()
|
|
if(!isliving(target))
|
|
return ELEMENT_INCOMPATIBLE
|
|
|
|
src.emote_message = emote_message
|
|
src.moodlet = moodlet
|
|
RegisterSignal(target, COMSIG_ATOM_ATTACK_HAND, PROC_REF(on_attack_hand))
|
|
|
|
/datum/element/pet_bonus/Detach(datum/target)
|
|
. = ..()
|
|
UnregisterSignal(target, COMSIG_ATOM_ATTACK_HAND)
|
|
|
|
/datum/element/pet_bonus/proc/on_attack_hand(mob/living/pet, mob/living/petter, list/modifiers)
|
|
SIGNAL_HANDLER
|
|
|
|
if(pet.stat != CONSCIOUS || petter.combat_mode || LAZYACCESS(modifiers, RIGHT_CLICK))
|
|
return
|
|
|
|
new /obj/effect/temp_visual/heart(pet.loc)
|
|
SEND_SIGNAL(pet, COMSIG_ANIMAL_PET, petter, modifiers)
|
|
if(emote_message && prob(33))
|
|
pet.manual_emote(emote_message)
|
|
petter.add_mood_event("petting_bonus", moodlet, pet)
|