Skip to content

Commit

Permalink
Fix VTOL swarms and AA building
Browse files Browse the repository at this point in the history
VTOLs would pile together and chase targets without any ammo.
Make AA site building come a bit earlier.
  • Loading branch information
KJeff01 authored Jul 12, 2017
1 parent 49f7169 commit 0f0f2a7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
20 changes: 9 additions & 11 deletions multiplay/skirmish/cobra_includes/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,14 @@ function buildSensors() {
}
}

//Builds an AA site for the personality. It will always use strombringer AA
//Builds an AA site for the personality. It will always use stormbringer AA
//once available.
function buildAAForPersonality() {
var vtolCount = countEnemyVTOL();

//Use stormbringer if we have it.
if(isStructureAvailable("P0-AASite-Laser")) {
if(countAndBuild("P0-AASite-Laser", Math.floor(vtolCount / 2))) {
if(countAndBuild("P0-AASite-Laser", Math.floor(vtolCount / 3))) {
return true;
}
}
Expand All @@ -276,7 +276,7 @@ function buildAAForPersonality() {

for(var i = aaType.length - 1; i >= 0; --i) {
if(isStructureAvailable(aaType[i].stat)) {
if(countAndBuild(aaType[i].stat, Math.floor(vtolCount / 2))) {
if(countAndBuild(aaType[i].stat, Math.floor(vtolCount / 3))) {
return true;
}
}
Expand All @@ -288,16 +288,10 @@ function buildAAForPersonality() {

//Build defense systems.
function buildDefenses() {
const MIN_GAME_TIME = 600000;

if(protectUnguardedDerricks()) {
return true;
}

if((gameTime > MIN_GAME_TIME) && buildSensors()) {
return true;
}

return false;
}

Expand Down Expand Up @@ -408,10 +402,14 @@ function buildPhase3() {
return false;
}

//Laser satellite/uplink center
//AA sites and Laser satellite/uplink center
function buildSpecialStructures() {
const MIN_POWER = 80;

if(buildAAForPersonality()) {
return true;
}

for(var i = 1, l = structures.extras.length; i < l; ++i) {
if((playerPower(me) > MIN_POWER) && isStructureAvailable(structures.extras[i])) {
if(countAndBuild(structures.extras[i], 1)) {
Expand Down Expand Up @@ -456,7 +454,7 @@ function buildOrder() {
if(buildSpecialStructures()) { return; }
lookForOil();
if(buildPhase2()) { return; }
if(buildAAForPersonality()) { return; }
if((gameTime > 600000) && buildSensors()) { return; }
if((getRealPower() < -300) || (countStruct(structures.derricks) < averageOilPerPlayer())) { return; }
if(buildPhase3()) { return; }
if(buildDefenses()) { return; }
Expand Down
4 changes: 2 additions & 2 deletions multiplay/skirmish/cobra_includes/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function eventDroidIdle(droid) {
var enemyObjects = enumRange(droid.x, droid.y, 14, ENEMIES, false);
if(isDefined(enemyObjects[0])) {
enemyObjects = enemyObjects.sort(distanceToBase);
orderDroidLoc(droid, DORDER_SCOUT, enemyObjects[0].x, enemyObjects[0].y);
attackThisObject(droid, enemyObjects[0]);
}
}
}
Expand Down Expand Up @@ -154,7 +154,7 @@ function eventAttacked(victim, attacker) {
}
}

units = units.filter(function(dr) { return (!repairDroid(dr) && droidCanReach(dr, attacker.x, attacker.y)); });
units = units.filter(function(dr) { return ((isVTOL(dr) && droidReady(dr)) || (!repairDroid(dr)) && droidCanReach(dr, attacker.x, attacker.y)); });
var cacheUnits = units.length;

if(cacheUnits >= MIN_ATTACK_DROIDS) {
Expand Down
3 changes: 1 addition & 2 deletions multiplay/skirmish/cobra_includes/research.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,9 @@ function evalResearch(lab, list) {
return found;
}


function eventResearched() {
const MIN_POWER = -130;
if((getRealPower() < MIN_POWER) || !isDefined(techlist) || !isDefined(turnOffMG) || !isDefined(turnOffCyborgs)) {
if((getRealPower() < MIN_POWER) || !(isDefined(techlist) && isDefined(turnOffMG) && isDefined(turnOffCyborgs))) {
return;
}

Expand Down

0 comments on commit 0f0f2a7

Please sign in to comment.