 # Arbitrary Damage Cap Using Damage Formulas

## Recommended Posts

Im using MV and all, and I was going through to redo the formulas on the spells in one of my games, of course I found a formula that worked wonders (Base Power * a.mat - b.mdf), but it came with the problem of the most powerful spells doing 90000 to 200000 damage. I was wondering if it would be possible to edit the formula to restrict the damage to less than or equal to some damage cap, like 9999 or something. It would be very appreciated if someone could help me out on this. ##### Share on other sites

I don't own MV, so can't test anything, but I know it uses JS, so perhaps just using the Math.min() method would work there?

Basically this method returns the lowest number from provided arguments (separated by commas), for example;

Math.min(235, 111, 563) => will return 111
Math.min(100+100+300, 200) => will return 200

So what you need is to put your damage formula as one of the arguments, and 9999 as the other.

Using your formula (Base Power * a.mat - b.mdf), the damage formula with the cap would be:

Math.min(Base Power * a.mat - b.mdf, 9999)

This will either return Base Power * a.mat - b.mdf OR 9999, whichever is lower, thus capping the damage output at 9999.

That's just my guess, because I'm not sure how damage formulas are processed there.

## Create an account

Register a new account  