T2 and T3 tech idea

Based on forum discussion here: http://forums.wz2100.net/viewtopic.php?f=35&t=9486

The cam2tech.vlo and cam3tech.vlo are excessively large files IMHO. Using JS API we should be able to find a way to shrink them down.

Also, it would be better if the T2 and T3 techs were applied in rules.js where the rest of Player Initialisation is handled, to keep everything in one place.

Here's my proposal...

1. Define goals, not paths

This is the quickest way to shrink down the number of lines required to define what techs we want for T2 and T3...

Hastily thrown together side-by-side example - compare line numbers (and the 'after' list could prolly be shrunk some more)...

Note: I was lazy and just did the T2 list as it was smaller than T3 list. It would be best to define the T3 goals, which would include T2 goals.

Before

var goals = [
  "R-Comp-CommandTurret01",
  "R-Comp-SynapticLink",
  "R-Cyborg-Legs01",
//  "R-Cyborg-Metals01",
//  "R-Cyborg-Metals02",
  "R-Cyborg-Metals03",
  "R-Cyborg-Wpn-Cannon",
  "R-Cyborg-Wpn-Flamer",
  "R-Cyborg-Wpn-MG",
  "R-Cyborg-Wpn-Rocket",
//  "R-Defense-HardcreteWall",
  "R-Defense-MortarPit",
  "R-Defense-MRL",
//  "R-Defense-Pillbox01",
//  "R-Defense-Pillbox04",
//  "R-Defense-Pillbox05",
  "R-Defense-Pillbox06",
  "R-Defense-TankTrap01",
  "R-Defense-Tower01",
  "R-Defense-Tower06",
  "R-Defense-WallTower01",
  "R-Defense-WallTower02",
  "R-Defense-WallTower03",
  "R-Defense-WallTower04",
  "R-Defense-WallTower06",
//  "R-Defense-WallUpgrade01",
//  "R-Defense-WallUpgrade02",
  "R-Defense-WallUpgrade03",
  "R-Struc-CommandRelay",
//  "R-Struc-Factory-Cyborg",
//  "R-Struc-Factory-Cyborg-Upgrade01",
//  "R-Struc-Factory-Cyborg-Upgrade02",
  "R-Struc-Factory-Cyborg-Upgrade03",
//  "R-Struc-Factory-Module",
//  "R-Struc-Factory-Upgrade01",
//  "R-Struc-Factory-Upgrade02",
  "R-Struc-Factory-Upgrade03",
//  "R-Struc-Materials01",
//  "R-Struc-Materials02",
  "R-Struc-Materials03",
  "R-Struc-PowerModuleMk1",
//  "R-Struc-RepairFacility",
//  "R-Struc-Research-Module",
//  "R-Struc-Research-Upgrade01",
//  "R-Struc-Research-Upgrade02",
  "R-Struc-Research-Upgrade03",
//  "R-Struc-RprFac-Upgrade01",
//  "R-Struc-RprFac-Upgrade02",
  "R-Struc-RprFac-Upgrade03",
  "R-Sys-CBSensor-Tower01",
//  "R-Sys-Engineering01",
//  "R-Sys-MobileRepairTurret01",
  "R-Sys-Sensor-Tower01",
//  "R-Sys-Sensor-Turret01",
  "R-Sys-Sensor-Upgrade01",
//  "R-Sys-Spade1Mk1",
  "R-Vehicle-Body01",
  "R-Vehicle-Body05",
  "R-Vehicle-Body11",
//  "R-Vehicle-Engine01",
//  "R-Vehicle-Engine02",
  "R-Vehicle-Engine03",
//  "R-Vehicle-Metals01",
//  "R-Vehicle-Metals02",
  "R-Vehicle-Metals03",
//  "R-Vehicle-Prop-Halftracks",
  "R-Vehicle-Prop-Hover",
  "R-Vehicle-Prop-Tracks",
//  "R-Vehicle-Prop-Wheels",
//  "R-Wpn-Cannon-Damage01",
//  "R-Wpn-Cannon-Damage02",
  "R-Wpn-Cannon-Damage03",
//  "R-Wpn-Cannon1Mk1",
//  "R-Wpn-Cannon2Mk1",
  "R-Wpn-Cannon3Mk1",
//  "R-Wpn-Flamer-Damage01",
//  "R-Wpn-Flamer-Damage02",
  "R-Wpn-Flamer-Damage03",
  "R-Wpn-Flamer-ROF01",
  "R-Wpn-Flamer01Mk1",
//  "R-Wpn-MG-Damage01",
//  "R-Wpn-MG-Damage02",
  "R-Wpn-MG-Damage03",
  "R-Defense-HvyMor",
  "R-Wpn-MG-ROF01",
//  "R-Wpn-MG1Mk1",
//  "R-Wpn-MG2Mk1",
  "R-Wpn-MG3Mk1",
//  "R-Wpn-Mortar-Damage01",
//  "R-Wpn-Mortar-Damage02",
  "R-Wpn-Mortar-Damage03",
  "R-Wpn-Mortar01Lt",
//  "R-Wpn-Rocket-Damage01",
//  "R-Wpn-Rocket-Damage02",
  "R-Wpn-Rocket-Damage03",
//  "R-Wpn-Rocket-ROF01",
  "R-Wpn-Rocket-ROF02",
  "R-Wpn-Rocket01-LtAT",
  "R-Wpn-Rocket02-MRL",
  "R-Wpn-Rocket05-MiniPod",
//  "R-Wpn-RocketSlow-Damage01",
//  "R-Wpn-RocketSlow-Damage02",
  "R-Wpn-RocketSlow-Damage03",
  "R-Vehicle-Body04",
  "R-Vehicle-Body08",
  "R-Wpn-Mortar02Hvy",
  "R-Wpn-AAGun03",
  "R-Sys-Sensor-Tower02",
  "R-Vehicle-Prop-VTOL",
  "R-Struc-VTOLFactory",
  "R-Struc-VTOLPad",
  "R-Wpn-Bomb01",
  "R-Defense-AASite-QuadMg1",
  "R-Cyborg-Sys-ComEng",
  "R-Cyborg-Sys-Mechanic",
  "R-Comp-CommandTurret02"
]

