I know that this works:
Math.max(a.atk-b.def,Math.randomInt(3)+1)
But personally I think it eats a lot of space in a box that is already not very big to begin with.
I was wondering if it's not possible to edit directly the js files so that the minimum damage is, say, random 1-4 instead of 0. Any clues?
I'm not sure why you care about the length of your damage formula...it's not limited to the amount you see in the text box, they can be quite long.
It is also not good coding habits to modify the source code directly. It is better practice to create a plugin. That's actually what I do for my standard damage formulas, I just made a function in JavaScript, saved it as a plugin, then my damage formulae just say TurDamage(a, b);
How can I make a plugin that performs this then?
if (value === 0) {
value = Math.randomInt(4) + 1;
}
Actually now that I think about it, put that after the call to Math.round because it may not be 0 after calling applyVariance. My bad!
Also Indinera if you look up my topic "The anatomy of a plugin" it tells you how to structure a plugin file that you can put that code into.
It might be the triple equal signs. When I was doing coding it was == for equals. Try that.
It's not a problem with the formula. I tried this and it didn't show 600 as damage.
value = this.applyVariance(value, item.damage.variance);
value = this.applyGuard(value, target);
value = Math.round(value);
value = 600;
return value;
Oh, yeah, I thought it would go without saying that my solution would only work if you weren't using any plugins that overwrite the makeDamageValue function. 😛
Bingo! This worked.
Thank you everyone who tried and helped in this thread, much appreciated.