home
This commit is contained in:
parent
362af1265c
commit
238d8a4697
@ -198,8 +198,8 @@ public class AssetManager {
|
||||
goldMines[3] = new goldMine(26f,-0.515f, 3.5f, 40000);
|
||||
goldMines[4] = new goldMine(29.75f,-0.515f, 30f, 30000);
|
||||
goldMines[5] = new goldMine(22.5f,-0.515f, 25.5f, 30000);
|
||||
goldMines[6] = new goldMine(15.5f,-0.515f, 17.75f, 45000);
|
||||
goldMines[7] = new goldMine(16.5f,-0.515f, 12.5f, 45000);
|
||||
goldMines[6] = new goldMine(15.5f,-0.515f, 17.75f, 50000);
|
||||
goldMines[7] = new goldMine(16.5f,-0.515f, 12.5f, 50000);
|
||||
|
||||
|
||||
//create trees from bitmap
|
||||
|
@ -493,7 +493,7 @@ public class mainThread extends JFrame implements KeyListener, ActionListener, M
|
||||
lastTime = thisTime;
|
||||
}
|
||||
sleepTime = 0;
|
||||
while(System.currentTimeMillis()-lastDraw<frameInterval){
|
||||
/*while(System.currentTimeMillis()-lastDraw<frameInterval){
|
||||
try {
|
||||
Thread.sleep(1);
|
||||
sleepTime++;
|
||||
@ -501,7 +501,7 @@ public class mainThread extends JFrame implements KeyListener, ActionListener, M
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
lastDraw=System.currentTimeMillis();
|
||||
}
|
||||
|
||||
|
@ -70,6 +70,8 @@ public class baseExpensionAI {
|
||||
expensionGoldMine = goldMines[expensionPiorityList[targetExpension]];
|
||||
|
||||
|
||||
|
||||
|
||||
//produce a total of 3 scout units, check if there are any stealth tank in the production
|
||||
numberOfActiveScout = 0;
|
||||
numberOfStealthTankScout = 0;
|
||||
|
@ -59,7 +59,7 @@ public class buildingManagerAI {
|
||||
public void addBuildingToQueue(int buildingType){
|
||||
//if the additional building will result in a lower power, then build power plant first
|
||||
if(buildingType != 101){
|
||||
if(theBaseInfo.currentPowerLevel <= constructionYard.getPowerConsumption(buildingType) + theBaseInfo.currentPowerConsumption && !powerPlantUnderConstruction){
|
||||
if(theBaseInfo.currentPowerLevel <= getPowerConsumption(buildingType) + theBaseInfo.currentPowerConsumption && !powerPlantUnderConstruction){
|
||||
addBuildingToQueue(101);
|
||||
return;
|
||||
}
|
||||
@ -532,5 +532,26 @@ public class buildingManagerAI {
|
||||
|
||||
}
|
||||
|
||||
public int getPowerConsumption(int buildingType){
|
||||
if(buildingType == 101)
|
||||
return -500;
|
||||
else if(buildingType == 102)
|
||||
return 150;
|
||||
else if(buildingType == 105)
|
||||
return 200;
|
||||
else if(buildingType == 106)
|
||||
return 250;
|
||||
else if(buildingType == 200)
|
||||
return 100;
|
||||
else if(buildingType == 199) {
|
||||
if(communicationCenter.rapidfireResearched_enemy)
|
||||
return 275;
|
||||
else
|
||||
return 200;
|
||||
}else if(buildingType == 107)
|
||||
return 400;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -240,6 +240,24 @@ public class combatManagerAI {
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < playerStructures.length; i++) {
|
||||
if(playerStructures[i] != null && playerStructures[i].currentHP > 0) {
|
||||
double d = Math.sqrt((combatCenterX - playerStructures[i].centre.x)*(combatCenterX - playerStructures[i].centre.x) + (combatCenterZ - playerStructures[i].centre.z)*(combatCenterZ - playerStructures[i].centre.z));
|
||||
if(d < 5){
|
||||
currentState = aggressing;
|
||||
attackDirection.set(playerStructures[i].centre.x - combatCenterX, 0, playerStructures[i].centre.z - combatCenterZ);
|
||||
attackDirection.unit();
|
||||
attackPosition.set(playerStructures[i].centre);
|
||||
|
||||
if(shouldDefenceAggressively)
|
||||
attackPosition.add(attackDirection);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -446,7 +464,7 @@ public class combatManagerAI {
|
||||
|
||||
float teamRadius = (float)Math.sqrt(mainThread.ec.theUnitProductionAI.numberOfCombatUnit)/2.5f;
|
||||
|
||||
if(distanceToTarget < 3 + teamRadius && unNeutralizedEntity != null){
|
||||
if(distanceToTarget < 3 + teamRadius && unNeutralizedEntity != null && !staticDefenseAhead){
|
||||
//adjust the attack location for better engagement
|
||||
playerForceCenter.set(0,0,0);
|
||||
int numOfPlayerUnitsInMinimap = 0;
|
||||
@ -523,16 +541,17 @@ public class combatManagerAI {
|
||||
}
|
||||
|
||||
//marching forward
|
||||
if((team[i].targetObject == null || team[i].targetObject.currentHP <=0) && !(team[i].currentMovementStatus == solidObject.hugRight || team[i].currentMovementStatus == solidObject.hugLeft)){
|
||||
if(team[i].targetObject == null || team[i].targetObject.currentHP <=0){
|
||||
|
||||
|
||||
|
||||
if(staticDefenseAhead) {
|
||||
if(team[i].type == 1)
|
||||
team[i].attackMoveTo(team[i].centre.x + attackDirection.x*teamRadius, team[i].centre.z + attackDirection.z*teamRadius);
|
||||
else
|
||||
else
|
||||
team[i].attackMoveTo(combatCenterX, combatCenterZ);
|
||||
}else {
|
||||
|
||||
}else if(!(team[i].currentMovementStatus == solidObject.hugRight || team[i].currentMovementStatus == solidObject.hugLeft)){
|
||||
|
||||
double d = Math.sqrt((team[i].centre.x - combatCenterX)*(team[i].centre.x - combatCenterX) + (team[i].centre.z - combatCenterZ)*(team[i].centre.z - combatCenterZ))*3;
|
||||
|
||||
@ -554,7 +573,7 @@ public class combatManagerAI {
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println(!playerForceIsMuchWeakerThanAI + " " + mainThread.ec.theMapAwarenessAI.playerAssetDestoryedCountDown);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -562,7 +581,7 @@ public class combatManagerAI {
|
||||
//make sure idle units are send to attack unNeutralized target
|
||||
if(unNeutralizedEntity != null){
|
||||
for(int i = 0; i < mainThread.ec.theUnitProductionAI.numberOfCombatUnit; i++){
|
||||
if(team[i] != null && team[i].currentHP > 0){
|
||||
if(team[i] != null && team[i].currentHP > 0 && !(team[i].type!= 1 && staticDefenseAhead)){
|
||||
if(team[i].currentCommand == solidObject.StandBy || (team[i].targetObject == null && (team[i].secondaryDestinationX != unNeutralizedEntity.centre.x || team[i].secondaryDestinationY != unNeutralizedEntity.centre.z))){
|
||||
float d = (team[i].centre.x - attackPosition.x)*(team[i].centre.x - attackPosition.x) + (team[i].centre.z - attackPosition.z)*(team[i].centre.z - attackPosition.z);
|
||||
if(d < 9){
|
||||
|
@ -72,13 +72,25 @@ public class defenseManagerAI {
|
||||
if(stealthTanksControlledByCombatAI[j] != null && stealthTanksControlledByCombatAI[j].currentHP == 80 && stealthTanksControlledByCombatAI[j].attackStatus != solidObject.isAttacking) {
|
||||
observers[i] = stealthTanksControlledByCombatAI[j];
|
||||
stealthTanksControlledByCombatAI[j] = null;
|
||||
float xPos = 21f;
|
||||
float xPos = 20f;
|
||||
float zPos = 30.5f;
|
||||
|
||||
if(i == 1) {
|
||||
xPos = 30f;
|
||||
zPos = 20f;
|
||||
}
|
||||
|
||||
|
||||
if(gameTime > 880) {
|
||||
xPos = 0.25f;
|
||||
zPos = 20.5f;
|
||||
|
||||
if(i == 1) {
|
||||
xPos = 18.75f;
|
||||
zPos = 5f;
|
||||
}
|
||||
}
|
||||
|
||||
observers[i].moveTo(xPos, zPos);
|
||||
observers[i].currentCommand = solidObject.move;
|
||||
observers[i].secondaryCommand = solidObject.StandBy;
|
||||
@ -106,6 +118,16 @@ public class defenseManagerAI {
|
||||
xPos = 20f;
|
||||
zPos = 24.5f;
|
||||
}
|
||||
|
||||
if(gameTime > 880) {
|
||||
if(gameTime%18 < 9) {
|
||||
xPos = 0.25f;
|
||||
zPos = 20.5f;
|
||||
}else {
|
||||
xPos = 5f;
|
||||
zPos = 20.5f;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -119,6 +141,16 @@ public class defenseManagerAI {
|
||||
zPos = 20f;
|
||||
}
|
||||
|
||||
if(gameTime > 880) {
|
||||
if(gameTime%14 < 7) {
|
||||
xPos = 18.75f;
|
||||
zPos = 5f;
|
||||
}else {
|
||||
xPos = 18.75f;
|
||||
zPos = 0.5f;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
observers[i].moveTo(xPos, zPos);
|
||||
observers[i].currentCommand = solidObject.move;
|
||||
@ -181,6 +213,9 @@ public class defenseManagerAI {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//take over controls of defenders from combat AI to deal with minor threat
|
||||
if(minorThreatLocation.x != 0 && numOfDefenders > 0) {
|
||||
takeOverDefendersFromCombatAI();
|
||||
@ -220,7 +255,24 @@ public class defenseManagerAI {
|
||||
}
|
||||
}
|
||||
|
||||
//System.out.println(numOfDefenders + " " + mainThread.ec.theMapAwarenessAI.numOfAIStructures);
|
||||
//check if AI needs to build static defenses
|
||||
/*
|
||||
build a gun turret when any of the following conditions are met:
|
||||
1. there is no threat detected and there are more than 1 construction yard, and there is no other gun turret being constructed at the same time
|
||||
2. there are threat detected and there is no other gun turret being constructed at the same time
|
||||
|
||||
build a missile turret when any of the following conditions are met:
|
||||
1. there is no threat detected and there are more than 1 construction yard, and there is no other missile turret being constructed at the same time
|
||||
2. there are threat detected and there is no other missile turret being constructed at the same time
|
||||
*/
|
||||
|
||||
|
||||
|
||||
//check if AI needs to deploy static defense
|
||||
/*
|
||||
Deploy gun turret if the threat location if
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -243,7 +243,7 @@ public class mapAwarenessAI {
|
||||
for(int i = 0; i < theAssetManager.constructionVehicles.length; i++){
|
||||
if(theAssetManager.constructionVehicles[i] != null && theAssetManager.constructionVehicles[i].teamNo ==0){
|
||||
if(visionMap[theAssetManager.constructionVehicles[i].occupiedTile0]){
|
||||
//addPlayerUnitInMinimap(theAssetManager.constructionVehicles[i]);
|
||||
addPlayerUnitInMinimap(theAssetManager.constructionVehicles[i]);
|
||||
mapAsset[theAssetManager.constructionVehicles[i].ID] = theAssetManager.constructionVehicles[i];
|
||||
}
|
||||
}
|
||||
@ -417,7 +417,7 @@ public class mapAwarenessAI {
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(mapAsset[i].attacker.teamNo != 0) {
|
||||
if(mapAsset[i].attacker != null && mapAsset[i].attacker.teamNo != 0) {
|
||||
if(mapAsset[i].type < 100)
|
||||
numberOfPlayerUnitDestroyed++;
|
||||
else
|
||||
|
@ -73,6 +73,8 @@ public class unitProductionAI {
|
||||
public void processAI(){
|
||||
frameAI++;
|
||||
|
||||
System.out.println(frameAI);
|
||||
|
||||
//set the rally point to near the construction yard which is closest to the AI player's starting position
|
||||
float x = 0;
|
||||
float z = 999999;
|
||||
@ -138,7 +140,8 @@ public class unitProductionAI {
|
||||
}
|
||||
|
||||
//make decision on what unit to produce
|
||||
int numberOfPlayerTurrets= mainThread.ec.theMapAwarenessAI.numberOfMissileTurret_player + mainThread.ec.theMapAwarenessAI.numberOfGunTurret_player;
|
||||
int numberOfPlayerGunTurrets= mainThread.ec.theMapAwarenessAI.numberOfGunTurret_player;
|
||||
int numberOfPlayerMissileTurrets= mainThread.ec.theMapAwarenessAI.numberOfMissileTurret_player;
|
||||
int numberOfLightTanks_player = mainThread.ec.theMapAwarenessAI.numberOfLightTanks_player;
|
||||
int numberOfRocketTanks_player = mainThread.ec.theMapAwarenessAI.numberOfRocketTanks_player;
|
||||
int numberOfStealthTanks_player = mainThread.ec.theMapAwarenessAI.numberOfStealthTanks_player;
|
||||
@ -152,14 +155,14 @@ public class unitProductionAI {
|
||||
boolean playerDoesntHaveMassHeavyTanks = mainThread.ec.theMapAwarenessAI.playerDoesntHaveMassHeavyTanks;
|
||||
boolean playerHasManyLightTanksButNoHeavyTank = mainThread.ec.theMapAwarenessAI.playerHasManyLightTanksButNoHeavyTank;
|
||||
|
||||
if(numberOfRocketTanks_AI < numberOfPlayerTurrets || (gameData.getRandom() > 925 && !playerHasMostlyLightTanks)){
|
||||
if((numberOfRocketTanks_AI < 2 && frameAI > 300 ) || numberOfRocketTanks_AI < numberOfPlayerGunTurrets + numberOfPlayerMissileTurrets*1.5 || (gameData.getRandom() > 925 && !playerHasMostlyLightTanks)){
|
||||
currentProductionOrder = produceRocketTank;
|
||||
}else if(theBaseInfo.canBuildHeavyTank
|
||||
&& !playerHasManyLightTanksButNoHeavyTank
|
||||
&& !playerHasMostlyLightTanks
|
||||
&& !(numberOfHeavyTanks_player == 0 && maxNumberOfStealthTanks_playerInLastFiveMinutes < 3 && mainThread.frameIndex/30 > 600)
|
||||
&& !(playerHasMostlyHeavyTanks && numberOfStealthTanks_player < numberOfHeavyTanks_AI*2)
|
||||
&& (playIsRushingHighTierUnits || gameData.getRandom() > 985 || maxNumberOfStealthTanks_playerInLastFiveMinutes*4 > numberOfHeavyTanks_AI || (mainThread.frameIndex/30 > 400 && mainThread.frameIndex/30 < 600 && numberOfPlayerTurrets + numberOfLightTanks_player + numberOfRocketTanks_player + numberOfHeavyTanks_player*5 < 5))){
|
||||
&& (playIsRushingHighTierUnits || gameData.getRandom() > 985 || maxNumberOfStealthTanks_playerInLastFiveMinutes*4 > numberOfHeavyTanks_AI || (mainThread.frameIndex/30 > 400 && mainThread.frameIndex/30 < 600 && numberOfPlayerGunTurrets + numberOfPlayerMissileTurrets+ numberOfLightTanks_player + numberOfRocketTanks_player + numberOfHeavyTanks_player*5 < 5))){
|
||||
currentProductionOrder = produceHeavyTank;
|
||||
}else if(theBaseInfo.canBuildStealthTank && (playerHasMostlyLightTanks || playerLikelyCanNotProduceHighTierUnits || playerDoesntHaveMassHeavyTanks) && !playerHasMostlyHeavyTanks){
|
||||
currentProductionOrder = produceStealthTank;
|
||||
@ -194,11 +197,11 @@ public class unitProductionAI {
|
||||
|
||||
//System.out.println("enemy light tank count: " + numberOfLightTanks_player + " at " + mainThread.frameIndex/30);
|
||||
if(currentProductionOrder == produceStealthTank)
|
||||
System.out.println("should make stealth tank now");
|
||||
if(currentProductionOrder == produceHeavyTank){
|
||||
System.out.println("should make stealth tank now--------------");
|
||||
if(currentProductionOrder == produceHeavyTank)
|
||||
System.out.println("should make Heavy tank now-----------------");
|
||||
}
|
||||
|
||||
if(currentProductionOrder == produceRocketTank)
|
||||
System.out.println("should make Rocket tank now----------------");
|
||||
|
||||
|
||||
if(numberOfRocketTanks_AI > 5 && theBaseInfo.currentCredit > 750){
|
||||
|
@ -1718,23 +1718,7 @@ public class constructionYard extends solidObject{
|
||||
|
||||
}
|
||||
|
||||
public static int getPowerConsumption(int buildingType){
|
||||
if(buildingType == 101)
|
||||
return -500;
|
||||
else if(buildingType == 102)
|
||||
return 150;
|
||||
else if(buildingType == 105)
|
||||
return 200;
|
||||
else if(buildingType == 106)
|
||||
return 250;
|
||||
else if(buildingType == 200)
|
||||
return 100;
|
||||
else if(buildingType == 199)
|
||||
return 200;
|
||||
else if(buildingType == 107)
|
||||
return 400;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//draw the model
|
||||
|
@ -249,7 +249,6 @@ public class lightTank extends solidObject{
|
||||
|
||||
//update and draw model
|
||||
public void update(){
|
||||
|
||||
|
||||
//check if tank has been destroyed
|
||||
if(currentHP <= 0){
|
||||
|
Loading…
x
Reference in New Issue
Block a user