diff --git a/core/AssetManager.java b/core/AssetManager.java index b624d26..f6e5b4b 100644 --- a/core/AssetManager.java +++ b/core/AssetManager.java @@ -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); diff --git a/core/mainThread.java b/core/mainThread.java index 36ad951..83b31a4 100644 --- a/core/mainThread.java +++ b/core/mainThread.java @@ -493,7 +493,7 @@ public class mainThread extends JFrame implements KeyListener, ActionListener, M lastTime = thisTime; } sleepTime = 0; - /*while(System.currentTimeMillis()-lastDraw 0) { - if(mainThread.ec.theMapAwarenessAI.playerStaticDefenseStrength[i] > 5) { + if(mainThread.ec.theMapAwarenessAI.playerStaticDefenseStrength[i] > 6) { float xPos = mainThread.ec.theMapAwarenessAI.playerStaticDefenseLocations[i].x; float zPos = mainThread.ec.theMapAwarenessAI.playerStaticDefenseLocations[i].z; float d = (xPos - combatCenterX)*(xPos - combatCenterX) + (zPos - combatCenterZ)*(zPos - combatCenterZ); diff --git a/enemyAI/defenseManagerAI.java b/enemyAI/defenseManagerAI.java index e5a8ffe..71681e3 100644 --- a/enemyAI/defenseManagerAI.java +++ b/enemyAI/defenseManagerAI.java @@ -6,6 +6,7 @@ import core.vector; import entity.lightTank; import entity.solidObject; import entity.stealthTank; +import entity.constructionYard; public class defenseManagerAI { public baseInfo theBaseInfo; @@ -32,6 +33,9 @@ public class defenseManagerAI { public vector majorThreatLocation; public int majorThreatCooldown; + public vector gunTurretDeployLocation; + public vector missileTurretDeployLocation; + public defenseManagerAI(baseInfo theBaseInfo){ this.theBaseInfo = theBaseInfo; @@ -46,6 +50,9 @@ public class defenseManagerAI { minorThreatLocation = new vector(0,0,0); majorThreatLocation = new vector(0,0,0); majorThreatCooldown = 20; + + gunTurretDeployLocation = new vector(0,0,0); + missileTurretDeployLocation = new vector(0,0,0); } @@ -266,13 +273,50 @@ public class defenseManagerAI { 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 - */ + Deploy gun turret if the minor/major threat is close enough to the construction yard + */ + solidObject[] AIStructures = mainThread.ec.theMapAwarenessAI.AIStructures; + gunTurretDeployLocation.reset(); + missileTurretDeployLocation.reset(); + + constructionYard[] constructionYards = mainThread.theAssetManager.constructionYards; + for(int i = 0; i < constructionYards.length; i++){ + if(constructionYards[i] != null && constructionYards[i].teamNo != 0 && constructionYards[i].currentHP >0) { + + float distanceToThreat = 999f; + + + float threatX = 0; + float threatZ = 0; + + if(minorThreatLocation.x !=0) { + distanceToThreat = (float)Math.sqrt((minorThreatLocation.x-constructionYards[i].centre.x)*(minorThreatLocation.x-constructionYards[i].centre.x) + + (minorThreatLocation.z-constructionYards[i].centre.z)*(minorThreatLocation.z-constructionYards[i].centre.z)); + threatX = minorThreatLocation.x; + threatZ = minorThreatLocation.z; + } + + if(majorThreatLocation.x !=0) { + distanceToThreat = (float)Math.sqrt((majorThreatLocation.x-constructionYards[i].centre.x)*(majorThreatLocation.x-constructionYards[i].centre.x) + + (majorThreatLocation.z-constructionYards[i].centre.z)*(majorThreatLocation.z-constructionYards[i].centre.z)); + threatX = majorThreatLocation.x; + threatZ = majorThreatLocation.z; + } + + //find deploy location of gun turret + if(threatX != 0 && distanceToThreat < 4.25) { + + //check the number of gun turrets that are already deployed near the threat location + } + + } + } } diff --git a/enemyAI/unitProductionAI.java b/enemyAI/unitProductionAI.java index d913eed..d6800bc 100644 --- a/enemyAI/unitProductionAI.java +++ b/enemyAI/unitProductionAI.java @@ -73,8 +73,6 @@ 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; diff --git a/particles/bullet.java b/particles/bullet.java index a7e5226..e97f5e9 100644 --- a/particles/bullet.java +++ b/particles/bullet.java @@ -109,6 +109,7 @@ public class bullet { movement.unit(); movement.scale(speed + distanceToTarget); target.currentHP -=damage; + int previousUnderAttackCountDown = target.underAttackCountDown; target.underAttackCountDown = 120; target.attacker = attacker; @@ -126,10 +127,10 @@ public class bullet { for(int j = 0; j < 4; j++){ if(tile[j] != null){ if(tile[j].teamNo == targetTeamNo && tile[j].teamNo!= attacker.teamNo && tile[j].attackStatus != solidObject.isAttacking && tile[j].currentCommand != solidObject.move && tile[j].isCloaked == false - && tile[j].currentCommand != solidObject.attackCautiously && tile[j].currentCommand != solidObject.attackInNumbers){ + && previousUnderAttackCountDown <=30 && (tile[j].currentCommand == solidObject.StandBy || tile[j].secondaryCommand == solidObject.attackMove)){ if(tile[j].type < 100){ tile[j].attack(attacker); - tile[j].currentCommand = solidObject.attackInNumbers; + tile[j].currentCommand = solidObject.attackCautiously; } }