posted 04-27-13 06:11 AM EDT (US)   
The Beginners' Guide to AI scripting - Comprehensive Tutorial, Part 2

If you have not read part one, I would highly advise that you do, even if you count yourself experienced in coding:

http://aoe3.heavengames.com/cgi-bin/forums/display.cgi?action=st&fn=14&tn=38878&st=recent&f=14,38878,0,10

-----


Dear readers, I do now embark upon my second part of this AI guide. It is in my interests and the best interests of the community that I do so, and hopefully you can learn something from it. Never do I intend to offend; never to confuse; our aim is simple English and English is shall be.

Where shall we begin, you ask? We shall begin where we left off.


Never in the history of modding have we come this far. Yet we know nothing. Simply a paradox, eh? Some coders know more than others; some have more experience than others. To the ends, there are infinite numbers of improvements that could be made, and I suppose if we had time to put them all down, not even the whole world would have books enough for them. Our point here is to continue the work we began; to see our own possibilities in modifying the game's artificial intelligence. I do humbly present:


Comprehensive Beginners' Guide to AI modification, Part 2

In the past two years, I have learned a lot about what to do and what not to do, especially when it comes to coding. A mature coder understands that the simplest fixes are the best. Thus, I implore you to take upon the mask of humility, put on the coat drenched with rain, and huddle over to the coffee shop so that you and I may have a little talk together. In clear words, I invite you to spend time reading my guide instead of wasting hours of time trying to found things out on your own, for I could not bear to see you suffer as I once did - struggling for hours trying hard to understand. You are not without help or supporters; the community is your home, even if you have none at all.

----

Thus, we begin with our Techtree and Protoy in our backup folder. As a reminder, the "y" indicates that these are for The Asian Dynasties Expansion pack, thus including all of the units and techs regarding the Asian Dynasties.

I will begin by helping you a little. The first tech you will see in the techtree is this:


<TechTree version ='3'>
<Tech name ='Age0French' type ='Normal'>
<DBID>105</DBID>
<Status>UNOBTAINABLE</Status>
<Flag>Shadow</Flag>
<Effects>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>Explorer</Target></Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>TownCenter</Target></Effect>
<Effect type ='TechStatus' status ='active'>AAStandardStartingTechs</Effect>
<Effect type ='TechStatus' status ='obtainable'>RGVoltigeur</Effect>
<Effect type ='TechStatus' status ='obtainable'>RGGendarmes</Effect>
<Effect type ='TechStatus' status ='obtainable'>ChurchCodeNapoleon</Effect>
<Effect type ='TechStatus' status ='obtainable'>ChurchGardeImperial1</Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>Hussar</Target></Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>Sheep</Target></Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>House</Target></Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>Mill</Target></Effect>
<Effect type ='TechStatus' status ='obtainable'>VeteranMusketeers</Effect>
<Effect type ='TechStatus' status ='obtainable'>GuardMusketeers</Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>Musketeer</Target></Effect>
<Effect type ='TechStatus' status ='obtainable'>ChurchGardeImperial3</Effect>
<Effect type ='TechStatus' status ='obtainable'>ChurchGardeImperial2</Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>Coureur</Target></Effect>
<Effect type ='TechStatus' status ='obtainable'>GuardHalberdiers</Effect>
<Effect type ='TechStatus' status ='obtainable'>GuardDragoons</Effect>
<Effect type ='TechStatus' status ='obtainable'>VeteranPikemen</Effect>
<Effect type ='TechStatus' status ='obtainable'>ImperialHalberdiers</Effect>
<Effect type ='TechStatus' status ='obtainable'>ImperialGendarme</Effect>
<Effect type ='TechStatus' status ='obtainable'>ImperialVoltigeur</Effect>
<Effect type ='TechStatus' status ='obtainable'>ImperialMusketeers</Effect>
<Effect type ='TechStatus' status ='obtainable'>ImperialDragoons</Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>Capitol</Target></Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>Falconet</Target></Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>ArtilleryDepot</Target></Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>Stable</Target></Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>Barracks</Target></Effect>
<Effect type ='TechStatus' status ='obtainable'>VeteranCrossbowmen</Effect>
<Effect type ='TechStatus' status ='obtainable'>PoliticianGeneral</Effect>
<Effect type ='TechStatus' status ='obtainable'>PoliticianPresidente</Effect>
<Effect type ='TechStatus' status ='obtainable'>PoliticianMohawk</Effect>
<Effect type ='TechStatus' status ='obtainable'>PoliticianEngineer</Effect>
<Effect type ='TechStatus' status ='obtainable'>PoliticianMusketeerFrench</Effect>
<Effect type ='TechStatus' status ='obtainable'>PoliticianNaturalist</Effect>
<Effect type ='TechStatus' status ='obtainable'>PoliticianMarksman</Effect>
<Effect type ='TechStatus' status ='obtainable'>PoliticianQuartermaster</Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>Plantation</Target></Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>TradingPost</Target></Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>Outpost</Target></Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>Caravel</Target></Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>Dock</Target></Effect>
<Effect type ='TechStatus' status ='active'>XPTrickle</Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>Market</Target></Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>Arsenal</Target></Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>Skirmisher</Target></Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>CWallGate</Target></Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>LivestockPen</Target></Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>Church</Target></Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>WallStraight2</Target></Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>WallStraight5</Target></Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>WallConnector</Target></Effect>
<Effect type ='TechStatus' status ='obtainable'>UnlockPoliticianTycoonFrench</Effect>
<Effect type ='TechStatus' status ='obtainable'>UnlockPoliticianScoutFrench</Effect>
<Effect type ='TechStatus' status ='obtainable'>UnlockPoliticianPhilosopherPrinceFrench</Effect>
<Effect type ='TechStatus' status ='obtainable'>UnlockPoliticianGovernorFrench</Effect>
<Effect type ='TechStatus' status ='obtainable'>UnlockPoliticianExiledPrinceFrench</Effect>
<Effect type ='TechStatus' status ='obtainable'>UnlockPoliticianCavalierFrench</Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>Pikeman</Target></Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>Crossbowman</Target></Effect>
<Effect type ='TechStatus' status ='obtainable'>ImperialHussars</Effect>
<Effect type ='TechStatus' status ='obtainable'>GuardHussars</Effect>
<Effect type ='TechStatus' status ='obtainable'>VeteranHussars</Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>Halberdier</Target></Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>FieldHospital</Target></Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>Priest</Target></Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>Cuirassier</Target></Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>Culverin</Target></Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>Mortar</Target></Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>Dragoon</Target></Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>Monitor</Target></Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>Frigate</Target></Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>Galleon</Target></Effect>
<Effect type ='TechStatus' status ='obtainable'>Bayonet</Effect>
<Effect type ='TechStatus' status ='active'>Levy</Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>FishingBoat</Target></Effect>
<Effect type ='Data' action ='SpawnCannon' amount ='1.00' subtype ='ActionEnable' relativity ='Absolute'>
<Target type ='ProtoUnit'>Factory</Target></Effect>
<Effect type ='TechStatus' status ='obtainable'>ImperialCannon</Effect>
<Effect type ='TechStatus' status ='obtainable'>ImperialFieldGun</Effect>
<Effect type ='TechStatus' status ='obtainable'>FieldGun</Effect>
<Effect type ='TechStatus' status ='obtainable'>VeteranDragoonsShadow</Effect>
<Effect type ='TechStatus' status ='obtainable'>VeteranSkirmishersShadow</Effect>
<Effect type ='TechStatus' status ='obtainable'>ImperialMonitors</Effect>
<Effect type ='TechStatus' status ='obtainable'>ImperialManOWar</Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>Saloon</Target></Effect>
<Effect type ='TechStatus' status ='obtainable'>XPRevolutionLouverture</Effect>
<Effect type ='TechStatus' status ='obtainable'>XPRevolutionSantander</Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>xpPetard</Target></Effect>
<Effect type ='TechStatus' status ='obtainable'>ImperialHorseArtillery</Effect>
<Effect type ='TechStatus' status ='obtainable'>HeavyHorseArtillery</Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>xpHorseArtillery</Target></Effect>
<Effect type ='Data' amount ='1.00' subtype ='Enable' relativity ='Absolute'>
<Target type ='ProtoUnit'>xpSpy</Target></Effect>
<Effect type ='TechStatus' status ='obtainable'>ShipHowitzers</Effect>
</Effects>
</Tech>




