AI Script Editor

Under Construction

1. How it works.
 
The ai uses a nation.nds file to work with. This is defined in Text\AI.txt and AI\AI.dat
The ai looks in an ai.xml which store's the data of what we want it to do.
 
Have a look first how the AI actually builds up by going to the map editor, load up any map with peasants on, select the colour of the ai, then press CTRL +E  and select the mAI Monitor.
Select an appropriate ai.xml file, eg france.ai.xml and press start.
You can monitor this way how it behaves.
 
Press CTRL + E, select Started AI script and load to access the ai.xml files itself. Open up the folder's and have a look at how they have been set - up
 
MenuStructure:  
 
Folders (E.G Use this to set difficulty settings)
+FolderCondition: leave blank for always
(or) add..
 *Upgrades:  
    -Upgrade is Run
 *Units:         
    -AmountOfReadyUnits
    -UnitsProduced
    -UnitsLost
 *EnemySpying:  
    -EnemyNearBase
 *Resources: 
   -CurResources
   -TotalResources
 *LivePlaces: 
    -FreeLivePlaces
    -TotalLivePlaces
    -LivePlacesUsed
 *Settlements: 
   -AmountOfSettlements
   -AmountOfEnemySettlements
 *Difficulty: 
   -Difficulty
 *Timing: 
   -GamingTime
   -OnceInPeriod
 
Inside this folder you can then define the triggers.
  Rules
  +Condition: again the same options as the folder, only these are for the trigger.
  +Action
    -Build
    -Produce
    -AddResources
    -GoDiversion
    -PeonsDistribution
    -SettlementsPriority
    -UpgradeSettlements
    -PerformUpgrade
    -BridgeConstruction
    -AutoUpRomeHero
    -BuyResource
 
Note: Each condition can have a 'sub condition'. You can use this to create and / or conditions.

 
2. Editing existing ai.xml files.
 
In Started Ai Script editor:
 
The first folder contains all the units the AI will recognize and is able to use. 
The second folder contains all the buildings the AI will recognize and is able to use.
The third folder are the actual triggers with what we want it to do. 
 
If you have added new units to a .nds file and you want the AI to use it, then add a new entry in the first folder by clicking on the grey entry bar and select the unit from the visual list, give it a short description name.
If you have added a new building to an .nds file and you want the AI to use it, then add a new entry in the second folder (buildings) by clicking on the grey entry bar and select the building from the visual list  and give it a short description name.
 
 

3. Creating new ai.xml files.
 
Define all units and buildings the AI can use in the 2 first folders. Direct them each time to the appropriate NDS file and give them a short description.
 
Then in the folder section. Give it a name and leave the condition default so it kicks off at start. In the actions set up which buildings you want the ai to build ( towncenter, mill,...), which units to produce, what upgrades to perform etc...
 
Save the new script in the Data\AI\ folder.
 
Go to the AI Router in the CTRL + E list. Add a new entry for your nation and link the AI to you new AI script.
 
Put peasants on the map and go to mAI Monitor in the CTRL +E list. Start up your new AI file and see how it works out.
 
You will also need to modify Data\AI\Ai.dat and Data\Text\AI.text