Fixes fleeing behaviour (#78821)

## About The Pull Request

This PR does three things:
- Fixes fleeing, I broke it in a recent PR so mobs would walk to a
location then sort of stand there doing nothing. This is due to using
`>=` instead of `>`.
- Makes lobstrosities stop running and charge at you more responsively
(when they detect they can charge).
- Inverts the `BB_BASIC_MOB_FLEEING` blackboard key to
`BB_BASIC_MOB_STOP_FLEEING` so that the default behaviour is "to perform
the behaviour that you put on the mob" instead of to not do that.

## Why It's Good For The Game

Makes commonly used behaviour work properly.
Removes footgun we hand to ai developers.

## Changelog

🆑
fix: Cowardly mobs will consistently run away from you instead of
getting tired and just sort of standing there after an initial burst of
movement.
/🆑
This commit is contained in:
Jacquerel
2023-10-08 23:27:31 -06:00
committed by GitHub
parent 8bc8703b6b
commit ed907096e3
24 changed files with 35 additions and 41 deletions
@@ -19,13 +19,13 @@
/datum/ai_behavior/run_away_from_target/perform(seconds_per_tick, datum/ai_controller/controller, target_key, hiding_location_key)
. = ..()
if (!controller.blackboard[BB_BASIC_MOB_FLEEING])
if (controller.blackboard[BB_BASIC_MOB_STOP_FLEEING])
return
var/atom/target = controller.blackboard[hiding_location_key] || controller.blackboard[target_key]
if (QDELETED(target) || !can_see(controller.pawn, target, run_distance))
finish_action(controller, succeeded = TRUE, target_key = target_key, hiding_location_key = hiding_location_key)
return
if (get_dist(controller.pawn, controller.current_movement_target) >= required_distance)
if (get_dist(controller.pawn, controller.current_movement_target) > required_distance)
return // Still heading over
if (plot_path_away_from(controller, target))
return
@@ -10,7 +10,7 @@
/datum/ai_planning_subtree/flee_target/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick)
. = ..()
var/atom/flee_from = controller.blackboard[target_key]
if (!controller.blackboard[BB_BASIC_MOB_FLEEING] || QDELETED(flee_from))
if (controller.blackboard[BB_BASIC_MOB_STOP_FLEEING] || QDELETED(flee_from))
return
var/flee_distance = controller.blackboard[BB_BASIC_MOB_FLEE_DISTANCE] || DEFAULT_BASIC_FLEE_DISTANCE
if (get_dist(controller.pawn, flee_from) >= flee_distance)
@@ -3,7 +3,7 @@
/datum/ai_planning_subtree/simple_find_nearest_target_to_flee/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick)
. = ..()
if (!controller.blackboard[BB_BASIC_MOB_FLEEING])
if (controller.blackboard[BB_BASIC_MOB_STOP_FLEEING])
return
controller.queue_behavior(/datum/ai_behavior/find_potential_targets/nearest, BB_BASIC_MOB_CURRENT_TARGET, BB_TARGETTING_DATUM, BB_BASIC_MOB_CURRENT_TARGET_HIDING_LOCATION)
@@ -13,7 +13,7 @@
/datum/ai_planning_subtree/find_nearest_thing_which_attacked_me_to_flee/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick)
. = ..()
if (!controller.blackboard[BB_BASIC_MOB_FLEEING])
if (controller.blackboard[BB_BASIC_MOB_STOP_FLEEING])
return
controller.queue_behavior(/datum/ai_behavior/target_from_retaliate_list/nearest, BB_BASIC_MOB_RETALIATE_LIST, BB_BASIC_MOB_CURRENT_TARGET, targeting_key, BB_BASIC_MOB_CURRENT_TARGET_HIDING_LOCATION)