mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-22 20:48:56 +01:00
fixes a few problems in ai targetting (#82998)
## About The Pull Request fixes #82964 , fixes #82866 ## Why It's Good For The Game fixes several problems with ai targetting. this pr resolves civil war that was brewing between several mobs. also fixes a major problem where mobs would only search for targets and not perform any other behaviors. also fixes a small problem where mobs would constantly stop and start while chasing targets ## Changelog 🆑 fix: mobs in the same faction will no longer be at odds against one another fix: mobs can now perform behaviors alongside searching for targets fix: mobs will no longer be starting and stopping when chasing targets /🆑
This commit is contained in:
@@ -172,9 +172,13 @@ multiple modular subtrees with behaviors
|
||||
return FALSE
|
||||
return TRUE
|
||||
|
||||
/datum/ai_controller/proc/recalculate_idle()
|
||||
/datum/ai_controller/proc/recalculate_idle(datum/exited)
|
||||
if(ai_status == AI_STATUS_OFF)
|
||||
return
|
||||
|
||||
if(exited && (get_dist(pawn, (islist(exited) ? exited[1] : exited)) <= interesting_dist)) //is our target in between interesting cells?
|
||||
return
|
||||
|
||||
if(should_idle())
|
||||
set_ai_status(AI_STATUS_IDLE)
|
||||
|
||||
@@ -187,7 +191,7 @@ multiple modular subtrees with behaviors
|
||||
/datum/ai_controller/proc/on_client_exit(datum/source, datum/exited)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
recalculate_idle()
|
||||
recalculate_idle(exited)
|
||||
|
||||
/// Sets the AI on or off based on current conditions, call to reset after you've manually disabled it somewhere
|
||||
/datum/ai_controller/proc/reset_ai_status()
|
||||
|
||||
@@ -7,6 +7,7 @@ GLOBAL_LIST_INIT(target_interested_atoms, typecacheof(list(/mob, /obj/machinery/
|
||||
|
||||
/datum/ai_behavior/find_potential_targets
|
||||
action_cooldown = 2 SECONDS
|
||||
behavior_flags = AI_BEHAVIOR_CAN_PLAN_DURING_EXECUTION
|
||||
/// How far can we see stuff?
|
||||
var/vision_range = 9
|
||||
/// Blackboard key for aggro range, uses vision range if not specified
|
||||
@@ -34,7 +35,7 @@ GLOBAL_LIST_INIT(target_interested_atoms, typecacheof(list(/mob, /obj/machinery/
|
||||
|
||||
// If we're using a field rn, just don't do anything yeah?
|
||||
if(controller.blackboard[BB_FIND_TARGETS_FIELD(type)])
|
||||
return
|
||||
return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_FAILED
|
||||
|
||||
var/list/potential_targets = hearers(aggro_range, get_turf(controller.pawn)) - living_mob //Remove self, so we don't suicide
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_SUCCEEDED
|
||||
pawn.visible_message(span_notice("[pawn] calms down.")) // We can blackboard key this if anyone else actually wants to customise it
|
||||
controller.clear_blackboard_key(BB_BASIC_MOB_RETALIATE_LIST)
|
||||
controller.clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET)
|
||||
controller.CancelActions() // Otherwise they will try and get one last kick in
|
||||
return AI_BEHAVIOR_DELAY
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
var/check_faction = FALSE
|
||||
|
||||
/datum/ai_planning_subtree/target_retaliate/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick)
|
||||
. = ..()
|
||||
controller.queue_behavior(/datum/ai_behavior/target_from_retaliate_list, BB_BASIC_MOB_RETALIATE_LIST, target_key, targeting_strategy_key, hiding_place_key, check_faction)
|
||||
|
||||
/datum/ai_planning_subtree/target_retaliate/check_faction
|
||||
@@ -35,7 +34,6 @@
|
||||
var/vision_range = 9
|
||||
|
||||
/datum/ai_behavior/target_from_retaliate_list/perform(seconds_per_tick, datum/ai_controller/controller, shitlist_key, target_key, targeting_strategy_key, hiding_location_key, check_faction)
|
||||
. = ..()
|
||||
var/mob/living/living_mob = controller.pawn
|
||||
var/datum/targeting_strategy/targeting_strategy = GET_TARGETING_STRATEGY(controller.blackboard[targeting_strategy_key])
|
||||
if(!targeting_strategy)
|
||||
@@ -58,7 +56,6 @@
|
||||
enemies_list += potential_target
|
||||
|
||||
if(!length(enemies_list))
|
||||
controller.clear_blackboard_key(target_key)
|
||||
return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_FAILED
|
||||
|
||||
var/atom/new_target = pick_final_target(controller, enemies_list)
|
||||
@@ -75,7 +72,7 @@
|
||||
/datum/ai_behavior/target_from_retaliate_list/proc/pick_final_target(datum/ai_controller/controller, list/enemies_list)
|
||||
return pick(enemies_list)
|
||||
|
||||
/datum/ai_behavior/target_from_retaliate_list/finish_action(datum/ai_controller/controller, succeeded, check_faction)
|
||||
/datum/ai_behavior/target_from_retaliate_list/finish_action(datum/ai_controller/controller, succeeded, shitlist_key, target_key, targeting_strategy_key, hiding_location_key, check_faction)
|
||||
. = ..()
|
||||
if (succeeded || check_faction)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user