[MIRROR] The honorbound trauma now makes use of the relay_attackers element. [MDB IGNORE] (#21961)

* The honorbound trauma now makes use of the relay_attackers element. (#75908)

## About The Pull Request
Whoever made the relay_attackers element, thank you for streamlining the
bucketload of signals that had to be registered for everything that
counted as an attack. It's very much needed.

Beside, I only had to add a few flags to be sent by the
ATOM_WAS_ATTACKED signal, so that stamina and shoving doesn't
automatically make the attacker guilty.

Oh, one more thing I have forgot to mention. Currently medical staff is
immune to "guilt" altogether, while the comments suggest they should be
affected by declaration but not attacking. This PR also covers that
issue.

## Why It's Good For The Game
This will fix #75904.

## Changelog

🆑
fix: Fixed the honourbound trauma not reacting to attacks from basic
mobs
fix: Fixed the "Declare Evil" spell not working against the medical
department.
/🆑

* The honorbound trauma now makes use of the relay_attackers element.

---------

Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
This commit is contained in:
SkyratBot
2023-06-23 16:06:06 -07:00
committed by GitHub
co-authored by Ghom
parent 14de551f9d
commit 7eedc90a99
3 changed files with 26 additions and 66 deletions
@@ -50,5 +50,9 @@
#define COMSIG_ATOM_ATTACK_ROBOT "atom_attack_robot"
/// from base of atom/attack_robot_secondary(): (mob/user)
#define COMSIG_ATOM_ATTACK_ROBOT_SECONDARY "atom_attack_robot_secondary"
///from relay_attackers element: (atom/attacker)
///from relay_attackers element: (atom/attacker, attack_flags)
#define COMSIG_ATOM_WAS_ATTACKED "atom_was_attacked"
///The damage type of the weapon projectile is non-lethal stamina
#define ATTACKER_STAMINA_ATTACK (1<<0)
///the attacker is shoving the source
#define ATTACKER_SHOVING (1<<1)
+8 -7
View File
@@ -34,12 +34,13 @@
/datum/element/relay_attackers/proc/after_attackby(atom/target, obj/item/weapon, mob/attacker)
SIGNAL_HANDLER
if(weapon.force)
relay_attacker(target, attacker)
relay_attacker(target, attacker, weapon.damtype == STAMINA ? ATTACKER_STAMINA_ATTACK : NONE)
/datum/element/relay_attackers/proc/on_attack_generic(atom/target, mob/living/attacker, list/modifiers)
SIGNAL_HANDLER
if(attacker.combat_mode || LAZYACCESS(modifiers, RIGHT_CLICK))
relay_attacker(target, attacker)
var/shoving = LAZYACCESS(modifiers, RIGHT_CLICK) ? ATTACKER_SHOVING : NONE
if(attacker.combat_mode || shoving)
relay_attacker(target, attacker, shoving)
/datum/element/relay_attackers/proc/on_attack_npc(atom/target, mob/living/attacker)
SIGNAL_HANDLER
@@ -52,7 +53,7 @@
return
if(!ismob(hit_projectile.firer))
return
relay_attacker(target, hit_projectile.firer)
relay_attacker(target, hit_projectile.firer, hit_projectile.damage_type == STAMINA ? ATTACKER_STAMINA_ATTACK : NONE)
/datum/element/relay_attackers/proc/on_hitby(atom/target, atom/movable/hit_atom, skipcatch = FALSE, hitpush = TRUE, blocked = FALSE, datum/thrownthing/throwingdatum)
SIGNAL_HANDLER
@@ -64,7 +65,7 @@
var/mob/thrown_by = hit_item.thrownby?.resolve()
if(!ismob(thrown_by))
return
relay_attacker(target, thrown_by)
relay_attacker(target, thrown_by, hit_item.damtype == STAMINA ? ATTACKER_STAMINA_ATTACK : NONE)
/datum/element/relay_attackers/proc/on_attack_hulk(atom/target, mob/attacker)
SIGNAL_HANDLER
@@ -75,5 +76,5 @@
relay_attacker(target, mecha_attacker)
/// Send out a signal identifying whoever just attacked us (usually a mob but sometimes a mech or turret)
/datum/element/relay_attackers/proc/relay_attacker(atom/victim, atom/attacker)
SEND_SIGNAL(victim, COMSIG_ATOM_WAS_ATTACKED, attacker)
/datum/element/relay_attackers/proc/relay_attacker(atom/victim, atom/attacker, attack_flags)
SEND_SIGNAL(victim, COMSIG_ATOM_WAS_ATTACKED, attacker, attack_flags)
@@ -15,13 +15,10 @@
//checking spells cast by honorbound
RegisterSignal(owner, COMSIG_MOB_CAST_SPELL, PROC_REF(spell_check))
RegisterSignal(owner, COMSIG_MOB_FIRED_GUN, PROC_REF(staff_check))
//signals that check for guilt
RegisterSignal(owner, COMSIG_ATOM_ATTACKBY, PROC_REF(attackby_guilt))
RegisterSignal(owner, COMSIG_ATOM_HULK_ATTACK, PROC_REF(hulk_guilt))
RegisterSignal(owner, COMSIG_ATOM_ATTACK_HAND, PROC_REF(hand_guilt))
RegisterSignal(owner, COMSIG_ATOM_ATTACK_PAW, PROC_REF(paw_guilt))
RegisterSignal(owner, COMSIG_ATOM_BULLET_ACT, PROC_REF(bullet_guilt))
RegisterSignal(owner, COMSIG_ATOM_HITBY, PROC_REF(thrown_guilt))
//adds the relay_attackers element to the owner so whoever attacks him becomes guilty.
owner.AddElement(/datum/element/relay_attackers)
RegisterSignal(owner, COMSIG_ATOM_WAS_ATTACKED, PROC_REF(on_attacked))
//signal that checks for dishonorable attacks
RegisterSignal(owner, COMSIG_MOB_CLICKON, PROC_REF(attack_honor))
@@ -32,12 +29,7 @@
/datum/brain_trauma/special/honorbound/on_lose(silent)
owner.clear_mood_event("honorbound")
UnregisterSignal(owner, list(
COMSIG_ATOM_ATTACKBY,
COMSIG_ATOM_HULK_ATTACK,
COMSIG_ATOM_ATTACK_HAND,
COMSIG_ATOM_ATTACK_PAW,
COMSIG_ATOM_BULLET_ACT,
COMSIG_ATOM_HITBY,
COMSIG_ATOM_WAS_ATTACKED,
COMSIG_MOB_CLICKON,
COMSIG_MOB_CAST_SPELL,
COMSIG_MOB_FIRED_GUN,
@@ -77,7 +69,7 @@
if(user in guilty)
return
var/datum/mind/guilty_conscience = user.mind
if(guilty_conscience) //sec and medical are immune to becoming guilty through attack (we don't check holy because holy shouldn't be able to attack eachother anyways)
if(guilty_conscience && !declaration) //sec and medical are immune to becoming guilty through attack (we don't check holy because holy shouldn't be able to attack eachother anyways)
var/datum/job/job = guilty_conscience.assigned_role
if(job.departments_bitflags & (DEPARTMENT_BITFLAG_MEDICAL | DEPARTMENT_BITFLAG_SECURITY))
return
@@ -88,6 +80,12 @@
to_chat(user, span_danger("[GLOB.deity] no longer considers you innocent!"))
guilty += user
///Signal sent by the relay_attackers element. It makes the attacker guilty unless the damage was stamina or it was a shove.
/datum/brain_trauma/special/honorbound/proc/on_attacked(mob/source, mob/attacker, attack_flags)
SIGNAL_HANDLER
if(!(attack_flags & (ATTACKER_STAMINA_ATTACK|ATTACKER_SHOVING)))
guilty(attacker)
/**
* Called by attack_honor signal to check whether an attack should be allowed or not
*
@@ -111,7 +109,7 @@
if(is_holy || (job?.departments_bitflags & DEPARTMENT_BITFLAG_SECURITY))
to_chat(honorbound_human, span_warning("There is nothing righteous in attacking the <b>just</b>."))
return FALSE
if(job?.departments_bitflags & DEPARTMENT_BITFLAG_MEDICAL)
if(job?.departments_bitflags & DEPARTMENT_BITFLAG_MEDICAL && !is_guilty)
to_chat(honorbound_human, span_warning("If you truly think this healer is not <b>innocent</b>, declare them guilty."))
return FALSE
//THE INNOCENT
@@ -120,49 +118,6 @@
return FALSE
return TRUE
// SIGNALS THAT ARE FOR BEING ATTACKED FIRST (GUILTY)
/datum/brain_trauma/special/honorbound/proc/attackby_guilt(datum/source, obj/item/I, mob/attacker)
SIGNAL_HANDLER
if(I.force && I.damtype != STAMINA)
guilty(attacker)
/datum/brain_trauma/special/honorbound/proc/hulk_guilt(datum/source, mob/attacker)
SIGNAL_HANDLER
guilty(attacker)
/datum/brain_trauma/special/honorbound/proc/hand_guilt(datum/source, mob/living/attacker)
SIGNAL_HANDLER
if(attacker.combat_mode)
guilty(attacker)
/datum/brain_trauma/special/honorbound/proc/paw_guilt(datum/source, mob/living/attacker)
SIGNAL_HANDLER
guilty(attacker)
/datum/brain_trauma/special/honorbound/proc/bullet_guilt(datum/source, obj/projectile/proj)
SIGNAL_HANDLER
var/mob/living/shot_honorbound = source
var/static/list/guilty_projectiles = typecacheof(list(
/obj/projectile/beam,
/obj/projectile/bullet,
/obj/projectile/magic,
))
if(!is_type_in_typecache(proj, guilty_projectiles))
return
if(proj.damage_type == STAMINA || !proj.is_hostile_projectile())
return
if(proj.damage > 0 && proj.damage < shot_honorbound.health && isliving(proj.firer))
guilty(proj.firer)
/datum/brain_trauma/special/honorbound/proc/thrown_guilt(datum/source, atom/movable/thrown_movable, skipcatch = FALSE, hitpush = TRUE, blocked = FALSE, datum/thrownthing/throwingdatum)
SIGNAL_HANDLER
if(isitem(thrown_movable))
var/mob/living/honorbound = source
var/obj/item/thrown_item = thrown_movable
var/mob/thrown_by = thrown_item.thrownby?.resolve()
if(thrown_item.throwforce < honorbound.health && ishuman(thrown_by))
guilty(thrown_by)
//spell checking
/datum/brain_trauma/special/honorbound/proc/spell_check(mob/user, datum/action/cooldown/spell/spell_cast)
SIGNAL_HANDLER