fixes megafauna not having an attack delay (#89271)

## About The Pull Request
i opted to fix this by making the `basic_mob_attack_telegraph`
compatible with simple animals for the moment, they now have their short
attack delay back.

## Why It's Good For The Game
closes #87791 , closes #88984 , 

## Changelog
🆑
fix: fixes megafauna instantly attacking people adjacent to them
/🆑

---------

Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
This commit is contained in:
Ben10Omintrix
2025-01-30 14:14:29 +02:00
committed by GitHub
parent d44f6003bb
commit cc130ba2ae
3 changed files with 37 additions and 14 deletions
@@ -14,14 +14,17 @@
/datum/component/basic_mob_attack_telegraph/Initialize(
telegraph_icon = 'icons/mob/telegraphing/telegraph.dmi',
telegraph_state = ATTACK_EFFECT_BITE,
display_telegraph_overlay = TRUE,
telegraph_duration = 0.4 SECONDS,
datum/callback/on_began_forecast,
)
. = ..()
if (!isbasicmob(parent))
if (!isbasicmob(parent) && !ishostile(parent))
return ELEMENT_INCOMPATIBLE
target_overlay = mutable_appearance(telegraph_icon, telegraph_state)
if(display_telegraph_overlay)
target_overlay = mutable_appearance(telegraph_icon, telegraph_state)
src.telegraph_duration = telegraph_duration
src.on_began_forecast = on_began_forecast
@@ -58,9 +61,13 @@
return COMPONENT_HOSTILE_NO_ATTACK
/// Perform an attack after a delay
/datum/component/basic_mob_attack_telegraph/proc/delayed_attack(mob/living/basic/source, atom/target)
/datum/component/basic_mob_attack_telegraph/proc/delayed_attack(mob/living/source, atom/target)
current_target = target
target.add_overlay(target_overlay)
if(target_overlay)
RegisterSignal(target, COMSIG_ATOM_UPDATE_OVERLAYS, PROC_REF(on_target_overlays_update))
target.update_appearance()
RegisterSignal(target, COMSIG_QDELETING, PROC_REF(forget_target))
RegisterSignal(target, COMSIG_MOVABLE_MOVED, PROC_REF(target_moved))
@@ -73,7 +80,12 @@
return
ADD_TRAIT(source, TRAIT_BASIC_ATTACK_FORECAST, REF(src))
forget_target(target)
source.melee_attack(target, ignore_cooldown = TRUE) // We already started the cooldown when we triggered the forecast
if(isbasicmob(source))
var/mob/living/basic/basic_source = source
basic_source.melee_attack(target, ignore_cooldown = TRUE) // We already started the cooldown when we triggered the forecast
return
var/mob/living/simple_animal/hostile/hostile_source = source
hostile_source.AttackingTarget(target)
/// The guy we're trying to attack moved, is he still in range?
/datum/component/basic_mob_attack_telegraph/proc/target_moved(atom/target)
@@ -86,5 +98,10 @@
/datum/component/basic_mob_attack_telegraph/proc/forget_target(atom/target)
SIGNAL_HANDLER
current_target = null
target.cut_overlay(target_overlay)
UnregisterSignal(target, list(COMSIG_QDELETING, COMSIG_MOVABLE_MOVED))
target.update_appearance()
UnregisterSignal(target, list(COMSIG_QDELETING, COMSIG_MOVABLE_MOVED, COMSIG_ATOM_UPDATE_OVERLAYS))
/datum/component/basic_mob_attack_telegraph/proc/on_target_overlays_update(atom/parent_atom, list/overlays)
SIGNAL_HANDLER
if(parent_atom == current_target)
overlays += target_overlay