AAI Programmable Vehicles

= AAI Programmable Vehicles =

Ways to use the mod
There are a lot of things that programmable vehicles can do with just a few clicks that can make it worth installing casually in a game. You can use the mod in a very simple way, or you can take programmable vehicles to the extreme and try and automate as much as you can using vehicles. Be aware that high numbers of automated vehicles can have a UPS costs and is not well suited to megabase scale.

Basic actions
To control units you must first craft an AI version of the vehicle then place it on the ground.

Press Y to access a unit remote control or path remote control.

With a unit remote control in-hand, click-drag a selection area to select units.

A selection can be saved with CTRL + 1, or any number from 1 to 9.

A selection can be loaded with CTRL + SHIFT + 1, or any number from 1 to 9.

(Note: If you have Space Exploration installed these keys will conflict with pinned locations so you should rebind one set.)

To give units a command, shift+click on on the ground while units are selected to make them go there. You also drag an area instead of click to distribute the units over the selected area.

If you send a command to empty ground the units will try to go there. If you click on another AI unit they will try to follow it. If you click on a player they will try to follow the player.

If multiple units are given a follow command then they will try to make a protective bubble and hold a specific angle instead of following with no preferred angle.

Units will usually try to use pathfinding to get to a target location. If that fails they try to drive straight until they hit something, then try pathfinding again.

Most units deal much less impact damage than vanilla (just enough so that a damage event is triggered so the code can switch modes). Tanks and the flame tumbler still do a lot of impact damage, so be careful when automating those inside bases.

With the path tool selected (Press Y twice) you can place waypoints on the selected path (it creates a new path if no path exists). Place 3 waypoints in a rough traingle outside the base to test this. Once the waypoints are created you can select them in the UI to edit them. Note that you can change a waypoint from a position to target another AI vehicle.

To assign a unit to a path, make sure that the desired path is always showing it's starting waypoint using the path options. Select a unit with the Unit Remote Controller tool, then give it a move order directly onto the path's starting waypoint. If there is another vehicle, depot, or player in the way that might interfere with the order to the path so starting waypoints in clear areas are more reliable.

Some basic uses cases
Where’s my car?: If you bound your car to control group 1 (with Ctrl+Shift+1) then pressing Ctrl+1 selects your car. Shift-click on yourself and it will drive to you, and follow you around.

Personal Driver: Maybe driving accurately in your base is just not your thing. Put a car in “AI On” mode and tell it where to go. It can drive you where you need to go, and you can focus on other things while being driven around.

Personal Delivery and trash collection: A path goes from you to a dropoff depot, then a pickup depot, and back to you. You can set your vehicle on the path to drop off any junk you gave it, then pick up supplies and deliver them to you.

Basic Attack Force: Get a group of chaingunners and mow down enemy bases.

Basic Attack Formation: Order a group of chaingunners on to your character location. They will form a protective circle around you. You can move towards enemy bases on foot or in your own vehicle while the other vehicles try to maintain the circle formation.

Extra game mechanics
No Man's Land: You and your enemies are restricted in where you can place new structures. Enemy worms and spawners can’t spawn in range of your structures. Likewise you can’t build turrets in range of enemy spawners or worms. Enemy biters are burrowed near spawners and disrupt the construction above them.

Car
The car is well suited as a personal transport vehicle if you don’t have access to the Flame Tumbler. A small group of cars can make a good rapid response force to hunt down small groups of biters that have bypassed defences and take them out before they reach anything important.

Tank
Tanks can make a powerful attack formation. Be careful which ammo they use, a 2nd ammo variant is added that doesn’t do penetration damage and accidental damage vehicles it shoots over. The area damage can compliment the damage from laser tanks and flame tanks.

Spidertron
Spidertrons are potentially the most powerful vehicles. They can walk over things so they are safer in bases than most other vehicles. They always move without pathfinding which is useful most of the time but can get stuck on lake edges.

Hauler
A basic utility vehicle designed for moving cargo. It can trigger inventory exchange with nearby vehicles like a vehicle depot. This lets it collect resources from miners and deliver them to depots, or collect fuel and ammo from depot and deliver them to attack formations.