After

var goals = [
  "R-Comp-CommandTurret01",
  "R-Comp-SynapticLink",
  "R-Cyborg-Legs01",
  "R-Cyborg-Metals03",
  "R-Cyborg-Wpn-Cannon",
  "R-Cyborg-Wpn-Flamer",
  "R-Cyborg-Wpn-MG",
  "R-Cyborg-Wpn-Rocket",
  "R-Defense-MortarPit",
  "R-Defense-MRL",
  "R-Defense-Pillbox06",
  "R-Defense-TankTrap01",
  "R-Defense-Tower01",
  "R-Defense-Tower06",
  "R-Defense-WallTower01",
  "R-Defense-WallTower02",
  "R-Defense-WallTower03",
  "R-Defense-WallTower04",
  "R-Defense-WallTower06",
  "R-Defense-WallUpgrade03",
  "R-Struc-CommandRelay",
  "R-Struc-Factory-Cyborg-Upgrade03",
  "R-Struc-Factory-Upgrade03",
  "R-Struc-Materials03",
  "R-Struc-PowerModuleMk1",
  "R-Struc-Research-Upgrade03",
  "R-Struc-RprFac-Upgrade03",
  "R-Sys-CBSensor-Tower01",
  "R-Sys-MobileRepairTurret01",
  "R-Sys-Sensor-Tower01",
  "R-Sys-Sensor-Upgrade01",
  "R-Vehicle-Body01",
  "R-Vehicle-Body05",
  "R-Vehicle-Body11",
  "R-Vehicle-Engine03",
  "R-Vehicle-Metals03",
  "R-Vehicle-Prop-Hover",
  "R-Vehicle-Prop-Tracks",
  "R-Wpn-Cannon-Damage03",
  "R-Wpn-Cannon3Mk1",
  "R-Wpn-Flamer-Damage03",
  "R-Wpn-Flamer-ROF01",
  "R-Wpn-Flamer01Mk1",
  "R-Wpn-MG-Damage03",
  "R-Defense-HvyMor",
  "R-Wpn-MG-ROF01",
  "R-Wpn-MG3Mk1",
  "R-Wpn-Mortar-Damage03",
  "R-Wpn-Mortar01Lt",
  "R-Wpn-Rocket-Damage03",
  "R-Wpn-Rocket-ROF02",
  "R-Wpn-Rocket01-LtAT",
  "R-Wpn-Rocket02-MRL",
  "R-Wpn-Rocket05-MiniPod",
  "R-Wpn-RocketSlow-Damage03",
  "R-Vehicle-Body04",
  "R-Vehicle-Body08",
  "R-Wpn-Mortar02Hvy",
  "R-Wpn-AAGun03",
  "R-Sys-Sensor-Tower02",
  "R-Vehicle-Prop-VTOL",
  "R-Struc-VTOLFactory",
  "R-Struc-VTOLPad",
  "R-Wpn-Bomb01",
  "R-Defense-AASite-QuadMg1",
  "R-Cyborg-Sys-ComEng",
  "R-Cyborg-Sys-Mechanic",
  "R-Comp-CommandTurret02"
]

