//============================================================================== /* 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() SIEGE starting."); getDataFromBiases(); setDefaultAIVariables(); } rule siegeFocusBiases active minInterval 2 { float temp = (gRandomInfantryBias - 95); btBiasInf = temp / 100.0; temp = (gRandomCavalryBias - 95); btBiasCav = temp / 100.0; temp = (gRandomRangedBias - 95); btBiasArcher = temp / 100.0; btBiasArt = 1; aiEcho("Biases: Inf - " + btBiasInf + ", Cav - " + btBiasCav + ", Arch - " + btBiasArcher + ", Siege - " + btBiasArt); setUnitPickerPreference(gLandUnitPicker); xsDisableSelf(); } //============================================================================== /* 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 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(); } } } rule reduceBiasesInAge4 active minInterval 60 { if(kbGetAge() == cAge4) { btBiasInf = -0.95; btBiasCav = -0.95; btBiasArcher = -0.95; 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() { initializeAndClearBuildingArrays(); int currentVillCount = getVillagerCountForBuildOrder(); int siegeID = cUnitTypeUnitTypeBldgSiegeWorkshop; // Adding Indians here as well because they don't have a siege workshop - PF2K 2024/07/15 if(kbGetCiv()==gCelticCivID || kbGetCiv() == gNorseCivID || kbGetCiv() == gIndianCivID) { siegeID = cUnitTypeUnitTypeBldgFortress; } int bt = 0; int offset = 0; switch (kbGetAge()) { case cAge1: { if(btHighStartingResources) { bt = kbFindBuilding(cUnitTypeUnitTypeBldgBarracks); offset = addBuildingToList(bt, 3, cMilitaryEscrowID, cAgeStateEarly, true, offset); } break; } case cAge2: { if(btDifficulty > cStrongDifficulty) { bt = kbFindBuilding(cUnitTypeUnitTypeBldgBarracks); offset = addBuildingToList(bt, currentVillCount / 15, cMilitaryEscrowID, cAgeStateEarly, true, offset); bt = kbFindBuilding(cUnitTypeUnitTypeBldgArcheryRange); offset = addBuildingToList(bt, currentVillCount / 15, cMilitaryEscrowID, cAgeStateEarly, true, offset); bt = kbFindBuilding(cUnitTypeUnitTypeBldgStables); offset = addBuildingToList(bt, currentVillCount / 15, cMilitaryEscrowID, cAgeStateEarly, true, offset); } else if(btDifficulty > cWeakDifficulty) { bt = kbFindBuilding(cUnitTypeUnitTypeBldgBarracks); offset = addBuildingToList(bt, currentVillCount / 20, cMilitaryEscrowID, cAgeStateEarly, true, offset); bt = kbFindBuilding(cUnitTypeUnitTypeBldgArcheryRange); offset = addBuildingToList(bt, currentVillCount / 20, cMilitaryEscrowID, cAgeStateEarly, true, offset); bt = kbFindBuilding(cUnitTypeUnitTypeBldgStables); offset = addBuildingToList(bt, currentVillCount / 20, cMilitaryEscrowID, cAgeStateEarly, true, offset); } else { bt = kbFindBuilding(cUnitTypeUnitTypeBldgBarracks); offset = addBuildingToList(bt, 1 + btDifficulty, cMilitaryEscrowID, cAgeStateEarly, true, offset); bt = kbFindBuilding(cUnitTypeUnitTypeBldgArcheryRange); offset = addBuildingToList(bt, 1 + btDifficulty, cMilitaryEscrowID, cAgeStateMid, true, offset); bt = kbFindBuilding(cUnitTypeUnitTypeBldgStables); offset = addBuildingToList(bt, 1 + btDifficulty, cMilitaryEscrowID, cAgeStateMid, true, offset); } break; } default: { if(btDifficulty > cStrongDifficulty) { bt = kbFindBuilding(siegeID); offset = addBuildingToList(bt, currentVillCount / 13, cMilitaryEscrowID, cAgeStateEarly, true, offset); bt = kbFindBuilding(cUnitTypeUnitTypeBldgBarracks); offset = addBuildingToList(bt, currentVillCount / 20, cMilitaryEscrowID, cAgeStateMid, true, offset); bt = kbFindBuilding(cUnitTypeUnitTypeBldgArcheryRange); offset = addBuildingToList(bt, currentVillCount / 20, cMilitaryEscrowID, cAgeStateMid, true, offset); // ensure some immortal camps get placed for Persians if(kbGetCiv() == gPersianCivID) { bt = kbFindBuilding(cUnitTypeUnitTypeBldgTemple); offset = addBuildingToList(bt, currentVillCount / 20, cMilitaryEscrowID, cAgeStateMid, true, offset); } bt = kbFindBuilding(cUnitTypeUnitTypeBldgStables); offset = addBuildingToList(bt, currentVillCount / 20, cMilitaryEscrowID, cAgeStateMid, true, offset); } else if(btDifficulty > cWeakDifficulty) { bt = kbFindBuilding(siegeID); offset = addBuildingToList(bt, currentVillCount / 20, cMilitaryEscrowID, cAgeStateEarly, true, offset); bt = kbFindBuilding(cUnitTypeUnitTypeBldgBarracks); offset = addBuildingToList(bt, currentVillCount / 25, cMilitaryEscrowID, cAgeStateMid, true, offset); bt = kbFindBuilding(cUnitTypeUnitTypeBldgArcheryRange); offset = addBuildingToList(bt, currentVillCount / 25, cMilitaryEscrowID, cAgeStateMid, true, offset); bt = kbFindBuilding(cUnitTypeUnitTypeBldgStables); offset = addBuildingToList(bt, currentVillCount / 25, cMilitaryEscrowID, cAgeStateMid, true, offset); } else { bt = kbFindBuilding(siegeID); offset = addBuildingToList(bt, 1, cMilitaryEscrowID, cAgeStateEarly, true, offset); bt = kbFindBuilding(cUnitTypeUnitTypeBldgBarracks); offset = addBuildingToList(bt, 1, cMilitaryEscrowID, cAgeStateEarly, 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; } } setupStandardBuildingInfo(offset, currentVillCount); } //============================================================================== // 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)); kbUnitPickSetPreferenceFactor(upID, cUnitTypeUnitTypeSiegeRam1, 1.0); }