From 4f7f64d80dec5f7e3fd959f9b502ca3198ee28cd Mon Sep 17 00:00:00 2001 From: Pan Date: Sun, 27 Jan 2019 00:06:48 +1300 Subject: [PATCH] home commit --- core/AssetManager.java | 4 ++-- enemyAI/baseExpensionAI.java | 6 ++++++ enemyAI/combatManagerAI.java | 20 ++++++++++++++++++++ enemyAI/defenseManagerAI.java | 2 ++ enemyAI/enemyCommander.java | 2 +- 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/core/AssetManager.java b/core/AssetManager.java index ef73f32..701368a 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); + stealthTank l = new stealthTank(new vector(i*0.25f+ 1.125f,-0.3f, 17.375f - 0.25f*j), 90, 0); + addStealthTank(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/enemyAI/baseExpensionAI.java b/enemyAI/baseExpensionAI.java index 0b5cc96..f4719fd 100644 --- a/enemyAI/baseExpensionAI.java +++ b/enemyAI/baseExpensionAI.java @@ -69,6 +69,7 @@ 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; @@ -159,6 +160,11 @@ public class baseExpensionAI { //move mcv to the next expension location if(myMCV != null){ + if(frameAI > 400 && frameAI < 550) { + mainThread.ec.theUnitProductionAI.rallyPoint.set(expensionGoldMine.centre.x, 0, expensionGoldMine.centre.z - 1.5f); + } + + isExpanding = true; if(myMCV.getDistance(expensionGoldMine) > 2 && !(myMCV.destinationX == expensionGoldMine.centre.x && myMCV.destinationY == expensionGoldMine.centre.z)){ myMCV.moveTo(expensionGoldMine.centre.x, expensionGoldMine.centre.z); diff --git a/enemyAI/combatManagerAI.java b/enemyAI/combatManagerAI.java index 5687320..3410346 100644 --- a/enemyAI/combatManagerAI.java +++ b/enemyAI/combatManagerAI.java @@ -54,6 +54,8 @@ public class combatManagerAI { public boolean staticDefenseAhead; + public boolean dealWithMajorThreat; + public combatManagerAI(baseInfo theBaseInfo){ this.theBaseInfo = theBaseInfo; @@ -238,6 +240,24 @@ public class combatManagerAI { } }else if(currentState == aggressing){ + //check if a major threat is found other than the current attack position + if(mainThread.ec.theDefenseManagerAI.majorThreatLocation.x != 0){ + float xPos = mainThread.ec.theDefenseManagerAI.majorThreatLocation.x; + float zPos = mainThread.ec.theDefenseManagerAI.majorThreatLocation.z; + float d1 = (attackPosition.x - combatCenterX)*(attackPosition.x - combatCenterX) + (attackPosition.z - combatCenterZ)*(attackPosition.z - combatCenterZ); + float d2 = (xPos - combatCenterX)*(xPos - combatCenterX) + (zPos - combatCenterZ)*(zPos - combatCenterZ); + if(d2 <= d1) { + attackPosition.set(xPos, 0, zPos); + } + dealWithMajorThreat = true; + }else { + if(dealWithMajorThreat == true) { + currentState = booming; + dealWithMajorThreat = false; + return; + } + } + attackDirection.set(attackPosition.x - combatCenterX, 0, attackPosition.z - combatCenterZ); distanceToTarget = attackDirection.getLength(); diff --git a/enemyAI/defenseManagerAI.java b/enemyAI/defenseManagerAI.java index d3003c3..18bb4a0 100644 --- a/enemyAI/defenseManagerAI.java +++ b/enemyAI/defenseManagerAI.java @@ -167,11 +167,13 @@ public class defenseManagerAI { //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)) { giveBackControlOfDefendersToCombatAI(); + majorThreatCooldown = 20; majorThreatLocation.set(mainPlayerForceLocation); }else { float d = playerForceIsMovingTwoardsBase(mainPlayerForceLocation, mainPlayerForceDirection); if(d != -1) { giveBackControlOfDefendersToCombatAI(); + majorThreatCooldown = 20; majorThreatLocation.set(mainPlayerForceLocation); majorThreatLocation.add(mainPlayerForceDirection, d); } diff --git a/enemyAI/enemyCommander.java b/enemyAI/enemyCommander.java index 1e779a1..62195c9 100644 --- a/enemyAI/enemyCommander.java +++ b/enemyAI/enemyCommander.java @@ -84,7 +84,7 @@ public class enemyCommander { public void thinkHardLikeHumanPlayer(){ - + //the order is important!! if(mainThread.frameIndex % 30 == 0){ theMapAwarenessAI.processAI(); }