diff --git a/code/modules/mob/living/carbon/xenomorph/ai/movement/crusher.dm b/code/modules/mob/living/carbon/xenomorph/ai/movement/crusher.dm index 675d9b872d..5c63a2364b 100644 --- a/code/modules/mob/living/carbon/xenomorph/ai/movement/crusher.dm +++ b/code/modules/mob/living/carbon/xenomorph/ai/movement/crusher.dm @@ -3,17 +3,8 @@ /// The turf we force our crusher to walk to when he charges var/turf/charge_turf - -#define AI_NEW_TARGET_COOLDOWN 1 SECONDS - /datum/xeno_ai_movement/crusher/New(mob/living/carbon/xenomorph/parent) . = ..() - addtimer(CALLBACK(src, PROC_REF(get_new_target), parent), AI_NEW_TARGET_COOLDOWN, TIMER_UNIQUE|TIMER_LOOP|TIMER_DELETE_ME) - -/datum/xeno_ai_movement/crusher/proc/get_new_target(mob/living/carbon/xenomorph/parent) - parent.current_target = parent.get_target(parent.ai_range) - -#undef AI_NEW_TARGET_COOLDOWN #define MIN_TARGETS_TO_CHARGE 2 diff --git a/code/modules/mob/living/carbon/xenomorph/ai/xeno_ai.dm b/code/modules/mob/living/carbon/xenomorph/ai/xeno_ai.dm index f19b317956..479fa613a4 100644 --- a/code/modules/mob/living/carbon/xenomorph/ai/xeno_ai.dm +++ b/code/modules/mob/living/carbon/xenomorph/ai/xeno_ai.dm @@ -19,6 +19,12 @@ var/datum/xeno_ai_movement/ai_movement_handler + /// The time interval before this xeno should forcefully get a new target + var/forced_retarget_time = (10 SECONDS) + + /// The actual cooldown declaration for forceful retargeting, reference forced_retarget_time for time in between checks + COOLDOWN_DECLARE(forced_retarget_cooldown) + /mob/living/carbon/xenomorph/Destroy() QDEL_NULL(ai_movement_handler) return ..() @@ -68,8 +74,9 @@ var/mob/current_target_mob = current_target stat_check = (current_target_mob.stat != CONSCIOUS) - if(QDELETED(current_target) || stat_check || get_dist(current_target, src) > ai_range) + if(QDELETED(current_target) || stat_check || get_dist(current_target, src) > ai_range || COOLDOWN_FINISHED(src, forced_retarget_cooldown)) current_target = get_target(ai_range) + COOLDOWN_START(src, forced_retarget_cooldown, forced_retarget_time) if(QDELETED(src)) return TRUE diff --git a/code/modules/mob/living/carbon/xenomorph/castes/Crusher.dm b/code/modules/mob/living/carbon/xenomorph/castes/Crusher.dm index 4ae1916521..07920c816c 100644 --- a/code/modules/mob/living/carbon/xenomorph/castes/Crusher.dm +++ b/code/modules/mob/living/carbon/xenomorph/castes/Crusher.dm @@ -74,6 +74,7 @@ icon_xenonid = 'icons/mob/xenonids/crusher.dmi' ai_range = 28 + forced_retarget_time = (3 SECONDS) /mob/living/carbon/xenomorph/crusher/init_movement_handler() return new /datum/xeno_ai_movement/crusher(src)