Modding AI Files
Moderators: wdolson, MOD_War-in-the-Pacific-Admirals-Edition
Modding AI Files
OK starting to see a few folks asking about modding or crating AI files so I will try to cover a few of the basics in this thread - there will be spoilers in here so dont look if you dont want to know.
Andy
Andy
RE: Modding AI Files
Lets start with the basics.
the AI instructions are all contained in the aei00x file.
You must have at lease one aei00x.dat file even if its blank for a game to operate
You can only access the headline variant via the editor
So if I have one AI file
for a scenario it will be called
aei00x.dat
I have the option of adding up to 99 additional AI files for a total of 100 each additional file is called
aei00x-01.dat
aei00x-02.dat up to
aei00x-99.dat
In order to access them the easiest way is to have each additional scenario AI file set up as a seperate scenario and then rename the resulting AI file at the end - this also helps with control
So I am currently maintaining 13 AI options for the master scenario
So I have 13 Scenarios set up from Scen 30 - 42 each one I then take the resulting AI file and rename it manually to the appropriate variant.
Each variant has an equal chance of being selected when the game launches and will then be used through out that game
So you can have up to 100 different scripts per scenario and the AI will randomly pick one of them at game launch
At present the official scenarios have 13 to choose from which is about the limit of what I am personally able to support.
With me so far ?
Andy
the AI instructions are all contained in the aei00x file.
You must have at lease one aei00x.dat file even if its blank for a game to operate
You can only access the headline variant via the editor
So if I have one AI file
for a scenario it will be called
aei00x.dat
I have the option of adding up to 99 additional AI files for a total of 100 each additional file is called
aei00x-01.dat
aei00x-02.dat up to
aei00x-99.dat
In order to access them the easiest way is to have each additional scenario AI file set up as a seperate scenario and then rename the resulting AI file at the end - this also helps with control
So I am currently maintaining 13 AI options for the master scenario
So I have 13 Scenarios set up from Scen 30 - 42 each one I then take the resulting AI file and rename it manually to the appropriate variant.
Each variant has an equal chance of being selected when the game launches and will then be used through out that game
So you can have up to 100 different scripts per scenario and the AI will randomly pick one of them at game launch
At present the official scenarios have 13 to choose from which is about the limit of what I am personally able to support.
With me so far ?
Andy
RE: Modding AI Files
FROM THIS POINT ONWARDS THERE WILL BE SPOILERS
RE: Modding AI Files
OK the basics a simple defence script.
The purpose of these scripts is to move LCU's and Air Groups to bases to act as garrisons they are the most simple form of script and their job is to act as static defence

The purpose of these scripts is to move LCU's and Air Groups to bases to act as garrisons they are the most simple form of script and their job is to act as static defence

