mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-28 15:47:15 +01:00
[no gbp] fixes ai controller runtime (#81134)
## About The Pull Request fixes the flaky error that would happen in cleanbot controllers. i discovered thru the profiler that a proc i was using to stop tracking unreachable targets and caching them to a blacklist in selectbehavior had a bit of a high real time cost, so if the mob got deleted midway through for any reason would cause a runtime error. ive moved this proc off selectbehavior and im instead letting the move loop cache this target into the blacklist if it reaches the max pathing attempts ## Why It's Good For The Game fixes a runtime that sometimes happens in ai controllers ## Changelog 🆑 fix: fixes a runtime that sometimes happens in ai controllers /🆑
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
BB_TARGETING_STRATEGY = /datum/targeting_strategy/basic/allow_items,
|
||||
BB_PET_TARGETING_STRATEGY = /datum/targeting_strategy/basic/not_friends,
|
||||
BB_TARGETING_STRATEGY = /datum/targeting_strategy/basic,
|
||||
BB_UNREACHABLE_LIST_COOLDOWN = 3 MINUTES,
|
||||
BB_SALUTE_MESSAGES = list(
|
||||
"salutes",
|
||||
"nods in appreciation towards",
|
||||
@@ -51,7 +52,7 @@
|
||||
/datum/ai_planning_subtree/cleaning_subtree
|
||||
|
||||
/datum/ai_planning_subtree/cleaning_subtree/SelectBehaviors(datum/ai_controller/basic_controller/bot/cleanbot/controller, seconds_per_tick)
|
||||
if(controller.reachable_key(BB_CLEAN_TARGET, BOT_CLEAN_PATH_LIMIT))
|
||||
if(controller.blackboard_key_exists(BB_CLEAN_TARGET))
|
||||
controller.queue_behavior(/datum/ai_behavior/execute_clean, BB_CLEAN_TARGET)
|
||||
return SUBTREE_RETURN_FINISH_PLANNING
|
||||
|
||||
@@ -68,7 +69,7 @@
|
||||
controller.queue_behavior(/datum/ai_behavior/find_and_set/in_list/clean_targets, BB_CLEAN_TARGET, final_hunt_list)
|
||||
|
||||
/datum/ai_behavior/find_and_set/in_list/clean_targets
|
||||
action_cooldown = 1 SECONDS
|
||||
action_cooldown = 3 SECONDS
|
||||
|
||||
/datum/ai_behavior/find_and_set/in_list/clean_targets/search_tactic(datum/ai_controller/controller, locate_paths, search_range)
|
||||
var/list/found = typecache_filter_list(oview(search_range, controller.pawn), locate_paths)
|
||||
@@ -76,6 +77,10 @@
|
||||
for(var/atom/found_item in found)
|
||||
if(LAZYACCESS(ignore_list, REF(found_item)))
|
||||
continue
|
||||
var/list/path = get_path_to(controller.pawn, found_item, max_distance = BOT_CLEAN_PATH_LIMIT, access = controller.get_access())
|
||||
if(!length(path))
|
||||
controller.set_blackboard_key_assoc_lazylist(BB_TEMPORARY_IGNORE_LIST, REF(found_item), TRUE)
|
||||
continue
|
||||
return found_item
|
||||
|
||||
/datum/ai_planning_subtree/acid_spray
|
||||
@@ -84,7 +89,7 @@
|
||||
var/mob/living/basic/bot/cleanbot/bot_pawn = controller.pawn
|
||||
if(!(bot_pawn.bot_access_flags & BOT_COVER_EMAGGED))
|
||||
return
|
||||
if(controller.reachable_key(BB_ACID_SPRAY_TARGET, BOT_CLEAN_PATH_LIMIT))
|
||||
if(controller.blackboard_key_exists(BB_ACID_SPRAY_TARGET))
|
||||
controller.queue_behavior(/datum/ai_behavior/execute_clean, BB_ACID_SPRAY_TARGET)
|
||||
return SUBTREE_RETURN_FINISH_PLANNING
|
||||
|
||||
@@ -130,6 +135,10 @@
|
||||
. = ..()
|
||||
controller.set_blackboard_key(BB_POST_CLEAN_COOLDOWN, POST_CLEAN_COOLDOWN + world.time)
|
||||
var/atom/target = controller.blackboard[target_key]
|
||||
if(!succeeded && !isnull(target))
|
||||
controller.clear_blackboard_key(target_key)
|
||||
controller.set_blackboard_key_assoc_lazylist(BB_TEMPORARY_IGNORE_LIST, REF(target), TRUE)
|
||||
return
|
||||
if(QDELETED(target) || is_type_in_typecache(target, controller.blackboard[BB_HUNTABLE_TRASH]))
|
||||
return
|
||||
if(!iscarbon(target))
|
||||
@@ -208,7 +217,7 @@
|
||||
return ..()
|
||||
|
||||
/datum/pet_command/point_targeting/clean/execute_action(datum/ai_controller/basic_controller/bot/controller)
|
||||
if(controller.reachable_key(BB_CURRENT_PET_TARGET))
|
||||
if(controller.blackboard_key_exists(BB_CURRENT_PET_TARGET))
|
||||
controller.queue_behavior(/datum/ai_behavior/execute_clean, BB_CURRENT_PET_TARGET)
|
||||
return SUBTREE_RETURN_FINISH_PLANNING
|
||||
|
||||
|
||||
Reference in New Issue
Block a user