Question: well sir, what does this mean? What tech is it?

Answer: This is the Discovery Age tech of the French civilization. The 'Age0French' tech enables every unit, politician and special tech for France, and also upgrades this:


<Effect type ='TechStatus' status ='active'>AAStandardStartingTechs</Effect>


Before you ask what the AAStandardStartingTechs are, I can explain: they are small things which every European civilization is enabled to have. The Native Americans civilizations and the Asian Civilizations also have their own "StandardStartingTechs," but we shall not get into that now.

However, as a note:

As a note all civilizations have something called an Age0Tech, which enables their specific units, politicians and techs. If you want in the future to add an upgrade to civilization or enable a unit for that civilization, you do that by adding it onto the end of the Age0Tech.

List of Age0Techs for all civilizations, in the order in which they appear in the Techtree (there are also some for the campaigns, but they are irrelevant at this moment):

Age0French (Tech DBID (number): 105)
Age0Russian (Tech DBID (number): 214)
Age0British (Tech DBID (number): 232)
Age0Dutch (Tech DBID (number): 233)
Age0German (Tech DBID (number): 235)
Age0Portuguese (Tech DBID (number): 236)
Age0Ottoman (Tech DBID (number): 238)
Age0Spanish (Tech DBID (number): 309)
Age0XPIroquois (Tech DBID (number): 2713)
Age0XPAztec (Tech DBID (number): 2750)
Age0XPSioux (Tech DBID (number): 2751)
ypAge0Japanese (Tech DBID (number): 3525)
ypAge0Chinese (Tech DBID (number): 3529)
ypAge0Indians (Tech DBID (number): 3530)


If you see a ypAge0IndiansSPC or anything with "SPC", note that this belongs to a Single Player Campaign. The same goes for units with SPC in front of their name.


------

AI coding: How to add techs, both for yourself and the AI

There are seven steps in getting the AI to research a new tech. They are

- Making the Tech in the techtree, enabling it at the Age0Tech, or by a 'Shadow' tech (such as those used for Veteran Skirmishers, Veteran Dragoons, which are in the techtree called 'VeteranSkirmishersShadow' and 'VeteranDragoonsShadow')

- Giving the Tech a name and description in the randommapstringsy file or stringtabley (the randommapstringsy is a file that simply adds strings to stringtabley, and stringtabley has all techs names and decriptions but their are no spaces between the lines of coding, making it look messy and hard to modify. In truth these two files are exactly the same type of thing).

- Making the AI build a building where you can research these new techs from

- Making a Research Monitor, with the tech plan to research, where it should be researched, and that the computer researches it if it is obtainable. Also tell the computer how often it should check in game seconds when it should attempt to research the tech, and if there are enough resources available to research the tech, etc.

- Also enable for specific civilizations

- Enabling the research monitor at a void-setup, in any case, the place in the AI coding which handles the enabling of techs for different ages.

- Putting a high priority on it, such as cEconomyEscrowID, 80); or cEconomyEscrowID, 99); where 99 is the highest priority.

- OPTIONAL: Lastly, an advisable thing, but not mandatory, a "researchplan" which tells the computer ahead of time to invest in resources enough before it ages or during its ageup to try and gather enough resources for that tech/building. For example, this can make the AI build another Town Center in Age 3.

------


Example:


