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 myRallyPointX, myRallyPointZ;
public boolean rallyPointChanged;
boolean shouldDefenceAggressively;
public float unrevealedPlayerForceStrength;
public int noPlayerActivityCountdown;
@ -118,7 +116,7 @@ public class combatManagerAI {
unitOutsideCombatRadius = mainThread.ec.theUnitProductionAI.unitOutsideCombatRadius;
troopsControlledByCombatAI = mainThread.ec.theUnitProductionAI.troopsControlledByCombatAI;
playerUnitInMinimap = mainThread.ec.theMapAwarenessAI.playerUnitInMinimap;
shouldDefenceAggressively = checkIfAIHasBiggerForce(1.6f);
@ -155,7 +153,6 @@ public class combatManagerAI {
unitCountLow = (numberOfLightTanks_AI + numberOfRocketTanks_AI + numberOfStealthTanks_AI + numberOfHeavyTanks_AI * 2 < 9) && frameAI > 480;
if(currentState == booming){
//enemy AI compares its own force with player's force, then make a decision whether it should attack or not
int attackTime = standardAttackTime;
if(mainThread.ec.theMapAwarenessAI.canRushPlayer)
@ -248,8 +245,6 @@ public class combatManagerAI {
attackDirection.unit();
attackPosition.set(playerUnitInMinimap[i].centre);
if(shouldDefenceAggressively)
attackPosition.add(attackDirection);
return;
}
@ -265,9 +260,6 @@ public class combatManagerAI {
attackDirection.unit();
attackPosition.set(playerStructures[i].centre);
if(shouldDefenceAggressively)
attackPosition.add(attackDirection);
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){
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);
@ -377,7 +381,7 @@ public class combatManagerAI {
//check if the player force has become stronger than the AI during the marching towards attack position
//System.out.println("distanceToTarget: " + distanceToTarget);
if(checkIfAIHasBiggerForce(1.5f) == false && distanceToTarget > 6){
if(checkIfAIHasBiggerForce(1.5f) == false && distanceToTarget > 8){
playerHasBecomeStrongerThanAIDuringMarching = true;
}
@ -441,12 +445,25 @@ public class combatManagerAI {
if(withdrawUnitOutsideCombatRadiusCooldown > 0){
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
if(troopsControlledByCombatAI[i] != null && troopsControlledByCombatAI[i].currentHP > 0){
troopsControlledByCombatAI[i].attackMoveTo(mainThread.ec.theUnitProductionAI.rallyPoint.x, mainThread.ec.theUnitProductionAI.rallyPoint.z);
troopsControlledByCombatAI[i].currentCommand = solidObject.attackMove;
troopsControlledByCombatAI[i].secondaryCommand = solidObject.attackMove;
//retreat tail portion of the troops to rally point
//but if the player's force is near the rally point, send tail portion of the troops to defend the rally point
float x = mainThread.ec.theMapAwarenessAI.mainPlayerForceLocation.x;
float z = mainThread.ec.theMapAwarenessAI.mainPlayerForceLocation.z;
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;
}
System.out.println(gatherPoint);
boolean playerForceIsMuchWeakerThanAI = checkIfAIHasBiggerForce(0.5f);
for(int i = 0; i < mainThread.ec.theUnitProductionAI.numberOfCombatUnit; i++){

View File

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

View File

@ -24,6 +24,7 @@ public class harassmentAI {
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(){
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;
}
}

View File

@ -109,10 +109,8 @@ public class unitProductionAI {
}
}
if(z != 999999) {
if(mainThread.ec.theCombatManagerAI.shouldDefenceAggressively && frameAI > 480)
rallyPoint.set(z - 2.5f, 0, z - 2.5f);
else
rallyPoint.set(x - 2f, 0, z - 1.5f);
rallyPoint.set(x - 2f, 0, z - 1.5f);
if(frameAI < 240) {
rallyPoint.set(mainThread.theAssetManager.goldMines[5].centre);
@ -188,7 +186,7 @@ public class unitProductionAI {
//make decision on what tech to research
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.rapidfireResearchProgress_enemy == 255){
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.lightTankResearchProgress_enemy >= 240 && techCenter.stealthTankResearchProgress_enemy >= 240 && techCenter.rocketTankResearchProgress_enemy >= 240 && techCenter.heavyTankResearchProgress_enemy >= 240){