valheimPlus / ValheimPlus

A HarmonyX Mod aimed at improving the gameplay and quality of life of the game Valheim.

Home Page:http://valheim.plus

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[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:

; The games health multiplier per person nearby in difficultyScaleRange(m) radius.
; Default is 30% monster health increase per player in radius.
gameDifficultyHealthScale=30

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:

public static class Game_GetDifficultyHealthScale_Patch
{
private static float baseDifficultyHealthScale = 0.3f;
private static void Postfix(ref float __result)
{
if (Configuration.Current.Game.IsEnabled)
__result = ((__result - 1f) / baseDifficultyHealthScale * Configuration.Current.Game.gameDifficultyHealthScale / 100f) + 1f;
}
}


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