Files
Bubberstation/code/datums/components/ai_retaliate_advanced.dm
SmArtKar 119c1e9ccc 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
/🆑
2026-05-08 20:40:01 +01:00

38 lines
1.4 KiB
Plaintext

/**
* Attached to a mob with an AI controller, passes things which have damaged it to a blackboard.
* The AI controller is responsible for doing anything with that information.
* Differs from the element as it passes new entries through a callback.
*/
/datum/component/ai_retaliate_advanced
/// Callback to a mob for custom behaviour
var/datum/callback/post_retaliate_callback
/datum/component/ai_retaliate_advanced/Initialize(datum/callback/post_retaliate_callback)
if(!ismob(parent))
return ELEMENT_INCOMPATIBLE
src.post_retaliate_callback = post_retaliate_callback
parent.AddElement(/datum/element/relay_attackers)
ADD_TRAIT(parent, TRAIT_SUBTREE_REQUIRED_OPERATIONAL_DATUM, type)
/datum/component/ai_retaliate_advanced/Destroy(force)
post_retaliate_callback = null
return ..()
/datum/component/ai_retaliate_advanced/RegisterWithParent()
RegisterSignal(parent, COMSIG_ATOM_WAS_ATTACKED, PROC_REF(on_attacked))
/datum/component/ai_retaliate_advanced/UnregisterFromParent()
UnregisterSignal(parent, COMSIG_ATOM_WAS_ATTACKED)
/// Add an attacking atom to a blackboard list of things which attacked us
/datum/component/ai_retaliate_advanced/proc/on_attacked(mob/victim, atom/attacker)
SIGNAL_HANDLER
if (!victim.ai_controller)
return
victim.ai_controller.set_blackboard_key_assoc_lazylist(BB_BASIC_MOB_RETALIATE_LIST, attacker, world.time)
post_retaliate_callback?.InvokeAsync(attacker)