Repository navigation
Tutorial 6: AI Tagging

In this tutorial we'll learn about adding ai tags to different ai ships to control their behaviour.
In this tutorial we'll learn how to:
- Make a set of ships attack with Torpedoes
- Make a set of ships prefer to attack large ships over small ships.
A. Add the node preload-loadmultipleships.
Time: 5
Location: Hoth
x: 0
y: 0
z: 0
xRot: 0
yRot: 0
zRot: 0
type: gr75transport
allegiance: rebel
number: 4
shipsperline: 2
This will load four gr75transports
B. Now we need to load the player ship.
Time: 5
Location: Hoth
x: 0
y: 0
z: 1000
xRot: 0
yRot: 0
zRot: 0
type: xwing
allegiance: rebel
number: 4
shipsperline: 2
A. Open up the previous mission we made in tutorial 6
B. Add a new starteventseries node and then add a loadmultipleshipsonground node and join then together.

Note: We're using a loadmultipleshipsonground node not a preload-loadmultipleshipsonground node, because we want the ships to load during the mission not when the location is loaded.
C. Fill in the following details on the loadmultipleshipsonground node.
Time: 15
Location: Hoth x: 0 y: 0 z: -5000 xRot: 0 yRot: 0 zRot: 0 type: tiebomber
name: Beta
number: 4
ships per line: 2
laser color: green

This will now cause 4 Tie Bombers to load, 15 seconds after the mission starts, 100m above the ground, and 5000m from the centre on the x-axis.
Note: When we load multiple ships the game will automatically inumerate the name of the ship, i.e. if you call your ships Alpha, then the first ship will be called Alpha01, the second Alpha02, etc.
A. Change the name of the player ship from Alpha to Rogue01.

B. Change the name of the freighters from Alpha to Transport.

You can now save your mission and play it. The Tie Bombers will appear after 15 seconds, they will attack the player and the freighters with lasers.
A. Add an addaitagtosmallship node and connect it to the loadmultipleshipsonground.

B. We want to change the behaviour of the Tie Bombers so that they attack the freighters with torpedoes. So fill in the following details.
Time: 1
Location: Hoth
Name: Beta
Weapons: singletorpedo
Pattern: strafewithdraw
targeting: targetallpreferlarge

Note: It's important that we wait at least 1 second after loading ships in the scene before running a node that will affect those ships. Otherwise the ships may not have finished loading before we try to change their behaviour and will load with their default behaviour.
- singletorpedo means that the bombers will only use one torpedo at a time, if the ship runs out of torpedos or just doesn't have them it will default to lasers.
- strafewithdraw means that the bombers will fire at their target from a distance and then withdraw again when they get too close until they again reach the optimal distance to attack. This is the ideal attack method when attacking a large ship.
- targetallpreferlarge means that the bomber will select an enemy largeship (capital ship or freighter) as their target, and will only select smaller enemy ships when there are no more enemy largeships. If you want the bombers to attack a specific largeship (or smallship) you will need to use the setshiptarget node.
Note:* If we only wanted to affect one bomber we would set the name of the node to that particular bomber. We loaded 4 bombers and called them Alpha so we know that there will be four bombers with the names Alpha01, Alpha02, Alpha03, and Alpha04 in the scene.
Now we've created a mission where the aim is for the player to defend the four transports from the attack Tie Bombers. You can save it and play it or you may want to now add some dialogue, a mission briefing, and an ending to the mission.