From e16ebb8593c4b5e1eab2125fdef2033618943cb5 Mon Sep 17 00:00:00 2001 From: Halonexus Date: Sun, 28 Apr 2024 17:54:27 +0300 Subject: [PATCH] timer better resets itself --- code/modules/mob/living/simple_animal/hostile/hostile.dm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/code/modules/mob/living/simple_animal/hostile/hostile.dm b/code/modules/mob/living/simple_animal/hostile/hostile.dm index 4ca0cd39bf15..85a21e5725cb 100644 --- a/code/modules/mob/living/simple_animal/hostile/hostile.dm +++ b/code/modules/mob/living/simple_animal/hostile/hostile.dm @@ -570,7 +570,9 @@ if(!client && AIStatus == AI_ON && target && !attack_is_on_cooldown) TryAttack() -/mob/living/simple_animal/hostile/proc/TryAttack() +/mob/living/simple_animal/hostile/proc/TryAttack(called_by_timer = FALSE) + if(called_by_timer) + attack_timer_id = null if(client || stat != CONSCIOUS || AIStatus != AI_ON || incapacitated() || !targets_from || !isturf(targets_from.loc)) attack_is_on_cooldown = FALSE if(attack_timer_id) @@ -598,7 +600,7 @@ else attack_is_on_cooldown = FALSE if(!attack_timer_id) - attack_timer_id = addtimer(CALLBACK(src, PROC_REF(TryAttack)), attack_cooldown, TIMER_STOPPABLE) + attack_timer_id = addtimer(CALLBACK(src, PROC_REF(TryAttack), TRUE), attack_cooldown, TIMER_STOPPABLE) // Called by automated_action and causes the AI to go idle if it returns false. This proc is pretty big. /mob/living/simple_animal/hostile/proc/MoveToTarget(list/possible_targets)