[NO GBP] Slime AI fixes + prerequisites (newest mirror: makes slimes not idle) (#27470)

* Reworks targeting behavior to fall back onto proximity monitors. Refactors ai cooldowns a bit (#82640)

## About The Pull Request

Nother bit ripped out of #79498
[Implements a get_cooldown() proc to get around dumb manual overrides
and empower me to optimize the findtarget
logic](https://github.com/tgstation/tgstation/commit/7047d294dd2675b7e38db2424d6d79c52f21783a)

[Adds modify_cooldown, uses it to optimize find_potential_targets
further](https://github.com/tgstation/tgstation/commit/4ebc8cedcefaa57a1c3d1afbbb485baa6fae0a4f)

No sense running the behavior if we're just waiting on its output, so
let's run it once a minute just in case, then push an update instantly
if we find something

[Optimizes connect_range and
promxity_monitors](https://github.com/tgstation/tgstation/commit/bcf7d7c5b371e46c02aa9039d4ccd4715b999400)

We know what turfs exist before and after a move
We can use this information to prevent trying to update turfs we don't
care about.

This is important because post these changes mobs with fields will be
moving a lot more, so it's gotta be cheap

[Implements a special kind of field to handle ai
targeting](https://github.com/tgstation/tgstation/commit/80b63b3445778eb2c75fc2f8f61aca07ed482b1f)

If we run targeting and don't like, find anything, we should setup a
field that listens for things coming near us and then handle those
things as we find them.

This incurs a slight startup cost but saves so much time on the churn of
constant costs

Note:
We should also work to figure out a way to avoid waking ais if none is
near them/they aren't doing anything interesting

We don't need to do that immediately this acts as somewhat of a stopgap
(and would be good regardless) but it is worth keeping in mind)

## IMPORTANT

I am unsure whether this is worth it anymore since #82539 was merged. As
I say it was done as a stopgap because ais didn't know how to idle.
If not I'll rip er out and we'll keep the other
refactoring/optimizations.

## Why It's Good For The Game

Cleaner basic ai code, maybe? faster basic ai code, for sure faster
proximity monitors (significantly)

* ai controllers use cell trackers to know when to idle (#82691)

## About The Pull Request
this makes ai controllers use cell trackers and signals to determine
when to idle

## Why It's Good For The Game
might be better than looping over all clients for every controller

## Changelog
🆑
code: The way mobs idle has been refactored, please report any issues
with non-reactive mobs
/🆑

* makes slimes not idle (#82742)

## About The Pull Request
slimes should still be able to do their everyday routine without needing
to be watched over

## Why It's Good For The Game
makes xenobiologist's lives easier

## Changelog
🆑
qol: slimes will stay active without needing any one to watch over
/🆑

---------

Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com>
Co-authored-by: Ben10Omintrix <138636438+Ben10Omintrix@users.noreply.github.com>
This commit is contained in:
Waterpig
2024-04-25 15:05:23 +00:00
committed by GitHub
co-authored by LemonInTheDark Ben10Omintrix
parent 6013863da9
commit 08d9f59838
23 changed files with 404 additions and 87 deletions
@@ -13,7 +13,7 @@
src.moods = moods
RegisterSignal(host, COMSIG_ATOM_EXAMINE, PROC_REF(on_examine))
/datum/proximity_monitor/advanced/demoraliser/field_turf_crossed(atom/movable/crossed, turf/location)
/datum/proximity_monitor/advanced/demoraliser/field_turf_crossed(atom/movable/crossed, turf/old_location, turf/new_location)
if (!isliving(crossed))
return
if (!can_see(crossed, host, current_range))
@@ -19,6 +19,7 @@
/datum/ai_planning_subtree/basic_melee_attack_subtree/slime,
/datum/ai_planning_subtree/random_speech/slime,
)
can_idle = FALSE
/datum/ai_controller/basic_controller/slime/CancelActions()
..()
@@ -67,7 +67,7 @@ GLOBAL_LIST_EMPTY(elevator_music)
QDEL_LIST_ASSOC_VAL(tracked_mobs)
return ..()
/datum/proximity_monitor/advanced/elevator_music_area/field_turf_crossed(mob/entered, turf/location)
/datum/proximity_monitor/advanced/elevator_music_area/field_turf_crossed(mob/entered, turf/old_location, turf/new_location)
if (!istype(entered) || !entered.mind)
return
@@ -80,7 +80,7 @@ GLOBAL_LIST_EMPTY(elevator_music)
tracked_mobs[entered] = null // Still add it to the list so we don't keep making this check
RegisterSignal(entered, COMSIG_QDELETING, PROC_REF(mob_destroyed))
/datum/proximity_monitor/advanced/elevator_music_area/field_turf_uncrossed(mob/exited, turf/location)
/datum/proximity_monitor/advanced/elevator_music_area/field_turf_uncrossed(mob/exited, turf/old_location, turf/new_location)
if (!(exited in tracked_mobs))
return
if (exited.z == host.z && get_dist(exited, host) <= current_range)