From c7e92c57ce9fd6256f8a695152da92acf5225d7a Mon Sep 17 00:00:00 2001 From: Pan Date: Sat, 6 Apr 2019 18:38:02 +1300 Subject: [PATCH] home commit --- enemyAI/buildingManagerAI.java | 2 +- enemyAI/economyManagerAI.java | 16 +++++++++++++++- enemyAI/unitProductionAI.java | 9 +++++++++ entity/lightTank.java | 2 +- entity/stealthTank.java | 2 +- particles/bullet.java | 19 ++++++++++++------- 6 files changed, 39 insertions(+), 11 deletions(-) diff --git a/enemyAI/buildingManagerAI.java b/enemyAI/buildingManagerAI.java index ad63a9f..3b52a21 100644 --- a/enemyAI/buildingManagerAI.java +++ b/enemyAI/buildingManagerAI.java @@ -117,7 +117,7 @@ public class buildingManagerAI { //build an additional refinery if there are more production building //don't build more than 2 refinery around a goldmine - if(getNumberOfFunctionalRefinery() < theBaseInfo.numberOfConstructionYard*2 && theBaseInfo.numberOfFactory > 0 && theBaseInfo.canBuildRefinery && getNumberOfRefineriesNearPreferedGoldMine() < 2){ + if(getNumberOfFunctionalRefinery() < theBaseInfo.numberOfConstructionYard*2 && (getNumberOfFunctionalRefinery() == 0 || theBaseInfo.numberOfFactory > 0) && theBaseInfo.canBuildRefinery && getNumberOfRefineriesNearPreferedGoldMine() < 2){ addBuildingToQueue(102); } diff --git a/enemyAI/economyManagerAI.java b/enemyAI/economyManagerAI.java index 7b5375d..68d8409 100644 --- a/enemyAI/economyManagerAI.java +++ b/enemyAI/economyManagerAI.java @@ -6,6 +6,7 @@ import core.vector; import entity.constructionYard; import entity.goldMine; import entity.harvester; +import entity.refinery; public class economyManagerAI { @@ -16,7 +17,7 @@ public class economyManagerAI { public int numberOfharvesters; public vector evadeDirection; - + public int numberOfFunctionalRefinery; public economyManagerAI(baseInfo theBaseInfo){ this.theBaseInfo = theBaseInfo; @@ -26,6 +27,19 @@ public class economyManagerAI { } public void processAI(){ + //find the number of functional refinery, (refinery with depleted gold mine are not considered functional) + numberOfFunctionalRefinery = 0; + refinery[] refineries = mainThread.theAssetManager.refineries; + for(int i = 0; i < refineries.length; i++) { + if(refineries[i] != null && refineries[i].teamNo == 1 && refineries[i].currentHP> 0) { + if(refineries[i].nearestGoldMine != null && refineries[i].nearestGoldMine.goldDeposite > 0) + numberOfFunctionalRefinery++; + } + + + } + + //find an ideal goldmine goldMine[] goldMines = mainThread.theAssetManager.goldMines; constructionYard[] constructionYards = mainThread.theAssetManager.constructionYards; diff --git a/enemyAI/unitProductionAI.java b/enemyAI/unitProductionAI.java index cc4fc20..2903ada 100644 --- a/enemyAI/unitProductionAI.java +++ b/enemyAI/unitProductionAI.java @@ -191,6 +191,15 @@ public class unitProductionAI { } } } + + if(mainThread.ec.theEconomyManagerAI.numberOfharvesters > 6 && theBaseInfo.currentCredit > 1500) { + if(!communicationCenter.harvesterSpeedResearched_enemy) { + if(communicationCenter.harvesterSpeedResearchProgress_enemy == 255){ + communicationCenter.researchHarvesterSpeed(1); + System.out.println("----------------------------AI starts researching harvester speed ability------------------------------------"); + } + } + } } if(mainThread.ec.theBuildingManagerAI.theBaseInfo.numberOfTechCenter > 0){ diff --git a/entity/lightTank.java b/entity/lightTank.java index 285533a..299aba2 100644 --- a/entity/lightTank.java +++ b/entity/lightTank.java @@ -853,7 +853,7 @@ public class lightTank extends solidObject{ for(int j = 0; j < 4; j++){ if(tile[j] != null){ if(tile[j].teamNo != teamNo && tile[j].teamNo != -1 && tile[j].currentHP > 0 && !tile[j].isCloaked){ - if(tile[j].type < 100){ + if(tile[j].type < 100 || tile[j].type >= 199){ attack(tile[j]); currentCommand = attackInNumbers; return; diff --git a/entity/stealthTank.java b/entity/stealthTank.java index 794356a..92e80c1 100644 --- a/entity/stealthTank.java +++ b/entity/stealthTank.java @@ -1113,7 +1113,7 @@ public class stealthTank extends solidObject{ for(int j = 0; j < 4; j++){ if(tile[j] != null){ if(tile[j].teamNo != teamNo && tile[j].teamNo != -1 && tile[j].currentHP > 0 && !tile[j].isCloaked){ - if(tile[j].type < 100){ + if(tile[j].type < 100 || tile[j].type >= 199){ attack(tile[j]); currentCommand = attackInNumbers; return; diff --git a/particles/bullet.java b/particles/bullet.java index e97f5e9..3e2bd56 100644 --- a/particles/bullet.java +++ b/particles/bullet.java @@ -100,7 +100,6 @@ public class bullet { public void updateAndDraw(){ if(!isInAction) return; - distanceToTarget -= speed; if(distanceToTarget < 0){ @@ -118,6 +117,7 @@ public class bullet { int start = xPos/16 + (127 - yPos/16)*128; int targetTeamNo = target.teamNo; solidObject[] tile; + solidObject o; for(int i = 0; i < 9; i++){ int index = start + tiles3x3[i]; @@ -125,12 +125,17 @@ public class bullet { continue; tile = mainThread.gridMap.tiles[index]; for(int j = 0; j < 4; j++){ - if(tile[j] != null){ - if(tile[j].teamNo == targetTeamNo && tile[j].teamNo!= attacker.teamNo && tile[j].attackStatus != solidObject.isAttacking && tile[j].currentCommand != solidObject.move && tile[j].isCloaked == false - && previousUnderAttackCountDown <=30 && (tile[j].currentCommand == solidObject.StandBy || tile[j].secondaryCommand == solidObject.attackMove)){ - if(tile[j].type < 100){ - tile[j].attack(attacker); - tile[j].currentCommand = solidObject.attackCautiously; + o = tile[j]; + if(o != null){ + if(o.teamNo == targetTeamNo + && o.teamNo!= attacker.teamNo + && (o.attackStatus != solidObject.isAttacking || (o.attackStatus == solidObject.isAttacking && o.secondaryCommand == solidObject.attackMove && (o.targetObject == null || o.targetObject.type > 100) )) + && o.currentCommand != solidObject.move && o.isCloaked == false + && previousUnderAttackCountDown <=30 + && (o.currentCommand == solidObject.StandBy || o.secondaryCommand == solidObject.attackMove)){ + if(o.type < 100){ + o.attack(attacker); + o.currentCommand = solidObject.attackCautiously; } }