by: “Wug”
[EDITOR: This tutorial is good for any version of Battlezone II, but the fixed AIP system is only available in 1.3pb3.]
If you were like me, and was completely lost how to do make or modify AIP files, this is for you!
AIPs control the basic functions of how the AI behaves - attack, defend and build. Until recently, there have been serious bugs that limited the AIPs' effectiveness. Thanks to GSH [Nathan Mates], pretty much all the known bugs have been fixed. Now, AIP scripting can help reduce the need for custom DLLs, or at least eliminate the need for DLLs to work around AIP problems.
Tools
To make AIP files, I recommend using the AIP Editor (http://www.leinensoft.com/bz2/aipeditor.htm), which helps simplify and streamline the scripting process. A text editor, like Notepad, is also needed, but for now, we'll do most of the stuff in the AIP Editor.
You will also probably need Pak Explorer (http://www.leinensoft.com/bz2/pakexplorer.htm) to extract AIP files from patch13.pak. It's always handy to have existing AIP files to use as a reference.
AIP files
In IA/MPI, there are 4 AIP sets - one for each AI and player race combo - designated "f
" for Scion and "i
" for ISDF. Each set has 6 files - ending in "0
", "1
", "3
", "a
", "l
" and "s
".
The file name format is:
<name of AIP set><AI race><player race><plan type>.aip
so the Stock 1.3 AIPs for ISDF AI vs. ISDF are: stock13ii0.aip
, stock13ii1.aip
, stock13ii3.aip
, stock13iia.aip
, stock13iil.aip
, stock13iis.aip
the "0
" file is used at the start of the game. It is used mostly to build and deploy scavengers. The AI switches to the next AIP file once the player has put down the recycler or 3 minutes have elapsed, whichever comes first.
"1
" and "3
" files are called next, with a 50/50 of being either one or the other. These two files are generally used to build the base, and execute early-game strategy.
The AI switches to "a
" when the player has around 5 to 8 assault units. Assault units on the ISDF side are the rocket tank, assault tank, walker and bomber, and mauler and titan on the Scion side.
"s
" is used when the AI base is under siege, where the player has an attacking unit within 200 meters of the AI's recycler for at least 45 seconds (this is from memory - don't quote me on this.)
l
", is used after the conditions for the assault and siege plans are no longer in effect. However, if the AI switched from either "1
" or "3
" to "s
", it will only switch to "a
", not "l
", and only when the conditions for "a
" are met.
My first AIP
There's nothing like hands-on experience, so let's dive right in and make a "hello world" AIP file. The first file to create is the "0
" AIP file. Let's make one for ISDF AI vs. ISDF; making the other three AIP sets (Scion AI vs. ISDF, Scion AI vs. Scion and ISDF AI vs. Scion) are pretty much a copy/paste and find/replace exercise.
Start by opening the AIP Editor. The left-hand pane lists the matching units, which we'll ignore for now. The right-hand pane is the "meat and potatoes", where you will spend most of your time.
Since the "0
" AIP file runs for only a short while, perhaps only a few seconds, it should not do too much - no base building, building attack units, etc. Pretty much build scavengers and maybe defenses.
Start by right-clicking in the right-hand pane and click "New". The "Plan Settings" box will appear. Under "Plan Type", select "CollectPool
"; give it a "Plan Priority" of, say, 10, and select "build units if necessary". Click "OK" to finish the plan. This plan will create a scavenger to go find an open scrap pool to take.
If "build units if necessary" (aka "buildIfNoIdle
") was *not* selected, the AI will wait for a scavenger to become available, rather than build a new one. Since we have none at the start, this would be a bad idea. Don't worry about the other options at this point - they're pretty much not used for "CollectPool
" plans anyway.
Filling out the AIP file
Well, that was easy, but we need more "stuff", so let's finish up the AIP file. Taking one scrap pool won't be enough, so we need to build more scavengers. Highlight the "CollectPool
" plan and do copy/paste (via edit menu or standard Windows hotkeys), say, 3 more times. Now we have 4 "CollectPool
" plans. On the top menu, click "Plan" and select "Auto-arrange Priorities", which will put the plans into a nice, orderly fashion. Now you should have plans numbered to 10 to 40.
Probably the AI won't get the chance to build even 4 scavengers before switching to either the "1
" or "3
" AIP file. But just in case, we can put in either more "CollectPool
" plans, or build a few defensive units, like Scouts or Turrets. Or build some units, and then build more scavengers. There are lots of choices. Save the file. Give it a name, and add "ii0
" to the end of it.
Completing the AIP file
Time to add the "extra stuff" and finish off the "0
" AIP file. To save time, here are the defaults used by the Stock 1.3 AIPs, which I recommend to use. In a text editor, copy this to the start of the file (remember to leave a blank line after the [IdleDispatcher] section. This can also be done from the AIP Editor, but it's faster this way. I don't recommend tampering with these values until later when you are in the fine-tuning phase.
[Start]
scrapCount = 40
consClass = "ivcons"
scavClass = "ivscav"
[IdleDispatcher]
ScavIdleSeconds = 25
UnitIdleSeconds = 120
MinAttackForce = 3
Now it's ready to test!
Turning on AIP logging
Before you test your AIPs, make sure you turn on AIP logging in two places. Add the /aiplogging parameter to your BZ2 game shortcut to enable ingame AIP logging. The more detailed option is to turn on the option for aip logging in the gameprefs.ini file in the Addon\Config folder. The files are written to the Logs folder, and you will probably need them to figure out what really happened.
Testing the AIP file
Maybe it's a bit premature, but let's see this puppy in action. Remember Pak Explorer that I mentioned in the Tools section? Well, we need it now. Extract the aipdesc.txt and aiplist.txt files from patch13.pak, and put them into the "addon
" folder. Add the name of your AIP set to the aiplist.txt, and give it a description in the aipdesc.txt.
Once that's done, you can start up a game in IA or MPI, and choose your AIP set on the options page in IA and third server options page in MPI. Since you only have the "0
" AIP file, you will have up to 3 minutes to see what the AI is doing, as long as don't deploy your recycler. The game won't crash afterwards, but it won't do anything either.
AIP structuring
All right, enough horsing around. Now it's time to get to the good stuff. I suggest writing the "1
" AIP file, but it doesn't really matter which file is done next. The "1
" file will serve as the template for the remaining AIP files.
Other than the "0
" file, I suggest that each of the AIP files be complete. At a minimum, each AIP file should be able to (re-) build the base from scratch, set up defenses and attack the player's base. This is because there is no guarantee which AIP file will be executing, say, when the player bombs the AI Factory.
The overall structure of the AIP file should be low scrap cost plans are put at the top, and build more expensive units and structures further down. This will prevent pre-requisite problems and unnecessary logic loops.
Early defenses
Head back into the AIP Editor. We'll need those scavengers, so save a copy of the "0
" file as the "1
" file.
The first thing to add after the "CollectPool
" plans is a "BuildMinimums
" for scouts, a "Hold
" plan for turrets, or both. This is to help protect the AI recycler early in the game.
Create a new plan. Put "BuildMinimums
" for Plan Type. Under Parameters, select "buildType
", then click the down-down list for Value, and choose the ISDF Units -> Vehicles -> Scout. Click Add. Then change "buildType
" to "buildCount
", then change the value to the number "3
", and click Add.
Now, the Plan Data box on the left should have: buildType - ivscout and buildCount - 3. This creates 3 Scouts from the Recycler. Also add a Plan Condition - choose "Team Computer has NOT" and choose ISDF Units -> Buildings -> Factory. This tells the AI to stop producing Scout once the Factory is available to produce more powerful units.
Click OK. The Scouts will hang around until they are assigned to attack or when the idle dispatcher sends them out. We'll discuss the idle dispatcher in detail later.
The "hold
" plan is done pretty much the same way, with "holdType
" being the ISDF Turret (ivturr). Usually, one turret is put at each defense point, but if you want more, add more "holdType
" parameters. Setting the "holdCount
" prevents the AI from endlessly sending Turrets each time one is destroyed. I recommend setting it to "1
", since you will need to switch to Gun Towers soon enough. Select "holdPoint
", and use the down-down list to choose Path Points -> Defense -> Hold 1. If you want to put a turret at the other defense points, create a "hold
" plan for each Hold 1 through 4.
Once you added new plans, click Plan -> Auto-arrange Priorities. This will re-number your plans into an orderly sequence. Remember to this after adding new plans.
Base build-up
After initial defenses are set, it's time to build the base. The buildings can be built in slightly different orders, but you must make sure the pre-requisite buildings are in place. The standard order is: Factory -> Relay Bunker -> Armory -> Service Bay -> Training Facility ->Technical Center -> Bombay Bay
Let's analyze the order. Factory should be the first to be built (or re-built), as it is so important. Usually, Relay Bunker comes next, as the Sabre, Rocket Tank and Assault Tank all require it. However, if you want to do a Mortar Bike rush, build the Armory second, as it is required. In either case, the Factory, Relay Bunker and Armory are usually the first three buildings, which allow most of the vehicles to be built, and Gun Towers and Rocket Tanks for defense.
Service bay usually comes next, so the Assault Tank and Service trucks can be built. After Service Bay, the last three structures cost over 60 scrap, so the AI must have at least two scrap pools before they can be built (and three, in the case of the Bomber Bay). The fastest way to build the Bomber Bay would be to skip the Service Bay and Technical Center, and build the Training Facility first. But there is no guarantee that the AI will control enough scrap pools to do this.
Gun Towers can be added anytime after the Relay Bunker is up. Putting up Gun Towers early in the game makes for a much stronger defense, but if the AI spends too much time and scrap on Gun Towers, the player might get a chance to build the Bombay Bay, and send the bomber to destroy the base. The ISDF also needs a Power Generator for every 3 buildings built, excluding the Power Generator itself. The Scion side is a bit simpler, and we'll discuss it later.
Before you can build base structures, create a "BuildMinimum
" plan to build two Constructors. The AI tends to have stalling problems with Constructors, so a second one is necessary to keep the base going.
Now, add a new "BuildBaseMinimum
" plan. Choose Parameter of "buildType
", Value of "Power Generator" and click Add. Then add the "buildCount
" with a Value of 1. Repeat the procedure to add the Factory, Relay Bunker and Armory. The Plan Data box on the left should now have a list of "buildType
" and "buildCount
" 1 through 4. Click OK. Don't forget to do Auto-arrange Priorities.
First attack wave
It's probably not a good idea to leave the player unmolested for too long. Now that you can build units from the Factory, it's probably a good time to send the Scouts out to pay the player a visit.
You can either add an "Attacker
" plan, or let the idle dispatcher send the units out. On default settings, the idle dispatcher waits for three units that have been idle for at least 2 minutes before sending them out. This may be a bit too quick, especially if you want to use the "Attacker
" plan to control what the Scouts attack, rather than have them attack randomly.
Let's not worry about idle dispatcher settings for now. So go ahead and add the "Attacker
" plan. First, decide what the AI should attack and assign it to "targetType
". You have a few choices - the player's constructor, power generators or extractors are probably a safe bet, but you can choose whatever you want. Remember, it's early in the game, so the big units and buildings are probably not available as targets.
You have to assign each Scout to "attackType
", so there should be three "attackType
" parameters after "targetType
". There are a few optional parameters, which you may wish to set - "maxAttacks
", "attackAnything
" and "buildIfNoIdle
". The "maxAttacks
" parameter is set to 3 by default. Since you probably don't want to waste any more scrap building Scouts, setting it to 1 is probably a good idea.
The "attackAnything
" parameter defaults to false, which means the Scouts would only attack if the "targetType
" is available. I generally set it to true, so the Scouts will randomly attack another target and not sit around doing nothing. The "build units if necessary" parameter defaults to 0; set it to 1 so it will build enough Scouts to attack. This may be necessary because even though you have already built three Scouts, there is no guarantee they are not busy fighting or have been destroyed.
Build more units!
Now that the player is a bit more pre-occupied, it's time to build more units to defend the base. From the Factory, you can now build the Missile Scout, Mortar Bike, Tank (Sabre) and Rocket Tank. Although Rocket Tanks can be build, they require 65 scrap, so the AI must control a second scrap pool to build them. It's a safer bet to build Sabres (at 55 scrap), since it's still early in the game.
Create a "BuildMinimum
" plan like the one used to build the Scouts earlier. Three units are considered the "sweet spot", but build more or less as you like. You probably want to put in a Plan Condition to check for the Service Bay (like above with the Factory), and add the parameter "maxTtlScrap
" with the value of 80. This will stop the plan from building Sabres when Assault Tanks (Bulldogs) can be built. Assume 2 scrap pools and keep building
---
>From this point forward, all the plans assume the AI controls two scrap pools (i.e. 80 scrap capacity). It's time to create a new "BuildBaseMinimum
" plan to build most of the remaining structures. Technically, Gun Towers could have been built before producing units from the Factory, but it may be risky to leave Constructors unprotected.
The building order I recommend is:
- Power Generator #2
- Gun Tower
- Service Bay
- Training Facility
- Power Generator #3
- Gun Tower #2
For Power Generator #2, put a "buildCount
" of 2, and Power Generator #3, put a "buildCount
" of 3. The "buildCount
" parameter states the total number of a particular unit or structure that the AI should have in the game, and not how many to build at one time. So to build the second Gun Tower, use a "buildCount
" of 2.
Attack wave #2 and beyond
Once the second Gun Tower is up, the base is good shape. Time to send out those Sabres to wreak some havoc. I'd probably go after the player's extractors, but again, choose whatever target you like. So create a new Attacker plan like you did for the Scouts.
Then start building your assault units - Assault Tanks (Bulldogs) and Rocket Tanks. The two units are very complimentary to each other, and are tougher to bring down as a team. A good mix would be two Bulldogs and one Rocket Tank. So create a new "BuildMinimum
" plan with "buildType
" of Assault Tank and "buildCount
" of 2, and "buildType
" of Rocket Tank and "buildCount
" of 1.
I recommend putting an "Attacker
" plan to attack the player's extractors with the three new units right away. You want to make sure the AI has a third extractor, so it has the necessary 100-scrap capacity. Unlike previous "Attacker
" plans, I recommend setting "maxAttacks
" to a higher value - probably 999, so that it effectively attacks indefinitely.
Assume 3 scrap pools
Now it's time to build the Tech Center and Bomber Bay. Although the Tech Center requires 80 scrap, it is required to build the Walker (Attila), which requires 100 scrap, so there's no point in building it early.
So the build is now:
- Bomber Bay
- Tech Center
- Power Generator #4
I recommend building the Bomber Bay before the Tech Center because of placement problems. If you build too many buildings before the Bombay Bay, there may not be enough room to build the Bombay Bay, especially on a small map. The fourth Power Generator is built to provide spare power in case a Power Generator is knocked out. Don't want the Gun Towers to stop working, now do we? ;)
Also, make sure to put a "BuildMinimum
" plan for the Bomber right after the "BuildBaseMinimum
", so the Bomber can be rebuilt after it is destroyed.
Attack with everything!
Now the base is complete, so build more units and attack! Since the Attila, Bulldog and Rocket Tank are roughly the same speed, they can be sent out as a group. While the Attila is powerful, its limited ammo and firing arc, makes it quite vulnerable. And with its high cost, it's probably best not to try to build too many.
Since you already have a previous "BuildMinimum
" plan with 2 Bulldogs and a Rocket Tank (and it's still in effect), the new "BuildMinimum
" plan has to include them in the "buildCount
". So if we are to build 3 more units - 1 Attila, 1 Bulldog and 1 Rocket Tank, the "buildCount
" would be 1 for Attila, 3 for Bulldogs and 2 for Rocket Tanks. Then add the "Attacker
" plan to use the three new units.
You can continue to add more "BuildMinimum
" and "Attacker
" plans, but be aware that it will take a long time before the AI will be able to even build and sustain 6 attacking units. You might also consider throwing in a convoy of APCs to attack deep into the player's base, just to keep him off balance.
For now, I recommend letting the idle dispatcher use the Bomber to attack, instead of using an "Attacker
" plan. Bomber attack plans tend to be too predictable and overly aggressive, which makes it ineffective and too costly (in terms of scrap) once the player catches on. The idle dispatcher randomly selects a nearby structure to attack, so it is quite effective and hard to defend against.
Copy and paste
Well, let's wrap things up. You should now have a basic, but functional AIP file. You can certainly add more gun towers and rocket tanks to strengthen the AI base defense. Or you could even forgo the gun towers and build units to attack sooner. How you tweak the AI's strategy is up to you.
You can now copy this file to create the "3
", "a
", "l
" and "s
" files for the ISDF AI vs. ISDF. It's basically the same procedure to create the remaining 3 AIP file groups, just changing the ISDF specific items to Scion as necessary.
Next issue, we'll analyze the Scion side of things, and discuss how to tweak the different AIP files for their specific roles.♠
Wug is the creator of the new AIP sets that are found in the new 1.3pb3 patch. He introduced Easy to Insane AIPs to keep players on their toes. His new AIPs are available for both Instant Action and Multiplayer player MPI matches.