Miner
Mines ores, harvests, trees, devours rocks. There are 5 tiers that improve mining speed, movement speed, cargo capacity, and other things. Although you can rely on miners exclusively for mining this is not necessary to do this just because you have the mod installed. Miners can be especially useful in situations where the target resources are remote and a long static supply line would be difficult to defend (especially with the Rampant AI mod) but some guard vehicles at the resources and a protective detail for the hauler would be less vulnerable. Miners are also useful to remove small resource deposits where it is not worth setting up a full train station.

Chaingunner
If you take a gun turret and stick some up-side-down transport belts to the button then you end up with something like the chaingunner. It is good for early game clearing of enemy bases. Late game a few can be useful to take out weaker enemies that are not worth wasting heavy weapons on.

Warden
An advanced utility vehicle. It has the same inventory transfer capability as the hauler, but where the hauler exells as a delivery vehicle, the warden is often best looking after a small group of vehicles or patrolling a base’s perimeter. The warden has a radar so having 1 with a remote attack force is useful to see where you are going. It can make a good ammo cache for nearby vehicles, so as other vehicles run low on ammo or fuel it can give them top-ups. It has a repair beam, so if there are repair packs in the inventory it can repair nearby vehicles or structures. A warden patrolling behind a wall can keep it repaired without needing construction robots. The warden’s weapon deals an AOE pulse on the target that slows enemies. The slow makes it difficult for biters to attack other vehicles before dying and can make a small group of vehicles much more survivable.

Flame Tank
The flame tank is a good front-liner. It has short range but very heavy armor and enough speed to stay at the front of a typical formation. The two ammo options are a flamethrower or flame jet. If using the flamethrower ammo be careful about other vehicles driving through the fire. The Flame tank is fireproof but most other vehicles are not.

Laser Tank
A heavy tank that doesn’t sacrifice too much speed. A powerful laser cannon deals massive damage. It is tougher and deals higher single target damage than a standard tank, but the AOE damage explosive rounds so a mix can still be useful.

Flame Tumbler
The flame tumbler is exceptionally fast and is built as a ramming vehicle. It is primarily designed to be controlled manually outside of a base where you can drive wildly and punch through obstacles with no worry of collateral damage. The flamethrower acts as a secondary weapon, with ramming being the primary weapon. The speed of the vehicle means that in most cases the flames land behind you, but that is useful in burning away any trail of biters following you. When used autonomously, the flame tumbler makes a great personal transport vehicle and it can drive through your base safely. Flame tumblers can be used in vehicle formations but are fragile compared to other front-line vehicles.

Ironclad
A heavy metal-plated boat armed with a long range mortar and a tank cannon. It has a weapon so it is not ideal for hauling cargo as it can't trigger inventory exchanges. Boats can't currently do pathfinding so they rely on careful order or paths.

Coming soon
There are other vehicles planned such as ships, thruster craft, and more unusual vehicles.

3rd party vehicles
There are lots of vehicles made by other mod makers that work with AAI Programmable Vehicles. Beware of overusing any vehicles from other mods that have multiple weapons or are overpowered. If the optimal vehicle formation doesn’t contain at least 3 vehicle types then try making sure you are limited to a more balanced set of options.

Vehicle AI State
You can deploy a vehicle by hand, or with the Vehicle Deployer structure. To have the vehicle be AI controlled, you must make an AI-enabled vehicle using the AI version of the vehicle recipe. When you deploy the vehicle by hand its starting AI setting depends on the player’s own mod setting for deploying vehicles. The default setting is “Auto”.

On: The vehicle will try to attack enemies if it has ammo. If given an order it will try to carry out that order. If a player enters the vehicle then the vehicle's AI stays in charge, the player is a passenger.

Auto: The vehicle behaves as though the AI is “On” as long as there is no player in the vehicle. If a player is in the vehicle then the player is in control and the vehicle behaves as though the AI were “Off”.

Off: The vehicle won’t respond to commands, or attack enemies. If already moving it will come to a stop. If a player enters the vehicle they will have complete control.

