[BUG] Difficulty Scaling Calculation Incorrect
ganiden opened this issue · comments
- OS: G-Portal Server
- Valheim Game Version: 0.214.2
- V+ Mod Version: Grantapher's 0.214.2 fix
Using the 0.214.2 fix, I was having trouble getting the health scaling for enemies to behave as expected based on the description in the config file, which reads:
gameDifficultyHealthScale - "Increases the health of NPCs nearby per person in difficultyScaleRange (m) radius (0.4 -> 40%, 0.04 -> 4%)."
So I tested the following configurations by fighting a 0 star boar which has a base health of 10.
Test 1:
gameDifficultyHealthScale = 1
extraPlayerCountNearby = 0
Boar Health = 10 (expected 10)
Test 2:
gameDifficultyHealthScale = 1
extraPlayerCountNearby = 1
Boar Health = 10 (expected 20)
Test 3:
gameDifficultyHealthScale = 50
extraPlayerCountNearby = 1
Boar Health = 20 (expected 510)
Important Note: The comment below is my own interpretation of ValheimPlus' code and am I prone to making errors. I just recently got into modding Valheim and sometimes I struggle with the logic behind stuff. Feel free to correct me if I'm wrong.
Default setting
Here is the default value of gameDifficultyHealthScale
:
Lines 349 to 351 in 24fd707
Explanation
This means that for each extra player, the health of enemies is scaled by 30%, not 30 times.
This means your expected values for Test 2 and Test 3 are slightly off. Let me explain.
What the setting does
gameDifficultyHealthScale = 1
means an increase of 1% of the original health pool, per extra player.
gameDifficultyHealthScale = 50
means an increase of 50% of the original health pool, per extra player.
Here is what ValheimPlus does to handle the enemies' health scaling configuration:
ValheimPlus/ValheimPlus/GameClasses/Game.cs
Lines 60 to 69 in 24fd707
Conclusion
It means having gameDifficultyHealthScale
set to 50 does not result in +5000% hp but rather +50% health points (per extra player).
Thus, with extraPlayerCountNearby = 1
and gameDifficultyHealthScale = 50
, the boar's health should be roughly around 50% above its original health points (10 => 15).