From 42d0541a28f54d130a34d93a35e968bfd10be492 Mon Sep 17 00:00:00 2001
From: kevinz000 <2003111+kevinz000@users.noreply.github.com>
Date: Tue, 24 Apr 2018 08:23:32 -0700
Subject: [PATCH] fixes cqc working outside chef assigned areas (#37375)
* cqc
* Update martial.dm
* Update cqc.dm
* Update cqc.dm
* Update human_defense.dm
* Update human_defense.dm
* Update human_defense.dm
---
code/datums/martial.dm | 3 +
code/datums/martial/cqc.dm | 74 +++++++++++--------
.../mob/living/carbon/human/human_defense.dm | 4 +-
3 files changed, 49 insertions(+), 32 deletions(-)
diff --git a/code/datums/martial.dm b/code/datums/martial.dm
index 04dadd7331..c4b0eb7c60 100644
--- a/code/datums/martial.dm
+++ b/code/datums/martial.dm
@@ -20,6 +20,9 @@
/datum/martial_art/proc/grab_act(mob/living/carbon/human/A, mob/living/carbon/human/D)
return 0
+/datum/martial_art/proc/can_use(mob/living/carbon/human/H)
+ return TRUE
+
/datum/martial_art/proc/add_to_streak(element,mob/living/carbon/human/D)
if(D != current_target)
current_target = D
diff --git a/code/datums/martial/cqc.dm b/code/datums/martial/cqc.dm
index cbf4292a80..8a480cc2d7 100644
--- a/code/datums/martial/cqc.dm
+++ b/code/datums/martial/cqc.dm
@@ -18,31 +18,40 @@
just_a_cook = TRUE
/datum/martial_art/cqc/proc/drop_restraining()
- restraining = 0
+ restraining = FALSE
+
+/datum/martial_art/cqc/can_use(mob/living/carbon/human/H)
+ if(just_a_cook && !(is_type_in_typecache(get_area(H), areas_under_siege)))
+ return FALSE
+ return ..()
/datum/martial_art/cqc/proc/check_streak(mob/living/carbon/human/A, mob/living/carbon/human/D)
+ if(!can_use(A))
+ return FALSE
if(findtext(streak,SLAM_COMBO))
streak = ""
Slam(A,D)
- return 1
+ return TRUE
if(findtext(streak,KICK_COMBO))
streak = ""
Kick(A,D)
- return 1
+ return TRUE
if(findtext(streak,RESTRAIN_COMBO))
streak = ""
Restrain(A,D)
- return 1
+ return TRUE
if(findtext(streak,PRESSURE_COMBO))
streak = ""
Pressure(A,D)
- return 1
+ return TRUE
if(findtext(streak,CONSECUTIVE_COMBO))
streak = ""
Consecutive(A,D)
- return 0
+ return FALSE
/datum/martial_art/cqc/proc/Slam(mob/living/carbon/human/A, mob/living/carbon/human/D)
+ if(!can_use(A))
+ return FALSE
if(!D.stat || !D.IsKnockdown())
D.visible_message("[A] slams [D] into the ground!", \
"[A] slams you into the ground!")
@@ -50,9 +59,11 @@
D.apply_damage(10, BRUTE)
D.Knockdown(120)
add_logs(A, D, "cqc slammed")
- return 1
+ return TRUE
/datum/martial_art/cqc/proc/Kick(mob/living/carbon/human/A, mob/living/carbon/human/D)
+ if(!can_use(A))
+ return FALSE
if(!D.stat || !D.IsKnockdown())
D.visible_message("[A] kicks [D] back!", \
"[A] kicks you back!")
@@ -67,27 +78,33 @@
playsound(get_turf(A), 'sound/weapons/genhit1.ogg', 50, 1, -1)
D.SetSleeping(300)
D.adjustBrainLoss(15, 150)
- return 1
+ return TRUE
/datum/martial_art/cqc/proc/Pressure(mob/living/carbon/human/A, mob/living/carbon/human/D)
+ if(!can_use(A))
+ return FALSE
D.visible_message("[A] forces their arm on [D]'s neck!")
D.adjustStaminaLoss(60)
playsound(get_turf(A), 'sound/weapons/cqchit1.ogg', 50, 1, -1)
- return 1
+ return TRUE
/datum/martial_art/cqc/proc/Restrain(mob/living/carbon/human/A, mob/living/carbon/human/D)
if(restraining)
return
+ if(!can_use(A))
+ return FALSE
if(!D.stat)
D.visible_message("[A] locks [D] into a restraining position!", \
"[A] locks you into a restraining position!")
D.adjustStaminaLoss(20)
D.Stun(100)
- restraining = 1
+ restraining = TRUE
addtimer(CALLBACK(src, .proc/drop_restraining), 50, TIMER_UNIQUE)
- return 1
+ return TRUE
/datum/martial_art/cqc/proc/Consecutive(mob/living/carbon/human/A, mob/living/carbon/human/D)
+ if(!can_use(A))
+ return FALSE
if(!D.stat)
D.visible_message("[A] strikes [D]'s abdomen, neck and back consecutively", \
"[A] strikes your abdomen, neck and back consecutively!")
@@ -97,15 +114,14 @@
A.put_in_hands(I)
D.adjustStaminaLoss(50)
D.apply_damage(25, BRUTE)
- return 1
+ return TRUE
/datum/martial_art/cqc/grab_act(mob/living/carbon/human/A, mob/living/carbon/human/D)
- if(just_a_cook)
- if(!is_type_in_typecache(get_area(A), areas_under_siege))
- return 0
+ if(!can_use(A))
+ return FALSE
add_to_streak("G",D)
if(check_streak(A,D))
- return 1
+ return TRUE
if(A.grab_state >= GRAB_AGGRESSIVE)
D.grabbedby(A, 1)
else
@@ -115,15 +131,14 @@
add_logs(A, D, "grabbed", addition="aggressively")
A.grab_state = GRAB_AGGRESSIVE //Instant aggressive grab
- return 1
+ return TRUE
/datum/martial_art/cqc/harm_act(mob/living/carbon/human/A, mob/living/carbon/human/D)
- if(just_a_cook)
- if(!is_type_in_typecache(get_area(A), areas_under_siege))
- return 0
+ if(!can_use(A))
+ return FALSE
add_to_streak("H",D)
if(check_streak(A,D))
- return 1
+ return TRUE
add_logs(A, D, "CQC'd")
A.do_attack_animation(D)
var/picked_hit_type = pick("CQC'd", "Big Bossed")
@@ -146,16 +161,15 @@
D.apply_damage(10, BRUTE)
D.Knockdown(60)
add_logs(A, D, "cqc sweeped")
- return 1
+ return TRUE
/datum/martial_art/cqc/disarm_act(mob/living/carbon/human/A, mob/living/carbon/human/D)
- if(just_a_cook)
- if(!is_type_in_typecache(get_area(A), areas_under_siege))
- return 0
+ if(!can_use(A))
+ return FALSE
add_to_streak("D",D)
var/obj/item/I = null
if(check_streak(A,D))
- return 1
+ return TRUE
if(prob(65))
if(!D.stat || !D.IsKnockdown() || !restraining)
I = D.get_active_held_item()
@@ -175,13 +189,13 @@
D.visible_message("[A] puts [D] into a chokehold!", \
"[A] puts you into a chokehold!")
D.SetSleeping(400)
- restraining = 0
+ restraining = FALSE
if(A.grab_state < GRAB_NECK)
A.grab_state = GRAB_NECK
else
- restraining = 0
- return 0
- return 1
+ restraining = FALSE
+ return FALSE
+ return TRUE
/mob/living/carbon/human/proc/CQC_help()
set name = "Remember The Basics"
diff --git a/code/modules/mob/living/carbon/human/human_defense.dm b/code/modules/mob/living/carbon/human/human_defense.dm
index e47e7e1b63..c5b9e2d7e3 100644
--- a/code/modules/mob/living/carbon/human/human_defense.dm
+++ b/code/modules/mob/living/carbon/human/human_defense.dm
@@ -44,7 +44,7 @@
return spec_return
if(mind)
- if(mind.martial_art && mind.martial_art.deflection_chance) //Some martial arts users can deflect projectiles!
+ if(mind.martial_art && !incapacitated(FALSE, TRUE) && mind.martial_art.can_use(src) && mind.martial_art.deflection_chance) //Some martial arts users can deflect projectiles!
if(prob(mind.martial_art.deflection_chance))
if(!lying && dna && !dna.check_mutation(HULK)) //But only if they're not lying down, and hulks can't do it
if(mind.martial_art.deflection_chance >= 100) //if they can NEVER be hit, lets clue sec in ;)
@@ -113,7 +113,7 @@
/mob/living/carbon/human/proc/check_block()
if(mind)
- if(mind.martial_art && prob(mind.martial_art.block_chance) && in_throw_mode && !stat && !IsKnockdown() && !IsStun())
+ if(mind.martial_art && prob(mind.martial_art.block_chance) && mind.martial_art.can_use(src) && in_throw_mode && !incapacitated(FALSE, TRUE))
return TRUE
return FALSE