- Attachments
-
- AIDefence.jpg (195.59 KiB) Viewed 834 times
RE: Modding AI Files
The above script operates between 411210 and 420630 and it will try to move those units at all times within that date range
Of the other fields the most improtant is the stage base which is the default port the Ai will try to use if it needs to form TF's under this script so in this case Aukland
OK now lets look at the 5 tabs
Tab one is the list of base to attack as this is a defensive script its blank
Tab 2 is the list of units that will try to follow Tab 1
Tab 3 is the air group bases that air units will use - if a base is not on the list the AI WILL NOT USE IT
Tab 4 is the Air Units that will try to follow Tab 4
Tab 5 is the defensive units
For this explanation we will focus on Tabs 3 4 and 5
Andy
Of the other fields the most improtant is the stage base which is the default port the Ai will try to use if it needs to form TF's under this script so in this case Aukland
OK now lets look at the 5 tabs
Tab one is the list of base to attack as this is a defensive script its blank
Tab 2 is the list of units that will try to follow Tab 1
Tab 3 is the air group bases that air units will use - if a base is not on the list the AI WILL NOT USE IT
Tab 4 is the Air Units that will try to follow Tab 4
Tab 5 is the defensive units
For this explanation we will focus on Tabs 3 4 and 5
Andy
RE: Modding AI Files
Lets look at Tabs 3 and 4 as these are the important ones for this script Tab 3 says the Ai may only use 3 bases
Auckland
Noumou
Luganville
So any air units used under this script will try to go in sequence to those base in turn - it will not skip bases and it will not go there unless at least 1 Av Support is present and a minimum supply and AF level depending on the size and type of Sqn
Those limits are deliberately low to alow transiting sqns to use bases.
If the range is to far the AI will try to forma transport TF to move the air unit by sea.
This is not flexible the AI will follow the bases in sequence
Now if we look at Tab 4
OK that says that this script will try to deploy 6 Sqns
There are two settings in this tab
Setting one is the Sqn without a name of a base after it - if it is just listed in that way then the AI will send each sqn to each base as and when it can all the way to the end as long as its a live script
In this particular script each of the Sqns has an assigned base which means that the air units will stop moving when it reaches its assigned base so No.7 Sqn RNZAF will try to Nomou but will never go onto Luganville.
The blank 3038 is an ironman only sqn the AI will ignore that slot unless the Sqn is on map
So far so good ?
Auckland
Noumou
Luganville
So any air units used under this script will try to go in sequence to those base in turn - it will not skip bases and it will not go there unless at least 1 Av Support is present and a minimum supply and AF level depending on the size and type of Sqn
Those limits are deliberately low to alow transiting sqns to use bases.
If the range is to far the AI will try to forma transport TF to move the air unit by sea.
This is not flexible the AI will follow the bases in sequence
Now if we look at Tab 4
OK that says that this script will try to deploy 6 Sqns
There are two settings in this tab
Setting one is the Sqn without a name of a base after it - if it is just listed in that way then the AI will send each sqn to each base as and when it can all the way to the end as long as its a live script
In this particular script each of the Sqns has an assigned base which means that the air units will stop moving when it reaches its assigned base so No.7 Sqn RNZAF will try to Nomou but will never go onto Luganville.
The blank 3038 is an ironman only sqn the AI will ignore that slot unless the Sqn is on map
So far so good ?
RE: Modding AI Files
Tab 5 is the defensive unit tab - this one MUST have a bvase defined so what its saying is New Zealand Command must garrison Auckland
And thats all there is to it - this defensive AI script is basically just shuffling the pack and moving units about nothing to it
And thats all there is to it - this defensive AI script is basically just shuffling the pack and moving units about nothing to it
RE: Modding AI Files
OK now lets turn to a very basic attack script.
The script below is telling the AI to attack Hong Kong.
When it activates the AI will attack Hong Kong and keep trying untilt he end date passes.
This is th esimplest type of attack script a single base with basically 2 reinforced Divs and some air support from Canton.
The script remains active until such time as either the date passes or HK falls.
Limitations to be carefull of.
1. You the scripter have no way to specify that you must have force X in place and ready to enter the base before crossing the river.
2. The AI will attack until the base is taken or the date passes or the attack force is destroyed.
3. While units are assigned to this script they may not be hijacked for other duties so subsequent attack scripts with these units need to be set to activate after this one ends
Any questions ?

The script below is telling the AI to attack Hong Kong.
When it activates the AI will attack Hong Kong and keep trying untilt he end date passes.
This is th esimplest type of attack script a single base with basically 2 reinforced Divs and some air support from Canton.
The script remains active until such time as either the date passes or HK falls.
Limitations to be carefull of.
1. You the scripter have no way to specify that you must have force X in place and ready to enter the base before crossing the river.
2. The AI will attack until the base is taken or the date passes or the attack force is destroyed.
3. While units are assigned to this script they may not be hijacked for other duties so subsequent attack scripts with these units need to be set to activate after this one ends
Any questions ?

- Attachments
-
- AIAttack.jpg (134.52 KiB) Viewed 822 times
RE: Modding AI Files
p.s. there is a trick you can use to organise your forces for an invasion of a specifi hex I call them delay scripts but thats for next time I get a few hours to write al this stuff down
RE: Modding AI Files
So if I want the RTA to move in and take the Shan states starting in May of 1942 (historical) I simply need to set up the simple attack script to do so, and if I want them to stay and garrison with a smaller force while sending the attack units home will I need two separate scripts for the defense? (1 for shan states, 1 for thailand)
Distant Worlds Fan
'When in doubt...attack!'
'When in doubt...attack!'
RE: Modding AI Files
No thats a combined script you can use a combined attack/defence for the initial attack and then a seperate defend to send them home later.
You will also have to go through and remove all other calls on those units or other scripts may hijak them
You will also have to go through and remove all other calls on those units or other scripts may hijak them
RE: Modding AI Files
I've added more mines in my custom campaign to both sides, what do I need to do to get the AI to use them?
Is there a way to get the AI to setup defense with PT's boats at forward bases? PT/MTB's don't have a specific entry date like other ships.
Andy, thanks for Editor/AI how too's[;)]
Is there a way to get the AI to setup defense with PT's boats at forward bases? PT/MTB's don't have a specific entry date like other ships.
Andy, thanks for Editor/AI how too's[;)]
Basic Naval Scripts
OK this is basic naval Scripts 101
Pad adding more mines and the AI will just use them if you want it to specifically mine a location you can set up a script to do it I will explain shortly
OK below is a really basic AI Naval Script.
This script tells the japanese AI to form a TF at Takao (the advanced base is vital in naval scripts as thats the base the Ai wil use to form the TF)
So this script will only form TF if Takao is Japanese it wil try to form the TF if the base is japanese and the date has passed.
In this particular example the Ai is trying to form a LARGE TF now a large TF has a minimum requirement of 2 Cruisers and 2 Destroyers if those ships do not exist at Takao the TF will not form.
A LARGE SCTF has a max of 4 BB's, 4 CA's and 10 DD's.
I can specify via the editor the size of TF to form as a minimum - in this case the AI is under orders to form a LARGE MINIMUM TF
Accordingly it will form 2 Cruisers and 2 Destroyers as a minimum - had I set it to Normal it would have required more to form if LARGE it would not form without all the ships.

