Skip to content

Commit

Permalink
Improved build, research, and power management.
Browse files Browse the repository at this point in the history
- Use SemperFi-JS's base structure build decisions.
- Tweak research to favor Twin-MG more early game.
- Fix Cobra barely researching anything becuase manufacturing and research power requirements
were to steep. Instead, favor manufacturing much more during the first three minutes.
  • Loading branch information
KJeff01 committed Jun 26, 2019
1 parent e6be9d9 commit 550a07c
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 22 deletions.
8 changes: 5 additions & 3 deletions multiplay/skirmish/Cobra.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,22 @@ const CYBORG_ARMOR = [
"R-Cyborg-Armor-Heat09",
];
const ESSENTIALS = [
"R-Sys-Engineering01",
"R-Wpn-MG-Damage01",
"R-Defense-Tower01",
"R-Wpn-MG2Mk1",
"R-Wpn-MG-Damage02",
"R-Struc-PowerModuleMk1",
"R-Struc-Research-Upgrade01",
];
const ESSENTIALS_2 = [
"R-Vehicle-Prop-Halftracks",
"R-Struc-RprFac-Upgrade01",
"R-Sys-Sensor-Upgrade01",
"R-Vehicle-Body11",
"R-Vehicle-Prop-Hover",
"R-Sys-Sensor-Upgrade01",
"R-Struc-Power-Upgrade03a",
"R-Struc-Research-Upgrade09",
"R-Sys-Autorepair-General",
"R-Vehicle-Prop-Hover",
"R-Struc-Factory-Upgrade09",
];
const SYSTEM_UPGRADES = [
Expand Down
64 changes: 50 additions & 14 deletions multiplay/skirmish/cobra_includes/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,19 +482,19 @@ function buildPhase1()
{
return true;
}
if (!researchComplete && countAndBuild(structures.labs, 1))
if (!researchComplete && countAndBuild(structures.labs, 2))
{
return true;
}
if (countAndBuild(structures.gens, 1))
if (countAndBuild(structures.gens, 2))
{
return true;
}
if (!researchComplete && countAndBuild(structures.labs, 2))
if (countAndBuild(structures.hqs, 1))
{
return true;
}
if (countAndBuild(structures.hqs, 1))
if (!researchComplete && countAndBuild(structures.labs, 3))
{
return true;
}
Expand Down Expand Up @@ -541,18 +541,47 @@ function buildPhase1()
//Build factories.
function factoryBuildOrder()
{
const MIN_FACTORY_COUNT = 2;
if (getRealPower() < MIN_POWER)
{
return false;
}

const MIN_FACTORY_COUNT = 1;
const MAX_FACTORY_COUNT = 5;

for (var i = 0; i < 3; ++i)
{
var fac = subPersonalities[personality].factoryOrder[i];

if ((fac === VTOL_FACTORY && !useVtol) || (fac === CYBORG_FACTORY && (turnOffCyborgs || forceHover)))
{
continue;
}

//Try building two of each before finishing on of the factoryOrder paths.
if ((getRealPower() > MIN_POWER || countStruct(fac) < MIN_FACTORY_COUNT) && countStruct(fac) < MAX_FACTORY_COUNT && countAndBuild(fac, countStruct(structures.gens)))
var derrNum = countStruct(structures.derricks);
var facNum = countStruct(fac);
if (derrNum >= 20)
{
num = 5;
}
else if (derrNum >= 16)
{
num = 4;
}
else if (derrNum >= 12)
{
num = 3;
}
else if (derrNum >= 8)
{
num = 2;
}
else
{
num = MIN_FACTORY_COUNT;
}

if (facNum < num && facNum < MAX_FACTORY_COUNT && countAndBuild(fac, countStruct(structures.gens)))
{
return true;
}
Expand All @@ -563,21 +592,27 @@ function factoryBuildOrder()

function researchBuildOrder()
{
var gens = countStruct(structures.gens);
var labs = countStruct(structures.labs);
var seaMap = turnOffCyborgs || forceHover;
if (getRealPower() > MIN_POWER && !researchComplete && countStruct(structures.labs) < 5)
const MAX_LAB_COUNT = 5;

if (getRealPower() > MIN_POWER && !researchComplete && labs < MAX_LAB_COUNT)
{
if ((!seaMap && countAndBuild(structures.labs, gens + 1)) || (seaMap && countAndBuild(structures.labs, gens + 2)))
var amount = 3;
var derrCount = countStruct(structures.derricks);

if (derrCount >= 12)
{
return true;
amount = 5;
}
//We have a lot of power, so build more.
if (getRealPower() > 280 && gameTime > 180000 && countAndBuild(structures.labs, labs + 1))
else if (amount >= 7)
{
amount = 4;
}
if (labs < amount && countAndBuild(structures.labs, amount))
{
return true;
}

}

return false;
Expand Down Expand Up @@ -679,6 +714,7 @@ function maintenance()
{
modList = [
{"mod": "A0PowMod1", "amount": 1, "structure": structures.gens},
{"mod": "A0FacMod1", "amount": 1, "structure": FACTORY},
{"mod": "A0ResearchModule1", "amount": 1, "structure": structures.labs},
{"mod": "A0FacMod1", "amount": 2, "structure": FACTORY},
{"mod": "A0FacMod1", "amount": 2, "structure": VTOL_FACTORY},
Expand Down
6 changes: 3 additions & 3 deletions multiplay/skirmish/cobra_includes/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@ function eventDroidBuilt(droid, struct)
if (isConstruct(droid.id))
{
//Combat engineesr are always base builders.
if (droid.body !== "CyborgLightBody" && enumGroup(oilGrabberGroup).length < MIN_TRUCKS - 3)
if (droid.body === "CyborgLightBody" || enumGroup(constructGroup).length < Math.floor(MIN_TRUCKS / 2))
{
groupAdd(oilGrabberGroup, droid);
groupAdd(constructGroup, droid);
}
else
{
groupAdd(constructGroup, droid);
groupAdd(oilGrabberGroup, droid);
}
}
else if (droid.droidType === DROID_SENSOR)
Expand Down
4 changes: 2 additions & 2 deletions multiplay/skirmish/cobra_includes/research.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ function research()
found = pursueResearch(lab, "R-Vehicle-Prop-Hover");
if (!found)
found = evalResearch(lab, techlist);
if (!found && random(100) < 25)
if (!found && random(100) < 20)
found = evalResearch(lab, ESSENTIALS_2);

if (!found && getRealPower() > MIN_POWER)
if (!found && getRealPower() > ((gameTime < 180000) ? MIN_POWER : SUPER_LOW_POWER))
{
if (!found && random(100) < 20)
found = evalResearch(lab, BODY_RESEARCH);
Expand Down

0 comments on commit 550a07c

Please sign in to comment.