Skip to content

Commit

Permalink
[MIRROR] Fixes some tackle business (#1202)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
2 people authored and StealsThePRs committed Feb 29, 2024
1 parent 1e68b4f commit a19e21f
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions code/datums/components/tackle.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
*
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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.
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit a19e21f

Please sign in to comment.