Files
Bubberstation/code/datums/ai/basic_mobs/basic_subtrees/shapechange_ambush.dm
Jacquerel 5e2c8459dd Basic Heretic Mobs: The Rest of Them (#78757)
## About The Pull Request

Raw Prophet and Armsy had fun stuff going on and merited their own PRs,
but the rest of these guys are basically just statblocks with abilities
so I converted them all at once.

Rust Walkers are present in a ruin and so have new AI which will
actually use their abilities. They rust the area around where they spawn
and throw their rust blast at people.

I also gave Flesh Stalkers AI even though nobody has put them in a map
because I thought it would be cool. This adds an AI behaviour where if
they're not doing anything else they will turn into an animal and chill
until someone's been around them for a bit, before attacking. They will
also use EMP almost immediately upon performing their ambush, which
kills the lights in that room. Spooky!
To support this I needed to make some changes to let AI continue
processing and targetting correctly while shapeshifted.

I didn't give Maids or Ash Spirits AI because they'd be really boring.

Other changes:
I made the maid in the mirror flicker when it takes examine damage
because the `visible_message` says it does but despite having the power,
nobody made it actually flicker...

## Why It's Good For The Game

No more simple mob heretic summons.

## Changelog

🆑
refactor: Rust Walkers, Ash Spirits, Flesh Stalkers, and The Maid in the
Mirror now use the basic mob framework. Please report any unusual
behaviour.
/🆑

---------

Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com>
2023-10-06 16:06:22 -06:00

42 lines
1.9 KiB
Plaintext

/// Shapeshift when we have no target, until someone has been nearby for long enough
/datum/ai_planning_subtree/shapechange_ambush
operational_datums = list(/datum/component/ai_target_timer)
/// Key where we keep our ability
var/ability_key = BB_SHAPESHIFT_ACTION
/// Key where we keep our target
var/target_key = BB_BASIC_MOB_CURRENT_TARGET
/// How long to lull our target into a false sense of security
var/minimum_target_time = 8 SECONDS
/datum/ai_planning_subtree/shapechange_ambush/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick)
var/mob/living/living_pawn = controller.pawn
var/is_shifted = ismob(living_pawn.loc)
var/has_target = controller.blackboard_key_exists(target_key)
var/datum/action/cooldown/using_action = controller.blackboard[ability_key]
if (!is_shifted)
if (has_target)
return // We're busy
if (using_action?.IsAvailable())
controller.queue_behavior(/datum/ai_behavior/use_mob_ability/shapeshift, BB_SHAPESHIFT_ACTION) // Shift
return SUBTREE_RETURN_FINISH_PLANNING
if (!has_target || !using_action?.IsAvailable())
return SUBTREE_RETURN_FINISH_PLANNING // Lie in wait
var/time_on_target = controller.blackboard[BB_BASIC_MOB_HAS_TARGET_TIME] || 0
if (time_on_target < minimum_target_time)
return // Wait a bit longer
controller.queue_behavior(/datum/ai_behavior/use_mob_ability/shapeshift, BB_SHAPESHIFT_ACTION) // Surprise!
/// Selects a random shapeshift ability before shifting
/datum/ai_behavior/use_mob_ability/shapeshift
/datum/ai_behavior/use_mob_ability/shapeshift/setup(datum/ai_controller/controller, ability_key)
var/datum/action/cooldown/spell/shapeshift/using_action = controller.blackboard[ability_key]
if (!using_action?.IsAvailable())
return FALSE
if (isnull(using_action.shapeshift_type)) // If we don't have a shape then pick one, AI can't use context wheels
using_action.shapeshift_type = pick(using_action.possible_shapes)
return ..()