The AI needs to be off for a vehicle to be picked up. (This is because the AI puts a fake character in the vehicle and Factorio won’t let vehicles be mined while a character is inside.)

Unit Remote Controller
Press [Y] to grab a Unit remote controller.

Selection
With the Unit Remote Controller in hand, you can left-click-drag a selection box over ai-enabled vehicles. Selected vehicles are shown with a selection circle underneath them, and the selected units list is displayed on the left of your screen.

Each selected unit has its own row. You can remove a unit from the selection using the left-most button in the row.

=== Orders[/color][/font]

Assigning an order
With 1 or more units selected you can hold shift and left-click or left-click-drag to assign a movement order to selected units.

Move to position
If a single point was selected by shift-clicking then all vehicles will try to move to or near the selected point.

Distribute over an area
If the movement was assigned over an area (by shift-click-dragging) then the selected vehicles will be sent to various locations in the selected area.

Follow a player or vehicle
If a point movement order was given at the location of a player or AI vehicle, then selected vehicles will be assigned a follow command instead of a simple movement command.

If a single unit was given a follow command it will try and maintain a constant distance (around 4 tiles) but won’t be concerned with it’s angle relative to the follow target.

If multiple units were given a follow command then to avoid bumping in to each other they will try to make a circle formation around the target. Each vehicle will try to maintain a specific angle from the target and a distance based on the number of units in the circle. The radius of the follow circle depends on the number of units selected. If the same target is followed by 2 circles of different number of units, like 6 units and 18 units, then the 6 units circle will be inside the other 12. (You can make more elaborate directional unit formations using the unit control tower with AAI Programmable Structures.)

Path Remote Controller
Press [Y] twice to give you a path remote controller [img=item/path-remote-control].

With the path remote controller in hand a left-click places a new waypoint. The waypoint is added to the end of the currently selected path. If no paths have been created a new path will be made automatically.

If you have a specific waypoint selected and expanded, then a click will replace the current waypoint instead of adding to the end of the path.

Types of waypoint:
A Position waypoint is just a coordinate on a surface. It is static and won't move.

A Position beacon waypoint is locked to a Position beacon id. If you move a position beacon by removing the old one and making a new one with the same ID, then path will be updated too. This is useful for blueprinting roads and access points.

A Vehicle depot waypoint is locked to a vehicle depot id. If you remove a vehicle depot and place a new one with the same ID then the waypoint will target the new depot position.\nA Unit waypoint targets an AI vehicle. It acts like a short-range follow command that is completed when the target vehicle is in range. This is useful to set a hauler to get near a sequence of miners before returning to a depot.\nA Player waypoit targets a player with a follow command that is completed when the vehicle gets close. This can be useful to make a hauler act like a logistic bot, bringing you commonly used items and taking trash away.

Assigning units to paths
A unit can be assigned to a path in 3 ways:

1. If the path has the “Always show start-waypoint” option checked, then ordering a unit directly on the the middle of the start waypoint marker will assign the vehicle to the path (Note: if there is a vehicle of other entity at the same location it may be assigned a follow or more command instead of a path command).

2. If there is a path and waypoint signal set to a Vehicle Deployer, the unit will be assigned to that path.

3. You can use a unit controller to set a vehicle to a specific path and waypoint.

Control Groups
The default control groups are from 0 to 9.

To assign selected units to a control group 1 press [Ctrl+Shift+1].

To select them again press [Ctrl+1].

A unit can be part of multiple control groups.

The keybinds are configurable. The default keybinds for control group 1 are Ctrl + 1 get and Ctrl + Shift + 1 to set. If you are using Space Exploration the default keybinds will conflixt with the Space Exploration pinned views.

Unit ID
When a unit is selected the 2nd button from the left is the Unit-ID icon for that unit type, and the number next to it is the unit’s Unit ID.

Unit IDs are unique and unchanging. The first unit placed has a Unit ID of 1 and no other unit will ever be assigned to that ID even if the unit with ID 1 is destroyed or picked up. Unit IDs are not split by unit type or by surface, all units share the same pool of numbers. (Note: In PvP multiplayer each force has a unique list of Unit IDs).

