home commit

This commit is contained in:
Pan 2019-01-20 23:11:22 +13:00
parent eb21e15d51
commit 525e28bfc3
2 changed files with 22 additions and 10 deletions

View File

@ -212,6 +212,15 @@ public class combatManagerAI {
} }
} }
} }
//check if defenceManager found a major threat
if(mainThread.ec.theDefenseManagerAI.majorThreatLocation.screenX != 0) {
currentState = aggressing;
attackDirection.set(mainThread.ec.theDefenseManagerAI.majorThreatLocation.x - combatCenterX, 0, mainThread.ec.theDefenseManagerAI.majorThreatLocation.z - combatCenterZ);
attackDirection.unit();
attackPosition.set(mainThread.ec.theDefenseManagerAI.majorThreatLocation);
return;
}
} }
if(currentState != aggressing) { if(currentState != aggressing) {

View File

@ -30,6 +30,7 @@ public class defenseManagerAI {
public vector minorThreatLocation; public vector minorThreatLocation;
public vector majorThreatLocation; public vector majorThreatLocation;
public int majorThreatCooldown;
public defenseManagerAI(baseInfo theBaseInfo){ public defenseManagerAI(baseInfo theBaseInfo){
@ -44,7 +45,7 @@ public class defenseManagerAI {
minorThreatLocation = new vector(0,0,0); minorThreatLocation = new vector(0,0,0);
majorThreatLocation = new vector(0,0,0); majorThreatLocation = new vector(0,0,0);
majorThreatCooldown = 20;
} }
@ -55,6 +56,9 @@ public class defenseManagerAI {
public void processAI(){ public void processAI(){
gameTime++; gameTime++;
if(majorThreatCooldown > 0)
majorThreatCooldown --;
currentState = mainThread.ec.theCombatManagerAI.currentState; currentState = mainThread.ec.theCombatManagerAI.currentState;
stealthTanksControlledByCombatAI = mainThread.ec.theUnitProductionAI.stealthTanksControlledByCombatAI; stealthTanksControlledByCombatAI = mainThread.ec.theUnitProductionAI.stealthTanksControlledByCombatAI;
@ -95,12 +99,12 @@ public class defenseManagerAI {
//if there is no player units in sight, return to patrol position //if there is no player units in sight, return to patrol position
if(i == 0) { if(i == 0) {
if(gameTime%30 < 15) { if(gameTime%28 < 14) {
xPos = 19f; xPos = 20f;
zPos = 30.5f; zPos = 30.5f;
}else { }else {
xPos = 19f; xPos = 20f;
zPos = 22.5f; zPos = 24.5f;
} }
} }
@ -130,12 +134,11 @@ public class defenseManagerAI {
int mainPlayerForceSize = mainThread.ec.theMapAwarenessAI.mainPlayerForceSize; int mainPlayerForceSize = mainThread.ec.theMapAwarenessAI.mainPlayerForceSize;
minorThreatLocation.reset(); minorThreatLocation.reset();
majorThreatLocation.reset(); if(majorThreatCooldown == 0)
majorThreatLocation.reset();
System.out.println(playerForceIsMovingTwoardsBase(mainPlayerForceLocation, mainPlayerForceDirection));
// if the size of the player unit cluster is less than 5, and no heavy tanks in the cluster, then borrow some unites from combatAI to deal with the threat // if the size of the player unit cluster is less than 5, and no heavy tanks in the cluster, then borrow some unites from combatAI to deal with the threat
if(mainPlayerForceSize < 5 && mainPlayerForceSize>0) { if(mainPlayerForceSize < 7 && mainPlayerForceSize>0) {
//check if base is attacked by long ranged units //check if base is attacked by long ranged units
boolean attackedByRocketTank = false; boolean attackedByRocketTank = false;
int numOfHeavyTanks = numOfHeavyTankAroundLocation(mainPlayerForceLocation); int numOfHeavyTanks = numOfHeavyTankAroundLocation(mainPlayerForceLocation);
@ -160,7 +163,7 @@ public class defenseManagerAI {
majorThreatLocation.set(mainPlayerForceLocation); majorThreatLocation.set(mainPlayerForceLocation);
} }
} }
}else if(mainPlayerForceSize >= 5){ }else if(mainPlayerForceSize >= 7){
//if the size of player unit cluster is bigger or equal to 5 then check if the threat is a big one //if the size of player unit cluster is bigger or equal to 5 then check if the threat is a big one
if(playerForceIsNearBase(mainPlayerForceLocation)) { if(playerForceIsNearBase(mainPlayerForceLocation)) {
giveBackControlOfDefendersToCombatAI(); giveBackControlOfDefendersToCombatAI();