Thx, I'm gonna give that a try, but I think I'd still need some kind of function that adjusts elementRate...
The idea of making a stacking state in the background has crossed my mind, but I also need the stacks to adjust based on the number of turns left on the Burning state (121). Sometimes an attack will add/reset the turns left or remove/reduce it.
Edit: Does this look about right?
Fair enough, that makes sense.
your code has one problems on why it will not work.
the existent element rate is being squared e.g ( 64 x 64 = 4096 times normal damage!). Elemental damage calculation already happens behind the scenes. they use something similar to user.Elemental(4) and multiply it with value. then your negate will multiply it again with the resistant rate, this means the target will take much more damage than it should.
heres basically what happens.
Note: this is Pseudo Code, that means its not actual JS or source code, its there to show coding logic
Code:
value = eval(damageFormula)
//defense already taken into account
// 1200
value *= elelemtRate; //element rate is 3x damage
//3600
//10 turns left
var elementrate = 3 + (0.1 x turns)
// element rate is 4
value *= elementrate
// 4 x 3600!!
//total damage is 14400!!!
the actual damage should only be around 4800, since you only increased the fire damage by 100%, not 1200%!
if you want to add on to the existing rate, you need to turn it into a fraction and divide out the existing damage.
e.g
i want to add 100% fire damage to a existing 130% damage (that's 30% extra) for a total of 230% damage or 2.3x normal dmamage
damage = 100;
damage *= 1.3; //30% extra damage!
//damage is now 130
//we want to get it to 230
damage *= (100 + 130) / 130
//damage is now 230
Code:
if (value > 0 && this.isHpEffect() && this.getItemElements().contains(4)) {
var elementRate = (user.elementRate(4) + (0.1 * user.stateTurns(121)) / user.elementRate();
value *= elementRate;
}