<Tech name ='VeteranSkirmishersShadow' type ='Normal'>
<DBID>2663</DBID>
<ResearchPoints>0.0000</ResearchPoints>
<Status>UNOBTAINABLE</Status>
<Flag>Shadow</Flag>
<Prereqs>
<TechStatus status ='Active'>Fortressize</TechStatus></Prereqs>
<Effects>
<Effect type ='Data' amount ='1.20' subtype ='Hitpoints' relativity ='BasePercent'>
<Target type ='ProtoUnit'>Skirmisher</Target></Effect>
<Effect type ='SetName' proto ='Skirmisher' culture ='none' newName ='41752'></Effect>
<Effect type ='Data' amount ='0.00' subtype ='UpdateVisual' unittype ='Skirmisher' relativity ='Absolute'>
<Target type ='Player'></Target></Effect>
<Effect type ='Data' amount ='1.20' subtype ='Damage' allactions ='1' relativity ='BasePercent'>
<Target type ='ProtoUnit'>Skirmisher</Target></Effect>
</Effects>
</Tech>
<Tech name ='VeteranDragoonsShadow' type ='Normal'>
<DBID>2664</DBID>
<ResearchPoints>0.0000</ResearchPoints>
<Status>UNOBTAINABLE</Status>
<Flag>Shadow</Flag>
<Prereqs>
<TechStatus status ='Active'>Fortressize</TechStatus></Prereqs>
<Effects>
<Effect type ='Data' amount ='1.20' subtype ='Hitpoints' relativity ='BasePercent'>
<Target type ='ProtoUnit'>Dragoon</Target></Effect>
<Effect type ='SetName' proto ='Dragoon' culture ='none' newName ='41753'></Effect>
<Effect type ='Data' amount ='0.00' subtype ='UpdateVisual' unittype ='Dragoon' relativity ='Absolute'>
<Target type ='Player'></Target></Effect>
<Effect type ='Data' amount ='1.20' subtype ='Damage' allactions ='1' relativity ='BasePercent'>
<Target type ='ProtoUnit'>Dragoon</Target></Effect>
</Effects>
</Tech>



A 'shadow' tech in the games language means that it upgrades automatically when it is enabled; thus generally shadow techs are free. Some techs are enabled by the 'Fortressize' tech (a tech which everyone gets, but every civilization has their own specific Fortressize tech; such as 'FortressizePortuguese', etc.). There are also 'Colonialize', and separate 'ColonizializeBritish' techs, etc., and 'Industrialize', and 'IndustrializeDutch' techs, etc., and 'Imperialize', and ImperializeOttomans techs, etc. Note that these above techs have 0 research points.


A research point is one game second of the game.


Recall then this:

<TechTree version ='3'>
<Tech name ='Age0French' type ='Normal'>
<DBID>105</DBID>
<Status>UNOBTAINABLE</Status>
<Flag>Shadow</Flag>
<Effects>


Doesn't it seem familiar? When available, it 'upgrades' the French civilization for free, enabling you to play as France. In the same way, we can take a look at an upgradeable tech:


<Tech name ='FactorySteamPower' type ='Normal'>
<DBID>1077</DBID>
<DisplayNameID>29530</DisplayNameID>
<Cost resourcetype ='Food'>250.0000</Cost>
<Cost resourcetype ='Wood'>250.0000</Cost>
<ResearchPoints>30.0000</ResearchPoints>
<Status>UNOBTAINABLE</Status>
<Icon>ui\techs\steam_power\steam_power</Icon>
<RolloverTextID>29529</RolloverTextID>
<Flag>CountsTowardEconomicScore</Flag>
<Prereqs>
<TechStatus status ='Active'>Industrialize</TechStatus></Prereqs>
<Effects>
<Effect type ='Data' action ='AutoGatherCoin' amount ='1.30' subtype ='WorkRate' unittype ='Gold' relativity ='BasePercent'>
<Target type ='ProtoUnit'>Factory</Target></Effect></Effects>
</Tech>


This tech pertains to the 'Steam Power' upgrade at the Factory.



Here is an example of a Homecity Shipment:


<Tech name ='HCRidingSchoolGerman2' type ='Normal'>
<DBID>2641</DBID>
<DisplayNameID>37519</DisplayNameID>
<Cost resourcetype ='Ships'>1.0000</Cost>
<ResearchPoints>40.0000</ResearchPoints>
<Status>UNOBTAINABLE</Status>
<Icon>ui\techs\hc_spanish_riding_school\hc_spanish_riding_school</Icon>
<RolloverTextID>37518</RolloverTextID>
<Flag>HomeCity</Flag>
<Effects>
<Effect type ='Data' amount ='1.10' subtype ='MaximumVelocity' relativity ='BasePercent'>
<Target type ='ProtoUnit'>AbstractCavalry</Target></Effect>
<Effect type ='Data' amount ='4.00' subtype ='FreeHomeCityUnit' unittype ='Uhlan' relativity ='Absolute'>
<Target type ='Player'></Target></Effect>
<Effect type ='TextOutput'>41903</Effect>
</Effects>
</Tech>


This homecity shipment pertains to 'Spanish Riding School' for the German civilization.

Note that techs with the HomeCity CANNOT be upgraded at buildings; they can only be placed at the homecity. If you want to use a homecity tech as a regular tech, copy it and paste it at the end of your techtree, rename it something new, and remove the homecity flag.


------

Question: How do I add techs to the Protoy, to new/different buildings?

Answer: by adding the techs on techrows to buildings in the protoy.

***One word of advice: it is better to copy, then modify, rather than make a tech or unit from scratch. Never think that you have to write something from scratch if there is an available thing from the Techtree/Protoy/AI3 already available. Manipulate more than you make, and you will be a superb coder, and also save much more time.

As a side note, I have copied and pasted all my code onto here directly from the Techtree/Protoy/AI3. I have done more copying, then modifying than I have done original techs; in fact, I have never written a tech without copying and pasting an original one first.


------

But how do we do add techs to buildings?

We open the Protoy. If we see correctly, the first unit that appears should be this:


