Files
Bubberstation/code/datums/elements/pet_bonus.dm
T
grungussussandGitHub a3a91f4d03 pet emotes, pet bonus adjustment (#87126)
## About The Pull Request
- pet bonus element now works by getting an emote fed into it.
- all pets who had pet bonus emotes now have it as a proper emote they
can use if controlled by a player.
## Why It's Good For The Game
- standardises pet bonus so it's easier to give more behaviors to
petting, like sounds :3
- allows basic mobs controlled by players to use the emote at will,
which will allow them to react to situations more with emotes.
## Changelog
🆑 grungussuss
add: a lot of basic mobs and pets got new emotes
refactor: emotes triggered by petting pets work differently now, please
report any oddities with these behaviors.
sound: new emotes for basic mobs got sounds
/🆑
2024-10-12 12:35:35 +00:00

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
///string key of the emote to do when pet.
var/emote_name
///actual moodlet given, defaults to the pet animal one
var/moodlet
/datum/element/pet_bonus/Attach(datum/target, emote_name, moodlet = /datum/mood_event/pet_animal)
. = ..()
if(!isliving(target))
return ELEMENT_INCOMPATIBLE
src.emote_name = emote_name
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_name && prob(33))
INVOKE_ASYNC(pet, TYPE_PROC_REF(/mob, emote), emote_name)
petter.add_mood_event("petting_bonus", moodlet, pet)