# Behavior Trees and EQS Squadcraft thinks in StateTree, but a project built on Behavior Trees can use it as it is. Every Squadcraft StateTree task is also a Behavior Tree task, and every condition a decorator. They run the very same code, with the same settings on the node. | Behavior Tree task | What it does | |---|---| | SQ Patrol | Walks its route, follows its leader or commander, or wanders round home, then waits | | SQ Investigate | Goes where the target was last known and looks around | | SQ Take Cover | Finds cover from the target and runs to it; fails when nothing fits | | SQ Fire From Cover | Hides, leans out, fires a few rounds (suppresses, fires blind, reloads); fails when the cover stops hiding it | | SQ Flank | Runs to cover at the target's side | | SQ Throw Grenade | Throws a grenade where the target hides | | SQ Chase And Strike | Runs at the target and strikes in reach | | SQ Evade Danger | Runs out of a grenade's blast | | SQ Revive | Goes to a downed friend, drags it to cover when an enemy sees the spot, gets it up | Decorators: SQ Alert State Is, SQ Squad Role Is, SQ Combat Style Is, SQ Health Below, SQ Has Not Flanked, SQ Target Hiding, SQ Suppressed, SQ In Danger, SQ Friend Downed, SQ Morale Broken. Each checks its condition every tick while it is relevant, so with an abort mode (Lower Priority, Self or Both) the tree switches the moment the answer changes: an AI patrolling goes straight to its fight branch when it turns Alert. ## Setting it up 1. Keep `SQAIController` (or a Blueprint child of it) as the AI Controller Class: the nodes read and write its state (target, cover, squad, suppression, ammo). 2. Clear its **Behavior** (the StateTree), so the two don't fight over the pawn. 3. Run your tree with **Run Behavior Tree** on possess, as usual. No blackboard key is needed. A tree that does what the default StateTree does, in short: ``` Selector ├── Sequence [SQ In Danger, abort Both] SQ Evade Danger ├── Sequence [SQ Alert State Is: Alert, abort Both] │ ├── Selector │ │ ├── Sequence [SQ Suppressed] SQ Take Cover (Retreat), SQ Fire From Cover │ │ ├── Sequence [SQ Target Hiding + grenade] SQ Throw Grenade │ │ ├── Sequence [SQ Squad Role Is: Flanker, SQ Has Not Flanked] SQ Flank, SQ Fire From Cover │ │ └── Sequence SQ Take Cover, SQ Fire From Cover ├── Sequence [SQ Alert State Is: Suspicious, abort Both] SQ Investigate └── SQ Patrol ``` Squads, attack tokens, callouts, suppression, profiles and orders all work the same under a Behavior Tree: they live on the controller and the subsystems, not in the tree. ## EQS **SQ Cover Spots** is an EQS generator: the Squadcraft cover spots round the querier, free or its own, optionally only those that hide from its combat target and that it can fire from. Score and filter them with the usual EQS tests (distance, dot, trace, pathfinding), then move there with Move To. Cover found this way is not claimed, so two AIs can pick the same spot: to hold one against squad mates, use SQ Take Cover. Next: back to [Getting started](1-getting-started.html).