<Proto version ='11'>
<Unit id ='712' name ='xpIroquoisWarChief'>
<DBID>1091</DBID>
<DisplayNameID>43489</DisplayNameID>
<EditorNameID>43493</EditorNameID>
<ObstructionRadiusX>0.4900</ObstructionRadiusX>
<ObstructionRadiusZ>0.4900</ObstructionRadiusZ>
<FormationCategory>Mobile</FormationCategory>
<MaxVelocity>4.5000</MaxVelocity>
<MaxRunVelocity>6.5000</MaxRunVelocity>
<MovementType>land</MovementType>
<TurnRate>8.0000</TurnRate>
<AnimFile>units\natives\iroquois\war_chief\war_chief.xml</AnimFile>
<ImpactType>Flesh</ImpactType>
<Icon>ui\units\IRO_warchief_icon</Icon>
<MinimapIcon>ui\minimap\hero</MinimapIcon>
<PortraitIcon>ui\units\IRO_warchief_portrait</PortraitIcon>
<SelectionPriority>5</SelectionPriority>
<RolloverTextID>43488</RolloverTextID>
<ShortRolloverTextID>43487</ShortRolloverTextID>
<InitialHitpoints>500.0000</InitialHitpoints>
<MaxHitpoints>500.0000</MaxHitpoints>
<LOS>18.0000</LOS>
<ProjectileProtoUnit>InvisibleProjectile</ProjectileProtoUnit>
<AutoAttackRange>18.0000</AutoAttackRange>
<UnitAIType>RangedCombative</UnitAIType>
<TrainPoints>20.0000</TrainPoints>
<BuildLimit>1</BuildLimit>
<Bounty>100.0000</Bounty>
<Cost resourcetype ='Gold'>200.0000</Cost>
<AllowedAge>0</AllowedAge>
<Armor type ='Ranged' value ='0.1000'></Armor>
<UnitType>LogicalTypeHealed</UnitType>
<UnitType>LogicalTypeNeededForVictory</UnitType>
<UnitType>LogicalTypeHandUnitsAutoAttack</UnitType>
<UnitType>LogicalTypeLandMilitary</UnitType>
<UnitType>LogicalTypeScout</UnitType>
<UnitType>LogicalTypeValidSPCUnitsDeadCondition</UnitType>
<UnitType>LogicalTypeGarrisonInShips</UnitType>
<UnitType>LogicalTypeRangedUnitsAutoAttack</UnitType>
<UnitType>LogicalTypeVillagersAttack</UnitType>
<UnitType>LogicalTypeHandUnitsAttack</UnitType>
<UnitType>LogicalTypeRangedUnitsAttack</UnitType>
<UnitType>LogicalTypeMinimapFilterMilitary</UnitType>
<UnitType>ConvertsHerds</UnitType>
<UnitType>AbstractRangedInfantry</UnitType>
<UnitType>AbstractCanSeeStealth</UnitType>
<UnitType>Ranged</UnitType>
<UnitType>AbstractGunpowderTrooper</UnitType>
<UnitType>HasBountyValue</UnitType>
<UnitType>AbstractCavalryInfantry</UnitType>
<UnitType>AbstractInfantry</UnitType>
<UnitType>Hero</UnitType>
<UnitType>Unit</UnitType>
<UnitType>Military</UnitType>
<UnitType>UnitClass</UnitType>
<Train row ='0' page ='6' column ='1'>TradingPost</Train>
<Train row ='0' page ='6' column ='0'>TownCenter</Train>
<Train row ='0' page ='6' column ='3'>NatBlowgunAmbusher</Train>
<Train row ='0' page ='6' column ='4'>NatClubmanLoyal</Train>
<Train row ='0' page ='6' column ='2'>PetWolf</Train>
<Train row ='0' page ='6' column ='5'>PetCougar</Train>
<Flag>CollidesWithProjectiles</Flag>
<Flag>ApplyHandicapTraining</Flag>
<Flag>CorpseDecays</Flag>
<Flag>ShowGarrisonButton</Flag>
<Flag>DontRotateObstruction</Flag>
<Flag>ObscuredByUnits</Flag>
<Flag>HeroName2</Flag>
<Flag>RotateInPlace</Flag>
<Flag>NotDeleteable</Flag>
<Flag>ForceBuildingData</Flag>
<Flag>KnockoutDeath</Flag>
<Flag>Tracked</Flag>
<Command page ='10' column ='0'>Garrison</Command>
<Command page ='10' column ='2'>Stop</Command>
<Command page ='11' column ='0'>Abilities</Command>
<Tactics>xpwarchief.tactics</Tactics>
<ProtoAction>
<Name>Build</Name>
<Rate type ='TradingPost'>3.000000</Rate>
<Rate type ='TownCenter'>1.000000</Rate>
</ProtoAction>
<ProtoAction>
<Name>BuildingAttack</Name>
<Damage>15.000000</Damage>
<DamageType>Siege</DamageType>
<ROF>3.000000</ROF>
<DamageBonus type ='Building'>1.000000</DamageBonus>
</ProtoAction>
<ProtoAction>
<Name>CrackshotAttack</Name>
<Damage>75.000000</Damage>
<DamageType>Ranged</DamageType>
<MaxRange>16.000000</MaxRange>
<ROF>3.000000</ROF>
<DamageCap>150.000000</DamageCap>
<DamageBonus type ='Guardian'>0.250000</DamageBonus>
<DamageArea>3.000000</DamageArea>
<DamageFlags>GAIAEnemy</DamageFlags>
<DamageBonus type ='MercType2'>0.250000</DamageBonus>
</ProtoAction>
<ProtoAction>
<Name>HandAttack</Name>
<Damage>6.000000</Damage>
<DamageType>Hand</DamageType>
<ROF>1.500000</ROF>
<DamageBonus type ='Guardian'>3.000000</DamageBonus>
<DamageBonus type ='AbstractVillager'>0.250000</DamageBonus>
</ProtoAction>
<ProtoAction>
<Name>Heal</Name>
<Rate type ='LogicalTypeHealed'>50.000000</Rate>
</ProtoAction>
<ProtoAction>
<Name>VolleyRangedAttack</Name>
<DamageBonus type ='AbstractVillager'>0.250000</DamageBonus>
<Damage>12.000000</Damage>
<DamageType>Ranged</DamageType>
<MaxRange>16.000000</MaxRange>
<ROF>3.000000</ROF>
<DamageBonus type ='Guardian'>3.000000</DamageBonus>
</ProtoAction>
</Unit>


This is the Iroquois Warchief. The most important things here are:


<Train row ='0' page ='6' column ='1'>TradingPost</Train>
<Train row ='0' page ='6' column ='0'>TownCenter</Train>
<Train row ='0' page ='6' column ='3'>NatBlowgunAmbusher</Train>
<Train row ='0' page ='6' column ='4'>NatClubmanLoyal</Train>
<Train row ='0' page ='6' column ='2'>PetWolf</Train>
<Train row ='0' page ='6' column ='5'>PetCougar</Train>


