From 8395d4ead5b12a4d35fbcd57fe3b2d1f3a277324 Mon Sep 17 00:00:00 2001 From: Jan Christoph Bernack Date: Thu, 5 Jan 2023 02:42:29 +0100 Subject: [PATCH] simplify modifier calculation --- ValheimPlus/Utility/Helper.cs | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/ValheimPlus/Utility/Helper.cs b/ValheimPlus/Utility/Helper.cs index 7da041df..0e2cc6ac 100644 --- a/ValheimPlus/Utility/Helper.cs +++ b/ValheimPlus/Utility/Helper.cs @@ -64,22 +64,11 @@ public static float tFloat(this float value, int digits) public static float applyModifierValue(float targetValue, float value) { - + // cap negative modifiers at -100% if (value <= -100) value = -100; - float newValue = targetValue; - - if (value >= 0) - { - newValue = targetValue + ((targetValue / 100) * value); - } - else - { - newValue = targetValue - ((targetValue / 100) * (value * -1)); - } - - return newValue; + return targetValue * (1 + value / 100); } public static Texture2D LoadPng(Stream fileStream)