//============================================================================== /* C:\projects\age4\age4-dev\age4w\ai\RUSHRUSHRUSH.xs This file is auto-generated. Edits will be lost when the file is regenerated. */ //============================================================================== include "aiHeader.xs"; // Gets global vars, function forward declarations include "aiUtil.xs"; // Misc. shared AI utility functions include "aiEcon.xs"; // All of the AI's econ functionality include "aiMilitary.xs"; // All of the AI's military functionality include "aiNavy.xs"; // All of the AI's naval functionality include "aiEventHandlers.xs"; // Event handler methods for the AI include "aiMain.xs"; // The bulk of the AI //============================================================================== /* preInit() This function is called in main() before any of the normal initialization happens. Use it to override default values of variables as needed for personality or scenario effects. */ //============================================================================== void preInit(void) { aiEcho("preInit() starting."); btRushBoom = -1; btTargetAge1ArmyCount = 2; btTargetAge2ArmyCount = 3; btTargetAge3ArmyCount = 3; btTargetAge4ArmyCount = 4; btAttackGroups = 3; btMilitaryInAge1 = true; cvNumTowers = 0; btTargetAge1VilCount = 0; btTargetAge4VilCount = 0; cvMaxAge = 1 - 1; btBiasInf = aiGetInfantryBias(); btBiasCav = aiGetCavalryBias(); btBiasArcher = aiGetArcherBias(); btBiasArt = aiGetSiegeBias(); btBaselineHandicap = aiGetEconHandicap() + 1; // We add one since the tool's range is -1 to 1, and we use the value as a multiplier. btBiasNavy = aiGetNavyBias(); btRevealEnemyBases = aiGetOKToAutoReveal(); cvOkToAttack = aiGetOKToAttack(); cvOkToTrainArmy = aiGetOKToTrainArmy(); cvOkToTrainNavy = aiGetOKToTrainNavy(); cvOkToFish = aiGetOKToFish(); cvOkToResign = aiGetOKToResign(); cvOkToExplore = aiGetOKToScout(); cvOKToResearchEcon = aiGetOKToResearchEcon(); cvOKToResearchMilitary = aiGetOKToResearchMilitary(); } //============================================================================== /* postInit() This function is called in main() after the normal initialization is complete. Use it to override settings and decisions made by the startup logic. */ //============================================================================== void postInit(void) { aiEcho("postInit() starting."); } //============================================================================== // rule autoExploreEnemyBases // // Cheat and show the AI where all of the enemy bases are. //============================================================================== rule autoExploreEnemyBases active minInterval 5 { float totalTime = xsGetTime() / 1000.0; static bool revealed = false; if (btRevealEnemyBases == false) { xsDisableSelf(); return; } if (totalTime >= cTimeToRevealEnemyBases) { if (revealed == false) { Vector pos = aiCheatReveal(); if (xsVectorIsValid(pos)) { findEnemyBase(pos); } revealed = true; } else { aiCheatUnreveal(); xsDisableSelf(); } } } //============================================================================== // setupBuildingInfo() // // Called when we age up--setup the buildings we want for the current age. This // controls the forecast values and what the AI attempts to build automatically. // Some things (like farms and dropsites) are built elsewhere, even though // they're listed in here (for forecast info) //============================================================================== void setupBuildingInfo() { // Create arrays if needed if (gBuildings == -1) { gBuildings = xsArrayCreateInt(gMaxBuildings, -1, "Building list"); gBuildingCount = xsArrayCreateInt(gMaxBuildings, 1, "Building count"); gBuildingEscrow = xsArrayCreateInt(gMaxBuildings, cEconomyEscrowID, "Building escrow"); gBuildingBuild = xsArrayCreateBool(gMaxBuildings, false, "Building build flag"); gBuildingAgeState = xsArrayCreateInt(gMaxBuildings, cAgeStateMid, "Building age state"); } // Clear arrays (inefficient, but saves us potential errors if something doesn't get cleared) int i=0; for (i = 0; < gMaxBuildings) { xsArraySetInt(gBuildings, i, -1); xsArraySetInt(gBuildingCount, i, 1); xsArraySetInt(gBuildingEscrow, i, cEconomyEscrowID); xsArraySetBool(gBuildingBuild, i, false); xsArraySetInt(gBuildingAgeState, i, cAgeStateMid); } int bt = 0; int offset = 0; switch (kbGetAge()) { case cAge1: { break; } case cAge2: { bt = kbFindBuilding(cUnitTypeUnitTypeBldgBarracks); offset = addBuildingToList(bt, 1, cMilitaryEscrowID, cAgeStateMid, true, offset); bt = kbFindBuilding(cUnitTypeUnitTypeBldgArcheryRange); offset = addBuildingToList(bt, 1, cMilitaryEscrowID, cAgeStateMid, true, offset); bt = kbFindBuilding(cUnitTypeUnitTypeBldgStables); offset = addBuildingToList(bt, 1, cMilitaryEscrowID, cAgeStateMid, true, offset); break; } case cAge3: { bt = kbFindBuilding(cUnitTypeUnitTypeBldgBarracks); offset = addBuildingToList(bt, 1, cMilitaryEscrowID, cAgeStateMid, true, offset); bt = kbFindBuilding(cUnitTypeUnitTypeBldgArcheryRange); offset = addBuildingToList(bt, 1, cMilitaryEscrowID, cAgeStateMid, true, offset); bt = kbFindBuilding(cUnitTypeUnitTypeBldgStables); offset = addBuildingToList(bt, 1, cMilitaryEscrowID, cAgeStateMid, true, offset); bt = kbFindBuilding(cUnitTypeUnitTypeBldgSiegeWorkshop); offset = addBuildingToList(bt, 1, cMilitaryEscrowID, cAgeStateMid, true, offset); bt = kbFindBuilding(cUnitTypeUnitTypeBldgMarket); offset = addBuildingToList(bt, 1, cEconomyEscrowID, cAgeStateMid, true, offset); bt = kbFindBuilding(cUnitTypeAbstractTownCenter); offset = addBuildingToList(bt, 1, cEconomyEscrowID, cAgeStateMid, true, offset); break; } case cAge4: { bt = kbFindBuilding(cUnitTypeUnitTypeBldgBarracks); offset = addBuildingToList(bt, 2, cMilitaryEscrowID, cAgeStateMid, true, offset); bt = kbFindBuilding(cUnitTypeUnitTypeBldgArcheryRange); offset = addBuildingToList(bt, 2, cMilitaryEscrowID, cAgeStateMid, true, offset); bt = kbFindBuilding(cUnitTypeUnitTypeBldgStables); offset = addBuildingToList(bt, 2, cMilitaryEscrowID, cAgeStateMid, true, offset); bt = kbFindBuilding(cUnitTypeUnitTypeBldgSiegeWorkshop); offset = addBuildingToList(bt, 2, cMilitaryEscrowID, cAgeStateMid, true, offset); bt = kbFindBuilding(cUnitTypeUnitTypeBldgMarket); offset = addBuildingToList(bt, 1, cEconomyEscrowID, cAgeStateMid, true, offset); bt = kbFindBuilding(cUnitTypeUnitTypeBldgTownCenter); offset = addBuildingToList(bt, 1, cEconomyEscrowID, cAgeStateMid, true, offset); break; } } } //============================================================================== // setUnitPickerPreference() // // Updates the unit picker biases. //============================================================================== void setUnitPickerPreference(int upID = -1) { // Add the main unit lines if (upID < 0) return; kbUnitPickSetPreferenceFactor(upID, cUnitTypeAbstractInfantry, 0.5 + (btBiasInf / 2.0)); // Range 0.0 to 1.0 kbUnitPickSetPreferenceFactor(upID, cUnitTypeAbstractArtillery, 0.5 + (btBiasArt / 2.0)); kbUnitPickSetPreferenceFactor(upID, cUnitTypeAbstractCavalry, 0.5 + (btBiasCav / 2.0)); kbUnitPickSetPreferenceFactor(upID, cUnitTypeAbstractArcher, 0.5 + (btBiasArcher / 2.0)); }