# Blueprints Everything Squadcraft does can be set, called, changed and listened to from Blueprint. No C++ needed, not even to add a command to the squad menu or to decide who is an enemy. ## Start from the ready-made Blueprints **Squadcraft Content / Blueprints** has five Blueprints that work as they are. Duplicate the ones you need into your project and change the copies (an update of the plugin would overwrite the originals). | Blueprint | What it is | |---|---| | `BP_SQEnemy` | An enemy rifleman: a Character run by `BP_SQEnemyController`, with a `SQHealthComponent` and a `Muzzle` component at the chest | | `BP_SQEnemyController` | Its controller: team 1, the Soldier profile, the default StateTree and the default abilities | | `BP_SQCompanion` | A squad mate for the player, the same body in blue | | `BP_SQCompanionController` | Team 0, and **Follow Player Index** 0: on possess it takes the first player as its commander and follows | | `BP_SQPlayerController` | A player controller with the squad command menu (the Tactical set). Hold Q, or press 1 to 9 | Drop `BP_SQEnemy` and `BP_SQCompanion` in a level with a Nav Mesh Bounds Volume, set your game mode's Player Controller Class to `BP_SQPlayerController` and press Play. The companions find you, the enemy fights the three of you, and Q gives orders. The bodies are a gray cylinder so you can see them before you have a mesh. To use your own character: 1. Open the copy of `BP_SQEnemy`, pick the **Mesh** component and set your skeletal mesh and Anim Blueprint. 2. Delete the **Body** cylinder. 3. Move the **Muzzle** component to the tip of the gun, or delete it and name a socket on your weapon mesh `Muzzle`. Shots start there. Your own character Blueprint works the same way: set its **AI Controller Class** to your copy of `BP_SQEnemyController`, **Auto Possess AI** to Placed in World or Spawned, and add a `SQHealthComponent` if it has no health of its own. ## Settings without code Most of what makes one enemy different from another is data: - **Profile** on the controller (a `SQEnemyProfile` data asset): aim, reactions, senses, nerve, ammo and pace. See [Profiles and difficulty](5-profiles-and-difficulty.html). - **Animation Set** and **Sound Set** on the controller: what it plays and says for each action. - **Combat Abilities** on the controller: the attacks it has. Swap one for a Blueprint child (below) to change it. - **Behavior** on the controller: the StateTree it runs. Duplicate `ST_Squadcraft` and edit it in the StateTree editor. - **Command Set** on the player's `SQ Command` component: which orders are in the menu, their order, labels, keys and icons. Per enemy placed in a level, actor tags on the pawn override the controller: `Squad:Alpha`, `Role:Flanker`, `Team:2`, `Profile:Veteran`, `Patrol:Route1`, `Commander:0`, `Animations:/Game/...`, `Sounds:/Game/...`. ## Calls Right-click in any graph and type **Squadcraft**. The main ones, all on the AI controller unless noted: | Call | What it does | |---|---| | Give Order, Give Flank Order | Follow, Hold, Move To, Attack, Suppress, Grenade, Take Cover, Regroup, Watch, Flank, Breach | | Set Commander | Joins a player's squad (None leaves it) | | Set Team Number, Set Squad | Changes side or squad at runtime, telling the senses and the squad | | Set Profile, Set Behavior | A new profile, or another StateTree from its start | | Grant Combat Ability | One more ability for the pawn, taken back on unpossess | | Set Boss Phase | Jumps to a boss phase, whatever the health | | May Open Fire, Get Awareness, Get Order, Get Activity, Get Current Cover | What it is doing and allowed to do | | Set Health, Set Max Health (`SQHealthComponent`) | Server only | | Add Manual Cover, Remove Cover, Request Cover In Bounds, Find Cover (`SQCoverSubsystem`) | Cover you place, and finding cover again after the level changes | | Report Shot, Report Danger | The player's shots suppress, a fire or a bomb is avoided | | Get Squadcraft Controller, Get Squad Settings, Get Cover Settings | Helpers | ## Hooks: change a decision Make a Blueprint child of `SQAIController` (or open your copy of `BP_SQEnemyController`), and under Functions > Override pick one of these. Each gets Squadcraft's own answer as an input, so you can keep it, adjust it or replace it: | Override | When it is asked | Example | |---|---|---| | **Is Hostile To** (Other, Hostile By Default) | For every actor it senses | Factions, a disguise, a truce until the alarm | | **May Open Fire** | Before each attack | Hold fire while a hostage is close. Call the parent for the fire rule | | **Score Cover** (Point, Default Score) | For each cover spot it weighs, lower is better | Prefer spots near a door, avoid one area | | **Modify Damage** (Victim, Damage, Hit) | Each hit it lands | Headshots, armour, difficulty | | **Get Muzzle Location** (Default Location) | Each shot | A weapon actor, a turret on a vehicle | Elsewhere: - `SQ Command` component, **Execute Command**: what a command does on the server. Call the parent for the built-in ones. - `SQSpawner`, **Get Spawn Location**: where each pawn of a wave appears. - `SQPatrolRoute`, **On Point Reached**: a pawn got to a point (play a look-around, check a radio). Is Hostile To is asked often. Keep it to a few nodes: compare tags or a variable, no loops over every actor. ## Events: react to what happens Bind these in the controller's Event Graph (Begin Play is early enough: the controller begins play before it possesses its pawn), or from anywhere that has the controller. | Event | On | Fires when | |---|---|---| | On Order Changed | AI controller | A new order, from the player, a squad leader or your own Give Order | | On Order Carried Out | AI controller | The order's own action is done: the grenade thrown, the room cleared | | On Activity Changed | AI controller | It goes from Patrol to Search, Cover, Flank, Orders... | | On Cover Changed | AI controller | It took a cover spot or gave it back | | On Shot Fired | AI controller | Every shot, from the muzzle to where it stopped | | On Damage Dealt | AI controller | Every hit it landed | | On Boss Phase Changed | AI controller | A new boss phase | | On Alert State Changed | Awareness (Get Awareness) | Unaware, Suspicious, Alert | | On Target Spotted, On Target Forgotten | Awareness | An enemy fully seen, or dropped from memory | | On Body Found | Awareness | It found a squad mate's body | | On Health Changed, On Death | `SQHealthComponent` | On the server and every client | | On Pawn Spawned, On Wave Started, On Wave Cleared | `SQSpawner` | Each pawn of a wave, each wave | | On Command Issued, On Menu Toggled, On Team Selected | `SQ Command` component | On the player's machine | | On Custom Command | `SQ Command` component | On the server, for your own commands (below) | | On Cover Generated | `SQCoverSubsystem` | A box of cover is done | The AI controller and its events live on the server. For something every player sees (a sound, a flash), use the Animation Set and Sound Set, which already play on every client, or a multicast event on your pawn. ## Your own commands 1. Open your command set (a copy of `DA_SQCommands_Tactical`) and add a command with **Type** Custom, a **Custom Name** (say `Distract`), a label and a key. 2. In your player controller, get the `SQ Command` component and bind **On Custom Command**. 3. The event gets the Custom Name, where the player aims, what is there, and the AIs of the selected team. Tell them what to do: Give Order, Set Behavior, play an animation. It runs on the server, so the same Blueprint works in multiplayer. ## Your own abilities Make a Blueprint child of a Squadcraft ability to change its numbers (damage, burst length, cooldown, range), then put it in the controller's **Combat Abilities** in place of the original. For a new attack, make a Blueprint child of `SQGameplayAbility`: 1. In Class Defaults, set its **Asset Tags** to the slot it fills: `Squadcraft.Ability.Fire` for the main attack, `.Melee`, `.Grenade`, `.Suppress`, `.SniperShot`. The StateTree calls abilities by these tags. 2. Implement **Event ActivateAbility**: aim with **Get Aim Target**, hit with **Deal Damage** (it goes through Modify Damage, the profile's scale and the damage sense), play with **Play Action Animation**, and finish with **End Ability**. 3. Add it to **Combat Abilities**. Next: back to [Getting started](1-getting-started.html), or [Debugging](4-debugging.html) when something does not do what you expect.