valheimPlus / ValheimPlus

A HarmonyX Mod aimed at improving the gameplay and quality of life of the game Valheim.
http://valheim.plus
GNU Affero General Public License v3.0
967 stars 236 forks source link

[BUG] Difficulty Scaling Calculation Incorrect #799

Closed ganiden closed 1 year ago

ganiden commented 1 year ago

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)

JF10R commented 1 year ago

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:

https://github.com/valheimPlus/ValheimPlus/blob/24fd70709f5b48affcb337a9ddb1d185330e4d3a/valheim_plus.cfg#L349-L351

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:

https://github.com/valheimPlus/ValheimPlus/blob/24fd70709f5b48affcb337a9ddb1d185330e4d3a/ValheimPlus/GameClasses/Game.cs#L60-L69


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).