Unit of Type ID
When a unit is selected the left-most button is the Unit-Of-Type icon for that unit type, and the number next to it is the unit’s Unit Of Type ID.

Every game surface has a list of living units of each type. Each unit type has its own list (cars, tanks, etc) and if you have multiple surfaces (e.g. multiple planets) then there will be seperate lists of cars/tanks for each one.

The oldest living unit of each type per-surface has the Unit Of Type ID of 1. The oldest unit of that type has an ID equal to the number of living units of that type on that surface. If a unit is destroyed or picked up then all unit type IDs are updated accordingly.

A unique unit can be identified using two signals: A: The signal type corresponding to the unit type. If the vehicle is an AI Car then the signal is the AI Car Signal (on the virtual signals page). The number that corresponds to this signal is the unit’s Unit Of Type ID. B: The Surface signal with a number corresponding to the surface index. If unspecified then surface 1 is assumed which is Nauvis (the game’s default surface). For example: Surface 1, AI Car Signal 5 means the 5th oldest living car on surface 1.

Unit Data
Unit data is a set of signals held in the unit’s memory like an internal constant combinator. When a unit is selected the 3rd from the left button allows you to view and edit a unit’s unit data.

Unit data can be used in a few ways:

Unit data is used as the settings for inventory transfer with hauler-type units and vehicle depots. (See Inventory Transfer page).

Arbitrary role assignment. Any signals that correspond to physical items will be used as part of inventory transfer settings, but virtual signals don’t have physical items and can be safely used to indicate other arbitrary things, such as role assignment, or other things to help you organise units. For example, let’s say you want some tanks to patrol a north border, and other tanks to patrol a southern border. You could mark all the north tanks with N = 1, and all the south tanks with S = 1. That way even if a tank is temporarily assigned to something else, like resupply, repair, or attack, they can return to their previous assignment based on whether they have an N or S signal.

Hand placement
Units that are placed by hand have some default unit data set automatically to help with basic vehicle automation, such as ammo and fuel values to help with inventory transfer requests.

Automated deployment
If you deploy a vehicle from a vehicle deployer it is deployed with only the signals from the vehicle deployer, or blank if you have not set any signals. The deployer has a built-in combinator that you can edit, or you can pass in signals from wires. Don’t confuse connecting wires to the deployer’s inventory and the deployer’s combinator. (See Vehicle Deployer for more details.)

If you have AAI Programmable Structures installed then unit data can be read and set remotely and autonomously by the unit data scanner and unit data control tower.

Inventory Transfer
Inventory transfer can transfer items at close range between a vehicle depot and a vehicle, or between a hauler-type vehicle and any type of vehicle.

Hauler type vehicles are generally restricted to vehicles that have no weapons, or their only weapon is not a damaging weapon. Examples include the AAI Hauler, and the AAI Warden.

When transfer happens between entities it is worth considering the priority hierarchy. Normal vehicles have top priority so they can push items to, or collect items from other entities. Haulers have Bottom priority, so they try to accommodate other entities. Vehicle depots have middle priority, so they can accommodate normal vehicles, but can push to or pull from haulers.

Transfers are managed via exchange data settings for vehicle depots, and unit data for units.

In general a positive unit data signal indicates that the entity wants or accepts items up to the specified value. A negative value means that the entity either allows the export of that item type or is actively trying to get rid of all the items of that type.

Example 1: Fuel & Ammo
In this example we will take fuel, ammo, and repair packs from a vehicle depot, and deliver it to combat vehicles on the front line. For this example we will use a Chaingunner as the combat vehicle, an AAI Warden as the delivery vehicle, and Processed fuel form AAI Industry as the fuel, but these could easily be replaced with a Car, AAI Hauler, and Solid fuel instead.

The Vehicle Depot has Processed fuel, Piercing rounds magazines, and repair packs in the inventory. In the Exhange data (top right of the structure) it has been given a Processed fuel signal of -1, and Piercing rounds magazine signal of -1, and Repair pack signal of -1, meaning that the depot wants to give away these items.

