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 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);
addLightTank(l);
//lightTank l = new lightTank(new vector(i*0.25f+ 1.125f,-0.3f, 17.375f - 0.25f*j), 90, 0);
//addLightTank(l);
//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);

View File

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