From c25508f1c28069f4f05c850f64c6a140f55500ad Mon Sep 17 00:00:00 2001
From: Ghommie <42542238+Ghommie@users.noreply.github.com>
Date: Wed, 4 Dec 2019 20:18:03 +0100
Subject: [PATCH 1/4] turns dog/cat petting into an element.
---
code/__DEFINES/misc.dm | 4 ++
code/datums/elements/wuv.dm | 60 +++++++++++++++++++
code/datums/emotes.dm | 3 -
.../mood_events/generic_positive_events.dm | 11 ++--
.../mob/living/simple_animal/friendly/cat.dm | 22 ++-----
.../mob/living/simple_animal/friendly/dog.dm | 23 ++-----
tgstation.dme | 1 +
7 files changed, 80 insertions(+), 44 deletions(-)
create mode 100644 code/datums/elements/wuv.dm
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"
From dfa57173db1e756f0cdeea0d0e05404590a64142 Mon Sep 17 00:00:00 2001
From: Ghommie <42542238+Ghommie@users.noreply.github.com>
Date: Wed, 4 Dec 2019 20:20:01 +0100
Subject: [PATCH 2/4] D'aww, a mistake...
---
code/datums/elements/wuv.dm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/code/datums/elements/wuv.dm b/code/datums/elements/wuv.dm
index d2b1f7aa6d..a8d488268a 100644
--- a/code/datums/elements/wuv.dm
+++ b/code/datums/elements/wuv.dm
@@ -49,7 +49,7 @@
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)
+ SEND_SIGNAL(user, COMSIG_ADD_MOOD_EVENT, target, pet_moodlet, target)
/datum/element/wuv/proc/kick_the_dog(mob/target, mob/user)
if(!QDELETED(target) || !QDELETED(user) || target.stat == DEAD)
@@ -57,4 +57,4 @@
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)
+ SEND_SIGNAL(user, COMSIG_ADD_MOOD_EVENT, target, punt_moodlet, target)
From 9455597e315c2c3b4e145482492b7ac54651f500 Mon Sep 17 00:00:00 2001
From: Ghommie <42542238+Ghommie@users.noreply.github.com>
Date: Wed, 4 Dec 2019 20:23:44 +0100
Subject: [PATCH 3/4] special snowflake.
---
code/modules/mob/living/simple_animal/friendly/dog.dm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/code/modules/mob/living/simple_animal/friendly/dog.dm b/code/modules/mob/living/simple_animal/friendly/dog.dm
index 43cc95b975..e3c055c785 100644
--- a/code/modules/mob/living/simple_animal/friendly/dog.dm
+++ b/code/modules/mob/living/simple_animal/friendly/dog.dm
@@ -270,7 +270,7 @@
return
if(!item_to_add)
user.visible_message("[user] pets [src].","You rest your hand on [src]'s head for a moment.")
- SEND_SIGNAL(user, COMSIG_ADD_MOOD_EVENT, "pet_corgi", /datum/mood_event/pet_corgi)
+ SEND_SIGNAL(user, COMSIG_ADD_MOOD_EVENT, src, /datum/mood_event/pet_animal, src)
return
if(user && !user.temporarilyRemoveItemFromInventory(item_to_add))
From b143a2d302257257d9a19bec081d2e35325bedf4 Mon Sep 17 00:00:00 2001
From: Ghommie <42542238+Ghommie@users.noreply.github.com>
Date: Fri, 6 Dec 2019 00:31:32 +0100
Subject: [PATCH 4/4] Right file.
---
code/__DEFINES/misc.dm | 4 ----
code/__DEFINES/say.dm | 4 ++++
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/code/__DEFINES/misc.dm b/code/__DEFINES/misc.dm
index 5f7c2cb396..29ff0a8fae 100644
--- a/code/__DEFINES/misc.dm
+++ b/code/__DEFINES/misc.dm
@@ -519,10 +519,6 @@ 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/__DEFINES/say.dm b/code/__DEFINES/say.dm
index af06a5a2d0..d582728acb 100644
--- a/code/__DEFINES/say.dm
+++ b/code/__DEFINES/say.dm
@@ -75,6 +75,10 @@
#define LINGHIVE_LING 2
#define LINGHIVE_LINK 3
+//whether the emote is visible or audible.
+#define EMOTE_VISIBLE 1
+#define EMOTE_AUDIBLE 2
+
//Don't set this very much higher then 1024 unless you like inviting people in to dos your server with message spam
#define MAX_MESSAGE_LEN 2048 //Citadel edit: What's the WORST that could happen?
#define MAX_NAME_LEN 42