BattletechModders / MechEngineer

Mod for BattleTech that introduces many CBT mechanics to the MechLab
GNU Lesser General Public License v2.1
11 stars 21 forks source link

Multiply engine weight factors #216

Open aflazmn opened 8 months ago

aflazmn commented 8 months ago

123 mentions that multiple weight factors are added together. They should be multiplied together. For an XL engine with a supercharger, the final weight should be 0.5 (XL is half the weight) times 1.1 (supercharger adds 10%) which equals 0.55, not 0.6 which is what it currently produces.

The difference is greater with XXL engines. Should be 0.36666 but instead has 0.43333. You should just be able to change

EngineFactor += savings.EngineFactor - 1;

to

EngineFactor *= savings.EngineFactor;

CptMoore commented 8 months ago

Years ago I tried to introduce a EngineFactorFactor to have a second factor that gets multiplied with the first one, but that was problematic with the code at the time. Looks like its possible now, the Weights code got overhauled several times since then.

I would like to keep a way to have multipliers that work only off the base, and in addition have the multiplier support you mentioned.

EngineFactor: Factor always from the base (a better name would be BaseMultiplier)

New (old FactorFactor idea):

EngineMultiplier: Multiplies against the Engine weight.

Does that make sense to you? If yes, try the latest build.

aflazmn commented 8 months ago

worked with a 400 XXL got 2.5 tons instead of 3 tons with a 400 XL, maybe a rounding issue somewhere worked with a 200 XL worked with a 300 Light worked with a 390 XL worked with 360 standard worked with 140 standard

CptMoore commented 8 months ago

Ok, due to the rounding issue, I have renamed the EngineMultiplier to Engine2Factor and now round in between calculations.

Implementation looks like this:

EngineTonnage1 => PrecisionUtils.RoundUp(StandardEngineTonnage * WeightFactors.EngineFactor, WeightPrecision);
EngineTonnage => PrecisionUtils.RoundUp(EngineTonnage1 * WeightFactors.Engine2Factor, WeightPrecision);
CptMoore commented 8 months ago

Ok I found out what the original issue with EngineFactorFactor was.. and unfortunately it still is here. Tooltips and componentinfo tonnage lists (all just informative) should be wrong as they only (can) work on the unmodified base standard engine weight. That was the original reason EngineFactorFactor was commented out. I'll make a note in the comments that tooltips are broken when using Engine2Factor when EngineFactor is not 1 on the mech

aflazmn commented 8 months ago

works with the 400 XL now. BATTLETECH 2024-03-03 07ː35ː31 BATTLETECH 2024-03-03 07ː35ː41 BATTLETECH 2024-03-03 07ː35ː50

The engine core tooltip (in BTA3062 at least) that breaks down core, gyro, and heat sink weights displays tonnage correctly

CptMoore commented 8 months ago

Thats nice, the tooltip / tonnage display on the supercharger item should be wrong though, as it assumes standard engine weights.