# Calculating the optimal fireballdamage with limited skillpoints to allocate in a Game (Diablo 2)

I have written a program for calculating the best skillpointallocation with limited points to maximize the fireballdamage in Diablo 2.

But there is a case where it's slightly off, because of the way you have to put points into prerequisiteskills.

The formula for the fireballdamage is:

damage$$=$$fireballbasedamage$$\times (1.23+(0.07\times ($$masterypoints+firemastery+fireskills$$))+($$fire percentage on gear$$)/ 100 )\times ( 1 + ( 0.14 \times ($$synergy$$)))$$

where fireballbasedamage is the damage without any synergypoints nor mastery but with +skills and +fireball.

masterypoints are spent points into the mastery.

firemastery are additional points from gear (as you see it makes no difference, wether you have 20 hard points without any gear or only 20 points with gear).

fireskills are any skills that the gear grants, wether it is +sorceress or +fireskills (again it makes no difference).

synergy are hard points into the synergies, namely Firebolt and Meteor.

The first point into Meteor requires 3 points into its requisiteskills.

And now I'm looking for an elegant solution (not bruteforce) for the following problem:

Hard points into Fireball$$=20$$

Firebolt$$=20$$ (one of the synergies, it can't go higher than this)

$$0\leq$$masterypoints$$<20$$

Let $$x$$ be the rest of skillpoints to allocate.

How big has $$x$$ to be, that it makes sense to put $$3$$ points into the requisiteskills of Meteor to eventually put points into Meteor, rather than simply putting them into Firemastery?

In dependancy of all other unknown variables.

For simplicity firemastery and fireskills can be added together and therefore be called $$y$$ and is fixed.

fire percentage on gear is now $$z$$ and is fixed

Therefore the formula changes to

damage$$=$$fireballbasedamage$$\times (1.23+(0.07\times ($$masterypoints$$+y))+z/100)\times (1+(0.14\times ($$synergy$$)))$$

Obviously $$x=$$ additional points into the firemastery$$+$$ additional points into synergy.

Also for $$x\leq 3$$ it's trivial, and you should put all points into the mastery.

I don't know how to tackle this problem except by bruteforce (aka unelegant).

Let me know if anything is unclear or if I used too many words for describing the problem.

For completeness, the fireballbasedamage is calculated by skilllevel and not linear:

Level                          1-8                      9-16                      17-22                     23-28                    >28
Min Fire Damage          (6.5*slvl)-0.5           (11.5*slvl)-40.5         (14*slvl)-80.5           (16.5*slvl)-135.5        (19*slvl)-205.5
Max Fire Damage          (7.5*slvl)+6.5           (12.5*slvl)-33.5         (15*slvl)-73.5           (17.5*slvl)-128.5        (20*slvl)-198.5

• How about you summarize this story into an objective function and constraints where the variables are single letters instead of words? Please also specify the domain of each variable (nonnegative? integral?) Apr 22, 2021 at 22:56
• Your question is not clear. It would be better if you did what @LinAlg suggested. I.e., under what constrains exactly do you want to maximize your expression $f$? $$f=\left(1.23+(0.07×(m+y))+\frac{z}{100}\right)\left(1+0.14s\right)b$$ Can you clearly define the bounds on all variables $m,y,z,s,b$ and which ones are constants, and which ones are not? Apr 29, 2021 at 12:12
• Is $b$ (fireballbasedamage) a constant that can pretty much be any number greater than $6$? (I do not see a cap on your table of levels.) Is $z$ a constant that can be anything in range $[0,100]$? Is $m$ a constant that can be anything in range $[0,20]$? ... Is $x$ then any positive integer such that $y+s=x$, and you want to decide how much of a given $x$ to put in $y$ and how much to put in $s$, such that $f$ is maximized? What else is hiding in your story? ... It seems first three points into $s$ "don't count" (requisiteskills), so actually replace $s\to\max\{s-3,0\}$ in $f$ expression? Apr 29, 2021 at 12:13