# Squads and tactics ## Squads and roles Enemies with the same squad form a squad: the tag `Squad:Name` on the pawn, or **Squad Name** on the controller. An enemy with no squad is a squad of one. Each squad hands out roles as members join: | Role | What it does | |---|---| | Leader | Fights like Assault. The flanker goes round the side of the line from the enemy to the leader | | Assault | Takes cover near the enemy and fires aimed bursts | | Suppressor | Fires long loose bursts at where the enemy hides, to keep its head down | | Flanker | Runs to cover at the enemy's side, then fights from there | The first to join leads, then the squad keeps a mix of two assault to one suppressor and one flanker. Choose with the tag `Role:Flanker` on the pawn or **Preferred Role** on the controller. A member that asks to lead leads. When the leader dies, the next member leads. What one member sees, the whole squad knows within half a second. When an enemy goes Alert it also **calls for help**: every Squadcraft AI of the same team within 30 m learns where the enemy is, whatever its squad. ## Enemy types The controller's **Combat Style** picks the kind of fighter, and the default tree has a branch for each: | Style | How it fights | |---|---| | Ranged | Takes cover and shoots: rifleman, suppressor, flanker, by squad role | | Melee | Runs at the enemy and strikes | | Sniper | Sees to 70 m (Sniper Sight Radius on the controller), takes cover 25 to 60 m from the enemy, aims for a second with the telegraph tag and cue on (your laser), one 45 damage shot, two shots per spot (no attack token needed: the laser is the warning), then moves to another spot so the player can't pre-aim it. With no such cover left (the enemy came close) it takes its shots from where it stands | | Hybrid | A rifleman who drops the rifle fight when the enemy comes within 4 m and strikes, until it is 7 m off again | Per enemy placed in a level, the tag `Style:Sniper` (or `Melee`, `Hybrid`, `Ranged`) on the pawn picks the style, like `Squad:` and `Role:`. **Bosses** are any of these with **Boss Phases** on the controller: each phase is entered once health drops under its share (with `SQHealthComponent`), and can swap the profile, change the combat style, grant extra abilities and say a callout. On Boss Phase Changed tells your game, for music or a cutscene. A boss at 60% that turns Veteran and Hybrid is two phase fields. ## Friends in the line of fire An AI never fires through a squad mate, an ally or its commander. A shot with one of them between the muzzle and the target is held (the burst goes on, so the next shot goes once they step aside), and an AI about to lean out of cover with a friend in the way leaves that spot for 4 seconds and takes another. Shots that hit a friend anyway (a mate stepping in at the last moment) deal no damage. ## Attack tokens Only **2 AIs** fire aimed bursts at the same target at once, across every squad (Project Settings > Plugins > Squadcraft Squads > Max Attackers Per Target). The others stay in cover or suppress. This is what keeps a group of eight from shredding the player in a second. ## Awareness Each enemy has an awareness meter per target, from 0 to 1: - seeing fills it, fast up close (a quarter second) and slower at the edge of sight (about two seconds); - a noise adds to it by loudness (a gunshot is 1, which makes it suspicious); - a hit fills it at once. A **dead squad mate** in view makes its killer a suspect where the body lies (0.6, Body Suspicion): the AI goes to look, saying so ("body found"). Each AI reacts once to each body, for a minute after the death. From 0.3 the AI is **Suspicious** and goes to look. At 1 it is **Alert** and fights. It keeps what it knows for 10 s after the last sight, noise or hit, then calms down. All of this is on the controller's **Awareness** component. Report noise from your game with Report Noise Event (AI Perception). Squadcraft's own shots and grenades already do. ## The default behavior The controller runs the StateTree in **Behavior**, by default `ST_Squadcraft`: - **Evade**: out of a grenade's blast (any danger), whatever else it was doing. - **Patrol**: walks its patrol route, follows its leader on one, or walks to random points within Patrol Radius of where it started. Under orders it stays with its commander or at its spot. - **Search** (Suspicious): a squad splits up. The first member goes to the last known location, the others each to a different hiding spot (cover spot) within 12 m of it, and every one looks around there. Turn off Split Search on the SQ Investigate task to send them all to the same place. - **Combat** (Alert), the first branch that fits: - Retreat when health is below 35% (needs `SQHealthComponent`): once per fight, to cover far from the enemy, then it holds there; - Rush for enemies with Combat Style = Melee: run in and strike; - Fall Back when the suppression meter is full: cover further away, then think again; - Grenade when the target has hidden for 4 s between 6 and 25 m away, one per squad every 6 s. A round of fire from cover ends early when that comes up, so the grenade gets its turn; - Flank, once per fight, for the flanker; - Push when it has hidden for 3 s between 22 and 60 m: everyone but the suppressor moves up to nearer cover, jumping its own low wall when that is the way; - Fight: take cover, fire from it a few bursts (reloading between them when low, firing blind when pinned down), think again. Cover is picked against the main target and against the other enemies it knows: a spot one of them could see into scores worse. Open `ST_Squadcraft` in the StateTree editor to change any of it. Every Squadcraft task and condition is in the node list under Squadcraft, with its settings on the node. Copy the asset and point Behavior at your copy to make your own. ## Cover Cover is found on its own when play starts. It looks for walls next to the navmesh at crouch height (70 cm) and stand height (160 cm): a wall that blocks only the first is low cover (the AI crouches and fires over it), one that blocks both is high cover (the AI leans out round the side, where the wall ends). The work is spread over frames, 3 ms a frame by default (Generation Budget), so a big level does not hitch when play starts; queries meanwhile see what is found so far. If the navmesh is still building, it waits for it. Levels streamed in (level streaming or World Partition) get cover in their area, and lose it when they stream out, on their own. When the level changes in other ways (a wall falls, a car moves), call **Request Cover In Bounds** on the Squadcraft Cover subsystem with the box around it (over frames), or **Generate Cover In Bounds** to have it at once. Settings are in Project Settings > Plugins > Squadcraft Cover. Next: [Debugging](4-debugging.html).