From 64e1fc64fb04aafad436fe25331a00416a521422 Mon Sep 17 00:00:00 2001 From: Bloop <13398309+vinylspiders@users.noreply.github.com> Date: Sat, 6 Jan 2024 08:45:38 -0500 Subject: [PATCH] [MISSED MIRROR] Fixes `COMSIG_LIVING_EARLY_UNARMED_ATTACK` arguments (#80783) (#344) Fixes `COMSIG_LIVING_EARLY_UNARMED_ATTACK` arguments (#80783) ## About The Pull Request Fixes #80566 Fixes the wrong arguments being passed to `COMSIG_LIVING_EARLY_UNARMED_ATTACK`. It now properly receives the proximity flag. Changes clicking with handcuffs to no longer always assume no proximity. Replaces some checks for hands blocked to some checks for `can_unarmed_attack` (which, currently, JUST checks for hands blocked, but this is good for future reasons, just in case) ## Changelog :cl: Melbert fix: Strong arm implant users can shove more correctly. /:cl: Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com> --- code/_onclick/click.dm | 10 +++++----- code/_onclick/cyborg.dm | 2 +- code/_onclick/other_mobs.dm | 4 +++- .../modules/mob/living/basic/bots/cleanbot/cleanbot.dm | 7 +++++-- .../living/basic/guardian/guardian_types/explosive.dm | 2 +- .../basic/guardian/guardian_types/gravitokinetic.dm | 2 +- code/modules/mob/living/basic/pets/cat/cat.dm | 9 ++++++--- code/modules/mob/living/simple_animal/bot/firebot.dm | 3 +-- code/modules/mob/living/simple_animal/bot/floorbot.dm | 2 +- code/modules/mob/living/simple_animal/bot/mulebot.dm | 2 +- code/modules/mob/living/simple_animal/bot/secbot.dm | 2 +- 11 files changed, 26 insertions(+), 19 deletions(-) diff --git a/code/_onclick/click.dm b/code/_onclick/click.dm index d898fd9f618..c907f45466d 100644 --- a/code/_onclick/click.dm +++ b/code/_onclick/click.dm @@ -115,7 +115,7 @@ if(HAS_TRAIT(src, TRAIT_HANDS_BLOCKED)) changeNext_move(CLICK_CD_HANDCUFFED) //Doing shit in cuffs shall be vey slow - UnarmedAttack(A, FALSE, modifiers) + UnarmedAttack(A, Adjacent(A), modifiers) return if(throw_mode) @@ -144,7 +144,7 @@ if(ismob(A)) changeNext_move(CLICK_CD_MELEE) - UnarmedAttack(A, FALSE, modifiers) + UnarmedAttack(A, TRUE, modifiers) return //Can't reach anything else in lockers or other weirdness @@ -164,7 +164,7 @@ else if(ismob(A)) changeNext_move(CLICK_CD_MELEE) - UnarmedAttack(A,1,modifiers) + UnarmedAttack(A, TRUE, modifiers) else if(W) if(LAZYACCESS(modifiers, RIGHT_CLICK)) @@ -173,12 +173,12 @@ if(after_attack_secondary_result == SECONDARY_ATTACK_CALL_NORMAL) W.afterattack(A, src, FALSE, params) else - W.afterattack(A,src,0,params) + W.afterattack(A, src, FALSE, params) else if(LAZYACCESS(modifiers, RIGHT_CLICK)) ranged_secondary_attack(A, modifiers) else - RangedAttack(A,modifiers) + RangedAttack(A, modifiers) /// Is the atom obscured by a PREVENT_CLICK_UNDER_1 object above it /atom/proc/IsObscured() diff --git a/code/_onclick/cyborg.dm b/code/_onclick/cyborg.dm index 50b341cd906..a67bd191b3f 100644 --- a/code/_onclick/cyborg.dm +++ b/code/_onclick/cyborg.dm @@ -190,7 +190,7 @@ change attack_robot() above to the proper function */ /mob/living/silicon/robot/UnarmedAttack(atom/A, proximity_flag, list/modifiers) - if(HAS_TRAIT(src, TRAIT_HANDS_BLOCKED)) + if(!can_unarmed_attack()) return A.attack_robot(src) diff --git a/code/_onclick/other_mobs.dm b/code/_onclick/other_mobs.dm index 03d6606a5f0..04bbc048e66 100644 --- a/code/_onclick/other_mobs.dm +++ b/code/_onclick/other_mobs.dm @@ -11,6 +11,8 @@ /** * Checks if this mob is in a valid state to punch someone. + * + * (Potentially) gives feedback to the mob if they cannot. */ /mob/living/proc/can_unarmed_attack() return !HAS_TRAIT(src, TRAIT_HANDS_BLOCKED) @@ -34,7 +36,7 @@ /mob/living/UnarmedAttack(atom/attack_target, proximity_flag, list/modifiers) // The sole reason for this signal needing to exist is making FotNS incompatible with Hulk. // Note that it is send before [proc/can_unarmed_attack] is called, keep this in mind. - var/sigreturn = SEND_SIGNAL(src, COMSIG_LIVING_EARLY_UNARMED_ATTACK, attack_target, modifiers) + var/sigreturn = SEND_SIGNAL(src, COMSIG_LIVING_EARLY_UNARMED_ATTACK, attack_target, proximity_flag, modifiers) if(sigreturn & COMPONENT_CANCEL_ATTACK_CHAIN) return TRUE if(sigreturn & COMPONENT_SKIP_ATTACK) diff --git a/code/modules/mob/living/basic/bots/cleanbot/cleanbot.dm b/code/modules/mob/living/basic/bots/cleanbot/cleanbot.dm index 8a8050b9afc..a81f48c9c95 100644 --- a/code/modules/mob/living/basic/bots/cleanbot/cleanbot.dm +++ b/code/modules/mob/living/basic/bots/cleanbot/cleanbot.dm @@ -321,15 +321,18 @@ INVOKE_ASYNC(weapon, TYPE_PROC_REF(/obj/item, attack), stabbed_carbon, src) stabbed_carbon.Knockdown(2 SECONDS) -/mob/living/basic/bot/cleanbot/proc/pre_attack(mob/living/source, atom/target) +/mob/living/basic/bot/cleanbot/proc/pre_attack(mob/living/source, atom/target, proximity, modifiers) SIGNAL_HANDLER + if(!proximity || !can_unarmed_attack()) + return NONE + if(is_type_in_typecache(target, huntable_pests) && !isnull(our_mop)) INVOKE_ASYNC(our_mop, TYPE_PROC_REF(/obj/item, melee_attack_chain), src, target) return COMPONENT_CANCEL_ATTACK_CHAIN if(!iscarbon(target) && !is_type_in_typecache(target, huntable_trash)) - return + return NONE visible_message(span_danger("[src] sprays hydrofluoric acid at [target]!")) playsound(src, 'sound/effects/spray2.ogg', 50, TRUE, -6) diff --git a/code/modules/mob/living/basic/guardian/guardian_types/explosive.dm b/code/modules/mob/living/basic/guardian/guardian_types/explosive.dm index 29902d68b81..82c69149f6e 100644 --- a/code/modules/mob/living/basic/guardian/guardian_types/explosive.dm +++ b/code/modules/mob/living/basic/guardian/guardian_types/explosive.dm @@ -22,7 +22,7 @@ return ..() /mob/living/basic/guardian/explosive/UnarmedAttack(atom/attack_target, proximity_flag, list/modifiers) - if(LAZYACCESS(modifiers, RIGHT_CLICK) && proximity_flag && isobj(attack_target)) + if(LAZYACCESS(modifiers, RIGHT_CLICK) && proximity_flag && isobj(attack_target) && can_unarmed_attack()) bomb.Trigger(target = attack_target) return return ..() diff --git a/code/modules/mob/living/basic/guardian/guardian_types/gravitokinetic.dm b/code/modules/mob/living/basic/guardian/guardian_types/gravitokinetic.dm index 1728254d3dd..1ce50a3e9fa 100644 --- a/code/modules/mob/living/basic/guardian/guardian_types/gravitokinetic.dm +++ b/code/modules/mob/living/basic/guardian/guardian_types/gravitokinetic.dm @@ -57,7 +57,7 @@ return TRUE /mob/living/basic/guardian/gravitokinetic/UnarmedAttack(atom/attack_target, proximity_flag, list/modifiers) - if (LAZYACCESS(modifiers, RIGHT_CLICK) && proximity_flag && !gravity_targets[attack_target]) + if (LAZYACCESS(modifiers, RIGHT_CLICK) && proximity_flag && !gravity_targets[attack_target] && can_unarmed_attack()) slam_turf(attack_target) return return ..() diff --git a/code/modules/mob/living/basic/pets/cat/cat.dm b/code/modules/mob/living/basic/pets/cat/cat.dm index 17fb3841e2d..1c86b2ffcb4 100644 --- a/code/modules/mob/living/basic/pets/cat/cat.dm +++ b/code/modules/mob/living/basic/pets/cat/cat.dm @@ -73,9 +73,12 @@ /mob/living/basic/pet/cat/proc/pre_unarmed_attack(mob/living/hitter, atom/target, proximity, modifiers) SIGNAL_HANDLER - if(istype(target, /obj/machinery/oven/range)) - target.attack_hand(src) - return COMPONENT_CANCEL_ATTACK_CHAIN + if(!proximity || !can_unarmed_attack()) + return NONE + if(!istype(target, /obj/machinery/oven/range)) + return NONE + target.attack_hand(src) + return COMPONENT_CANCEL_ATTACK_CHAIN /mob/living/basic/pet/cat/Exited(atom/movable/gone, direction) . = ..() diff --git a/code/modules/mob/living/simple_animal/bot/firebot.dm b/code/modules/mob/living/simple_animal/bot/firebot.dm index 98d34fc2f71..da07d6f0efd 100644 --- a/code/modules/mob/living/simple_animal/bot/firebot.dm +++ b/code/modules/mob/living/simple_animal/bot/firebot.dm @@ -77,7 +77,7 @@ /mob/living/simple_animal/bot/firebot/UnarmedAttack(atom/A, proximity_flag, list/modifiers) if(!(bot_mode_flags & BOT_MODE_ON)) return - if(HAS_TRAIT(src, TRAIT_HANDS_BLOCKED)) + if(!can_unarmed_attack()) return if(internal_ext) internal_ext.afterattack(A, src) @@ -316,4 +316,3 @@ #undef SPEECH_INTERVAL #undef DETECTED_VOICE_INTERVAL #undef FOAM_INTERVAL - diff --git a/code/modules/mob/living/simple_animal/bot/floorbot.dm b/code/modules/mob/living/simple_animal/bot/floorbot.dm index 2884b0a0486..e6554b4caea 100644 --- a/code/modules/mob/living/simple_animal/bot/floorbot.dm +++ b/code/modules/mob/living/simple_animal/bot/floorbot.dm @@ -397,7 +397,7 @@ return ..() /mob/living/simple_animal/bot/floorbot/UnarmedAttack(atom/A, proximity_flag, list/modifiers) - if(HAS_TRAIT(src, TRAIT_HANDS_BLOCKED)) + if(!can_unarmed_attack()) return if(isturf(A)) repair(A) diff --git a/code/modules/mob/living/simple_animal/bot/mulebot.dm b/code/modules/mob/living/simple_animal/bot/mulebot.dm index af505f53caa..88210a714c8 100644 --- a/code/modules/mob/living/simple_animal/bot/mulebot.dm +++ b/code/modules/mob/living/simple_animal/bot/mulebot.dm @@ -769,7 +769,7 @@ unload() /mob/living/simple_animal/bot/mulebot/UnarmedAttack(atom/A, proximity_flag, list/modifiers) - if(HAS_TRAIT(src, TRAIT_HANDS_BLOCKED)) + if(!can_unarmed_attack()) return if(isturf(A) && isturf(loc) && loc.Adjacent(A) && load) unload(get_dir(loc, A)) diff --git a/code/modules/mob/living/simple_animal/bot/secbot.dm b/code/modules/mob/living/simple_animal/bot/secbot.dm index 288d1a7c872..5115dd4c8e2 100644 --- a/code/modules/mob/living/simple_animal/bot/secbot.dm +++ b/code/modules/mob/living/simple_animal/bot/secbot.dm @@ -278,7 +278,7 @@ /mob/living/simple_animal/bot/secbot/UnarmedAttack(atom/attack_target, proximity_flag, list/modifiers) if(!(bot_mode_flags & BOT_MODE_ON)) return - if(HAS_TRAIT(src, TRAIT_HANDS_BLOCKED)) + if(!can_unarmed_attack()) return if(!iscarbon(attack_target)) return ..()