Scaling HP with Maths
With the release of The Binding of Isaac: Afterbirth Edmund and Co. added two new bosses to the game: Ultra-Greed and Hush. Both of these bosses have a resistance value which scales with player damage. I can understand where Edmund is coming from by introducing a scaling resistance; it means that less people will be relying on pure damage to get them through the fights and more on skill. Unfortunately, I feel, the current implementation of this scaling resistance goes against the principles of the game and at times is even unfun.
The problem
From my research on how the scaling works there seems to be hard upper and lower caps at 155 and 10 respectively. Then the damage is scaled down by dividing by a value x which is incremented by a random number between 1 and 20 on each successful hit†† This will be the footnote when views on a large monitor. If the player does not attack the boss within a certain time frame (assumed to be around two to three seconds) then the value of x will be reset.
The problem with this is that to optimally kill the boss you need to not attack for half the time, effectively giving the boss a 50% resistance†† This will be the footnote when views on a large monitor.. Not only this, capping the absolute maximum damage gimps any truly OP run or any glass cannon builds as it is not possible to one shot the boss.
Potential Solution
My attempt at a solution is to calculate the boss’ resistance from the damage stat of the player such that for a certain range in the middle, encompassing the majority of runs, the player will do effectively the same damage. This would mean that for the average player, skill would be a much more determining factor within the game than sheer power, however for those broken runs where nothing can stand in your way will still feel incredibly powerful. The tricky part is trying to come up with a simple and smooth solution to calculating the boss’ resistance on the fly.
To start with we will decide on the shape of our effective damage curve. I’ve sketched this out in the figure on the side, however the general idea is such that from zero to some point a the effective damage is related linearly to the players true damage, we then have a smooth transition which will level out the graph until a point b then smoothly transitions back to a linear relationship. We can describe this graph in terms of the steepness, or its gradient. The gradient needs to be one from zero to a, zero from a to b and finally one from b onwards. For a sketch of this see another figure.
If we look at the transition around b and we compare it to the hyperbolic tangent, tanh(x)‡‡ This is the second type of note for the fullsized view. I should make these collapse to under the article on smaller displays. — as sketched out in yet another figure — we can see that the two share a very similar shape. The only thing we need to do is transform the functino to be able to match desired one. To start with we will scale the function in vertical direction and move it up so that the lowest part lies on zero. To do this we use the following two transformations: f(x)+a to move the function up and a*f(x) to scale it vertically. In this case we need to move the graph up by one and then scale it by a half. These operations give the following equation:
The next step is to scale the x-axis so that we can control the speed at which the transition occurs. To do this we need to first find the range in which the transition occurs. This is roughly 6 units wide from -3 to +3, technically the value is asymptotic and thus never actually reaches one but tanh(+/-3) is 0.995 which for our use is more than enough to say that it is one. Using this we can scale the function in the horizontal direction such that the transition occurs over a range which we will call r. To do this we multiply the x in the function by 6/r. Our function is now shown below with yet another figure to show this change.
The final thing we need to do to the equation is to move it into location, we can do this using the transformation f(x-a) to shift the graph to the right by a units. We want the centre of the transition to be placed at the value b, giving our final equation:
To work out the transition at a can use the result above combined with one more transformation, -f(x), to flip the graph on its head. Then replacing our transition point b with a we end up with the following equation at a:
By adding these two equations together we get a final, continuous function which will give us the gradient of our effective damage graph, compare this to the original sketch of our required gradient to see how it compares. Our final function ends up as follow:
To convert this function of the gradient into a function for the effective damage we need to use the power of calculus and integrate with respect to x. I won’t bore you with the exact details as it is more tedious than anything, however, to do it yourself just use the fact that the integral of tanh(x) is ln(cosh(x)) and integration by parts. Our effective damage is then given by the following equation:
Again check the figure of this graph with or initial sketch for what we want the effective damage graph to look like. The value of c in this equation can be calculated by setting the values of x and y to be zero and rearranging. This is left as an exercise to the reader, as it adds nothing to this article.
Now the final step is to find a relation between effective damage and boss resistance. This is a relatively simple task compared to the maths before since we can use the following formula:
Combining these two equations and making the resistance R the subject we end up with:
Final Thoughts
This equation is by no means perfect, without in game testing there’s no telling if it is fun or if it gains anything over a simple piecewise function, sharp transitions. I do feel that by allowing the player to exceed a cap and start becoming stronger again it retains the fun of glass cannon or extremely broken runs. The function itself can be adapted in many ways. The level of the plateau can be adjusted by where the transition occurs. It is even possible through a slight modification of the initial gradient to give players who surpass the plateau a bonus to the damage done.
Footnotes
- [1] Test . ....
- [2] test ...
