Makes tendrils less out for blood, cleans up The Thing's code (#96332)

## About The Pull Request

I didn't realize that default aggro range for mobs is 9, so tendrils
would try to attack you with their whips and spikes despite you being
completely out of their range, which looks pretty funny.
I've fixed this by separating out aggro ***grab*** range and aggro
sustain ranges, lowering latter to 5 for tendrils, and adding checks for
target distance for both abilities it has. The Thing also had a similar
behavior but used rather jank code for that (which I don't think even
worked), so I've modified it to use the new system as well.

## Why It's Good For The Game

Stationary mobs probably shouldn't try to attack mobs completely out of
their reach

## Changelog
🆑
fix: Tendrils no longer try to attack you when you're out of their reach
code: Cleaned up The Thing's aggro code
/🆑
This commit is contained in:
SmArtKar
2026-06-11 15:36:37 -04:00
committed by nevimer
parent b976715b42
commit 4f8b9f2418
6 changed files with 29 additions and 14 deletions
@@ -12,6 +12,8 @@ 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
/// Range in which we can acquire a new target
var/aggro_grab_range_key = BB_AGGRO_GRAB_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?
@@ -34,7 +36,12 @@ GLOBAL_LIST_INIT(target_interested_atoms, typecacheof(list(/mob, /obj/machinery/
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
var/aggro_range = vision_range
if(isnull(current_target) && !isnull(controller.blackboard[aggro_grab_range_key]))
aggro_range = controller.blackboard[aggro_grab_range_key]
else if(!isnull(controller.blackboard[aggro_range_key]))
aggro_range = controller.blackboard[aggro_range_key]
controller.clear_blackboard_key(target_key)
// If we're using a field rn, just don't do anything yeah?
@@ -87,7 +94,12 @@ GLOBAL_LIST_INIT(target_interested_atoms, typecacheof(list(/mob, /obj/machinery/
return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_SUCCEEDED
/datum/ai_behavior/find_potential_targets/proc/failed_to_find_anyone(datum/ai_controller/controller, target_key, targeting_strategy_key, hiding_location_key)
var/aggro_range = controller.blackboard[aggro_range_key] || vision_range
var/aggro_range = vision_range
if(!isnull(controller.blackboard[aggro_grab_range_key]))
aggro_range = controller.blackboard[aggro_grab_range_key]
else if(!isnull(controller.blackboard[aggro_range_key]))
aggro_range = controller.blackboard[aggro_range_key]
// takes the larger between our range() input and our implicit hearers() input (world.view)
aggro_range = max(aggro_range, ROUND_UP(max(getviewsize(world.view)) / 2))
// Alright, here's the interesting bit
@@ -187,6 +199,3 @@ GLOBAL_LIST_INIT(target_interested_atoms, typecacheof(list(/mob, /obj/machinery/
if(length(priority_targets))
return ..(controller, priority_targets)
return ..()
/datum/ai_behavior/find_potential_targets/bigger_range
vision_range = 16
@@ -22,9 +22,5 @@
/datum/ai_planning_subtree/simple_find_target/to_flee
target_key = BB_BASIC_MOB_FLEE_TARGET
/datum/ai_planning_subtree/simple_find_target/increased_range
target_behavior = /datum/ai_behavior/find_potential_targets/bigger_range
/datum/ai_planning_subtree/simple_find_target/hunt
strategy_key = BB_HUNT_TARGETING_STRATEGY