Pad adding more mines and the AI will just use them if you want it to specifically mine a location you can set up a script to do it I will explain shortly
OK below is a really basic AI Naval Script.
This script tells the japanese AI to form a TF at Takao (the advanced base is vital in naval scripts as thats the base the Ai wil use to form the TF)
So this script will only form TF if Takao is Japanese it wil try to form the TF if the base is japanese and the date has passed.
In this particular example the Ai is trying to form a LARGE TF now a large TF has a minimum requirement of 2 Cruisers and 2 Destroyers if those ships do not exist at Takao the TF will not form.
A LARGE SCTF has a max of 4 BB's, 4 CA's and 10 DD's.
I can specify via the editor the size of TF to form as a minimum - in this case the AI is under orders to form a LARGE MINIMUM TF
Accordingly it will form 2 Cruisers and 2 Destroyers as a minimum - had I set it to Normal it would have required more to form if LARGE it would not form without all the ships.

- Attachments
-
- Naval.jpg (126.68 KiB) Viewed 831 times
RE: Basic Naval Scripts
The TF is set to go to Vigan first as a destination and then patrol the three waypoints specified.
So this script will set that TF to patrol northern PI to keep off the pesky USN PT Boats
So this script will set that TF to patrol northern PI to keep off the pesky USN PT Boats
RE: Basic Naval Scripts
Now Pad if you wanted to set up a TF to patrol a forward base you can set up a PT Boat TF 3 6 and 9 are the min, norm and max for PT Boats
You would set a wide date range and a destination base of that hex.
The AI will try to form TYF's at largeports of its own accord
You can specify a specific ML TF as well in this way if you want to mine a specific base
A small or normal ML TF will use 1 ML a large adds an escort.
I tend to tell the AI to set up MSW TF's in support of later war US integrated scripts.
The scripts so far are very very simple.
When we get into multi layered integrated scripts like USN attack Marianas then it gets complicated !!!!
You would set a wide date range and a destination base of that hex.
The AI will try to form TYF's at largeports of its own accord
You can specify a specific ML TF as well in this way if you want to mine a specific base
A small or normal ML TF will use 1 ML a large adds an escort.
I tend to tell the AI to set up MSW TF's in support of later war US integrated scripts.
The scripts so far are very very simple.
When we get into multi layered integrated scripts like USN attack Marianas then it gets complicated !!!!
RE: Basic Naval Scripts
Andy, if you want an ASW patrol fleet to 'continuous patrol', that is to repeat the patrol on refuel at home base, need you make any changes to the above example? (other than changing the end date)
Example: Setting up the Japanese AI to always have some ships ASW patrolling the Sea of Japan until war's end.
Example: Setting up the Japanese AI to always have some ships ASW patrolling the Sea of Japan until war's end.
Distant Worlds Fan
'When in doubt...attack!'
'When in doubt...attack!'
RE: Basic Naval Scripts
Thats exactly how I do it for Grand Escort Command Scripts just be carefull when you start them if you set the up to early they suck all the escorts from Japanese opening
RE: Basic Naval Scripts
Bump in case anyone needs it
RE: Basic Naval Scripts
Thanks. REally appreciate some of the insight here and great appreciation for the amount of work to create the great AI.
Pax
RE: Basic Naval Scripts
Andy, where can i get hold of the modded scripts you have developed? Or was it a what if??
Thanks
Drew
Thanks
Drew
WitE2 - Alpha Tester/Beta Tester
Wite: 1.10 Beta Tester
Wite: Lost Battles Beta Tester
WitW - Beta Tester
Wite: 1.10 Beta Tester
Wite: Lost Battles Beta Tester
WitW - Beta Tester