Units thus are told to build buildings/units - this because they that use in the game, and also that they have constructing animations (building with a hammer). Buildings do not build other buildings. Only moving units can do that, for this pertains to the units art files. Art modification is not the point of this guide and we will not get into that now.


If we go down to a building, however, (this is a modified building):



<Unit id ='1487' name ='Observatory'>
<DBID>2168</DBID>
<DisplayNameID>200268</DisplayNameID>
<EditorNameID>200269</EditorNameID>
<ObstructionRadiusX>5.0000</ObstructionRadiusX>
<ObstructionRadiusZ>5.0000</ObstructionRadiusZ>
<MaxVelocity>0.0000</MaxVelocity>
<MovementType>land</MovementType>
<AnimFile>buildings\spc\ossuary\spc_ossuary.xml</AnimFile>
<ImpactType>Stone</ImpactType>
<PhysicsInfo>house</PhysicsInfo>
<Icon>buildings\spc\ossuary\spc_ossuary_icon_64x64</Icon>
<PortraitIcon>buildings\spc\ossuary\spc_ossuary_portrait</PortraitIcon>
<RolloverTextID>200270</RolloverTextID>
<ShortRolloverTextID>200271</ShortRolloverTextID>
<InitialHitpoints>5000.0000</InitialHitpoints>
<MaxHitpoints>5000.0000</MaxHitpoints>
<LOS>26.0000</LOS>
<BuildPoints>40.0000</BuildPoints>
<BuildLimit>1</BuildLimit>
<Bounty>320.0000</Bounty>
<BuildBounty>160.0000</BuildBounty>
<Cost resourcetype ='Wood'>400.0000</Cost>
<Cost resourcetype ='Gold'>400.0000</Cost>
<InitialResource resourcetype ='XP'>10.0000</InitialResource>
<AllowedAge>3</AllowedAge>
<Armor type ='Siege' value ='0.0000'></Armor>
<BuilderLimit>8</BuilderLimit>
<UnitType>LogicalTypeValidSabotage</UnitType>
<UnitType>LogicalTypeMinimapFilterEconomic</UnitType>
<UnitType>LogicalTypeHandUnitsAutoAttack</UnitType>
<UnitType>LogicalTypeBuildingsNotWalls</UnitType>
<UnitType>LogicalTypeRangedUnitsAutoAttack</UnitType>
<UnitType>LogicalTypeVillagersAttack</UnitType>
<UnitType>LogicalTypeHandUnitsAttack</UnitType>
<UnitType>LogicalTypeShipsAndBuildings</UnitType>
<UnitType>LogicalTypeRangedUnitsAttack</UnitType>
<UnitType>LogicalTypeBuildingsNotWallsOrGroves</UnitType>
<UnitType>LogicalTypeMinimapFilterMilitary</UnitType>
<UnitType>BuildingClass</UnitType>
<UnitType>MilitaryBuilding</UnitType>
<UnitType>ColonyBuilding</UnitType>
<UnitType>Building</UnitType>
<UnitType>ConvertsHerds</UnitType>
<UnitType>CountsTowardMilitaryScore</UnitType>
<UnitType>HasBountyValue</UnitType>
<Tech row ='0' page ='1' column ='0'>WealthOfNations</Tech>
<Tech row ='0' page ='1' column ='0'>DivisionOfLabour</Tech>
<Tech row ='0' page ='1' column ='0'>PackagedMeats</Tech>
<Tech row ='0' page ='1' column ='0'>ChurchfpGermanMeats</Tech>
<Tech row ='0' page ='1' column ='1'>Pasteurization</Tech>
<Tech row ='0' page ='1' column ='1'>TheJungle</Tech>
<Tech row ='0' page ='1' column ='2'>SpinningJenny</Tech>
<Tech row ='0' page ='1' column ='2'>MechanicalEngineering</Tech>
<Tech row ='0' page ='1' column ='3'>DailyNewspaper</Tech>
<Tech row ='0' page ='1' column ='3'>Nationalism</Tech>
<Tech row ='0' page ='1' column ='3'>Imperialism</Tech>
<Tech row ='0' page ='1' column ='4'>FrontierTerritory</Tech>
<Tech row ='0' page ='1' column ='4'>TheGreatPioneerWagonTrain</Tech>
<Tech row ='0' page ='1' column ='5'>HotAirBalloonTechnology</Tech>
<Tech row ='0' page ='1' column ='5'>AdvancedHotAirBalloonFrench</Tech>
<Tech row ='0' page ='1' column ='6'>TransContinentalRailroad</Tech>
<Tech row ='0' page ='1' column ='6'>LumberMillsEuropean</Tech>
<Tech row ='0' page ='1' column ='7'>ScoutCavalryEuropean</Tech>
<Tech row ='0' page ='1' column ='8'>BattlefieldSurveyors</Tech>
<Tech row ='0' page ='1' column ='9'>Dragooning</Tech>
<Tech row ='0' page ='1' column ='10'>Admirality</Tech>
<Tech row ='0' page ='1' column ='11'>PiratesOfTheBarbaryCoast</Tech>
<Tech row ='0' page ='1' column ='11'>TheRightsOfMan</Tech>
<Tech row ='0' page ='1' column ='11'>BritishImperialism</Tech>
<Tech row ='0' page ='1' column ='11'>RuleBritannia</Tech>
<Tech row ='0' page ='1' column ='12'>ExplosiveShells</Tech>
<Tech row ='0' page ='1' column ='12'>QuicklimeShells</Tech>
<Tech row ='0' page ='1' column ='13'>Fusils</Tech>
<Tech row ='0' page ='1' column ='13'>OttomanEgyptianMarket</Tech>
<Tech row ='0' page ='1' column ='13'>GreatElectorOfBrandenburg</Tech>
<Tech row ='0' page ='1' column ='14'>NativeFrenchAlliances</Tech>
<Tech row ='0' page ='1' column ='14'>Rifles</Tech>
<Tech row ='0' page ='1' column ='14'>OttomanBazaars</Tech>
<Tech row ='0' page ='1' column ='14'>DutchSpiceTrade</Tech>
<Tech row ='0' page ='1' column ='14'>DutchTeaTrade</Tech>
<Tech row ='0' page ='1' column ='14'>CanisterShot</Tech>
<Tech row ='0' page ='1' column ='14'>GatlingGuns</Tech>
<Tech row ='0' page ='1' column ='14'>GermanUniversities</Tech>
<Tech row ='0' page ='1' column ='15'>OttomanSpiceTrade</Tech>
<Tech row ='0' page ='1' column ='15'>OttomanCoffeeTrade</Tech>
<Tech row ='0' page ='1' column ='15'>OttomanTradeGuilds</Tech>
<Tech row ='0' page ='1' column ='15'>GermanExplorers</Tech>
<Tech row ='0' page ='1' column ='15'>IndustrialRevolutionRussian</Tech>
<Tech row ='0' page ='1' column ='15'>IronandCoalBusiness</Tech>
<Tech row ='0' page ='1' column ='15'>CottonPlantations</Tech>
<Tech row ='0' page ='1' column ='16'>BritishEastIndiaCompany</Tech>
<Tech row ='0' page ='1' column ='16'>SiberianFurTrade</Tech>
<Tech row ='0' page ='1' column ='16'>FishingFleets</Tech>
<Tech row ='0' page ='1' column ='16'>BrazilianWoodTrade</Tech>
<Tech row ='0' page ='1' column ='17'>SlaveTrade</Tech>
<Tech row ='0' page ='1' column ='17'>BritishHiredPrivateers</Tech>
<Tech row ='0' page ='1' column ='17'>SpanishGoldTrade</Tech>
<Tech row ='0' page ='1' column ='18'>AbolitionOfSlavery</Tech>
<Tech row ='0' page ='1' column ='18'>NaturalPhilosophy</Tech>
<Tech row ='0' page ='1' column ='18'>PublicSchooling</Tech>
<Tech row ='0' page ='1' column ='18'>SeparationofPowers</Tech>
<Tech row ='0' page ='1' column ='18'>NizamECeditLineInfantry</Tech>
<Tech row ='0' page ='255' column ='2'>ComputerObservatoryTechs1</Tech>
<Flag>UnlimitedSupply</Flag>
<Flag>CollidesWithProjectiles</Flag>
<Flag>StartsAtFullEfficiency</Flag>
<Flag>Immoveable</Flag>
<Flag>NoBloodOnDeath</Flag>
<Flag>ObscuresUnits</Flag>
<Flag>NoIdleActions</Flag>
<Flag>NonAutoFormedUnit</Flag>
<Flag>Doppled</Flag>
<Flag>SelectWithObstruction</Flag>
<Flag>PaintTextureWhenPlacing</Flag>
<Flag>FlattenGround</Flag>
<Flag>HasGatherPoint</Flag>
<Flag>Tracked</Flag>
<Command page ='10' column ='0'>Delete</Command>
<Tactics>autogatherer.tactics</Tactics>
<ProtoAction>
<Name>Autogather</Name>
<Rate type ='XP'>0.400000</Rate>
</ProtoAction>
</Unit>


