Would it be possible for you to make it so you can adjust the damage reduction multiplier in the mod configs below 1.0? for example id want to adjust the damage reduction multiplier of the mk3 hull reinforcement to smth like 0.4
Something is wrong with you math for mirroredSelfDamageFraction. If I equip one Hull Reinforcement MK2 the log will show: [Info :Hull Reinforcement Fix] Original dmg fraction = 0.5 [Info :Hull Reinforcement Fix] Altered damage fraction = 0 But if I equip one Hull Reinforcement MK3 the log will show: [Info :Hull Reinforcement Fix] Original dmg fraction = 0.5 [Info :Hull Reinforcement Fix] Altered damage fraction = 0.09
The Mathf.Min(newDamageFraction, mk3DamageFraction) will always return 0 when you have no mk3 modules since mk3DamageFraction is 0 then. So having at least one MK2 and no MK3 modules installed will always give 0 damage fraction.
And looking at the code it looks like you assume that the existing mirroredSelfDamageFraction has been set by theoriginal OnUpgradeModuleChange() mehtod, but that method only sets that value when you are adding or removing a vanilla hull reinforcement module. So removing the last MK2/MK3 module will not update the mirroredSelfDamageFraction and and when adding several MK2/MK3 modules it will use the old mirroredSelfDamageFraction value calculated previously by your patch, not one calcuclated by the vanilla OnUpgradeModuleChange() method. You need to calculate the value for any vanilla modules installed in your method since the vanilla method only calculates that value when you actually add or remove a vanilla module. You can't assume the old mirroredSelfDamageFraction is for any installed vanilla modules.
And your attempt to get some "average" value by summing the values for the different variants of the modules and dividing them with the total count of modules installed will in several cases make the result worse the more modules you install.
Better to just use the best(lowest) value instead: newDamageFraction = Mathf.Min(Mathf.Min(originalDamageFraction ,mk2DamageFraction), mk3DamageFraction); The same applies to the calculation for creature damage. But here it's actually the other way around. Having more modules installed makes it very overpowered. First the number of modules is used in Mathf.Pow(0.85f, mk2HullModuleCount) which is correct, but then you divide that value with the number of modules making the damage taken much less then intended. With one vanilla module installed: [Info:Hull Reinforcement Fix] Original dmg = 42.53373 (Mk1 Module Count = 1 | Mk2 Module Count = 0 | Mk3 Module Count = 0 [Info:Hull Reinforcement Fix] Altered damages: 29.77361 | 0.7 | 0 | 0 This results in the correct damage taken. 42.53373 * 0.7 = 29.773611
With 3 vanilla modules installed: [Info :Hull Reinforcement Fix] Original dmg = 42.53373 (Mk1 Module Count = 3 | Mk2 Module Count = 0 | Mk3 Module Count = 0 [Info :Hull Reinforcement Fix] Altered damages: 7.500113 | 0.5289999 | 0 | 0 This results in to little damage taken. Should have been 42.53373 * 0.528999 = 22.5003 but only took 7.500113 since 22.5003 was divided by 3
Does the mod have to be installed before the start of a playthrough. I started a save then found the mod later. I installed it like the other mods, but they don't show up in my game. I then started a creative save to check if it was there, and it worked fine on that one.
The mod folder goes in your plugins folder. So once it's installed correctly the files will go like this Subnautica/BepInEx/plugins/HullReinforcementFix
I know you posted a Desmos value chart but I have difficulty interpreting it. Could you please reply to this with the number values of creature and collision damage reduction that hull module mk1, mk2, and mk3 provide?
Thank you for the mod! Very helpful for me since I adore the Seamoth and am always scared of losing mine to bone sharks.
what exactly determines the stacking effect? by that I mean how did you come to those values? the reason I ask is because I don't see an equation that would make it make sense.
62 comments
Anyone know why hull reinforcement upgrades don't work with the cyclops?
Please test with this modification.
I don't know English well, so I use online translation from Russian.
If I equip one Hull Reinforcement MK2 the log will show:
[Info :Hull Reinforcement Fix] Original dmg fraction = 0.5
But if I equip one Hull Reinforcement MK3 the log will show:[Info :Hull Reinforcement Fix] Altered damage fraction = 0
[Info :Hull Reinforcement Fix] Original dmg fraction = 0.5
[Info :Hull Reinforcement Fix] Altered damage fraction = 0.09
I checked your code and you do:
float mk2DamageFraction = mk2Count > 0 ? 0.4f * Mathf.Pow(0.55f, mk2Count) : 0;
The Mathf.Min(newDamageFraction, mk3DamageFraction) will always return 0 when you have no mk3 modules since mk3DamageFraction is 0 then.float mk3DamageFraction = mk3Count > 0 ? 0.3f * Mathf.Pow(0.3f, mk3Count) : 0;
if ((mk2Count + mk3Count) != 0)
{
newDamageFraction = (originalDamageFraction + mk2DamageFraction + mk3DamageFraction) / (mk1Count + mk2Count + mk3Count);
newDamageFraction = Mathf.Min(newDamageFraction, mk3DamageFraction);
}
dealDamageOnImpact.mirroredSelfDamageFraction = newDamageFraction;
So having at least one MK2 and no MK3 modules installed will always give 0 damage fraction.
And looking at the code it looks like you assume that the existing mirroredSelfDamageFraction has been set by theoriginal OnUpgradeModuleChange() mehtod, but that method only sets that value when you are adding or removing a vanilla hull reinforcement module. So removing the last MK2/MK3 module will not update the mirroredSelfDamageFraction and and when adding several MK2/MK3 modules it will use the old mirroredSelfDamageFraction value calculated previously by your patch, not one calcuclated by the vanilla OnUpgradeModuleChange() method.
You need to calculate the value for any vanilla modules installed in your method since the vanilla method only calculates that value when you actually add or remove a vanilla module. You can't assume the old mirroredSelfDamageFraction is for any installed vanilla modules.
And your attempt to get some "average" value by summing the values for the different variants of the modules and dividing them with the total count of modules installed will in several cases make the result worse the more modules you install.
Better to just use the best(lowest) value instead:
newDamageFraction = Mathf.Min(Mathf.Min(originalDamageFraction ,mk2DamageFraction), mk3DamageFraction);
The same applies to the calculation for creature damage. But here it's actually the other way around. Having more modules installed makes it very overpowered. First the number of modules is used in Mathf.Pow(0.85f, mk2HullModuleCount) which is correct, but then you divide that value with the number of modules making the damage taken much less then intended.
With one vanilla module installed:
[Info:Hull Reinforcement Fix] Original dmg = 42.53373 (Mk1 Module Count = 1 | Mk2 Module Count = 0 | Mk3 Module Count = 0
This results in the correct damage taken. 42.53373 * 0.7 = 29.773611[Info:Hull Reinforcement Fix] Altered damages: 29.77361 | 0.7 | 0 | 0
With 3 vanilla modules installed:
[Info :Hull Reinforcement Fix] Original dmg = 42.53373 (Mk1 Module Count = 3 | Mk2 Module Count = 0 | Mk3 Module Count = 0
This results in to little damage taken. Should have been 42.53373 * 0.528999 = 22.5003 but only took 7.500113 since 22.5003 was divided by 3[Info :Hull Reinforcement Fix] Altered damages: 7.500113 | 0.5289999 | 0 | 0
You can add the mod mid game just fine. Just need to unequipe/reequipe any hull reinforcement modules you already have in your vehicles.
Subnautica/BepInEx/plugins/HullReinforcementFix
Thank you for the mod! Very helpful for me since I adore the Seamoth and am always scared of losing mine to bone sharks.
Creature damage reduction:
Default module: 1x = 30% reduction; 2x = 39.0% reduction; 3x = 47.1% reduction; 4x = 54.4% reduction
Mk2: 1x = 35% reduction; 2x = 48.7% reduction; 3x = 58.6% reduction; 4x = 68.8% reduction
Mk3: 1x = 40% reduction; 2x = 56.0% reduction; 3x = 68.8% reduction; 4x = 79.9% reduction
Collision damage reduction:
Default module: 1x = 75% reduction; 2x = 87.5% reduction; 3x = 93.8% reduction; 4x = 96.9% reduction
Mk2: 1x = 78% reduction; 2x = 87.9% reduction; 3x = 93.4% reduction; 4x = 96.3% reduction
Mk3: 1x = 91% reduction; 2x = 93.3% reduction; 3x = 99.2% reduction; 4x = 99.8% reduction
https://www.desmos.com/calculator/xuxxtn5wj9
https://www.desmos.com/calculator/fhfkaeuggl