diff --git a/code/__DEFINES/misc.dm b/code/__DEFINES/misc.dm index 29ff0a8fae..5f7c2cb396 100644 --- a/code/__DEFINES/misc.dm +++ b/code/__DEFINES/misc.dm @@ -519,6 +519,10 @@ GLOBAL_LIST_INIT(pda_reskins, list(PDA_SKIN_CLASSIC = 'icons/obj/pda.dmi', PDA_S #define VOMIT_TOXIC 1 #define VOMIT_PURPLE 2 +//whether the emote is visible or audible. +#define EMOTE_VISIBLE 1 +#define EMOTE_AUDIBLE 2 + // possible bitflag return values of intercept_zImpact(atom/movable/AM, levels = 1) calls #define FALL_INTERCEPTED (1<<0) //Stops the movable from falling further and crashing on the ground #define FALL_NO_MESSAGE (1<<1) //Used to suppress the "[A] falls through [old_turf]" messages where it'd make little sense at all, like going downstairs. diff --git a/code/datums/elements/wuv.dm b/code/datums/elements/wuv.dm new file mode 100644 index 0000000000..d2b1f7aa6d --- /dev/null +++ b/code/datums/elements/wuv.dm @@ -0,0 +1,60 @@ + +/datum/element/wuv //D'awwwww + element_flags = ELEMENT_BESPOKE + id_arg_index = 2 + //the for the me emote proc call when petted. + var/pet_emote + //whether the emote is visible or audible + var/pet_type + //same as above, except when harmed. "You are going into orbit, you stupid mutt!" + var/punt_emote + //same as pet_type + var/punt_type + //mood typepath for the moodlet signal when petted. + var/pet_moodlet + //same as above but for harm + var/punt_moodlet + +/datum/element/wuv/Attach(datum/target, pet, pet_t, pet_mood, punt, punt_t, punt_mood) + . = ..() + + if(!isliving(target)) + return ELEMENT_INCOMPATIBLE + + pet_emote = pet + pet_type = pet_t + punt_emote = punt + punt_type = punt_t + pet_moodlet = pet_mood + punt_moodlet = punt_mood + + RegisterSignal(target, COMSIG_MOB_ATTACK_HAND, .proc/on_attack_hand) + +/datum/element/wuv/proc/on_attack_hand(datum/source, mob/user) + var/mob/living/L = source + + if(L.stat == DEAD) + return + //we want to delay the effect to be displayed after the mob is petted, not before. + switch(user.a_intent) + if(INTENT_HARM, INTENT_DISARM) + addtimer(CALLBACK(src, .proc/pet_the_dog, source, user), 1) + if(INTENT_HELP) + addtimer(CALLBACK(src, .proc/kick_the_dog, source, user), 1) + +/datum/element/wuv/proc/pet_the_dog(mob/target, mob/user) + if(!QDELETED(target) || !QDELETED(user) || target.stat == DEAD) + return + new /obj/effect/temp_visual/heart(target.loc) + if(pet_emote) + target.emote("me", pet_type, pet_emote) + if(pet_moodlet && !CHECK_BITFIELD(target.flags_1, HOLOGRAM_1)) //prevents unlimited happiness petting park exploit. + SEND_SIGNAL(user, COMSIG_ADD_MOOD_EVENT, target, pet_moodlet) + +/datum/element/wuv/proc/kick_the_dog(mob/target, mob/user) + if(!QDELETED(target) || !QDELETED(user) || target.stat == DEAD) + return + if(punt_emote) + target.emote("me", punt_type, punt_emote) + if(punt_moodlet && !CHECK_BITFIELD(target.flags_1, HOLOGRAM_1)) + SEND_SIGNAL(user, COMSIG_ADD_MOOD_EVENT, target, punt_moodlet) diff --git a/code/datums/emotes.dm b/code/datums/emotes.dm index 6c91cc3a7d..f0fca5db5a 100644 --- a/code/datums/emotes.dm +++ b/code/datums/emotes.dm @@ -1,6 +1,3 @@ -#define EMOTE_VISIBLE 1 -#define EMOTE_AUDIBLE 2 - /datum/emote var/key = "" //What calls the emote var/key_third_person = "" //This will also call the emote diff --git a/code/datums/mood_events/generic_positive_events.dm b/code/datums/mood_events/generic_positive_events.dm index 678802aed9..8c5ecb205b 100644 --- a/code/datums/mood_events/generic_positive_events.dm +++ b/code/datums/mood_events/generic_positive_events.dm @@ -23,10 +23,13 @@ mood_change = 3 timeout = 3000 -/datum/mood_event/pet_corgi - description = "Corgis are adorable! I can't stop petting them!\n" - mood_change = 3 - timeout = 3000 +/datum/mood_event/pet_animal + description = "Animals are adorable! I can't stop petting them!\n" + mood_change = 2 + timeout = 5 MINUTES + +/datum/mood_event/pet_animal/add_effects(mob/animal) + description = "\The [animal.name] is adorable! I can't stop petting [animal.p_them()]!\n" /datum/mood_event/honk description = "Maybe clowns aren't so bad after all. Honk!\n" diff --git a/code/modules/mob/living/simple_animal/friendly/cat.dm b/code/modules/mob/living/simple_animal/friendly/cat.dm index 58d8a3ccca..cd0c1ce2d7 100644 --- a/code/modules/mob/living/simple_animal/friendly/cat.dm +++ b/code/modules/mob/living/simple_animal/friendly/cat.dm @@ -38,6 +38,10 @@ . = ..() verbs += /mob/living/proc/lay_down +/mob/living/simple_animal/pet/cat/ComponentInitialize() + . = ..() + AddElement(/datum/element/wuv, "purrs!", EMOTE_AUDIBLE, /datum/mood_event/pet_animal, "hisses!", EMOTE_AUDIBLE) + /mob/living/simple_animal/pet/cat/update_canmove() ..() if(client && stat != DEAD) @@ -228,24 +232,6 @@ stop_automated_movement = 1 walk_to(src,movement_target,0,3) -/mob/living/simple_animal/pet/cat/attack_hand(mob/living/carbon/human/M) - . = ..() - switch(M.a_intent) - if("help") - wuv(1, M) - if("harm") - wuv(-1, M) - -/mob/living/simple_animal/pet/cat/proc/wuv(change, mob/M) - if(change) - if(change > 0) - if(M && stat != DEAD) - new /obj/effect/temp_visual/heart(loc) - emote("me", 1, "purrs!") - else - if(M && stat != DEAD) - emote("me", 1, "hisses!") - /mob/living/simple_animal/pet/cat/cak //I told you I'd do it, Remie name = "Keeki" desc = "It's a cat made out of cake." diff --git a/code/modules/mob/living/simple_animal/friendly/dog.dm b/code/modules/mob/living/simple_animal/friendly/dog.dm index c194233c42..43cc95b975 100644 --- a/code/modules/mob/living/simple_animal/friendly/dog.dm +++ b/code/modules/mob/living/simple_animal/friendly/dog.dm @@ -16,6 +16,10 @@ do_footstep = TRUE +/mob/living/simple_animal/pet/dog/ComponentInitialize() + . = ..() + AddElement(/datum/element/wuv, "yaps_happily!", EMOTE_AUDIBLE, /datum/mood_event/pet_animal, "growls!", EMOTE_AUDIBLE) + //Corgis and pugs are now under one dog subtype /mob/living/simple_animal/pet/dog/corgi @@ -634,22 +638,3 @@ for(var/i in list(1,2,4,8,4,2,1,2,4,8,4,2,1,2,4,8,4,2)) setDir(i) sleep(1) - -/mob/living/simple_animal/pet/dog/attack_hand(mob/living/carbon/human/M) - . = ..() - switch(M.a_intent) - if("help") - wuv(1,M) - if("harm") - wuv(-1,M) - -/mob/living/simple_animal/pet/dog/proc/wuv(change, mob/M) - if(change) - if(change > 0) - if(M && stat != DEAD) // Added check to see if this mob (the dog) is dead to fix issue 2454 - new /obj/effect/temp_visual/heart(loc) - emote("me", 1, "yaps happily!") - SEND_SIGNAL(M, COMSIG_ADD_MOOD_EVENT, "pet_corgi", /datum/mood_event/pet_corgi) - else - if(M && stat != DEAD) // Same check here, even though emote checks it as well (poor form to check it only in the help case) - emote("me", 1, "growls!") diff --git a/tgstation.dme b/tgstation.dme index 07915f2e04..c8852a6d52 100755 --- a/tgstation.dme +++ b/tgstation.dme @@ -465,6 +465,7 @@ #include "code\datums\elements\_element.dm" #include "code\datums\elements\cleaning.dm" #include "code\datums\elements\earhealing.dm" +#include "code\datums\elements\wuv.dm" #include "code\datums\helper_datums\events.dm" #include "code\datums\helper_datums\getrev.dm" #include "code\datums\helper_datums\icon_snapshot.dm"