Fixes being able to punch yourself (#79033)

## About The Pull Request

Fixes #79031 

Fixes #79042

I forgot some logic here when making the human override. 
Not the cleanest way to do it but it'll suffice. 

## Changelog

🆑 Melbert
fix: You can punch yourself again
/🆑
This commit is contained in:
MrMelbert
2023-10-17 13:02:07 -06:00
committed by GitHub
parent 9bb75adc5c
commit dcedf89c70
6 changed files with 48 additions and 10 deletions
+2 -2
View File
@@ -40,7 +40,7 @@
if(sigreturn & COMPONENT_SKIP_ATTACK)
return FALSE
if(!can_unarmed_attack(attack_target))
if(!can_unarmed_attack())
return FALSE
sigreturn = SEND_SIGNAL(src, COMSIG_LIVING_UNARMED_ATTACK, attack_target, proximity_flag, modifiers)
@@ -55,7 +55,7 @@
/mob/living/carbon/human/UnarmedAttack(atom/attack_target, proximity_flag, list/modifiers)
// Humans can always check themself regardless of having their hands blocked or w/e
if(src == attack_target)
if(src == attack_target && !combat_mode && HAS_TRAIT(src, TRAIT_HANDS_BLOCKED))
check_self_for_injuries()
return TRUE
+1 -1
View File
@@ -39,7 +39,7 @@
if(!source.combat_mode || !proximity || LAZYACCESS(modifiers, RIGHT_CLICK))
return NONE
if(!source.can_unarmed_attack())
return COMPONENT_CANCEL_ATTACK_CHAIN
return COMPONENT_SKIP_ATTACK
if(!target.attack_hulk(owner))
return NONE
@@ -256,14 +256,13 @@
if(try_inject(user, affecting, injection_flags = INJECT_TRY_SHOW_ERROR_MESSAGE))//Thick suits can stop monkey bites.
if(..()) //successful monkey bite, this handles disease contraction.
var/obj/item/bodypart/arm/active_arm = user.get_active_hand()
var/damage = rand(active_arm.unarmed_damage_low, active_arm.unarmed_damage_high)
var/obj/item/bodypart/head/monkey_mouth = user.get_bodypart(BODY_ZONE_HEAD)
var/damage = HAS_TRAIT(user, TRAIT_PERFECT_ATTACKER) ? monkey_mouth.unarmed_damage_high : rand(monkey_mouth.unarmed_damage_low, monkey_mouth.unarmed_damage_high)
if(!damage)
return
return FALSE
if(check_shields(user, damage, "the [user.name]"))
return FALSE
if(stat != DEAD)
apply_damage(damage, BRUTE, affecting, run_armor_check(affecting, MELEE))
apply_damage(damage, BRUTE, affecting, run_armor_check(affecting, MELEE))
return TRUE
/mob/living/carbon/human/attack_alien(mob/living/carbon/alien/adult/user, list/modifiers)
+1 -1
View File
@@ -329,7 +329,7 @@
to_chat(user, span_warning("You can't bite with your mouth covered!"))
return FALSE
user.do_attack_animation(src, ATTACK_EFFECT_BITE)
if (prob(75))
if (HAS_TRAIT(user, TRAIT_PERFECT_ATTACKER) || prob(75))
log_combat(user, src, "attacked")
playsound(loc, 'sound/weapons/bite.ogg', 50, TRUE, -1)
visible_message(span_danger("[user.name] bites [src]!"), \
@@ -412,7 +412,7 @@
if(dna?.check_mutation(/datum/mutation/human/hulk)) //NO HULK
return NONE
if(!source.can_unarmed_attack())
return COMPONENT_CANCEL_ATTACK_CHAIN
return COMPONENT_SKIP_ATTACK
var/mob/living/living_target = target
source.changeNext_move(CLICK_CD_MELEE)
+39
View File
@@ -99,3 +99,42 @@
TEST_ASSERT_EQUAL(victim.loc.x, run_loc_floor_bottom_left.x + 2, "Victim was moved after being pushed against a wall")
TEST_ASSERT(victim.has_status_effect(/datum/status_effect/incapacitating/knockdown), "Victim was not knocked down after being pushed against a wall")
TEST_ASSERT_EQUAL(victim.get_active_held_item(), null, "Victim didn't drop toolbox after being pushed against a wall")
/// Tests you can punch yourself
/datum/unit_test/self_punch
/datum/unit_test/self_punch/Run()
var/mob/living/carbon/human/dummy = allocate(/mob/living/carbon/human/consistent)
ADD_TRAIT(dummy, TRAIT_PERFECT_ATTACKER, TRAIT_SOURCE_UNIT_TESTS)
dummy.set_combat_mode(TRUE)
dummy.ClickOn(dummy)
TEST_ASSERT_NOTEQUAL(dummy.getBruteLoss(), 0, "Dummy took no brute damage after self-punching")
/// Tests handcuffed (HANDS_BLOCKED) mobs cannot punch
/datum/unit_test/handcuff_punch
/datum/unit_test/handcuff_punch/Run()
var/mob/living/carbon/human/attacker = allocate(/mob/living/carbon/human/consistent)
var/mob/living/carbon/human/victim = allocate(/mob/living/carbon/human/consistent)
ADD_TRAIT(attacker, TRAIT_PERFECT_ATTACKER, TRAIT_SOURCE_UNIT_TESTS)
ADD_TRAIT(attacker, TRAIT_HANDS_BLOCKED, TRAIT_SOURCE_UNIT_TESTS)
attacker.set_combat_mode(TRUE)
attacker.ClickOn(victim)
TEST_ASSERT_EQUAL(victim.getBruteLoss(), 0, "Victim took brute damage from being punched by a handcuffed attacker")
attacker.next_move = -1
attacker.next_click = -1
attacker.ClickOn(attacker)
TEST_ASSERT_EQUAL(attacker.getBruteLoss(), 0, "Attacker took brute damage from self-punching while handcuffed")
/// Tests handcuffed (HANDS_BLOCKED) monkeys can still bite despite being cuffed
/datum/unit_test/handcuff_bite
/datum/unit_test/handcuff_bite/Run()
var/mob/living/carbon/human/attacker = allocate(/mob/living/carbon/human/consistent)
var/mob/living/carbon/human/victim = allocate(/mob/living/carbon/human/consistent)
ADD_TRAIT(attacker, TRAIT_PERFECT_ATTACKER, TRAIT_SOURCE_UNIT_TESTS)
ADD_TRAIT(attacker, TRAIT_HANDS_BLOCKED, TRAIT_SOURCE_UNIT_TESTS)
attacker.set_combat_mode(TRUE)
attacker.set_species(/datum/species/monkey)
attacker.ClickOn(victim)
TEST_ASSERT_NOTEQUAL(victim.getBruteLoss(), 0, "Victim took no brute damage from being bit by a handcuffed monkey, which is incorrect, as it's a bite attack")