From df7c7fba0a6356452d78292dd3dd9c361512145c Mon Sep 17 00:00:00 2001
From: Luc <89928798+lewcc@users.noreply.github.com>
Date: Fri, 1 Sep 2023 17:38:48 -0400
Subject: [PATCH] Makes dchat controlled humans resist while moving (#21820)
* makes humans resist when moving
* oops this is a list
* Moves human deadchat stuff out to its own file
---
code/datums/components/deadchat_control.dm | 17 +++
.../carbon/human/human_deadchat_control.dm | 143 ++++++++++++++++++
.../mob/living/carbon/human/human_mob.dm | 136 -----------------
paradise.dme | 1 +
4 files changed, 161 insertions(+), 136 deletions(-)
create mode 100644 code/modules/mob/living/carbon/human/human_deadchat_control.dm
diff --git a/code/datums/components/deadchat_control.dm b/code/datums/components/deadchat_control.dm
index a3a45e9c5f1..24e7c916b2a 100644
--- a/code/datums/components/deadchat_control.dm
+++ b/code/datums/components/deadchat_control.dm
@@ -260,3 +260,20 @@
_inputs["right"] = CALLBACK(parent, TYPE_PROC_REF(/obj/effect/immovablerod, walk_in_direction), EAST)
return ..()
+
+/**
+ * Deadchat Moves Things
+ *
+ * A special variant of the deadchat_control component that comes pre-baked with basic inputs for moving humans around,
+ * with special behavior that has them resist while moving.
+ */
+/datum/component/deadchat_control/human/Initialize(_deadchat_mode, _inputs, _input_cooldown, _on_removal)
+ if(!ishuman(parent))
+ return COMPONENT_INCOMPATIBLE
+
+ _inputs["up"] = CALLBACK(parent, TYPE_PROC_REF(/mob/living/carbon/human, dchat_step), NORTH)
+ _inputs["down"] = CALLBACK(parent, TYPE_PROC_REF(/mob/living/carbon/human, dchat_step), SOUTH)
+ _inputs["left"] = CALLBACK(parent, TYPE_PROC_REF(/mob/living/carbon/human, dchat_step), WEST)
+ _inputs["right"] = CALLBACK(parent, TYPE_PROC_REF(/mob/living/carbon/human, dchat_step), EAST)
+
+ return ..()
diff --git a/code/modules/mob/living/carbon/human/human_deadchat_control.dm b/code/modules/mob/living/carbon/human/human_deadchat_control.dm
new file mode 100644
index 00000000000..fdb6db4f5b6
--- /dev/null
+++ b/code/modules/mob/living/carbon/human/human_deadchat_control.dm
@@ -0,0 +1,143 @@
+// Custom human behavior for deadchat control
+
+
+/mob/living/carbon/human/proc/dchat_emote()
+ var/list/possible_emotes = list("scream", "clap", "snap", "crack", "dap", "burp")
+ emote(pick(possible_emotes), intentional = TRUE)
+
+/mob/living/carbon/human/proc/dchat_attack(intent)
+ var/turf/ahead = get_turf(get_step(src, dir))
+ var/atom/victim = locate(/mob/living) in ahead
+ var/obj/item/in_hand = get_active_hand()
+ var/implement = "[isnull(in_hand) ? "[p_their()] fists" : in_hand]"
+ if(!victim)
+ victim = locate(/obj/structure) in ahead
+ if(!victim)
+ switch(intent)
+ if(INTENT_HARM)
+ visible_message("[src] swings [implement] wildly!")
+ if(INTENT_HELP)
+ visible_message("[src] seems to take a deep breath.")
+ return
+ if(isLivingSSD(victim))
+ visible_message("[src] [intent == INTENT_HARM ? "reluctantly " : ""]lowers [p_their()] [implement].")
+ return
+
+ var/original_intent = a_intent
+ a_intent = intent
+ if(in_hand)
+ in_hand.melee_attack_chain(src, victim)
+ else
+ UnarmedAttack(victim, TRUE)
+ a_intent = original_intent
+
+/mob/living/carbon/human/proc/dchat_resist()
+ if(!can_resist())
+ visible_message("[src] seems to be unable to do anything!")
+ return
+ if(!restrained())
+ visible_message("[src] seems to be doing nothing in particular.")
+ return
+
+ visible_message("[src] is trying to break free!")
+ resist()
+
+/mob/living/carbon/human/proc/dchat_pickup()
+ var/turf/ahead = get_step(src, dir)
+ var/obj/item/thing = locate(/obj/item) in ahead
+ if(!thing)
+ return
+
+ var/old_loc = thing.loc
+ var/obj/item/in_hand = get_active_hand()
+
+ if(in_hand)
+ if(in_hand.flags & NODROP)
+ visible_message("[src] attempts to drop [in_hand], but it seems to be stuck to [p_their()] hand!")
+ return
+ if(in_hand.flags & ABSTRACT)
+ visible_message("[src] seems to have [p_their()] hands full!")
+ return
+ visible_message("[src] drops [in_hand] and picks up [thing] instead!")
+ unEquip(in_hand)
+ in_hand.forceMove(old_loc)
+ else
+ visible_message("[src] picks up [thing]!")
+ put_in_active_hand(thing)
+
+/mob/living/carbon/human/proc/dchat_throw()
+ var/obj/item/in_hand = get_active_hand()
+ if(!in_hand || in_hand.flags & ABSTRACT)
+ visible_message("[src] makes a throwing motion!")
+ return
+ var/atom/possible_target
+ var/cur_turf = get_turf(src)
+ for(var/i in 1 to 5)
+ cur_turf = get_step(cur_turf, dir)
+ possible_target = locate(/mob/living) in cur_turf
+ if(possible_target)
+ break
+
+ possible_target = locate(/obj/structure) in cur_turf
+ if(possible_target)
+ break
+
+ if(!possible_target)
+ possible_target = cur_turf
+ if(in_hand.flags & NODROP)
+ visible_message("[src] tries to throw [in_hand][isturf(possible_target) ? "" : " towards [possible_target]"], but it won't come off [p_their()] hand!")
+ return
+ throw_item(possible_target)
+
+/mob/living/carbon/human/proc/dchat_shove()
+ var/turf/ahead = get_turf(get_step(src, dir))
+ var/mob/living/carbon/human/H = locate(/mob/living/carbon/human) in ahead
+ if(!H)
+ visible_message("[src] tries to shove something away!")
+ return
+ dna?.species.disarm(src, H)
+
+/mob/living/carbon/human/proc/dchat_shoot()
+
+ var/atom/possible_target
+ var/cur_turf = get_turf(src)
+ for(var/i in 1 to 5)
+ cur_turf = get_step(cur_turf, dir)
+ possible_target = locate(/mob/living) in cur_turf
+ if(possible_target)
+ break
+
+ if(!possible_target)
+ possible_target = cur_turf
+
+ var/obj/item/gun/held_gun = get_active_hand()
+ if(!held_gun)
+ visible_message("[src] makes fingerguns towards [possible_target]!")
+ return
+ if(!istype(held_gun))
+ visible_message("[src] points [held_gun] towards [possible_target]!")
+ return
+ // for his neutral special, he wields a Gun
+ held_gun.afterattack(possible_target, src)
+ visible_message("[src] fires [held_gun][isturf(possible_target) ? "" : " towards [possible_target]!"]")
+
+/mob/living/carbon/human/proc/dchat_step(dir)
+ if(length(grabbed_by))
+ resist_grab()
+ step(src, dir)
+
+
+/mob/living/carbon/human/deadchat_plays(mode = DEADCHAT_DEMOCRACY_MODE, cooldown = 7 SECONDS)
+ var/list/inputs = list(
+ "emote" = CALLBACK(src, PROC_REF(dchat_emote)),
+ "attack" = CALLBACK(src, PROC_REF(dchat_attack), INTENT_HARM),
+ "help" = CALLBACK(src, PROC_REF(dchat_attack), INTENT_HELP),
+ "pickup" = CALLBACK(src, PROC_REF(dchat_pickup)),
+ "throw" = CALLBACK(src, PROC_REF(dchat_throw)),
+ "disarm" = CALLBACK(src, PROC_REF(dchat_shove)),
+ "resist" = CALLBACK(src, PROC_REF(dchat_resist)),
+ "shoot" = CALLBACK(src, PROC_REF(dchat_shoot)),
+ )
+
+ AddComponent(/datum/component/deadchat_control/human, mode, inputs, cooldown)
+
diff --git a/code/modules/mob/living/carbon/human/human_mob.dm b/code/modules/mob/living/carbon/human/human_mob.dm
index 8b202ba9970..4527d045a48 100644
--- a/code/modules/mob/living/carbon/human/human_mob.dm
+++ b/code/modules/mob/living/carbon/human/human_mob.dm
@@ -2072,139 +2072,3 @@ Eyes need to have significantly high darksight to shine unless the mob has the X
set category = "IC"
update_flavor_text()
-
-// Behavior for deadchat control
-
-/mob/living/carbon/human/proc/dchat_emote()
- var/list/possible_emotes = list("scream", "clap", "snap", "crack", "dap", "burp")
- emote(pick(possible_emotes), intentional = TRUE)
-
-/mob/living/carbon/human/proc/dchat_attack(intent)
- var/turf/ahead = get_turf(get_step(src, dir))
- var/atom/victim = locate(/mob/living) in ahead
- var/obj/item/in_hand = get_active_hand()
- var/implement = "[isnull(in_hand) ? "[p_their()] fists" : in_hand]"
- if(!victim)
- victim = locate(/obj/structure) in ahead
- if(!victim)
- switch(intent)
- if(INTENT_HARM)
- visible_message("[src] swings [implement] wildly!")
- if(INTENT_HELP)
- visible_message("[src] seems to take a deep breath.")
- return
- if(isLivingSSD(victim))
- visible_message("[src] [intent == INTENT_HARM ? "reluctantly " : ""]lowers [p_their()] [implement].")
- return
-
- var/original_intent = a_intent
- a_intent = intent
- if(in_hand)
- in_hand.melee_attack_chain(src, victim)
- else
- UnarmedAttack(victim, TRUE)
- a_intent = original_intent
-
-/mob/living/carbon/human/proc/dchat_resist()
- if(!can_resist())
- visible_message("[src] seems to be unable to do anything!")
- return
- if(!restrained())
- visible_message("[src] seems to be doing nothing in particular.")
- return
-
- visible_message("[src] is trying to break free!")
- resist()
-
-/mob/living/carbon/human/proc/dchat_pickup()
- var/turf/ahead = get_step(src, dir)
- var/obj/item/thing = locate(/obj/item) in ahead
- if(!thing)
- return
-
- var/old_loc = thing.loc
- var/obj/item/in_hand = get_active_hand()
-
- if(in_hand)
- if(in_hand.flags & NODROP)
- visible_message("[src] attempts to drop [in_hand], but it seems to be stuck to [p_their()] hand!")
- return
- if(in_hand.flags & ABSTRACT)
- visible_message("[src] seems to have [p_their()] hands full!")
- return
- visible_message("[src] drops [in_hand] and picks up [thing] instead!")
- unEquip(in_hand)
- in_hand.forceMove(old_loc)
- else
- visible_message("[src] picks up [thing]!")
- put_in_active_hand(thing)
-
-/mob/living/carbon/human/proc/dchat_throw()
- var/obj/item/in_hand = get_active_hand()
- if(!in_hand || in_hand.flags & ABSTRACT)
- visible_message("[src] makes a throwing motion!")
- return
- var/atom/possible_target
- var/cur_turf = get_turf(src)
- for(var/i in 1 to 5)
- cur_turf = get_step(cur_turf, dir)
- possible_target = locate(/mob/living) in cur_turf
- if(possible_target)
- break
-
- possible_target = locate(/obj/structure) in cur_turf
- if(possible_target)
- break
-
- if(!possible_target)
- possible_target = cur_turf
- if(in_hand.flags & NODROP)
- visible_message("[src] tries to throw [in_hand][isturf(possible_target) ? "" : " towards [possible_target]"], but it won't come off [p_their()] hand!")
- return
- throw_item(possible_target)
-
-/mob/living/carbon/human/proc/dchat_shove()
- var/turf/ahead = get_turf(get_step(src, dir))
- var/mob/living/carbon/human/H = locate(/mob/living/carbon/human) in ahead
- if(!H)
- visible_message("[src] tries to shove something away!")
- return
- dna?.species.disarm(src, H)
-
-/mob/living/carbon/human/proc/dchat_shoot()
-
- var/atom/possible_target
- var/cur_turf = get_turf(src)
- for(var/i in 1 to 5)
- cur_turf = get_step(cur_turf, dir)
- possible_target = locate(/mob/living) in cur_turf
- if(possible_target)
- break
-
- if(!possible_target)
- possible_target = cur_turf
-
- var/obj/item/gun/held_gun = get_active_hand()
- if(!held_gun)
- visible_message("[src] makes fingerguns towards [possible_target]!")
- return
- if(!istype(held_gun))
- visible_message("[src] points [held_gun] towards [possible_target]!")
- return
- // for his neutral special, he wields a Gun
- held_gun.afterattack(possible_target, src)
- visible_message("[src] fires [held_gun][isturf(possible_target) ? "" : " towards [possible_target]!"]")
-
-/mob/living/carbon/human/deadchat_plays(mode = DEADCHAT_DEMOCRACY_MODE, cooldown = 7 SECONDS)
- var/list/inputs = list(
- "emote" = CALLBACK(src, PROC_REF(dchat_emote)),
- "attack" = CALLBACK(src, PROC_REF(dchat_attack), INTENT_HARM),
- "help" = CALLBACK(src, PROC_REF(dchat_attack), INTENT_HELP),
- "pickup" = CALLBACK(src, PROC_REF(dchat_pickup)),
- "throw" = CALLBACK(src, PROC_REF(dchat_throw)),
- "disarm" = CALLBACK(src, PROC_REF(dchat_shove)),
- "resist" = CALLBACK(src, PROC_REF(dchat_resist)),
- "shoot" = CALLBACK(src, PROC_REF(dchat_shoot)),
- )
-
- AddComponent(/datum/component/deadchat_control/cardinal_movement, mode, inputs, cooldown)
diff --git a/paradise.dme b/paradise.dme
index cce7f6aff08..b0feee6edf6 100644
--- a/paradise.dme
+++ b/paradise.dme
@@ -2014,6 +2014,7 @@
#include "code\modules\mob\living\carbon\human\appearance.dm"
#include "code\modules\mob\living\carbon\human\body_accessories.dm"
#include "code\modules\mob\living\carbon\human\human_damage.dm"
+#include "code\modules\mob\living\carbon\human\human_deadchat_control.dm"
#include "code\modules\mob\living\carbon\human\human_death.dm"
#include "code\modules\mob\living\carbon\human\human_defense.dm"
#include "code\modules\mob\living\carbon\human\human_defines.dm"