Basically what I wanted to get through to you is that you add techs to the buildings in the Tech row =... Tech, etc; You should place your techs inbetween UnitTypes and Flags. Like so, for instance:


<UnitType>HasBountyValue</UnitType>
<Tech row ='0' page ='1' column ='0'>WealthOfNations</Tech>
<Tech row ='0' page ='1' column ='2'>SpinningJenny</Tech>
<Flag>UnlimitedSupply</Flag>


------

But how do I train units from buildings?

Let me take from the European 'Barracks' building:


<Unit id ='296' name ='Barracks'>
<DBID>18</DBID>
<DisplayNameID>22847</DisplayNameID>
<ObstructionRadiusX>4.0000</ObstructionRadiusX>
<ObstructionRadiusZ>4.0000</ObstructionRadiusZ>
<MaxVelocity>0.0000</MaxVelocity>
<MovementType>land</MovementType>
<AnimFile>buildings\barracks\barracks.xml</AnimFile>
<DeadReplacement>BuildingRubble4x4</DeadReplacement>
<DeadReplacementLifespan>15</DeadReplacementLifespan>
<ImpactType>Wood</ImpactType>
<PhysicsInfo>barracks</PhysicsInfo>
<PlacementFile>buildinglarge.xml</PlacementFile>
<Icon>buildings\barracks\barracks_icon</Icon>
<PortraitIcon>buildings\barracks\barracks_portraits</PortraitIcon>
<RolloverTextID>22846</RolloverTextID>
<ShortRolloverTextID>25610</ShortRolloverTextID>
<InitialHitpoints>2500.0000</InitialHitpoints>
<MaxHitpoints>2500.0000</MaxHitpoints>
<LOS>12.0000</LOS>
<BuildPoints>30.0000</BuildPoints>
<Bounty>40.0000</Bounty>
<BuildBounty>20.0000</BuildBounty>
<Cost resourcetype ='Food'>0.0000</Cost>
<Cost resourcetype ='Wood'>200.0000</Cost>
<BuildingWorkRate>1.0000</BuildingWorkRate>
<AllowedAge>1</AllowedAge>
<Armor type ='Siege' value ='0.0000'></Armor>
<BuilderLimit>8</BuilderLimit>
<UnitType>LogicalTypeValidSabotage</UnitType>
<UnitType>LogicalTypeHandUnitsAutoAttack</UnitType>
<UnitType>LogicalTypeBuildingsNotWalls</UnitType>
<UnitType>LogicalTypeRangedUnitsAutoAttack</UnitType>
<UnitType>LogicalTypeVillagersAttack</UnitType>
<UnitType>LogicalTypeHandUnitsAttack</UnitType>
<UnitType>LogicalTypeShipsAndBuildings</UnitType>
<UnitType>LogicalTypeRangedUnitsAttack</UnitType>
<UnitType>LogicalTypeBuildingsNotWallsOrGroves</UnitType>
<UnitType>LogicalTypeMinimapFilterMilitary</UnitType>
<UnitType>Building</UnitType>
<UnitType>MilitaryBuilding</UnitType>
<UnitType>BuildingClass</UnitType>
<UnitType>ConvertsHerds</UnitType>
<UnitType>AbstractBarracks2</UnitType>
<UnitType>CountsTowardMilitaryScore</UnitType>
<UnitType>HasBountyValue</UnitType>
<Train row ='0' page ='0' column ='0'>Crossbowman</Train>
<Train row ='0' page ='0' column ='0'>Longbowman</Train>
<Train row ='0' page ='0' column ='4'>Musketeer</Train>
<Train row ='0' page ='0' column ='4'>Janissary</Train>
<Train row ='0' page ='0' column ='5'>Cacadore</Train>
<Train row ='0' page ='0' column ='5'>Skirmisher</Train>
<Train row ='0' page ='0' column ='1'>Pikeman</Train>
<Train row ='0' page ='0' column ='2'>Halberdier</Train>
<Train row ='0' page ='0' column ='2'>Rodelero</Train>
<Train row ='0' page ='0' column ='2'>Dopplesoldner</Train>
<Train row ='0' page ='0' column ='2'>Boneguard</Train>
<Train row ='0' page ='0' column ='2'>BoneguardAge2</Train>
<Tech row ='0' page ='1' column ='2'>ImperialNassauers</Tech>
<Tech row ='0' page ='1' column ='4'>ImperialRedcoat</Tech>
<Tech row ='0' page ='1' column ='4'>GuardMusketeers</Tech>
<Tech row ='0' page ='1' column ='0'>GuardLongbowmen</Tech>
<Tech row ='0' page ='1' column ='2'>VeteranDopplesoldners</Tech>
<Tech row ='0' page ='1' column ='4'>VeteranJanissaries</Tech>
<Tech row ='0' page ='1' column ='2'>VeteranRodeleros</Tech>
<Tech row ='0' page ='1' column ='1'>VeteranPikemen</Tech>
<Tech row ='0' page ='1' column ='2'>GuardHalberdiers</Tech>
<Tech row ='0' page ='1' column ='2'>ImperialEspada</Tech>
<Tech row ='0' page ='1' column ='4'>VeteranMusketeers</Tech>
<Tech row ='0' page ='1' column ='5'>ImperialNeedleGun</Tech>
<Tech row ='0' page ='1' column ='5'>GuardSkirmishers</Tech>
<Tech row ='0' page ='1' column ='0'>VeteranCrossbowmen</Tech>
<Tech row ='0' page ='1' column ='2'>RGNassausLinearTactics</Tech>
<Tech row ='0' page ='1' column ='5'>GuardCacadores</Tech>
<Tech row ='0' page ='1' column ='5'>RGVoltigeur</Tech>
<Tech row ='0' page ='1' column ='2'>GuardRodeleros</Tech>
<Tech row ='0' page ='1' column ='1'>RGTercio</Tech>
<Tech row ='0' page ='1' column ='4'>RGRedcoats</Tech>
<Tech row ='0' page ='1' column ='2'>ImperialDopplesoldner</Tech>
<Tech row ='0' page ='1' column ='2'>ImperialHalberdiers</Tech>
<Tech row ='0' page ='1' column ='4'>ImperialJanissaries</Tech>
<Tech row ='0' page ='1' column ='0'>ImperialLongbowmen</Tech>
<Tech row ='0' page ='1' column ='5'>ImperialSkirmishers</Tech>
<Tech row ='0' page ='1' column ='5'>ImperialVoltigeur</Tech>
<Tech row ='0' page ='1' column ='5'>RGPrussianNeedleGun</Tech>
<Tech row ='0' page ='1' column ='4'>GuardJanissaries</Tech>
<Tech row ='0' page ='1' column ='0'>VeteranLongbowmen</Tech>
<Tech row ='0' page ='1' column ='2'>RGEspadachins</Tech>
<Tech row ='0' page ='1' column ='1'>ImperialTercio</Tech>
<Tech row ='0' page ='1' column ='4'>RGGuerreiros</Tech>
<Tech row ='0' page ='1' column ='5'>ImperialCacadores</Tech>
<Tech row ='0' page ='1' column ='4'>ImperialMusketeers</Tech>
<Tech row ='0' page ='1' column ='2'>GuardDopplesoldners</Tech>
<Tech row ='0' page ='1' column ='4'>ImperialGuerreiros</Tech>
<Flag>CollidesWithProjectiles</Flag>
<Flag>StartsAtFullEfficiency</Flag>
<Flag>Immoveable</Flag>
<Flag>NoBloodOnDeath</Flag>
<Flag>ObscuresUnits</Flag>
<Flag>NoIdleActions</Flag>
<Flag>NonAutoFormedUnit</Flag>
<Flag>Doppled</Flag>
<Flag>SelectWithObstruction</Flag>
<Flag>PaintTextureWhenPlacing</Flag>
<Flag>FlattenGround</Flag>
<Flag>HasGatherPoint</Flag>
<Flag>InitialGarrisonOnly</Flag>
<Flag>Tracked</Flag>
<Command page ='10' column ='0'>SetGatherPointMilitary</Command>
<Command page ='10' column ='1'>Delete</Command>
<Tactics>barracks.tactics</Tactics>
</Unit>



