home commit

This commit is contained in:
Pan 2019-01-17 22:38:57 +13:00
parent 92ed7b523d
commit 7e64f1e650
2 changed files with 26 additions and 17 deletions

View File

@ -251,8 +251,8 @@ public class AssetManager {
for(int i = 0; i < 10; i ++){ for(int i = 0; i < 10; i ++){
for(int j = 0; j < 6; j++){ for(int j = 0; j < 6; j++){
lightTank l = new lightTank(new vector(i*0.25f+ 1.125f,-0.3f, 17.375f - 0.25f*j), 90, 0); //lightTank l = new lightTank(new vector(i*0.25f+ 1.125f,-0.3f, 17.375f - 0.25f*j), 90, 0);
addLightTank(l); //addLightTank(l);
//l.hasMultiShotUpgrade = true; //l.hasMultiShotUpgrade = true;
//lightTank l = new lightTank(new vector(i*0.25f + 1.125f,-0.3f, 0.5f + 18.625f + j*0.25f), 90, 0); //lightTank l = new lightTank(new vector(i*0.25f + 1.125f,-0.3f, 0.5f + 18.625f + j*0.25f), 90, 0);

View File

@ -134,24 +134,32 @@ public class defenseManagerAI {
if(mainPlayerForceSize < 5 && mainPlayerForceSize>0) { if(mainPlayerForceSize < 5 && 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;
for(int i = 0; i < mainThread.ec.theMapAwarenessAI.numOfAIStructures; i++) { int numOfHeavyTanks = numOfHeavyTankAroundLocation(mainPlayerForceLocation);
if(mainThread.ec.theMapAwarenessAI.AIStructures[i].underAttackCountDown > 0 && if(numOfHeavyTanks < 1) {
mainThread.ec.theMapAwarenessAI.AIStructures[i].attacker != null && for(int i = 0; i < mainThread.ec.theMapAwarenessAI.numOfAIStructures; i++) {
mainThread.ec.theMapAwarenessAI.AIStructures[i].attacker.currentHP > 0 && if(mainThread.ec.theMapAwarenessAI.AIStructures[i].underAttackCountDown > 0 &&
mainThread.ec.theMapAwarenessAI.AIStructures[i].attacker.type == 1) { mainThread.ec.theMapAwarenessAI.AIStructures[i].attacker != null &&
attackedByRocketTank = true; mainThread.ec.theMapAwarenessAI.AIStructures[i].attacker.currentHP > 0 &&
minorThreatLocation.set(mainThread.ec.theMapAwarenessAI.AIStructures[i].attacker.centre); mainThread.ec.theMapAwarenessAI.AIStructures[i].attacker.type == 1) {
break; attackedByRocketTank = true;
minorThreatLocation.set(mainThread.ec.theMapAwarenessAI.AIStructures[i].attacker.centre);
break;
}
} }
} }
if(!attackedByRocketTank && playerForceContainsNoHeavyTank(mainPlayerForceLocation) && playerForceIsNearBase(mainPlayerForceLocation)) { if(!attackedByRocketTank && playerForceIsNearBase(mainPlayerForceLocation)) {
if(numOfHeavyTanks < 1)
minorThreatLocation.set(mainPlayerForceLocation); minorThreatLocation.set(mainPlayerForceLocation);
System.out.println("SOS!"); else {
giveBackControlOfDefendersToCombatAI();
majorThreatLocation.set(mainPlayerForceLocation);
}
} }
}else if(mainPlayerForceSize >= 5){ }else if(mainPlayerForceSize >= 5){
//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) || playerForceIsMovingTwoardsBase(mainPlayerForceLocation, mainPlayerForceDirection))
} }
//take over controls of defenders from combat AI to deal with minor threat //take over controls of defenders from combat AI to deal with minor threat
@ -263,15 +271,16 @@ public class defenseManagerAI {
return false; return false;
} }
public boolean playerForceContainsNoHeavyTank(vector location) { public int numOfHeavyTankAroundLocation(vector location) {
solidObject o = null; solidObject o = null;
int numberOfHeaveyTankNearLocation = 0;
for(int i = 0; i < mainThread.ec.theMapAwarenessAI.playerUnitInMinimap.length; i++) { for(int i = 0; i < mainThread.ec.theMapAwarenessAI.playerUnitInMinimap.length; i++) {
o = mainThread.ec.theMapAwarenessAI.playerUnitInMinimap[i]; o = mainThread.ec.theMapAwarenessAI.playerUnitInMinimap[i];
if(o !=null && o.currentHP > 0 && o.type == 7 && (o.centre.x - location.x)*(o.centre.x - location.x) + (o.centre.z - location.z)*(o.centre.z - location.z) < 4) if(o !=null && o.currentHP > 0 && o.type == 7 && (o.centre.x - location.x)*(o.centre.x - location.x) + (o.centre.z - location.z)*(o.centre.z - location.z) < 4)
return false; numberOfHeaveyTankNearLocation++;
} }
return true; return numberOfHeaveyTankNearLocation;
} }
public void addUnitToDefenders(solidObject o) { public void addUnitToDefenders(solidObject o) {