mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-17 13:12:37 +00:00
* 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](7047d294dd) [Adds modify_cooldown, uses it to optimize find_potential_targets further](4ebc8cedce) 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](bcf7d7c5b3) 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](80b63b3445) 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>
66 lines
2.5 KiB
Plaintext
66 lines
2.5 KiB
Plaintext
// Proximity monitor applies forced gravity to all turfs in range.
|
|
/datum/proximity_monitor/advanced/gravity
|
|
edge_is_a_field = TRUE
|
|
var/gravity_value = 0
|
|
var/list/modified_turfs = list()
|
|
|
|
/datum/proximity_monitor/advanced/gravity/New(atom/_host, range, _ignore_if_not_on_turf = TRUE, gravity)
|
|
. = ..()
|
|
gravity_value = gravity
|
|
recalculate_field(full_recalc = TRUE)
|
|
|
|
/datum/proximity_monitor/advanced/gravity/setup_field_turf(turf/target)
|
|
. = ..()
|
|
if(!isnull(modified_turfs[target]))
|
|
return
|
|
if(HAS_TRAIT(target, TRAIT_FORCED_GRAVITY))
|
|
return
|
|
target.AddElement(/datum/element/forced_gravity, gravity_value, can_override = TRUE)
|
|
modified_turfs[target] = gravity_value
|
|
|
|
/datum/proximity_monitor/advanced/gravity/cleanup_field_turf(turf/target)
|
|
. = ..()
|
|
if(isnull(modified_turfs[target]))
|
|
return
|
|
var/grav_value = modified_turfs[target] || 0
|
|
target.RemoveElement(/datum/element/forced_gravity, grav_value, can_override = TRUE)
|
|
modified_turfs -= target
|
|
|
|
// Subtype which pops up a balloon alert when a mob enters the field
|
|
/datum/proximity_monitor/advanced/gravity/warns_on_entrance
|
|
/// This is a list of mob refs that have recently entered the field.
|
|
/// We track it so that we don't spam a player who is stutter stepping in and out with balloon alerts.
|
|
var/list/recently_warned
|
|
|
|
/datum/proximity_monitor/advanced/gravity/warns_on_entrance/setup_field_turf(turf/target)
|
|
. = ..()
|
|
for(var/mob/living/guy in target)
|
|
warn_mob(guy, target)
|
|
|
|
/datum/proximity_monitor/advanced/gravity/warns_on_entrance/cleanup_field_turf(turf/target)
|
|
. = ..()
|
|
for(var/mob/living/guy in target)
|
|
warn_mob(guy, target)
|
|
|
|
/datum/proximity_monitor/advanced/gravity/warns_on_entrance/field_edge_crossed(atom/movable/movable, turf/old_location, turf/new_location)
|
|
. = ..()
|
|
if(isliving(movable))
|
|
warn_mob(movable, new_location)
|
|
|
|
/datum/proximity_monitor/advanced/gravity/warns_on_entrance/field_edge_uncrossed(atom/movable/movable, turf/old_location, turf/new_location)
|
|
. = ..()
|
|
if(isliving(movable))
|
|
warn_mob(movable, old_location)
|
|
|
|
/datum/proximity_monitor/advanced/gravity/warns_on_entrance/proc/warn_mob(mob/living/to_warn, turf/location)
|
|
var/mob_ref_key = REF(to_warn)
|
|
if(mob_ref_key in recently_warned)
|
|
return
|
|
|
|
location.balloon_alert(to_warn, "gravity [(location in modified_turfs) ? "shifts!" : "reverts..."]")
|
|
LAZYADD(recently_warned, mob_ref_key)
|
|
addtimer(CALLBACK(src, PROC_REF(clear_recent_warning), mob_ref_key), 3 SECONDS)
|
|
|
|
/datum/proximity_monitor/advanced/gravity/warns_on_entrance/proc/clear_recent_warning(mob_ref_key)
|
|
LAZYREMOVE(recently_warned, mob_ref_key)
|