I'm trying to mess with a couple different flavors of healing magic in my game and am trying to compare and balance them, but whenever I try a formula more complex than 200+a.mdf I just get zero. So can anyone tell me why the following formulas will not work for healing spells? (Note the first one might be kind of ugly because I went bracket crazy trying to separate things better trying to get it to work, it didn't work.)
((5000*((a.lvl+1)/100))+((a.mdf*5)+(b.def*3)))/4
(550*((a.lvl+1)/100))+(a.mdf*10)+(b.mdf*3)
All default values are stored as integers, dropping any fractional part.
Which means that (a.lvl+1)/100 is zero for levels smaller than 99 and one for levels 100-199.
Divisions need to go last or at a position where the dropped part doesn't affect the results.
5000*((a.lvl+1)/100) is zero for levels smaller than 100, but (a.lvl+1)*5000/100 will work.
lvl is not a valid parameter.
level is the correct.
Also, what andar said is not correct for MV. Different from Ace, where all math operatins with only integers would return only integers, on MV this don't happen. So, a math operation between two integers can return a float value.
And notice that enemies doesn't have levels by default. So this formula will not work for enemies.
I don't normally show off my games damage formula's, but this is a sample of the *basic* melee attack.
Game_Battler.prototype.attack = function(a, b) {
if (a.isActor()) {
damage = (((a.atk+Math.pow((a.atk/10), 2)))*(100/(100.00+b.def))+((a.atk-b.def)/2))
fi = $gameVariables.value( 8)
wi = $gameVariables.value( 9)
wa = $gameVariables.value(10)
ea = $gameVariables.value(11)
damage *= ((fi+wi+wa+ea)*0.0025)+1.00
if (a.isStateAffected(40)) { damage *= 1.25 }
if (a.isStateAffected(47)) { damage *= 0.75 }
if (b.isStateAffected(46)) { damage *= 0.75 }
if (b.isStateAffected(54)) { damage *= 1.25 }
if (damage <= 0) { damage = 1 }
damage = parseInt(damage*a.pdr)
console.log(a._name+": Melee ("+(parseInt(damage*0.8))+"-"+(parseInt(damage*1.2)+")"))
return damage
}
else {
a._mp += a.mmp/10
damage = (((a.atk+Math.pow((a.atk/10), 2)))*(100/(100.00+b.def))+((a.atk-b.def)/2))*1.50
damage *= (b.level*0.05)+1.00
if (a.isStateAffected(40)) { damage *= 1.25 }
if (a.isStateAffected(47)) { damage *= 0.75 }
if (b.isStateAffected(46)) { damage *= 0.75 }
if (b.isStateAffected(54)) { damage *= 1.25 }
if (damage <= 0) { damage = 1 }
damage = parseInt(damage*a.pdr)
console.log(a.originalName()+": Melee ("+(parseInt(damage*0.8))+"-"+(parseInt(damage*1.2)+")"))
return damage
}
}
This makes it so players and enemies can use the same skill/attack and have different outcomes and this works for damage, healing, and items. 🙂
All you have to do to make a formula like this work is make a new JavaScript file (Formula.js works just fine), create the formula, and inside the attack/skill/spell/items formula box you put in "a.attack(a,b)" or whatever term you use after defining it in the initial line, and you can repeat this for as many abilities and items as you please. Just make sure it is one of the first plugins in your list in case anything you have may need to ready it for something!
I know my formula has a lot of extra info in it, but it works and is very balance for both early and late game on top of scaling well for both players and enemies over time. If you want help making a simpler formula that doesn't have all my state calls in it I can make you a basic one and you can go from there.