db’s Twitter Digest for 2010-11-22 to 2010-11-28

Getting The Arma II AI To Takeoff And Land.

A10 Takeoff Arma II AI

How To Get AI Pilots to Use The Airport.

A while back I was chatting with a reader of this blog (Robert) about AI pilots and how to get them to take off and land from the airports. Robert suggested other people may be interested and that I should write up a post. So I did.

In this post I’m going to take a look at fixed wing aircraft and how the AI uses them with the stock Arma II airports. Note that nothing in this post applies to helicopters, as the Arma 2 AI treats helicopters completely different than planes.

AI Taking Off From An Airport

Getting an AI piloted aircraft to take off from an airport is straight forward. All that is required is to insert an occupied aircraft near the taxiway. At the mission start the AI will taxi to the end of the runway and take off; no waypoint or scripting required.

Grishno air traffic patterns

Grishno Air Traffic Patterns

Each airport will have its own unchanging traffic pattern for taxiing, take off and landing. As an example, see the figure to the right for the traffic patterns of the Grishno airport in Chernarus. The only thing you as a mission builder have to be concerned with is the placement of the aircraft and any other units near the taxiway.  If you place the plane too far from the taxiway the plane may collide with buildings as the AI pilot tries to get to the taxiway. If there are any editor placed units too close to the taxiway the AI pilot will stop and start repeatedly until it taxies past the nearby unit. Ideally the AI should be placed on the taxiway faceing the same direction as the traffic pattern with no other units near the taxiway. Another alternative is to place the plane near the taxiway perbendicular to the trafic pattern. See figure below.

Aircraft Placement on Taxiway

Aircraft Placement on Taxiway

AI Landing At An Airport

Depending on what your mission requires, you have three options to get the AI to land a fixed wing aircraft at an Arma II Airport. The Get Out waypoint type, the landAt script command or the “land” action script command.

Get Out Waypoint Type

When a flying aircraft has a Get Out waypoint placed on the map, the AI will:

  1. land at the airport closest to the Get Out waypoint, following the airport’s air traffic pattern
  2. taxi the aircraft
  3. stop the aircraft on the taxiway
  4. stop the engines and disembark

landAt Script command

The landAt script command will cause the AI pilot to:

  1. fly towards the airfield specified by the landAt command
  2. land at the airport, following the airport’s air traffic pattern
  3. taxi the aircraft
  4. take off again.

Syntax for the landAt command is:

plane_name landAt airport_id

“land” Action Script command

The “land” Action script command will cause the AI pilot to:

  1. fly towards the nearest airfield
  2. land at the airport, following the airport’s air traffic pattern
  3. taxi the aircraft
  4. take off again.

Syntax for the “land” Action command is:

plane_name action ["Land", plane_name]

The two script commands could be used anywhere; inside a larger script, in a radio trigger, in a waypoint etc. so it’s a bit difficult to come up with an example of their uses. To keep things simple I’ve created an example mission where I inserted an A-10 and an F-35 near Grishno.

For the F-35 I set the following:
Name: my_f35
Special: Flying

For the F-35 I inserted a waypoint with
my_f35 action ["Land", my_f35]
in the On Act. field.

When I inserted the A-10 I set the following options:
Name:
my_a10
Special:
Flying

For the A-10 I inserted a waypoint with
mya10 landAt 0
in the On Act. field. (0 is the airport ID of the Grishno airport)

When I preview the example mission the F-35 finds the nearest airport (Grishno), lands, taxis and takes off again. The A-10 flies directly to Grishno, lands and takes off like the F-35. Grab the example mission below and try it out.

Reference

landAt command reference

action command reference

Example mission ai_landing.Chernarus

Adding Units & Equipment To A Custom Warfare Mission.

How to add playable units, AI and equipment to a Custom Warfare Mission.

AI_Manning_base_defenses

AI Manning Warfare Base Defenses

It is possible to add additional multi-player units and equipment and AI units to a custom built Warfare mission. For a simple mission usually all you have to do is insert the units into the mission editor and synchronize them to the Warfare Editor Module.

For this example I’m building on an existing mission and I’m assuming you already have a Warfare Editor Module inserted in your mission. (see How to Setup the Arma II Warfare Module. first)

Adding Multi-Player Units

To add playable units for Multi-player, in the Mission Editor select Units (F1) and double click to insert a unit. In my example I set the settings as follows:

Insert a Playable Unit for a Custom Arma2 Warfare Mission

Insert a Playable Unit for Multi-Player

Side: Blufor

Faction: USMC

Class: Men

Control: Playable

Unit: Rifleman

You can insert as many Playable units as the game engine will allow or your server can handle; I chose to insert 4 Blufor infantry units in my example.

Once you have the Blufor units inserted make sure that they are not grouped together (A light blue between the two). Arma has a feature that groups together units inserted near each other in the editor – you don’t want them grouped. If your units are grouped, first select Groups (F2), then click and hold your mouse button on one of the grouped units. Drag your mouse to an empty area of the map and release your mouse button. This will ungroup your Units.

