GR - Subsystem Upgrades

Subsystem Upgrades are a combination of Tech Tree information, Upgrade stats information, an Picnums (mesh) information to represent upgrades in elements of a unit. Generally intended for space units in GR

Modules (SubSystems)
0 : Armour / Shielding

1 : Command (ie front section)

2 : Cargo (optional)

3 : Engines

4 : Weapons

Levels
0 (Base) / 1 / 2 / 3

Levels are optional, not all will have all levels

TechTree
Upgrades effect a Unit Class - every unit in class gets upgrade (in resv / new prod)

Using Tech Effect 500 - 755

Upgrade Levels per active unit are stored in CUnitList systemupgrade[] variable

Current maximum upgrade Levels stored in ruupgrades[player][Class/Subsystem]


 * Offset = classnum * 8 + subsystemnum
 * Supports up to 8 subsystems/modules, only 5 used at present

Upgrades triggered by research achievement


 * Each Unit Class in game supports 8 Upgrade systems (only 5 used)
 * Tech Effect increases are additive
 * We can upgrade through techs partially, ie 0.3 + 0.3 + 0.6 or through the final tech ie 0.0 + 0.0 + 1.0
 * Visual change only happens on whole numbers
 * Effect / spec improvements happen on partial upgrades, ie Interceptor Armour improvement by 0.5 will gain 50% of the spec benefit, even though a full level is not visible.
 * Improvements above 3.0 (maximum visual) are allowed but have no different effect than the 3.0 level
 * Examples:
 * Effect 500 would be for Infantry - Armour
 * Effect for Space Fighter, Engines would be 22*8 + 3 = 179 + 500
 * (Class 22, skip 8 elements each class, Engines is entry 3)

Affected Stats
Stored in CUpgradeComponents class CUpgradeComponent { float			groundattackrange; float			airattackrange; float			surfaceattackrange;		// Also Ballistic Range float			subattackrange;			// Also Beam Range float			groundattack; float			airattack; float			navalattack;			// Also Ballistic Attack float			subattack;			// Also Beam Attack float			grounddefence;			// Also Hull Defence float			tacairdefence;			// Also Shield Defence float			indirectdefence; float			closedefence; float			stealth; unsigned short	       spottype[2];			// Spot type replacements if non-zero float			speed; float			cargocap; float			crew; float			fuelcap; float			fueluse; float			ammocap; float			ammouse; float			buildspeed; float			weight; float			carriercap; float			initiative; }; && UPGRADECOMPONENT classnum

1-24 : UpgradeComponent class for each upgrade level (0 not used)


 * 5 Modules (0 to 4), 3 upgrades levels each (supporting 1/2/3)
 * 3 more modules not used (5/6/7), reserved

Each value is a modifier of the original value, similar to tech effects.


 * 0.0 would be unchanged; 0.5 would be "increase by 50%"; -0.5 would be "reduce by 50%"

Implementation:

 * See Default Picnums
 * Base Hull is always single object (submesh) - submesh # 0
 * Upgrades can ADD (cumulative) or REPLACE (previous upgrades) on Base Hull object mesh - using OptionOb flag (if set T, then replace)
 * Upgrade Level Calculation Example:
 * Faction has researched three techs with Tech Effect 679 - effect values are 0.4, 0.5, 0.7
 * Effect number 679 minus 500 (base for subsystem upgrades) = 179
 * This is in section for class number 22, Space Fighter (22*8 = 176, start of upgrade effects for class 22, eight modules per class supported)
 * This is upgrade module 3 (179-176). Per Module chart above, this is the entry for Engines.
 * Total effect value is 1.6 (0.4+0.5+0.7). This means the Upgrade Level to be used is level 1 (zero is base unit).  Partial levels are ignored.
 * Unit Stat Upgrades Example:
 * Values to upgrade stats are UPGRADECOMPONENT line 3 * 3 + 1 = 10 (upgrade module 3 for engines, times 3 levels per module, plus level 1 for current Upgrade Level)
 * This will be a stats/specs upgrade using the value in the UPGRADECOMPONENT array
 * If value "speed" in the array of specs is 0.2 (20% boost), and the unit's base speed is 50, then the upgraded speed is 50 * (1.0 + 0.2) = 60
 * If value "ammouse" in the array of specs is -0.15 (15% reduction), and the unit's base ammo use is 20, then the upgraded ammo use is 20 * (1.0 - 0.15) = 17
 * Upgrade values are not cumulative - at Level 1 the unit will receive Level 1 stat adjustments, at Level 2 the unit will only receive Level 2 adjustments.
 * No Partial stat upgrades are done - if the the total upgrade tech effect is 1.6, then Level 1 stats are used. Total upgrade tech effect of 0.9 results in no stat changes (base only)
 * This will be a visual upgrade to Level 1 on the unit mesh
 * Unit Mesh Picnum will be drawn with Base Hull mesh, and with SubMesh of Meshtype 43 (first engine level upgrade - module 3 for engines, times 3 levels per module, plus 34 for base submodules Meshtype)
 * Unit Mesh Picnum will be drawn with Base Hull mesh, and with SubMesh of Meshtype 43 (first engine level upgrade - module 3 for engines, times 3 levels per module, plus 34 for base submodules Meshtype)

UpgradeComponent.csv Definitions

 * Column A is the ID for the upgrade type
 * 1 - Armor Level 1
 * 2 - Armor Level 2
 * 3 - Armor Level 3
 * 4 - Command Level 1
 * 5 - Command Level 2
 * (etc. through Armor, Command, Cargo, Engines, Weapons
 * Rows begging at B are values for upgrades
 * B - Ground Attack Range
 * C - Air Attack Range
 * D - Surface Attack Range (also Ballistic Attack Range)
 * E - Submarine Attack Range (also Beam Attack Range)
 * F - Ground Attack
 * G - Air Attack
 * H - Surface Attack (also Ballistic Attack)
 * I - Submarine Attack (also Beam Attack)
 * J - Ground Defense (also Hull Defense)
 * K - Tactical Air Defense (also Shield Defense)
 * L - Indirect Air Defense
 * M - Close Combat Defense
 * N - Stealth
 * O - Spotting Type 1
 * P - Spotting Type 2
 * Q - Speed
 * R - Cargo Capacity
 * S - Crew
 * T - Fuel Capacity
 * U - Fuel Usage
 * V - Ammo Capacity
 * W - Ammo Usage
 * X - Build Speed
 * Y - Weight
 * Z - Carrier Capacity
 * AA - Initiative