Adds a priority targeting framework, and priority targeting to mining mobs (#95720)

## About The Pull Request

Introduces a new targeting priority strategy system for basicmob AIs,
which allows controllers to decide which mob to prioritize over others.

Mining mobs will now focus on the NODE drone unless hit, and will pursue
the attacker for 25 seconds before dropping the aggro. They also get
increased aggro if you've attacked other mobs in their view recently,
and after a few hits will have enough aggro to swap to you from the NODE
drone. Ashwalkers get a reduction in aggro because they live there.
Legion broods and brimdemons will immediately target anyone who attacks
their allies rather than waiting for multiple hits. Broods also now
inherit their parent's targets and retaliation/reinforcements lists.


https://github.com/user-attachments/assets/6baaba8a-8b3c-4b2f-ae8b-842f0b1f2b6d

#### This is a bounty for ArcaneMusic

## Why It's Good For The Game

Makes vent defense mob behavior more predictable and easier for players
to manipulate, allowing them to draw aggro from the NODE drone should
make vents more engaging and less of an AI rng fest

## Changelog
🆑
add: Mining mobs now use priority when choosing their target,
prioritizing NODE drones over miners who haven't attacked them or their
allies
/🆑
This commit is contained in:
SmArtKar
2026-05-08 20:40:01 +01:00
committed by GitHub
parent 7579ccc8c2
commit 119c1e9ccc
24 changed files with 216 additions and 38 deletions
@@ -12,6 +12,10 @@ GLOBAL_LIST_INIT(target_interested_atoms, typecacheof(list(/mob, /obj/machinery/
var/vision_range = 9
/// Blackboard key for aggro range, uses vision range if not specified
var/aggro_range_key = BB_AGGRO_RANGE
/// Blackboard key for the target priority strategy
var/priority_strategy_key = BB_TARGET_PRIORITY_STRATEGY
/// If we have a priority strategy set, how often do we refresh our target search?
var/priority_refresh_cooldown = 6 SECONDS
/datum/ai_behavior/find_potential_targets/get_cooldown(datum/ai_controller/cooldown_for)
if(cooldown_for.blackboard[BB_FIND_TARGETS_FIELD(type)])
@@ -26,7 +30,8 @@ GLOBAL_LIST_INIT(target_interested_atoms, typecacheof(list(/mob, /obj/machinery/
CRASH("No target datum was supplied in the blackboard for [controller.pawn]")
var/atom/current_target = controller.blackboard[target_key]
if (targeting_strategy.can_attack(living_mob, current_target, vision_range))
var/datum/target_priority_strategy/priority_strategy = GET_TARGET_PRIORITY_STRATEGY(controller.blackboard[priority_strategy_key])
if((!priority_strategy || controller.blackboard[BB_BASIC_MOB_TARGET_REFRESH_COOLDOWN] > world.time) && current_target && targeting_strategy.can_attack(living_mob, current_target, vision_range))
return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_FAILED
var/aggro_range = controller.blackboard[aggro_range_key] || vision_range
@@ -46,22 +51,30 @@ GLOBAL_LIST_INIT(target_interested_atoms, typecacheof(list(/mob, /obj/machinery/
potential_targets += hostile_machine
if(!potential_targets.len)
failed_to_find_anyone(controller, target_key, targeting_strategy_key, hiding_location_key)
if(!current_target)
failed_to_find_anyone(controller, target_key, targeting_strategy_key, hiding_location_key)
return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_FAILED
var/list/filtered_targets = list()
var/current_priority = 0
if(priority_strategy)
current_priority = priority_strategy.get_target_priority(controller, current_target)
for(var/atom/pot_target in potential_targets)
if(targeting_strategy.can_attack(living_mob, pot_target))//Can we attack it?
filtered_targets += pot_target
if(!targeting_strategy.can_attack(living_mob, pot_target))
continue
if (priority_strategy && priority_strategy.get_target_priority(controller, pot_target) < current_priority)
continue
filtered_targets += pot_target
if(!filtered_targets.len)
failed_to_find_anyone(controller, target_key, targeting_strategy_key, hiding_location_key)
if(!current_target)
failed_to_find_anyone(controller, target_key, targeting_strategy_key, hiding_location_key)
return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_FAILED
var/atom/target = pick_final_target(controller, filtered_targets)
controller.set_blackboard_key(target_key, target)
controller.set_blackboard_key(BB_BASIC_MOB_TARGET_REFRESH_COOLDOWN, world.time + priority_refresh_cooldown)
var/atom/potential_hiding_location = targeting_strategy.find_hidden_mobs(living_mob, target)
@@ -153,7 +166,10 @@ GLOBAL_LIST_INIT(target_interested_atoms, typecacheof(list(/mob, /obj/machinery/
/// Returns the desired final target from the filtered list of targets
/datum/ai_behavior/find_potential_targets/proc/pick_final_target(datum/ai_controller/controller, list/filtered_targets)
return pick(filtered_targets)
var/datum/target_priority_strategy/priority_strategy = GET_TARGET_PRIORITY_STRATEGY(controller.blackboard[priority_strategy_key])
if (!priority_strategy)
return pick(filtered_targets)
return priority_strategy.select_target(controller, filtered_targets)
/// Targets with the trait specified by the BB_TARGET_PRIORITY_TRAIT blackboard key will be prioritized over the rest.
/datum/ai_behavior/find_potential_targets/prioritize_trait
@@ -164,7 +180,7 @@ GLOBAL_LIST_INIT(target_interested_atoms, typecacheof(list(/mob, /obj/machinery/
if(HAS_TRAIT(target, controller.blackboard[BB_TARGET_PRIORITY_TRAIT]))
priority_targets += target
if(length(priority_targets))
return pick(priority_targets)
return ..(controller, priority_targets)
return ..()
/datum/ai_behavior/find_potential_targets/bigger_range