Here you see the various things: the Display name number, the obstruction radius, the maximum velocity (speed), hitpoints, build points (game seconds it takes to build), Build bounty (amount of XP you gain from building it), Cost, Allowed Age (0=Discovery, 1= Colonial Age; 2=Fortress, 3=Industrial, 4=Imperial), its armor resistance, its builder limit, etc., the units it can train, the techs it can upgrade, the different it has, and command pages for Military Gathering points, and lastly, its Tactics information. From all of this, we can understand what the building does, and what we can add/subtract to it.



------

Before we add techs, it is important to note the following: The AI, or artificial intelligence, can only upgrade a maximum of 12-13 upgrades at a given building before it decides to not research anymore at that building. Therefore if you want to make it research more at a building, you should make a 'bundle' tech that upgrades many small techs at that building for free. Place this tech on row '0', page '255' on column '2', if you want only Computer players to be able to research it.

The AI can only upgrade a maximum of 12-13 upgrades at a given building. This is most likely a game bug. Therefore if you make a lot of techs at a building, make a 'bundle' tech that upgrades many small upgrades at that building for free.


------

Simply here is what my AI looks like for upgrading Capitols:

Note: '...' below means abbreviating a lot of code inbetween the AI tech rules:

...

In the // rule age4Monitor:

xsEnableRule("age5Monitor");

