//------------------------------------------------------------------- // INCLUDES: //------------------------------------------------------------------- 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 //------------------------------------------------------------------- extern int gAIAttackRoute01PlanID = -1; extern int gAIAttackRoute02PlanID = -1; extern int gAIAttackRoute03PlanID = -1; extern int gAIAttackRoute04PlanID = -1; extern int gAIAttackRoute05PlanID = -1; extern int gAIAttackRoute06PlanID = -1; extern int gAIAttackRoute07PlanID = -1; extern int gAIAttackRoute08PlanID = -1; extern int gAIAttackRoute03Direct = -1; extern int gAIAttackRoute07Direct = -1; extern int gAIAttackRouteSeekerWest = -1; extern int gAIAttackRouteSeekerEast = -1; extern int gAIAttackRouteNaval = -1; extern vector MapCenter = vector(300,0,300); extern vector Route01Village = vector(467,0,431); extern vector Route02Village = vector(432,0,272); extern vector Route03Village = vector(488,0,142); extern vector Route04Village = vector(372,0,165); extern vector Route05Village = vector(204,0,158); extern vector Route06Village = vector(114,0,192); extern vector Route07Village = vector(134,0,342); extern vector Route08Village = vector(215,0,468); extern vector Route03Extra1 = vector(411,0,200); extern vector Route03Extra2 = vector(328,0,240); extern vector Route03Direct1 = vector(505,0,278); extern vector Route03Direct2 = vector(446,0,331); extern vector Route03Direct3 = vector(394,0,333); extern vector Route07Direct1 = vector(142,0,411); extern vector Route07Direct2 = vector(177,0,425); extern vector Route07Direct3 = vector(219,0,391); extern vector RouteNaval1 = vector(256,0,367); extern vector RouteNaval2 = vector(265,0,246); extern vector RouteNaval3 = vector(328,0,240); extern vector RouteNaval4 = vector(362,0,235); extern vector RouteNaval5 = vector(325,0,178); //------------------------------------------------------------------- void preInit(void) { aiEcho("preInit() starting."); cvOkToBuild = false; cvOKToDefend = false; cvOkToAttack = false; cvOkToExplore = false; cvOkToSelectMissions = false; cvGuardAlliedBases = false; cvOkToGatherFood = false; cvOkToGatherGold = false; cvOkToGatherWood = false; cvOkToGatherStone = false; xsDisableRule("checkForGold"); xsDisableRule("checkForEnemyBases"); } //------------------------------------------------------------------- void postInit(void) { aiEcho("postInit() starting."); } //------------------------------------------------------------------- rule RevealMapLocations active minInterval 5 { kbLookAtAllUnitsOnMap(); aiCheatReveal(); aiEcho("RevealMapLocations: --- now revealing enemy"); xsSetRuleMinIntervalSelf(123); } //------------------------------------------------------------------- rule AIAttack_Route01_MGR active minInterval 11 { int PlanID = gAIAttackRoute01PlanID; if (PlanID > 0) { if ( UpdateSpawnedUnitDefenseLoc(PlanID, Route01Village, 50) ) return; if ( UpdateSpawnedUnitDefenseLoc(PlanID, MapCenter, 80) ) return; int P1VictoryUnitID = getUnit(cUnitTypeLogicalTypeNeededForVictory, 1, cUnitStateAlive); if (P1VictoryUnitID > -1) { if ( UpdateSpawnedUnitDefenseLoc(PlanID, kbUnitGetPosition(P1VictoryUnitID)) ) return; } int P3VictoryUnitID = getUnit(cUnitTypeLogicalTypeNeededForVictory, 3, cUnitStateAlive); if (P3VictoryUnitID > -1) { if ( UpdateSpawnedUnitDefenseLoc(PlanID, kbUnitGetPosition(P3VictoryUnitID)) ) return; } } } //------------------------------------------------------------------- rule AIAttack_Route02_MGR active minInterval 11 { int PlanID = gAIAttackRoute02PlanID; if (PlanID > 0) { if ( UpdateSpawnedUnitDefenseLoc(PlanID, Route02Village, 50) ) return; if ( UpdateSpawnedUnitDefenseLoc(PlanID, MapCenter, 80) ) return; int P1VictoryUnitID = getUnit(cUnitTypeLogicalTypeNeededForVictory, 1, cUnitStateAlive); if (P1VictoryUnitID > -1) { if ( UpdateSpawnedUnitDefenseLoc(PlanID, kbUnitGetPosition(P1VictoryUnitID)) ) return; } int P3VictoryUnitID = getUnit(cUnitTypeLogicalTypeNeededForVictory, 3, cUnitStateAlive); if (P3VictoryUnitID > -1) { if ( UpdateSpawnedUnitDefenseLoc(PlanID, kbUnitGetPosition(P3VictoryUnitID)) ) return; } } } //------------------------------------------------------------------- rule AIAttack_Route03_MGR active minInterval 12 { int PlanID = gAIAttackRoute03PlanID; if (PlanID > 0) { if ( UpdateSpawnedUnitDefenseLoc(PlanID, Route03Village, 50) ) return; if ( UpdateSpawnedUnitDefenseLoc(PlanID, Route03Extra1, 15) ) return; if ( UpdateSpawnedUnitDefenseLoc(PlanID, Route03Extra2, 15) ) return; if ( UpdateSpawnedUnitDefenseLoc(PlanID, MapCenter, 80) ) return; int P1VictoryUnitID = getUnit(cUnitTypeLogicalTypeNeededForVictory, 1, cUnitStateAlive); if (P1VictoryUnitID > -1) { if ( UpdateSpawnedUnitDefenseLoc(PlanID, kbUnitGetPosition(P1VictoryUnitID)) ) return; } int P3VictoryUnitID = getUnit(cUnitTypeLogicalTypeNeededForVictory, 3, cUnitStateAlive); if (P3VictoryUnitID > -1) { if ( UpdateSpawnedUnitDefenseLoc(PlanID, kbUnitGetPosition(P3VictoryUnitID)) ) return; } } } //------------------------------------------------------------------- rule AIAttack_Route03Direct_MGR active minInterval 12 { int PlanID = gAIAttackRoute03Direct; if (PlanID > 0) { if ( UpdateSpawnedUnitDefenseLoc(PlanID, Route03Direct1) ) return; if ( UpdateSpawnedUnitDefenseLoc(PlanID, Route03Direct2) ) return; if ( UpdateSpawnedUnitDefenseLoc(PlanID, Route03Direct3) ) return; if ( UpdateSpawnedUnitDefenseLoc(PlanID, MapCenter, 80) ) return; int P1VictoryUnitID = getUnit(cUnitTypeLogicalTypeNeededForVictory, 1, cUnitStateAlive); if (P1VictoryUnitID > -1) { if ( UpdateSpawnedUnitDefenseLoc(PlanID, kbUnitGetPosition(P1VictoryUnitID)) ) return; } int P3VictoryUnitID = getUnit(cUnitTypeLogicalTypeNeededForVictory, 3, cUnitStateAlive); if (P3VictoryUnitID > -1) { if ( UpdateSpawnedUnitDefenseLoc(PlanID, kbUnitGetPosition(P3VictoryUnitID)) ) return; } } } //------------------------------------------------------------------- rule AIAttack_Route04_MGR active minInterval 12 { int PlanID = gAIAttackRoute04PlanID; if (PlanID > 0) { if ( UpdateSpawnedUnitDefenseLoc(PlanID, Route04Village, 50) ) return; if ( UpdateSpawnedUnitDefenseLoc(PlanID, MapCenter, 80) ) return; int P1VictoryUnitID = getUnit(cUnitTypeLogicalTypeNeededForVictory, 1, cUnitStateAlive); if (P1VictoryUnitID > -1) { if ( UpdateSpawnedUnitDefenseLoc(PlanID, kbUnitGetPosition(P1VictoryUnitID)) ) return; } int P3VictoryUnitID = getUnit(cUnitTypeLogicalTypeNeededForVictory, 3, cUnitStateAlive); if (P3VictoryUnitID > -1) { if ( UpdateSpawnedUnitDefenseLoc(PlanID, kbUnitGetPosition(P3VictoryUnitID)) ) return; } } } //------------------------------------------------------------------- rule AIAttack_Route05_MGR active minInterval 13 { int PlanID = gAIAttackRoute05PlanID; if (PlanID > 0) { if ( UpdateSpawnedUnitDefenseLoc(PlanID, Route05Village, 50) ) return; if ( UpdateSpawnedUnitDefenseLoc(PlanID, MapCenter, 80) ) return; int P1VictoryUnitID = getUnit(cUnitTypeLogicalTypeNeededForVictory, 1, cUnitStateAlive); if (P1VictoryUnitID > -1) { if ( UpdateSpawnedUnitDefenseLoc(PlanID, kbUnitGetPosition(P1VictoryUnitID)) ) return; } int P3VictoryUnitID = getUnit(cUnitTypeLogicalTypeNeededForVictory, 3, cUnitStateAlive); if (P3VictoryUnitID > -1) { if ( UpdateSpawnedUnitDefenseLoc(PlanID, kbUnitGetPosition(P3VictoryUnitID)) ) return; } } } //------------------------------------------------------------------- rule AIAttack_Route06_MGR active minInterval 13 { int PlanID = gAIAttackRoute06PlanID; if (PlanID > 0) { if ( UpdateSpawnedUnitDefenseLoc(PlanID, Route06Village, 50) ) return; if ( UpdateSpawnedUnitDefenseLoc(PlanID, MapCenter, 80) ) return; int P1VictoryUnitID = getUnit(cUnitTypeLogicalTypeNeededForVictory, 1, cUnitStateAlive); if (P1VictoryUnitID > -1) { if ( UpdateSpawnedUnitDefenseLoc(PlanID, kbUnitGetPosition(P1VictoryUnitID)) ) return; } int P3VictoryUnitID = getUnit(cUnitTypeLogicalTypeNeededForVictory, 3, cUnitStateAlive); if (P3VictoryUnitID > -1) { if ( UpdateSpawnedUnitDefenseLoc(PlanID, kbUnitGetPosition(P3VictoryUnitID)) ) return; } } } //------------------------------------------------------------------- rule AIAttack_Route07_MGR active minInterval 14 { int PlanID = gAIAttackRoute07PlanID; if (PlanID > 0) { if ( UpdateSpawnedUnitDefenseLoc(PlanID, Route07Village, 50) ) return; if ( UpdateSpawnedUnitDefenseLoc(PlanID, MapCenter, 80) ) return; int P1VictoryUnitID = getUnit(cUnitTypeLogicalTypeNeededForVictory, 1, cUnitStateAlive); if (P1VictoryUnitID > -1) { if ( UpdateSpawnedUnitDefenseLoc(PlanID, kbUnitGetPosition(P1VictoryUnitID)) ) return; } int P3VictoryUnitID = getUnit(cUnitTypeLogicalTypeNeededForVictory, 3, cUnitStateAlive); if (P3VictoryUnitID > -1) { if ( UpdateSpawnedUnitDefenseLoc(PlanID, kbUnitGetPosition(P3VictoryUnitID)) ) return; } } } //------------------------------------------------------------------- rule AIAttack_Route07Direct_MGR active minInterval 12 { int PlanID = gAIAttackRoute07Direct; if (PlanID > 0) { if ( UpdateSpawnedUnitDefenseLoc(PlanID, Route07Direct1) ) return; if ( UpdateSpawnedUnitDefenseLoc(PlanID, Route07Direct2) ) return; if ( UpdateSpawnedUnitDefenseLoc(PlanID, Route07Direct3) ) return; if ( UpdateSpawnedUnitDefenseLoc(PlanID, MapCenter, 80) ) return; int P1VictoryUnitID = getUnit(cUnitTypeLogicalTypeNeededForVictory, 1, cUnitStateAlive); if (P1VictoryUnitID > -1) { if ( UpdateSpawnedUnitDefenseLoc(PlanID, kbUnitGetPosition(P1VictoryUnitID)) ) return; } int P3VictoryUnitID = getUnit(cUnitTypeLogicalTypeNeededForVictory, 3, cUnitStateAlive); if (P3VictoryUnitID > -1) { if ( UpdateSpawnedUnitDefenseLoc(PlanID, kbUnitGetPosition(P3VictoryUnitID)) ) return; } } } //------------------------------------------------------------------- rule AIAttack_Route08_MGR active minInterval 14 { int PlanID = gAIAttackRoute08PlanID; if (PlanID > 0) { if ( UpdateSpawnedUnitDefenseLoc(PlanID, Route08Village, 50) ) return; if ( UpdateSpawnedUnitDefenseLoc(PlanID, MapCenter, 80) ) return; int P1VictoryUnitID = getUnit(cUnitTypeLogicalTypeNeededForVictory, 1, cUnitStateAlive); if (P1VictoryUnitID > -1) { if ( UpdateSpawnedUnitDefenseLoc(PlanID, kbUnitGetPosition(P1VictoryUnitID)) ) return; } int P3VictoryUnitID = getUnit(cUnitTypeLogicalTypeNeededForVictory, 3, cUnitStateAlive); if (P3VictoryUnitID > -1) { if ( UpdateSpawnedUnitDefenseLoc(PlanID, kbUnitGetPosition(P3VictoryUnitID)) ) return; } } } //------------------------------------------------------------------- rule AIAttack_SeekerWest_MGR active minInterval 13 { int PlanID = gAIAttackRouteSeekerWest; if (PlanID > 0) { } } //------------------------------------------------------------------- rule AIAttack_SeekerEast_MGR active minInterval 13 { int PlanID = gAIAttackRouteSeekerEast; if (PlanID > 0) { } } //------------------------------------------------------------------- rule AIAttack_RouteNaval_MGR active minInterval 14 { int PlanID = gAIAttackRouteNaval; if (PlanID > 0) { if ( UpdateSpawnedUnitDefenseLoc(PlanID, RouteNaval1, 50) ) return; if ( UpdateSpawnedUnitDefenseLoc(PlanID, RouteNaval2, 50) ) return; if ( UpdateSpawnedUnitDefenseLoc(PlanID, RouteNaval3, 50) ) return; if ( UpdateSpawnedUnitDefenseLoc(PlanID, RouteNaval4, 50) ) return; if ( UpdateSpawnedUnitDefenseLoc(PlanID, RouteNaval5, 50) ) return; if ( UpdateSpawnedUnitDefenseLoc(PlanID, MapCenter, 80) ) return; int P1VictoryUnitID = getUnit(cUnitTypeLogicalTypeNeededForVictory, 1, cUnitStateAlive); if (P1VictoryUnitID > -1) { if ( UpdateSpawnedUnitDefenseLoc(PlanID, kbUnitGetPosition(P1VictoryUnitID)) ) return; } int P3VictoryUnitID = getUnit(cUnitTypeLogicalTypeNeededForVictory, 3, cUnitStateAlive); if (P3VictoryUnitID > -1) { if ( UpdateSpawnedUnitDefenseLoc(PlanID, kbUnitGetPosition(P3VictoryUnitID)) ) return; } } } //------------------------------------------------------------------- void AIAttack_Route01(int val = -1) { if (val > -1) { // create the initial plan, if needed if (gAIAttackRoute01PlanID < 0) { gAIAttackRoute01PlanID = CreateSpawnedUnitDefensePlan("AIAttack_Route01"); AIAttack_Route01_MGR(); } // update the plan with the new units UpdateSpawnedUnitDefenseUnits(gAIAttackRoute01PlanID, val); } } //------------------------------------------------------------------- void AIAttack_Route02(int val = -1) { if (val > -1) { // create the initial plan, if needed if (gAIAttackRoute02PlanID < 0) { gAIAttackRoute02PlanID = CreateSpawnedUnitDefensePlan("AIAttack_Route02"); AIAttack_Route02_MGR(); } // update the plan with the new units UpdateSpawnedUnitDefenseUnits(gAIAttackRoute02PlanID, val); } } //------------------------------------------------------------------- void AIAttack_Route03(int val = -1) { if (val > -1) { // create the initial plan, if needed if (gAIAttackRoute03PlanID < 0) { gAIAttackRoute03PlanID = CreateSpawnedUnitDefensePlan("AIAttack_Route03"); AIAttack_Route03_MGR(); } // update the plan with the new units UpdateSpawnedUnitDefenseUnits(gAIAttackRoute03PlanID, val); } } //------------------------------------------------------------------- void AIAttack_Route03Direct(int val = -1) { if (val > -1) { // create the initial plan, if needed if (gAIAttackRoute03Direct < 0) { gAIAttackRoute03Direct = CreateSpawnedUnitDefensePlan("AIAttack_Route03Direct"); AIAttack_Route03Direct_MGR(); } // update the plan with the new units UpdateSpawnedUnitDefenseUnits(gAIAttackRoute03Direct, val); } } //------------------------------------------------------------------- void AIAttack_Route04(int val = -1) { if (val > -1) { // create the initial plan, if needed if (gAIAttackRoute04PlanID < 0) { gAIAttackRoute04PlanID = CreateSpawnedUnitDefensePlan("AIAttack_Route04"); AIAttack_Route04_MGR(); } // update the plan with the new units UpdateSpawnedUnitDefenseUnits(gAIAttackRoute04PlanID, val); } } //------------------------------------------------------------------- void AIAttack_Route05(int val = -1) { if (val > -1) { // create the initial plan, if needed if (gAIAttackRoute05PlanID < 0) { gAIAttackRoute05PlanID = CreateSpawnedUnitDefensePlan("AIAttack_Route05"); AIAttack_Route05_MGR(); } // update the plan with the new units UpdateSpawnedUnitDefenseUnits(gAIAttackRoute05PlanID, val); } } //------------------------------------------------------------------- void AIAttack_Route06(int val = -1) { if (val > -1) { // create the initial plan, if needed if (gAIAttackRoute06PlanID < 0) { gAIAttackRoute06PlanID = CreateSpawnedUnitDefensePlan("AIAttack_Route06"); AIAttack_Route06_MGR(); } // update the plan with the new units UpdateSpawnedUnitDefenseUnits(gAIAttackRoute06PlanID, val); } } //------------------------------------------------------------------- void AIAttack_Route07(int val = -1) { if (val > -1) { // create the initial plan, if needed if (gAIAttackRoute07PlanID < 0) { gAIAttackRoute07PlanID = CreateSpawnedUnitDefensePlan("AIAttack_Route07"); AIAttack_Route07_MGR(); } // update the plan with the new units UpdateSpawnedUnitDefenseUnits(gAIAttackRoute07PlanID, val); } } //------------------------------------------------------------------- void AIAttack_Route07Direct(int val = -1) { if (val > -1) { // create the initial plan, if needed if (gAIAttackRoute07Direct < 0) { gAIAttackRoute07Direct = CreateSpawnedUnitDefensePlan("AIAttack_Route07Direct"); AIAttack_Route07Direct_MGR(); } // update the plan with the new units UpdateSpawnedUnitDefenseUnits(gAIAttackRoute07Direct, val); } } //------------------------------------------------------------------- void AIAttack_Route08(int val = -1) { if (val > -1) { // create the initial plan, if needed if (gAIAttackRoute08PlanID < 0) { gAIAttackRoute08PlanID = CreateSpawnedUnitDefensePlan("AIAttack_Route08"); AIAttack_Route08_MGR(); } // update the plan with the new units UpdateSpawnedUnitDefenseUnits(gAIAttackRoute08PlanID, val); } } //------------------------------------------------------------------- void AIAttack_RouteNaval(int val = -1) { if (val > -1) { // create the initial plan, if needed if (gAIAttackRouteNaval < 0) { // set this plan to use naval units, with a slightly larger engage radius than normal gAIAttackRouteNaval = CreateSpawnedUnitDefensePlan("AIAttack_RouteNaval", 50, cUnitTypeAbstractWarShip); AIAttack_RouteNaval_MGR(); } // update the plan with the new units UpdateSpawnedUnitDefenseUnits(gAIAttackRouteNaval, val); } } //------------------------------------------------------------------- void AIAttack_SeekerWest(int val = -1) { if (val > -1) { // create the initial plan, if needed if (gAIAttackRouteSeekerWest < 0) { gAIAttackRouteSeekerWest = CreateSpawnedUnitDefensePlan("AIAttack_SeekerWest"); //AIAttack_SeekerWest_MGR(); } // update the plan with the new units UpdateSpawnedUnitDefenseUnits(gAIAttackRouteSeekerWest, val); } } //------------------------------------------------------------------- void AIAttack_SeekerEast(int val = -1) { if (val > -1) { // create the initial plan, if needed if (gAIAttackRouteSeekerEast < 0) { gAIAttackRouteSeekerEast = CreateSpawnedUnitDefensePlan("AIAttack_SeekerEast"); //AIAttack_SeekerEast_MGR(); } // update the plan with the new units UpdateSpawnedUnitDefenseUnits(gAIAttackRouteSeekerEast, val); } }