From 454f1ae114c024e9dafc5d292fade831605d146c Mon Sep 17 00:00:00 2001 From: Ben10Omintrix <138636438+Ben10Omintrix@users.noreply.github.com> Date: Wed, 13 Nov 2024 20:39:48 +0200 Subject: [PATCH] fixes meteor heart AI runtimes (#87813) ## About The Pull Request fixes a few runtimes with the meteor heart's sleep behavior, mostly because it was trying to add an element to a blackboard key list, eventhough said key wasnt a list. ## Why It's Good For The Game fixes meteor heart AI runtimes --- .../basic_subtrees/sleep_with_no_target.dm | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/code/datums/ai/basic_mobs/basic_subtrees/sleep_with_no_target.dm b/code/datums/ai/basic_mobs/basic_subtrees/sleep_with_no_target.dm index 5d9841a5247..649a45d4cc7 100644 --- a/code/datums/ai/basic_mobs/basic_subtrees/sleep_with_no_target.dm +++ b/code/datums/ai/basic_mobs/basic_subtrees/sleep_with_no_target.dm @@ -11,23 +11,24 @@ /// Disables AI after a certain amount of time spent with no target, you will have to enable the AI again somewhere else /datum/ai_behavior/sleep_after_targetless_time - /// Turn off AI if we spend this many seconds without a target, don't use the macro because seconds_per_tick is already in seconds - var/time_to_wait = 10 + /// Turn off AI if we spend this many seconds without a target + var/time_to_wait = 10 SECONDS /datum/ai_behavior/sleep_after_targetless_time/perform(seconds_per_tick, datum/ai_controller/controller, target_key) - var/atom/target = controller.blackboard[target_key] - if(QDELETED(target)) - return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_SUCCEEDED - return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + return (controller.blackboard_key_exists(target_key)) ? ( AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED) : ( AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_SUCCEEDED) -/datum/ai_behavior/sleep_after_targetless_time/finish_action(datum/ai_controller/controller, succeeded, seconds_per_tick) +/datum/ai_behavior/sleep_after_targetless_time/finish_action(datum/ai_controller/controller, succeeded, target_key) . = ..() if (!succeeded) - controller.set_blackboard_key(BB_TARGETLESS_TIME, 0) + controller.clear_blackboard_key(BB_TARGETLESS_TIME) return - controller.add_blackboard_key(BB_TARGETLESS_TIME, seconds_per_tick) - if (controller.blackboard[BB_TARGETLESS_TIME] > time_to_wait) + + if (isnull(controller.blackboard[BB_TARGETLESS_TIME])) + controller.set_blackboard_key(BB_TARGETLESS_TIME, world.time + time_to_wait) + + if (controller.blackboard[BB_TARGETLESS_TIME] < world.time) enter_sleep(controller) + controller.clear_blackboard_key(BB_TARGETLESS_TIME) /// Disables AI, override to do additional things or something else /datum/ai_behavior/sleep_after_targetless_time/proc/enter_sleep(datum/ai_controller/controller)