Just thought I'd run up a quick tutorial on how to mod the AI scripts.
First up, go download notepad++. Seriously, just make life easy on yourself. open it up, set the language to XML, and then in a new file copy and paste the following code:
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<AIStrategyList
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../Schema/AIStrategyDefs.xsd">
<AIStrategy>
<InternalName>Diplomatic_Strategy_General</InternalName>
<TurnStart>100</TurnStart>
<TurnLifetime>15</TurnLifetime>
<PlayerAtWar>NoWar</PlayerAtWar>
<PersonalityTraits>Diplomatic</PersonalityTraits>
<Spending>BreakEven</Spending>
<SpendUntilBrokeBuffer>1000</SpendUntilBrokeBuffer>
<WealthSlider>0.10</WealthSlider>
<ManufacturingSlider>0.30</ManufacturingSlider>
<ResearchSlider>0.60</ResearchSlider>
<MilitarySlider>0.70</MilitarySlider>
<StarbaseDefenderFillCap>0.4</StarbaseDefenderFillCap>
<ShipyardDefenderFillCap>0.4</ShipyardDefenderFillCap>
<PlanetDefenderFillCap>1</PlanetDefenderFillCap>
<PreferToRush>Manufacturing</PreferToRush>
<BuildShip>
<ShipClass>Colony</ShipClass>
<BuildFirst>2</BuildFirst>
<Weight>30</Weight>
</BuildShip>
<BuildShip>
<ShipClass>Constructor</ShipClass>
<Weight>15</Weight>
</BuildShip>
<BuildShip>
<ShipClass>Defender</ShipClass>
<MaintenanceCreditPerTurnMultipleBuffer>1</MaintenanceCreditPerTurnMultipleBuffer>
<Weight>8</Weight>
</BuildShip>
<BuildShip>
<ShipClass>Freighter</ShipClass>
<Weight>12</Weight>
</BuildShip>
<BuildShip>
<ShipClass>Escort</ShipClass>
<MaintenanceCreditPerTurnMultipleBuffer>1</MaintenanceCreditPerTurnMultipleBuffer>
<Weight>2</Weight>
</BuildShip>
<BuildShip>
<ShipClass>Assault</ShipClass>
<Weight>2</Weight>
</BuildShip>
<BuildShip>
<ShipClass>Sentinel</ShipClass>
<Weight>2</Weight>
</BuildShip>
<BuildShip>
<ShipClass>Transport</ShipClass>
<Weight>1</Weight>
</BuildShip>
<BuildShip>
<ShipClass>CapitalShip</ShipClass>
<MaintenanceCreditPerTurnMultipleBuffer>1</MaintenanceCreditPerTurnMultipleBuffer>
<Weight>1</Weight>
</BuildShip>
<TechWeightOffset>
<UseOffset>true</UseOffset>
<WeightOffset>
<Military>0</Military>
<Growth>4</Growth>
<Tech>4</Tech>
<Diplomacy>5</Diplomacy>
<Expansion>0</Expansion>
<Wealth>5</Wealth>
<Influence>5</Influence>
<Fortification>5</Fortification>
</WeightOffset>
</TechWeightOffset>
</AIStrategy>
</AIStrategyList>
We're going to go through this a bit at a time, so don't panic. There's a couple of things to be aware of - first, XML is case-sensitive, so copy capital letters EXACTLY. GC3 uses standard coding conventions for the most part, AndSoWritesLikeThis, with no spaces and marking the start of every new word with a capital letter. Second, spaces are a character. IF you leave a space at the end of a tag, it is a different tag from one with no spaces. Third, everything is basically a mass of nested scopes. A scope is when you have matching sets of brackets around things that are aspects of the same thing, so to describe a dog we'd have:
<dog>
<tail>1</tail>
<nose>1</nose>
<stupid>1<stupid>
</dog>
Finally, all lines MUST be in the correct order. You can't, for example, stick the tech weighting at the top of a strategy - or shift the economy settings to the bottom. The order required is outlined in the Schema, but for general purposes as long as you copy from the other stuff in AIStrategyDefs.xml then you should be OK. The game will flid out and give you a debug log if these are incorrect.
That's more or less it in terms of rules for XML. Everything else is just learning the vocab.
On to the files.
The blurb at the top tells the game that this should be appended to the AI strategy list:
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<AIStrategyList
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../Schema/AIStrategyDefs.xsd">
We don't want to touch that. Next up is the beginning of the individual strategy class:
Every new strategy you create MUST start with this, and end with </AIStrategy>. This tells the game that everything between this pair is a single strategy.
Below this, we have the internal name - every strategy must have a unique one. The strategy above is called Diplomatic_Strategy_General. Since it already exists, change it to 'Xenophobic_strategy_General':
<InternalName>Xenophobic_Strategy_General</InternalName>
Under that, we have the triggers:
<TurnStart>100</TurnStart>
<TurnLifetime>15</TurnLifetime>
<PlayerAtWar>NoWar</PlayerAtWar>
<PersonalityTraits>Diplomatic</PersonalityTraits>
This tells the AI that it can start using this strategy after turn 100, that it uses the strategy for 15 turns before checking for another, that it can only pick it if it's not at war, and that it's only valid for AIs that have the 'diplomatic' personality traits. Since we're coding for the Xenophobic AI, change the <PersonalityTraits> value to 'Xenophobic'. Everything else can be left as it is, though you might want to bring the turn lifetime down to 5 so the AI can change direction quicker:
<TurnStart>100</TurnStart>
<TurnLifetime>5</TurnLifetime>
<PlayerAtWar>NoWar</PlayerAtWar>
<PersonalityTraits>Xenophobic</PersonalityTraits>
You can also use <TurnEnd></TurnEnd> to tell the AI to stop using a strategy at a certain point. This MUST come after the TurnStart, but before the TurnLifetime.
After that comes the AI's economy settings:
<Spending>BreakEven</Spending>
<SpendUntilBrokeBuffer>1000</SpendUntilBrokeBuffer>
<WealthSlider>0.10</WealthSlider>
<ManufacturingSlider>0.30</ManufacturingSlider>
<ResearchSlider>0.60</ResearchSlider>
<MilitarySlider>0.70</MilitarySlider>
<Spending> tells the AI whether to spend all it's money, break even, or try to save up. It is generally better to put this on SpendUntilBroke.
<SpendUntilBrokeBuffer> is the point where the AI will switch to breaking even, in this case at 1000 credits.
Below that are the slider settings. Wealth, manufacturing and research should total at 1. So you might have 0.2 wealth, 0.5 manufacturing and 0.3 research. The AI will usually adjust the wheel toward wealth the moment it hits breakeven anyway, so wealth can pretty much be left at 0.
The military slider can be set to anything between 0 and 1. At 0, it spends 100% social manufacturing. At 1, it spends 100% military manufacturing.
So, baring the above in mind, a more reasonable set of economy settings might be:
<Spending>SpendUntilBroke</Spending>
<SpendUntilBrokeBuffer>200</SpendUntilBrokeBuffer>
<WealthSlider>0.0</WealthSlider>
<ManufacturingSlider>0.6</ManufacturingSlider>
<ResearchSlider>0.4</ResearchSlider>
<MilitarySlider>0.9</MilitarySlider>
This tells the AI to spend aggressively until it only has 200 cash left. Once it has 200 cash, it will raise only as much money as it needs to pay its maintenance costs, and splits the rest 60-40 between manufacturing and research. It spends 90% of it's manufacturing clout on units, and saves 10% for social production.
After that comes
<StarbaseDefenderFillCap>0.4</StarbaseDefenderFillCap>
<ShipyardDefenderFillCap>0.4</ShipyardDefenderFillCap>
<PlanetDefenderFillCap>1</PlanetDefenderFillCap>
This determines how many defenders the AI will station around starbases, shipyards and planets. It can more or less be left alone. After that, we have <PreferToRush>, which tells the AI what kind of improvements to rush-buy. Either Manufacturing or Research are the best settings here.
Then we come to the ship building list. The AI determines what to build by rolling a dice on a weighted table. So it may have 10 weight for a constructor, 10 weight for a frigate and 20 weight for a colony ship; it rolls a 40-sided dice, and on 1-10 builds a constructor, on 11-20 it builds a frigate and on 21-40 it builds a colony ship.
<BuildShip>
<ShipClass>Colony</ShipClass>
<BuildFirst>2</BuildFirst>
<Weight>30</Weight>
</BuildShip>
<Shipclass> is the AI ship class listed for a ship in ShipClassDefs.xml. <BuildFirst> is optional, and tells the AI to build x number of this before rolling on the table. <Weight> determines it's weight on the table. You can add or remove as many different classes to the table as you like; the AI will only build things available to it on this list for as long as the script is active. There's a good mixed bag there, but since this is a turn 100+ strategy, maybe we should dump the <BuildFirst> from the colony ship. It's up to you.
Finally, we have the Tech Weights:
<TechWeightOffset>
<UseOffset>true</UseOffset>
<WeightOffset>
<Military>0</Military>
<Growth>4</Growth>
<Tech>4</Tech>
<Diplomacy>5</Diplomacy>
<Expansion>0</Expansion>
<Wealth>5</Wealth>
<Influence>5</Influence>
<Fortification>5</Fortification>
</WeightOffset>
</TechWeightOffset>
<WeightOffset> and <TechWeightOffset> are class definitions - so everything in between them is part of the same thing, in this case the offset values for technology. <UseOffset> just tells the AI to apply the settings listed. Military, Growth, Tech, Diplomacy, Expansion, Wealth, Influence and Fortification are all characteristics of techs. Every faction has it's own set of preferred ones, and this applies an offset - it increases or decreases the number. The number is then compared to the values listed on the technologies, and the closer it is to a match, the higher the chance the AI will research that tech.
Then we just close </AIStrategy>, save the file as xenophobicstrat.xml, and make it into a mod. Go to the My Documents/My Games/GalCiv3/mods folder, and create a new folder called 'AImods'. Put the xenophobicstrat.xml file into this folder. Launch the game, activate mods, and then restart the game. Viola, your first added AI is now working.