Attackedby differentiates failed attacks from 0 damage attacks (#92564)

## About The Pull Request

Fixes #92558

Currently `attacked_by` does not differentiate an attack that did 0
damage with an attack that failed (due to blocking or whatnot)

See also: This hack I left in

https://github.com/tgstation/tgstation/blob/ce958c77c006a5fe279fb46fed513206e341cfce/code/_onclick/item_attack.dm#L346-L347

This causes problems because successful attacks can deal 0 damage. See
linked issue.

This PR addresses the issue by having `attacked_by` return `-1`
(`ATTACK_FAILED`) for attacks which entirely do not connect.
-1 was used so consumers can easily check if an attack did 0 damage OR
failed (via checking `<= 0`)

This isn't the preferred fix - I'd prefer if all block checking and zone
targeting was moved to `/item/proc/attack`, but that requires attack
itself be reigned in a bit (cuz it's still a bit of a mess).

## Changelog

🆑 Melbert
fix: Item on-attack effects will trigger as expected when hitting a limb
at damage cap
/🆑
This commit is contained in:
MrMelbert
2025-08-19 22:40:47 -04:00
committed by nevimer
parent 46c780404a
commit 57884727ca
6 changed files with 17 additions and 10 deletions
+1 -1
View File
@@ -277,7 +277,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/mirror/broken, 28)
/obj/structure/mirror/attacked_by(obj/item/I, mob/living/user, list/modifiers, list/attack_modifiers)
. = ..()
if(broken || !.) // breaking a mirror truly gets you bad luck!
if(broken || . <= 0) // breaking a mirror truly gets you bad luck!
return
to_chat(user, span_warning("A chill runs down your spine as [src] shatters..."))
user.AddComponent(/datum/component/omen, incidents_left = 7)