Damage math calculation according to min and max attack

I have been trying to make turn-based combat with a hero that has set Min and Max Attack.

I already have basic formula for full damage with buffs and other things, problem is I am dumb at math and can’t figure this one out

I tried getting current Hero Level (Level 50), which has Min Attack of 1261 and Max attack 10575 at Level 100.
I tried getting the 50% out of the Max attack, but that doesnt correspond with Min attack when I go back to level 1…

I need some sort of example or help on how I can increase the attack based on min and max attack

Think of it like this, when you are getting 50% off of 100 (for example), then you are technically getting it off of min = 0, max = 100. The answer in this case would be 50.

If we instead set min = 5, max = 15, we already know that the answer is 10, as 5 is the difference to both min & max. But how can we show we get this mathematically? Let’s start with another example.
Let’s say we have min = 10 and max = 100. If we subtract min from max, then we get their difference, which in this case is 90. Doing the multiplication from that would give us 45, but this is not correct, as we are missing the 10 we subtracted. If we add it back to the result we get 55, which is halfway between 10 and 100.

Returning to our previous example with min = 5 and max = 15, if we apply the same logic there we would get:

local minValue = 5
local maxValue = 15
local difference = maxValue - minValue -- 15 - 5 = 10
local percentageResult = difference * percentage -- 10 * 0.5 = 5
local correctedResult = minValue + percentageResult -- 5 + 5 = 10

I can explain this further if you are still confused, I didn’t explain how to get any percentage of a value (ex. 5%) as I assume you already know this. If you don’t, just let me know and I’ll do my best to explain that as well.

2 Likes

Thank you very much. This was nicely explained even with examples that even some people would find useful.
Also putting it to test, it all worked just as it was written.

1 Like