This commit is contained in:
Pan 2019-04-23 10:42:59 +12:00
parent 1c9bbd5f84
commit f090ad038b
5 changed files with 47 additions and 29 deletions

View File

@ -47,8 +47,6 @@ public class combatManagerAI {
public float combatCenterX, combatCenterZ; public float combatCenterX, combatCenterZ;
public float myRallyPointX, myRallyPointZ; public float myRallyPointX, myRallyPointZ;
public boolean rallyPointChanged; public boolean rallyPointChanged;
boolean shouldDefenceAggressively;
public float unrevealedPlayerForceStrength; public float unrevealedPlayerForceStrength;
public int noPlayerActivityCountdown; public int noPlayerActivityCountdown;
@ -118,7 +116,7 @@ public class combatManagerAI {
unitOutsideCombatRadius = mainThread.ec.theUnitProductionAI.unitOutsideCombatRadius; unitOutsideCombatRadius = mainThread.ec.theUnitProductionAI.unitOutsideCombatRadius;
troopsControlledByCombatAI = mainThread.ec.theUnitProductionAI.troopsControlledByCombatAI; troopsControlledByCombatAI = mainThread.ec.theUnitProductionAI.troopsControlledByCombatAI;
playerUnitInMinimap = mainThread.ec.theMapAwarenessAI.playerUnitInMinimap; playerUnitInMinimap = mainThread.ec.theMapAwarenessAI.playerUnitInMinimap;
shouldDefenceAggressively = checkIfAIHasBiggerForce(1.6f);
@ -154,8 +152,7 @@ public class combatManagerAI {
int numberOfHeavyTanks_AI = mainThread.ec.theUnitProductionAI.numberOfHeavyTanksControlledByCombatAI; int numberOfHeavyTanks_AI = mainThread.ec.theUnitProductionAI.numberOfHeavyTanksControlledByCombatAI;
unitCountLow = (numberOfLightTanks_AI + numberOfRocketTanks_AI + numberOfStealthTanks_AI + numberOfHeavyTanks_AI * 2 < 9) && frameAI > 480; unitCountLow = (numberOfLightTanks_AI + numberOfRocketTanks_AI + numberOfStealthTanks_AI + numberOfHeavyTanks_AI * 2 < 9) && frameAI > 480;
if(currentState == booming){ if(currentState == booming){
//enemy AI compares its own force with player's force, then make a decision whether it should attack or not //enemy AI compares its own force with player's force, then make a decision whether it should attack or not
int attackTime = standardAttackTime; int attackTime = standardAttackTime;
if(mainThread.ec.theMapAwarenessAI.canRushPlayer) if(mainThread.ec.theMapAwarenessAI.canRushPlayer)
@ -247,9 +244,7 @@ public class combatManagerAI {
attackDirection.set(playerUnitInMinimap[i].centre.x - combatCenterX, 0, playerUnitInMinimap[i].centre.z - combatCenterZ); attackDirection.set(playerUnitInMinimap[i].centre.x - combatCenterX, 0, playerUnitInMinimap[i].centre.z - combatCenterZ);
attackDirection.unit(); attackDirection.unit();
attackPosition.set(playerUnitInMinimap[i].centre); attackPosition.set(playerUnitInMinimap[i].centre);
if(shouldDefenceAggressively)
attackPosition.add(attackDirection);
return; return;
} }
@ -265,9 +260,6 @@ public class combatManagerAI {
attackDirection.unit(); attackDirection.unit();
attackPosition.set(playerStructures[i].centre); attackPosition.set(playerStructures[i].centre);
if(shouldDefenceAggressively)
attackPosition.add(attackDirection);
return; return;
} }
} }
@ -313,10 +305,22 @@ public class combatManagerAI {
} }
} }
//if a rush tactics is denied by the player (e.g player builds static defenses around natural), then change status to booming //if a rush tactics is denied by the player (e.g player builds static defenses around natural), then call back the troops that were sent to rush the player
if(frameAI < standardAttackTime && !mainThread.ec.theMapAwarenessAI.canRushPlayer){ if(frameAI < standardAttackTime && !mainThread.ec.theMapAwarenessAI.canRushPlayer){
currentState = booming;
return; if(Math.abs(attackPosition.x - myRallyPointX) > 12 || Math.abs(attackPosition.z - myRallyPointZ) > 12) {
for(int i = 0; i < troopsControlledByCombatAI.length; i++) {
if(troopsControlledByCombatAI[i] != null && troopsControlledByCombatAI[i].currentHP > 0) {
troopsControlledByCombatAI[i].attackMoveTo(myRallyPointX, myRallyPointZ);
troopsControlledByCombatAI[i].currentCommand = solidObject.attackMove;
troopsControlledByCombatAI[i].secondaryCommand = solidObject.attackMove;
}
}
currentState = booming;
return;
}
} }
attackDirection.set(attackPosition.x - combatCenterX, 0, attackPosition.z - combatCenterZ); attackDirection.set(attackPosition.x - combatCenterX, 0, attackPosition.z - combatCenterZ);
@ -377,7 +381,7 @@ public class combatManagerAI {
//check if the player force has become stronger than the AI during the marching towards attack position //check if the player force has become stronger than the AI during the marching towards attack position
//System.out.println("distanceToTarget: " + distanceToTarget); //System.out.println("distanceToTarget: " + distanceToTarget);
if(checkIfAIHasBiggerForce(1.5f) == false && distanceToTarget > 6){ if(checkIfAIHasBiggerForce(1.5f) == false && distanceToTarget > 8){
playerHasBecomeStrongerThanAIDuringMarching = true; playerHasBecomeStrongerThanAIDuringMarching = true;
} }
@ -441,12 +445,25 @@ public class combatManagerAI {
if(withdrawUnitOutsideCombatRadiusCooldown > 0){ if(withdrawUnitOutsideCombatRadiusCooldown > 0){
team = unitInCombatRadius; //exclude the tail portion of the troops from the attack force team = unitInCombatRadius; //exclude the tail portion of the troops from the attack force
for(int i = 0; i < troopsControlledByCombatAI.length; i++){
//send the tail portion of the troops to rally point //retreat tail portion of the troops to rally point
if(troopsControlledByCombatAI[i] != null && troopsControlledByCombatAI[i].currentHP > 0){ //but if the player's force is near the rally point, send tail portion of the troops to defend the rally point
troopsControlledByCombatAI[i].attackMoveTo(mainThread.ec.theUnitProductionAI.rallyPoint.x, mainThread.ec.theUnitProductionAI.rallyPoint.z); float x = mainThread.ec.theMapAwarenessAI.mainPlayerForceLocation.x;
troopsControlledByCombatAI[i].currentCommand = solidObject.attackMove; float z = mainThread.ec.theMapAwarenessAI.mainPlayerForceLocation.z;
troopsControlledByCombatAI[i].secondaryCommand = solidObject.attackMove; double d = Math.sqrt((x-myRallyPointX)*(x-myRallyPointX) + (z-myRallyPointZ)*(z-myRallyPointZ));
for(int i = 0; i < unitOutsideCombatRadius.length; i++){
if(unitOutsideCombatRadius[i] != null && unitOutsideCombatRadius[i].currentHP > 0){
if(d > 3.5) {
unitOutsideCombatRadius[i].attackMoveTo(mainThread.ec.theUnitProductionAI.rallyPoint.x, mainThread.ec.theUnitProductionAI.rallyPoint.z);
}else {
unitOutsideCombatRadius[i].attackMoveTo(x, z);
}
unitOutsideCombatRadius[i].currentCommand = solidObject.attackMove;
unitOutsideCombatRadius[i].secondaryCommand = solidObject.attackMove;
} }
} }
} }
@ -580,6 +597,8 @@ public class combatManagerAI {
break; break;
} }
System.out.println(gatherPoint);
boolean playerForceIsMuchWeakerThanAI = checkIfAIHasBiggerForce(0.5f); boolean playerForceIsMuchWeakerThanAI = checkIfAIHasBiggerForce(0.5f);
for(int i = 0; i < mainThread.ec.theUnitProductionAI.numberOfCombatUnit; i++){ for(int i = 0; i < mainThread.ec.theUnitProductionAI.numberOfCombatUnit; i++){

View File

@ -64,7 +64,7 @@ public class enemyCommander {
thinkHardLikeHumanPlayer(); thinkHardLikeHumanPlayer();
//drawVisionMap(); drawVisionMap();
//reset tempBitmap; //reset tempBitmap;
for(int i = 0 ;i < tempBitmap.length; i++){ for(int i = 0 ;i < tempBitmap.length; i++){

View File

@ -24,6 +24,7 @@ public class harassmentAI {
gameTime++; gameTime++;
System.out.println(gameTime + " (" + mainThread.ec.theCombatManagerAI.combatCenterX + " " + mainThread.ec.theCombatManagerAI.combatCenterZ + ") " + mainThread.ec.theCombatManagerAI.attackPosition);
} }

View File

@ -339,7 +339,7 @@ public class scoutingManagerAI {
public boolean needStealthTank(){ public boolean needStealthTank(){
if(theBaseInfo.canBuildStealthTank){ if(theBaseInfo.canBuildStealthTank){
if((scout == null || scout.currentHP <= 0 || scout.type != 6) && gameTime > 480){ if((scout == null || scout.currentHP <= 0 || scout.type != 6) && gameTime > 380){
return true; return true;
} }
} }

View File

@ -109,10 +109,8 @@ public class unitProductionAI {
} }
} }
if(z != 999999) { if(z != 999999) {
if(mainThread.ec.theCombatManagerAI.shouldDefenceAggressively && frameAI > 480)
rallyPoint.set(z - 2.5f, 0, z - 2.5f); rallyPoint.set(x - 2f, 0, z - 1.5f);
else
rallyPoint.set(x - 2f, 0, z - 1.5f);
if(frameAI < 240) { if(frameAI < 240) {
rallyPoint.set(mainThread.theAssetManager.goldMines[5].centre); rallyPoint.set(mainThread.theAssetManager.goldMines[5].centre);
@ -188,7 +186,7 @@ public class unitProductionAI {
//make decision on what tech to research //make decision on what tech to research
if(mainThread.ec.theBuildingManagerAI.theBaseInfo.numberOfCommunicationCenter > 0) { if(mainThread.ec.theBuildingManagerAI.theBaseInfo.numberOfCommunicationCenter > 0) {
if(mainThread.ec.theDefenseManagerAI.needMissileTurret || theBaseInfo.currentCredit > 1500) { if(mainThread.ec.theDefenseManagerAI.needMissileTurret || theBaseInfo.currentCredit > 1500 && frameAI > 450) {
if(!communicationCenter.rapidfireResearched_enemy) { if(!communicationCenter.rapidfireResearched_enemy) {
if(communicationCenter.rapidfireResearchProgress_enemy == 255){ if(communicationCenter.rapidfireResearchProgress_enemy == 255){
communicationCenter.researchRapidfire(1); communicationCenter.researchRapidfire(1);
@ -237,7 +235,7 @@ public class unitProductionAI {
} }
} }
if(numberOfRocketTanks_AI > 2 && theBaseInfo.currentCredit > 750 && (numberOfPlayerGunTurrets > 0 || numberOfPlayerMissileTurrets > 0)){ if(numberOfRocketTanks_AI > 2 && theBaseInfo.currentCredit > 1250 && (numberOfPlayerGunTurrets > 0 || numberOfPlayerMissileTurrets > 0 || frameAI > 600)){
if(!techCenter.rocketTankResearched_enemy){ if(!techCenter.rocketTankResearched_enemy){
if(techCenter.lightTankResearchProgress_enemy >= 240 && techCenter.stealthTankResearchProgress_enemy >= 240 && techCenter.rocketTankResearchProgress_enemy >= 240 && techCenter.heavyTankResearchProgress_enemy >= 240){ if(techCenter.lightTankResearchProgress_enemy >= 240 && techCenter.stealthTankResearchProgress_enemy >= 240 && techCenter.rocketTankResearchProgress_enemy >= 240 && techCenter.heavyTankResearchProgress_enemy >= 240){