The AAI Warden is on a looping path from the depot, moves along the front line from east to west, then returns to the depot. The Warden's Unit Data hsa been modified with the additional signals of 1000 Processed fuel, 1000 Piercing rounds magazine, 100 repair packs, and a "[img=virtual-signal/signal-minimum-fuel] Minimum fuel(MJ)" signal of 800. When the warden approaches the depot the depot triggers an echange. The warden, like the hauler, is a support vehicle and has a lower exchange priority than the depot. The depot tries to give away the items, and the warden is accepting matching items, so itms are given to the warden until it has 1000 Processed fuel, 1000 Piercing rounds magazines, and 100 repair packs.

The warden moves the the front line. Chaingunners are there doing a loop from east to west, then west to east. The warden should pass close to all the chaingunners on the patrol as it moves from east to west. The warden is a support vehicle and can trigger inventroy transfers with the chaingunners.

The chaingunner unit data has the signals: 50 Piercing rounds magazines and 50 Processed fuel. The Chaingunner has a higher exhange priority than the warden, so it will take items intul it has 50 Piercing rounds magazines and 50 Processed fuel. The warden will give away all of the ammo if it can, but it won't give away every piece of fuel. The warden has the "[img=virtual-signal/signal-minimum-fuel] Minimum fuel(MJ)" signal, so it will always try to keep at least this fuel value in reserve and not give that away.

The Warden will also repair nearby chaingunners with repair packs. When it has reached the end of the combat line it will return to the depot and start the loop again.

Example 2: Iron Ore
An AAI Miner vehicle has a unit data signal of Iron ore set at -1. It is a normal type of vehicle with top priority so it is actively trying to export Iron ore to anything that will accept it.

If an AAI Hauler vehicle approaches the miner it can initiate an inventory transfer because it is a special hauler-type vehicle. If the hauler has no unit data settings nothing will happen because it is not configured to accept any item types. If the hauler has unit data settings of 5000 Iron ore then it will accept up to 5000 Iron ore from other vehicles and can collect ore from the miner.

If the hauler that collected the iron ore approaches a vehicle depot, then the vehicle depot can initiate an inventory transfer with the hauler based on the depot’s exchanged data. Vehicle depots have a higher transfer priority than haulers, so if the vehicle depot has a positive Iron ore signal then it can force the hauler to drop its ore. The higher the signal in the depot the more ore it will try to pull from the hauler. menu_vehicle_depot=[img=item/vehicle-depot] Vehicle Depot title_vehicle_depot=Vehicle Depot page_vehicle_depot_text_1=The Vehicle Depot can receive and provide materials to vehicles. The depot has a general wire connection that outputs the container contents. The top-right connection sets the depot transfer information (like unit data).

The depot has a higher transfer priority than a hauler, meaning the depot can push or pull items to a hauler that can accept those items or has those items to pull.

The depot has a lower transfer priority than other vehicles, meaning those vehicles can push or pull items to the depot, providing the depot is set to accept those items, or has those items to be pulled from.

Vehicle Deployer
The vehicle deployer allows you to deploy vehicles from an item version to an entity version. The vehicle is pushed out of the structure on a conveyor into the space in front, and that space needs to be empty of obstructions for the vehicle to be deployed. You can put transport belt overlapping the conveyor to move the deployed vehicle around even if it doesn’t have fuel.

If the deployed vehicle is an AI vehicle, it will be given unit data based on the any signals set on, or linked to a small built-in combinator on the bottom-right of the structure. If no signals are set the unit will have no unit data, and won’t perform inventory transfers. If a path and waypoint signal is defined then the unit will be assigned to that path (like a rally point).

The Vehicle deployer has 2 wire connection points. The main structure is the container, that outputs any items in the container. The bottom-right combinator connection is the unit data connection, you can set unit data there directly, or have the value bought in via external wires.

Position Beacon
A position beacon is just a location marker. You can use it to get the coordinates of a position, or use the position beacon as a waypoint or move-to target based on its Position beacon ID.