From a19e21f1606505ec6992249fcef5e82eb38f47fa Mon Sep 17 00:00:00 2001 From: NovaBot <154629622+NovaBot13@users.noreply.github.com> Date: Wed, 28 Feb 2024 23:00:36 -0500 Subject: [PATCH] [MIRROR] Fixes some tackle business (#1202) * Fixes some tackle business (#81727) ## About The Pull Request Fixes #81691 Tackling was making the tackler grab themselves. I took this opportunity to cut down on some of these weird typecasts. ## Changelog :cl: Melbert fix: Fixes grabbing yourself when you tackle someone. /:cl: * Fixes some tackle business --------- Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com> --- code/datums/components/tackle.dm | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/code/datums/components/tackle.dm b/code/datums/components/tackle.dm index 7a65524788a..de42ae64cfd 100644 --- a/code/datums/components/tackle.dm +++ b/code/datums/components/tackle.dm @@ -164,8 +164,6 @@ neutral_outcome(user, target, tackle_word) //Forces a neutral outcome so you're not screwed too much from being blocked while tackling return COMPONENT_MOVABLE_IMPACT_FLIP_HITPUSH - - switch(roll) if(-INFINITY to -1) negative_outcome(user, target, roll, tackle_word) //OOF @@ -178,6 +176,15 @@ return COMPONENT_MOVABLE_IMPACT_FLIP_HITPUSH +/// Helper to do a grab and then adjust the grab state if necessary +/datum/component/tackler/proc/do_grab(mob/living/carbon/tackler, mob/living/carbon/tackled, skip_to_state = GRAB_PASSIVE) + set waitfor = FALSE + + if(!tackler.grab(tackled) || tackler.pulling != tackled) + return + if(tackler.grab_state != skip_to_state) + tackler.setGrabState(skip_to_state) + /** * Our positive tackling outcomes. * @@ -198,15 +205,10 @@ var/potential_outcome = (roll * 10) if(ishuman(target)) - var/mob/living/carbon/human/human_target = target - var/target_armor = human_target.run_armor_check(BODY_ZONE_CHEST, MELEE) - potential_outcome *= ((100 - target_armor) /100) + potential_outcome *= ((100 - target.run_armor_check(BODY_ZONE_CHEST, MELEE)) /100) else potential_outcome *= 0.9 - var/mob/living/carbon/human/human_target = target - var/mob/living/carbon/human/human_sacker = user - switch(potential_outcome) if(-INFINITY to 0) //I don't want to know how this has happened, okay? neutral_outcome(user, target, roll, tackle_word) //Default to neutral @@ -233,9 +235,7 @@ target.Paralyze(0.5 SECONDS) target.Knockdown(3 SECONDS) target.adjust_staggered_up_to(STAGGERED_SLOWDOWN_LENGTH * 2, 10 SECONDS) - if(ishuman(target) && ishuman(user)) - INVOKE_ASYNC(human_sacker, TYPE_PROC_REF(/mob/living, grab), human_sacker, human_target) - human_sacker.setGrabState(GRAB_PASSIVE) + do_grab(user, target) if(50 to INFINITY) // absolutely BODIED var/stamcritted_user = HAS_TRAIT_FROM(user, TRAIT_INCAPACITATED, STAMINA) @@ -259,9 +259,7 @@ target.Paralyze(0.5 SECONDS) target.Knockdown(3 SECONDS) target.adjust_staggered_up_to(STAGGERED_SLOWDOWN_LENGTH * 3, 10 SECONDS) - if(ishuman(target) && ishuman(user)) - INVOKE_ASYNC(human_sacker, TYPE_PROC_REF(/mob/living, grab), human_sacker, human_target) - human_sacker.setGrabState(GRAB_AGGRESSIVE) + do_grab(user, target, GRAB_AGGRESSIVE) /** * Our neutral tackling outcome. @@ -300,9 +298,7 @@ var/potential_roll_outcome = (roll * -10) if(ishuman(user)) - var/mob/living/carbon/human/human_sacker = target - var/attacker_armor = human_sacker.run_armor_check(BODY_ZONE_CHEST, MELEE) - potential_roll_outcome *= ((100 - attacker_armor) /100) + potential_roll_outcome *= ((100 - target.run_armor_check(BODY_ZONE_CHEST, MELEE)) /100) else potential_roll_outcome *= 0.9