...


rule age5Monitor
inactive
minInterval 10
{
if (kbGetAge() >= cAge5)
{
aiEcho("*** We're in age 5.");
// Bump up settler train plan
updateSettlerCounts();

// Upgrade Capitol Upgrades
xsEnableRule("CapitolUpgradeMonitor");

// Enable brigade technologies at the consulate
if (civIsAsian() == true)
xsEnableRule("brigadeMonitor");


xsDisableSelf();
gAgeUpTime = xsGetTime();

updateEscrows();

}
}


...


rule CapitolUpgradeMonitor
inactive
minInterval 30
{
int upgradePlanID = -1;

if ((kbTechGetStatus(cTechImpExcessiveTaxation) == cTechStatusActive) &&
(kbTechGetStatus(cTechImpDeforestation) == cTechStatusActive) &&
(kbTechGetStatus(cTechImpLargeScaleAgriculture) == cTechStatusActive) &&
(kbTechGetStatus(cTechColonialGovernment) == cTechStatusActive) &&
(kbTechGetStatus(cTechImpKnighthood) == cTechStatusActive) &&
(kbTechGetStatus(cTechImpImmigrants) == cTechStatusActive) &&
(kbTechGetStatus(cTechImpPeerage) == cTechStatusActive))
{
xsDisableSelf();
return;
}


// Get upgrades one at a time
if (kbTechGetStatus(cTechImpExcessiveTaxation) == cTechStatusObtainable)
{
upgradePlanID = aiPlanGetIDByTypeAndVariableType(cPlanResearch, cResearchPlanTechID, cTechImpExcessiveTaxation);
if (upgradePlanID >= 0)
aiPlanDestroy(upgradePlanID);
createSimpleResearchPlan(cTechImpExcessiveTaxation, getUnit(cUnitTypeCapitol), cEconomyEscrowID, 99);
return;
}
if (kbTechGetStatus(cTechImpDeforestation) == cTechStatusObtainable)
{
upgradePlanID = aiPlanGetIDByTypeAndVariableType(cPlanResearch, cResearchPlanTechID, cTechImpDeforestation);
if (upgradePlanID >= 0)
aiPlanDestroy(upgradePlanID);
createSimpleResearchPlan(cTechImpDeforestation, getUnit(cUnitTypeCapitol), cEconomyEscrowID, 99);
return;
}
if (kbTechGetStatus(cTechImpLargeScaleAgriculture) == cTechStatusObtainable)
{
upgradePlanID = aiPlanGetIDByTypeAndVariableType(cPlanResearch, cResearchPlanTechID, cTechImpLargeScaleAgriculture);
if (upgradePlanID >= 0)
aiPlanDestroy(upgradePlanID);
createSimpleResearchPlan(cTechImpLargeScaleAgriculture, getUnit(cUnitTypeCapitol), cEconomyEscrowID, 99);
return;
}
if (kbTechGetStatus(cTechColonialGovernment) == cTechStatusObtainable)
{
upgradePlanID = aiPlanGetIDByTypeAndVariableType(cPlanResearch, cResearchPlanTechID, cTechColonialGovernment);
if (upgradePlanID >= 0)
aiPlanDestroy(upgradePlanID);
createSimpleResearchPlan(cTechColonialGovernment, getUnit(cUnitTypeCapitol), cEconomyEscrowID, 99);
return;
}
if (kbTechGetStatus(cTechImpKnighthood) == cTechStatusObtainable)
{
upgradePlanID = aiPlanGetIDByTypeAndVariableType(cPlanResearch, cResearchPlanTechID, cTechImpKnighthood);
if (upgradePlanID >= 0)
aiPlanDestroy(upgradePlanID);
createSimpleResearchPlan(cTechImpKnighthood, getUnit(cUnitTypeCapitol), cEconomyEscrowID, 99);
return;
}
if (kbTechGetStatus(cTechImpImmigrants) == cTechStatusObtainable)
{
upgradePlanID = aiPlanGetIDByTypeAndVariableType(cPlanResearch, cResearchPlanTechID, cTechImpImmigrants);
if (upgradePlanID >= 0)
aiPlanDestroy(upgradePlanID);
createSimpleResearchPlan(cTechImpImmigrants, getUnit(cUnitTypeCapitol), cEconomyEscrowID, 99);
return;
}
if (kbTechGetStatus(cTechImpPeerage) == cTechStatusObtainable)
{
upgradePlanID = aiPlanGetIDByTypeAndVariableType(cPlanResearch, cResearchPlanTechID, cTechImpPeerage);
if (upgradePlanID >= 0)
aiPlanDestroy(upgradePlanID);
createSimpleResearchPlan(cTechImpPeerage, getUnit(cUnitTypeCapitol), cEconomyEscrowID, 99);
return;
}
}


------


Furthermore, if we want the AI to build a building we do it so:


// And how 'bout a capitol, as long as we're here (not for natives or Asians)
if ( (civIsNative() == false) && (civIsAsian() == false) )
{
planID = aiPlanGetIDByTypeAndVariableType(cPlanBuild, cBuildPlanBuildingTypeID, cUnitTypeCapitol);
if ( (planID < 0) && (kbUnitCount(cMyID, cUnitTypeCapitol, cUnitStateAlive) < 1) )
{ // Start a new one
createSimpleBuildPlan(cUnitTypeCapitol, 1, 60, true, cEconomyEscrowID, kbBaseGetMainID(cMyID), 1);
aiEcho("Starting a new capitol build plan.");
}
}


Note, in C+ Coding, which Age of Empires III is related to, // indicates a nullifying of the coding language; if you want to comment on some thing put // in front of it and say what you wish. Then include the tech.


------


As with this, I must close for today, and hopefully I will be able to continue this work in a little while.


Link to Previous Part 1 of the Guide:

http://aoe3.heavengames.com/cgi-bin/forums/display.cgi?action=st&fn=14&tn=38878&st=recent&f=14,38878,0,10


Best of regards,



murdilator

[This message has been edited by murdilator (edited 08-24-2013 @ 08:53 AM).]