2. Determine paths & complete research

A key benefit of defining goals instead of paths is that if the tech tree structure is changed, we'll automatically determine the new paths to the goals.

Assuming 'goals' array contains all tech goals for all levels, we'd know what index in the array each level starts at.

T1 is already dealt with by rules.js, where things like baseType determine how many techs are gifted.

We could perhaps have T2 and T3 tech gifts altered by base type too?

In which case we'd need some way to determine where to splice the list of goals - possibly by finding the index by searching for a tech ID? ...As that would be better than hard-coding an index IMHO.

Anyway, for now, let's assume we just hard-code an index and that T0 has already been applied...

 var t3Start = 67; // or whatever index T3 starts at in 'goals' array
 
function applyTechLevelToAllPlayers() {
 
  if (techLevel < 2) return; // T1 already given by existing rules.js stuff
 
  if (techLevel == 2) { // need to splice list down to just T2 goals
    goals = goals.splice(0,t3Start-1);
  }
 
  // this will be master list of required techs to reach all goals
  var techList = [];
 
  // work out path to reach a goal
  function definePrereqs(goal) {
    var preReqs = findResearch(goal); // requires warzone 3.2
    // add preReqs & goal to techList
    techList = techList.concat(preReqs.concat(goal));
  }
 
  // now populate our techList
  goals.forEach(definePrereqs);
 
  // sort tech list alphabetically
  techList.sort();
 
  // used to filter dupes
  function duplicates(tech,idx,list) {
    return ( (idx+1 == list.length) || (tech != list[idx+1]) );
  }
 
  // filter dupes from the array
  techList = techList.filter(duplicates);
 
  // give a tech to all players
  function giveToAllPlayers(tech) {
    var player = maxPlayers;
    while (-1<--player) completeResearch(tech,player);
  }
 
  // now give techs to each player
  techList.forEach(giveToAllPlayers);
}

3. Further ponderance

IMHO there should be a big list of tech goals, up to T4 maybe?

There should be a certain goal that defines the end of each tech level, like this:

var techLevels = [
  "whatever", // last item in tech level 0 (scav tech)
  "R-Wpn-RocketSlow-Damage02", // last item in tech level 1
  "R-Wpn-RocketSlow-ROF02", // last item in tech level 2
  ... etc ...
]

This would make splicing the goals list easy - just specify the last tech of each level, then we slice the list to the desired tech.

After splicing list to get our tech, we could then further reduce it based on baseType setting so a T3 with CAMP_BASE would get less techs than a T3 with CAMP_WALLS.

The results would be a much more manageable list of goals, an easy way to define (using tech id) where each tech level starts, baseType setting affecting T2 and T3, the ability to have as many tech levels as desired, and no worries about getting research paths wrong.

Comments?

Please post feedback in the forums: http://forums.wz2100.net/viewtopic.php?f=35&t=9486