To make the Warfare Module aware of your units in the mission, you will have to be synchronize them with the Warfare Module. Select Synchronize (F5), then click and hold your mouse button on your newly inserted unit. Drag your mouse to the Warfare Editor Module and let go of your mouse.

Warfare_unit_synchronized

Unit Synchronized to Warfare Module

Once you have inserted and synchronized all of your units you should have something that looks like the figure below. Note the top unit in the figure below is an unplayable AI unit, which will be used to patrol the Blufor base (see AI section below)

West Units Synchronized with Warfare Module

West Units Synchronized with Warfare Module

For my opposition I inserted Russian Infantry with the following settings:

Side: Opfor

Faction: Russia

Class: Men

Control: Playable

Unit: Rifleman

Once I had inserted a balanced set of Opfor units, I synchronized the Opfor Units to the Warfare Modual as I did with the Blufor units above.

Starting Equipment

It is possible to have additional starting equipment for your Warfare Mission. The Warfare module will handle the random placement of the unit at your base on mission start and respawn any equipment abandoned or destroyed on the battlefield.  Any empty equipment with a Side/faction associated with it (in my example the HMMWV [USMC]) can be used by the Warfare Module. To make the Warfare Module aware of the unit you will have to insert and synchronize the unit to the Warfare Module as I did with the Blufor Units above.

Equipment_warfare

Inserting Empty Equipment

Side: Empty

Class: Car

Unit: HMMWV [USMC]

Note that Empty will not be a valid option if there is no playable unit on the map.

For the Opfor in my example I inserted a couple of empty UAZ [Russia], and synchronized them to the Warfare Module as well.

Making The AI Defend The Base

By default any AI inserted and synchronized to the Warfare Module will go off and try to capture cities. If you would like to designate a group to defend the base (something players wont want to do) it requires a bit of code in the AI units Initialization field. There are two types of defense options available; “DefendBase” and “PatrolBase”

DefendBase

The AI group will defend the base, buy units, and man any static defenses. To use this option place the following bit of script in the AI Unit’s Initialization field

Group this SetVariable["dedicatedMission","DefendBase"];

Or

PatrolBase

The AI group will patrol the base and buy units. It will not man static defenses. To use this option place the following bit of script in the AI Unit’s Initialization field

Group this SetVariable["dedicatedMission","PatrolBase"];

In my example I set the AI to DefendBase:

Warfare_AI_defend_base

AI Set to Defend The Base

Note that to use the defense script the AI must be set to Control: Non Playable.

Once all the Units are inserted and synchronized my Warfare Mission looks like this:

warfare_example

Warfare Units Example

Reference

Helmand Valley Custom Warfare Example v1.3.1

Creating Bunkers for Arma II Warfare City Defense.

How To Automatically Spawn Bunkers For City Defense.

ArmaII Warfare Module Camps

Warfare Module Camps

The Warfare module can spawn camps/bunkers to aid in city defense. Usable by both the Player and the AI, these bunkers will increase city capture time and allow for the building of additional defensive assets. (machine gun nests etc.).

I had mentioned how to create these camps/bunkers when I was talking about how to setup City Locations using the Warfare module (read this first) but I glossed over the details. So here are the details.

In Your Mission Editor.

Warfare Module City Loctions

City Loctions

I’m going to assume that you have built a mission with the Warfare module and setup a City Location like the figure to the right. If you have not, read
Cities with the Arma II Warfare Module first. To Create a camp/bunker to defend your city you will have to insert a Camp Location game logic and synchronize it to the city location.

Inserting A Camp Location Logic

To insert a Camp select Units (F1) in the mission editor and double click where you would like the Warfare module to spawn a camp/bunker. In my example I’m going to insert one north of my city.  In the Insert Unit dialog box change the following settings:

Side: Game Logic

Class: Locations

Unit: Camp

Azimut: Direction (Azimuth) you would like the Camp to face when spawned.

Your dialog box should look like the figure below. Click finish to insert the camp. (To give a bit more randomness to your Warfare mission you can also change the Probabilty of Presence and Placement Radius of the Camp Location Logic.)

Inserting a Warfare Camp Location.

Inserting a Warfare Camp Location.

Synchronize The Camp With The City

To tell the Warfare Module which city the camp belongs to you will need to synchronize the Camp Location Logic to your existing City Location Logic.

First make sure that your Camp and City Location Logics are not grouped together (A light blue between the two). Arma has a feature that groups together units inserted near each other in the editor – you don’t want them grouped. If your units are grouped, first select Groups (F2), then click and hold your mouse button on one of the Game Logics. Drag your mouse to an empty area of the map and release your mouse button. This will ungroup your Units.

To synchronize your Camp to your city select Synchronize (F5), then click and hold your mouse button on your Camp Location logic. Drag your mouse to the City Location Logic and let go of your mouse. You should have something that looks like the figure below.

Warfare Camp Locations

Warfare Camp Locations

If everything is setup correctly when you start your mission you should see a random camp spawn at you Camp Location Logic.

Random Warfare Bunker

Random Warfare Bunker

Reference

CustomWarfare_Example v1_2_1.villa_afgana

db’s Twitter Digest for 2010-10-11 to 2010-10-17