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.
/🆑
This commit is contained in:
Ghom
2023-06-21 06:01:09 -07:00
committed by GitHub
parent ee53c92a97
commit 85b72e4b30
3 changed files with 26 additions and 66 deletions
@@ -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