//============================================================================== /* C:\work\Spartan\main\age4\age4-dev\age4w\ai\CORE\Age2_BarracksRush_Hardcore.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 include "aiSkirmish.xs"; // Skirmish Hall specific overrides //============================================================================== /* 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) { // check for default selection aiEcho("preInit() NAVAL starting."); getDataFromBiases(); setDefaultAIVariables(); btBiasInf = 0; btBiasCav = 0; btBiasArcher = 0; btBiasArt = 0; btBiasNavy = 1.0; cvOkToTrainNavy = true; cvOkToFish = true; cvOKToResearchEcon = false;//aiGetOKToResearchEcon(); cvOKToResearchMilitary = false;//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."); skirmishPostInit(); } rule allowAttacks inactive minInterval 5 { if(isCurrentMapNaval() == false) { xsDisableSelf(); return; } //kbLookAtAllUnitsOnMap(); int enemyNavySize = kbUnitCount(getNavalTargetPlayer(), gNavalMilitaryUnitType, cUnitStateAlive); if(enemyNavySize > 1) { cvOkToAttack = false; } else { cvOkToAttack = true; } } rule buildMoreDocks active minInterval 17 { if (gWaterAreaID == -1) { xsDisableSelf(); return; } if(kbGetAge() >= cAge2) { int newArea = -1; int numAreas = kbAreaGetNumberBorderAreas(gWaterAreaID); int borderID = -1; // didn't find a border area that was water if(newArea == -1) { for (i=0; = 0 && temp != gWaterAreaID && kbAreaGetType(temp) == cAreaTypeWater) { newArea = temp; } } } } if(newArea == -1) { newArea = gWaterAreaID; } aiEcho("buildMoreDocks: building a new dock at area " + newArea); buildDockAtLocation(kbAreaGetCenter(newArea)); xsDisableSelf(); } } //============================================================================== // 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 initializeAndClearBuildingArrays(); setUpBalancedBuildOrder(); } //============================================================================== // setUnitPickerPreference() // // Updates the unit picker biases. //============================================================================== void setUnitPickerPreference(int upID = -1) { // Add the main unit lines if (upID < 0) return; setBalancedUnitPreference(upID); kbUnitPickSetPreferenceFactor(upID, cUnitTypeAbstractInfantry, 0.5 + (btBiasInf / 2.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)); }