diff --git a/multiplay/skirmish/cobra_includes/adaption.js b/multiplay/skirmish/cobra_includes/adaption.js index e080aa7..fc0dd5a 100644 --- a/multiplay/skirmish/cobra_includes/adaption.js +++ b/multiplay/skirmish/cobra_includes/adaption.js @@ -8,7 +8,7 @@ function switchOffMG() { } var len = subpersonalities[personality].primaryWeapon.weapons.length; - if(isDesignable(subpersonalities[personality].primaryWeapon.weapons[len - 1].stat)) { + if(isDesignable(subpersonalities[personality].primaryWeapon.weapons[len - 1].stat) || (playerAlliance(true).length > 0)) { turnOffMG = true; removeThisTimer("switchOffMG"); } @@ -42,10 +42,10 @@ function adaptToMap() { const T3_MATCH = isDesignable("Howitzer03-Rot"); const ADAPT_PERSONALITIES = ["AM", "AR", "AB", "AC", "AL"]; - if(!T3_MATCH && (((maxPlayers - 1) === 1) || (MAP_OIL_LEVEL === "LOW") || (baseType === CAMP_CLEAN))) { + if(!T3_MATCH && (((maxPlayers - 1) === 1) || ((MAP_OIL_LEVEL === "LOW") && !ALLY_COUNT))) { choice = ADAPT_PERSONALITIES[random(3)]; // AM, AR, AB. } - else if ((MAP_OIL_LEVEL === "MEDIUM") || ((ALLY_COUNT !== 0) && (ALLY_COUNT < ENEMY_COUNT))) { + else if ((MAP_OIL_LEVEL === "MEDIUM") || ALLY_COUNT) { var offset = (T3_MATCH && (baseType !== CAMP_CLEAN)) ? 4 : 3; choice = ADAPT_PERSONALITIES[random(offset) + 1]; // AR, AB, AC, AL. } diff --git a/multiplay/skirmish/cobra_includes/build.js b/multiplay/skirmish/cobra_includes/build.js index dd7a9b7..4475108 100644 --- a/multiplay/skirmish/cobra_includes/build.js +++ b/multiplay/skirmish/cobra_includes/build.js @@ -233,7 +233,7 @@ function checkUnfinishedStructures() { //Look for oil. function lookForOil() { - var droids = (gameTime < 10000) ? enumGroup(constructGroup) : enumGroup(oilGrabberGroup); + var droids = (gameTime < 15000) ? enumDroid(me, DROID_CONSTRUCT) : enumGroup(oilGrabberGroup); var oils = enumFeature(-1, oilResources).sort(distanceToBase); // grab closer oils first var s = 0; var success = false; @@ -319,7 +319,7 @@ function buildAAForPersonality() { //Build defense systems. function buildDefenses() { - const MIN_POWER = 30; + const MIN_POWER = 90; if((gameTime > 120000) && (getRealPower() > MIN_POWER)) { if(buildSensors()) { @@ -338,12 +338,11 @@ function buildDefenses() { function buildPhase1() { //if a hover map without land enemies, then build research labs first to get to hover propulsion even faster if(!forceHover || seaMapWithLandEnemy) { - if(countAndBuild(FACTORY, 1)) { + if(countAndBuild(FACTORY, 2)) { return true; } - var res = (baseType !== CAMP_CLEAN) ? 2 : 1; - if(!researchComplete && countAndBuild(structures.labs, res)) { + if(!researchComplete && countAndBuild(structures.labs, 1)) { return true; } @@ -365,16 +364,12 @@ function buildPhase1() { return true; } - if(countAndBuild(FACTORY, 2)) { - return true; - } - return false; } //Build at least one of each factory and then pursue the favorite factory. function factoryBuildOrder() { - const MIN_POWER = 80; + const MIN_POWER = 200; if(getRealPower() < MIN_POWER) { return false; } @@ -399,28 +394,28 @@ function factoryBuildOrder() { //Build all research labs and one of each factory and pursue the decided factory order. //Build repair bays when possible. function buildPhase2() { - const MIN_POWER = 30; - const MIN_TIME = 150000; + const MIN_POWER = 250; + const MIN_TIME = 180000; if(!countStruct(structures.gens) || (getRealPower() < MIN_POWER)) { return true; } + if(!researchComplete && countAndBuild(structures.labs, 2)) { + return true; + } + if(gameTime > MIN_TIME) { - if(!researchComplete && countAndBuild(structures.labs, 5)) { + if(random(3) && countAndBuild(structures.extras[0], 5)) { return true; } - if(countAndBuild(FACTORY, 2)) { + if(!researchComplete && countAndBuild(structures.labs, 5)) { return true; } if (factoryBuildOrder()) { return true; } - - if(countAndBuild(structures.extras[0], 5)) { - return true; - } } return false; @@ -443,7 +438,7 @@ function buildSpecialStructures() { //Build the minimum repairs and any vtol pads. function buildExtras() { - const MIN_POWER = 30; + const MIN_POWER = 70; if(!isStructureAvailable("A0PowMod1") || (gameTime < 80000) || (getRealPower() < MIN_POWER)) { return false; } @@ -467,39 +462,39 @@ function buildOrder() { if(enemyUnitsInBase()) { return; } if(buildSpecialStructures()) { return; } if(buildExtras()) { return; } - if(!lookForOil()) { buildDefenses(); } + lookForOil(); if(buildPhase2()) { return; } + buildDefenses(); } //Check if a building has modules to be built function maintenance() { - const list = ["A0PowMod1", "A0ResearchModule1", "A0FacMod1", "A0FacMod1"]; - const mods = [1, 1, 2, 2]; //Number of modules paired with list above - var cacheList = list.length; + const LIST = ["A0PowMod1", "A0FacMod1", "A0ResearchModule1", "A0FacMod1"]; + const MODS = [1, 2, 1, 2]; //Number of modules paired with list above var struct = null, module = "", structList = []; if(countStruct(structures.derricks) < 4) { return false; } - for (var i = 0; i < cacheList; ++i) { - if (isStructureAvailable(list[i])) { + for (var i = 0, l = LIST.length; i < l; ++i) { + if (isStructureAvailable(LIST[i])) { if(struct !== null) { break; } switch(i) { case 0: { structList = enumStruct(me, structures.gens).sort(distanceToBase); break; } - case 1: { structList = enumStruct(me, structures.labs).sort(distanceToBase); break; } - case 2: { structList = enumStruct(me, FACTORY).sort(distanceToBase); break; } + case 1: { structList = enumStruct(me, FACTORY).sort(distanceToBase); break; } + case 2: { structList = enumStruct(me, structures.labs).sort(distanceToBase); break; } case 3: { structList = enumStruct(me, VTOL_FACTORY).sort(distanceToBase); break; } default: { break; } } for (var c = 0, s = structList.length; c < s; ++c) { - if (structList[c].modules < mods[i]) { + if (structList[c].modules < MODS[i]) { //Only build the last factory module if we have a heavy body if(structList[c].modules === 1) { - if((i === 2) && !componentAvailable("Body11ABT")) { + if((i === 1) && !componentAvailable("Body11ABT")) { continue; } //Build last vtol factory module once Cobra gets retribution (or has good power levels) @@ -508,7 +503,7 @@ function maintenance() { } } struct = structList[c]; - module = list[i]; + module = LIST[i]; break; } } diff --git a/multiplay/skirmish/cobra_includes/events.js b/multiplay/skirmish/cobra_includes/events.js index 33114f4..290cfe8 100644 --- a/multiplay/skirmish/cobra_includes/events.js +++ b/multiplay/skirmish/cobra_includes/events.js @@ -85,7 +85,7 @@ function eventDroidIdle(droid) { function eventDroidBuilt(droid, struct) { if (droid) { if(isConstruct(droid)) { - if(!isDefined(enumGroup(constructGroup)[3])) { + if(enumGroup(constructGroup).length < 3) { groupAdd(constructGroup, droid); queue("checkUnfinishedStructures", 2500); } @@ -212,7 +212,6 @@ function eventBeacon(x, y, from, to, message) { return; } - if(allianceExistsBetween(from, to) || (to === from)) { var cyborgs = enumGroup(cyborgGroup); var tanks = enumGroup(attackGroup); diff --git a/multiplay/skirmish/cobra_includes/globalVariables.js b/multiplay/skirmish/cobra_includes/globalVariables.js index db92f24..f507f8c 100644 --- a/multiplay/skirmish/cobra_includes/globalVariables.js +++ b/multiplay/skirmish/cobra_includes/globalVariables.js @@ -20,7 +20,7 @@ const subpersonalities = { "artillery": weaponStats.howitzers, "antiAir": weaponStats.AA, //cannons_AA is too weak. "factoryOrder": [FACTORY, CYBORG_FACTORY, VTOL_FACTORY], - "peaceChance": 70, + "peaceChance": 100, "defensePriority": 10, "vtolPriority": 20, "systemPriority": 30, @@ -66,7 +66,7 @@ const subpersonalities = { "artillery": weaponStats.mortars, "antiAir": weaponStats.AA, "factoryOrder": [FACTORY, CYBORG_FACTORY, VTOL_FACTORY], - "peaceChance": 40, + "peaceChance": 80, "defensePriority": 30, "vtolPriority": 80, "systemPriority": 45, @@ -81,7 +81,7 @@ const subpersonalities = { "artillery": weaponStats.fireMortars, "antiAir": weaponStats.AA, "factoryOrder": [VTOL_FACTORY, FACTORY, CYBORG_FACTORY], - "peaceChance": 55, + "peaceChance": 75, "defensePriority": 10, "vtolPriority": 60, "systemPriority": 40, diff --git a/multiplay/skirmish/cobra_includes/miscFunctions.js b/multiplay/skirmish/cobra_includes/miscFunctions.js index fa34c8a..04de178 100644 --- a/multiplay/skirmish/cobra_includes/miscFunctions.js +++ b/multiplay/skirmish/cobra_includes/miscFunctions.js @@ -11,6 +11,11 @@ function isDefined(data) { return (typeof(data) !== "undefined"); } +//Determine if a game object is destroyed or not. +function isObjectAlive(object) { + return (isDefined(object) && object && (object.id !== 0)); +} + //Sort an array from smallest to largest in value. function sortArrayNumeric(a, b) { return (a - b); @@ -162,24 +167,6 @@ function diffPerks() { } } -//See if we can design this droid. Mostly used for checking for new weapons with the NIP. -function isDesignable(item, body, prop) { - if(!isDefined(item)) { - return false; - } - - if(!isDefined(body)) { - body = "Body1REC"; - } - - if(!isDefined(prop)) { - prop = "wheeled01"; - } - - var virDroid = makeTemplate(me, "Virtual Droid", body, prop, "", "", item, item); - return (virDroid !== null); -} - //See if power levels are low. This takes account of only the power obtained from the generators. function checkLowPower(pow) { if(!isDefined(pow)) { @@ -307,7 +294,7 @@ function countEnemyVTOL() { var enemies = findLivingEnemies(); var enemyVtolCount = 0; - for (var x = 0, e = enemies.length; x < e; ++x) { + for(var x = 0, e = enemies.length; x < e; ++x) { enemyVtolCount += enumDroid(enemies[x]).filter(function(obj) { return isVTOL(obj); }).length; diff --git a/multiplay/skirmish/cobra_includes/production.js b/multiplay/skirmish/cobra_includes/production.js index 2637494..d24089c 100644 --- a/multiplay/skirmish/cobra_includes/production.js +++ b/multiplay/skirmish/cobra_includes/production.js @@ -38,6 +38,24 @@ const repairTurrets = [ "LightRepair1", ]; +//See if we can design this droid. Mostly used for checking for new weapons with the NIP. +function isDesignable(item, body, prop) { + if(!isDefined(item)) { + return false; + } + + if(!isDefined(body)) { + body = "Body1REC"; + } + + if(!isDefined(prop)) { + prop = "wheeled01"; + } + + var virDroid = makeTemplate(me, "Virtual Droid", body, prop, "", "", item, item); + return (virDroid !== null); +} + //Pick a random weapon line. May return undefined for machineguns. function chooseRandomWeapon() { var weaps; @@ -52,7 +70,7 @@ function chooseRandomWeapon() { default: weaps = subpersonalities[personality].primaryWeapon; break; } - if(!isDefined(weaps) || (returnPrimaryAlias() !== "las")) { + if(!isDefined(weaps)) { weaps = subpersonalities[personality].primaryWeapon; } @@ -341,7 +359,7 @@ function produce() { return; } - const MIN_POWER = -20; + const MIN_POWER = 30; const MIN_TRUCKS = 5; const MIN_COM_ENG = 3; const MIN_SENSORS = 2; @@ -369,10 +387,10 @@ function produce() { if(buildTrucks) { buildSys(fac[x], "Spade1Mk1"); } - else if(buildSensors) { + else if(buildSensors && componentAvailable("SensorTurret1Mk1")) { buildSys(fac[x]); } - else if(allowSpecialSystems && buildRepairs) { + else if(allowSpecialSystems && buildRepairs && componentAvailable("LightRepair1")) { buildSys(fac[x], repairTurrets); } else { diff --git a/multiplay/skirmish/cobra_includes/research.js b/multiplay/skirmish/cobra_includes/research.js index 260dced..4dd0a36 100644 --- a/multiplay/skirmish/cobra_includes/research.js +++ b/multiplay/skirmish/cobra_includes/research.js @@ -19,15 +19,15 @@ const ESSENTIALS = [ "R-Struc-Power-Upgrade03a", "R-Vehicle-Prop-Halftracks", "R-Vehicle-Body05", - "R-Vehicle-Body04", + "R-Struc-RprFac-Upgrade01", "R-Vehicle-Prop-Hover", + "R-Vehicle-Body04", ]; const SYSTEM_UPGRADES = [ - "R-Struc-RprFac-Upgrade01", "R-Sys-Sensor-Upgrade03", - "R-Struc-Factory-Upgrade09", "R-Sys-MobileRepairTurretHvy", + "R-Struc-Factory-Upgrade09", "R-Sys-Autorepair-General", "R-Struc-RprFac-Upgrade06", ]; @@ -72,7 +72,7 @@ const MID_GAME_TECH = [ "R-Wpn-Bomb04", "R-Wpn-Bomb-Accuracy02", "R-Struc-VTOLPad-Upgrade04", - "R-Defense-WallUpgrade05", + "R-Defense-WallUpgrade03", ]; const LATE_EARLY_GAME_TECH = [ @@ -153,7 +153,7 @@ function evalResearch(lab, list) { } function eventResearched() { - const MIN_POWER = -30; + const MIN_POWER = -10; if((gameTime < 2000) || (getRealPower() < MIN_POWER) || !(isDefined(techlist) && isDefined(turnOffMG) && isDefined(turnOffCyborgs))) { return; } @@ -171,13 +171,6 @@ function eventResearched() { if(!found) found = evalResearch(lab, techlist); - if(!turnOffMG || (returnPrimaryAlias() === "mg")) { - if(!found) - found = pursueResearch(lab, mgWeaponTech); - if(!found) - found = pursueResearch(lab, "R-Wpn-MG-Damage08"); - } - if(!found) found = evalResearch(lab, SYSTEM_UPGRADES); @@ -207,6 +200,13 @@ function eventResearched() { } } + if(!turnOffMG || (returnPrimaryAlias() === "mg")) { + if(!found) + found = pursueResearch(lab, mgWeaponTech); + if(!found) + found = pursueResearch(lab, "R-Wpn-MG-Damage08"); + } + if(!found && !turnOffCyborgs) found = evalResearch(lab, cyborgWeaps); if(!found) @@ -224,12 +224,13 @@ function eventResearched() { found = evalResearch(lab, DEFENSE_UPGRADES); } + if(!found) + found = evalResearch(lab, MID_GAME_TECH); + if(!found) found = evalResearch(lab, artilleryTech); if(!found) found = evalResearch(lab, extraTech); - if(!found) - found = evalResearch(lab, MID_GAME_TECH); if(!found) found = evalResearch(lab, BODY_RESEARCH);