@freebooter In LeTBS demo there is "LeDamageFormula.js" plugin.
In this short plugin you can see that there is a physical and magical damage
For physical damage :
this.phyDmg = function (rate) {
//var rawDmg = (a.atk * 4 - b.def * 2) * rate * 0.01;
var rawDmg = a.atk * 2 * rate * 0.01;
var reduction = b.def / (b.def + 2 * rawDmg);
return Math.floor(rawDmg - reduction * rawDmg);
};
So basically if you write : this.phyDmg(120), it is a shortcut for :
1) a.atk * 2 *
120 * 0.01 = X
2) b.def / (b.def + 2 * X) = Y
THEN, the Final damage output = X - (Y * X) (if the result is a decimal number, then return to the closest lower number (example 46.74 return : 46)
So basically if you are using "LeDamageFormula.js" and do not want to use complicated formulas this is an easy tool.
If you are comfortable with JavaScript you can even edit it and use your OWN custom damages formulas!
Edit :
If you want a formula that work like the game "Dofus" here is how you do (it is not exactly the same but inspired) :
(in this game, there is a stat called "power" (lets use actor atk) that boost your attack power in% and enemies have %resistance instead flat resistance (let's use b.def))
this.phyDmg = function (rate) {
var rawDmg = a.atk * rate * 0.01;
var reduction = rawDmg * b.def * 0.01;
return Math.floor(rawDmg - reduction);
};
So if your character have 800 power and the enemy have 50% defense on a skill that deals 120 damages like this : this.phyDmg(120)
1) 800 * 120 / 100 = 960 ( "/100" and "*0.01" is the same)
2) 960 * 50 / 100 = 480 (so it is really 50% reduction) (be careful having 100% defense would make an enemy invulnerable, that might be good for a state on an enemy you can remove with a special spell like a boss that protect himself or his summons)
Final damage = 960 - 480 = 480
In this formula, if you have 0 power you will deal 0 damage (in "Dofus" if you have 0 power you will still deal 100% of the basic attack so if you want the same formula you can change :
var rawDmg = a.atk * rate * 0.01;
by
var rawDmg = (a.atk * rate * 0.01) + rate;
So even if you have 0 power, you will deal the base damage.
The really good thing with this plugin is : if you want %defense reduction AND flat defense reduction, you can by adding one variable and remove the result in the final output like that (here flat defense is on target luck)
You can also add flat damage output (lets use actor agi stat) :
this.phyDmg = function (rate) {
var rawDmg = (a.atk * rate * 0.01) + rate;
var reduction = rawDmg * b.def * 0.01;
var flatDmg = a.agi;
var flatReduction = b.luk;
return Math.floor(rawDmg + flatDmg - flatReduction - reduction);
};
So here you have a really complicated formula but very easy to use.
Be careful with the final order :
return Math.floor(rawDmg + flatDmg - flatReduction - reduction); //(good)
is NOT equal to :
return Math.floor(rawDmg + flatDmg - reduction - flatReduction); //(bad)
Because of the nature of flat attack and flat defense, it is way more effective on comparatively small numbers so adding a flat defense after the %defense or flat attack in the rawDmg might be way too OP (having a smaller number to deal with, the reduction or attack would be exponentially too effective) but you probably already know about it!
Of course this is just a sample, you can use even more complicated formula if you want : )