There is no such term as universal damage formula, unless your game plot explains it rationally, and yes, you can use function from plugin as damage, but you must remember important thing
that function MUST ALWAYS RETURN NUMERIC RESULT:
example:
Code:
wrongFormula = function(a, b){
$gameParty.gainGold(1000);
}
Skill with this formula may give 1000 gold to team, but after that either it will deal 0 damage, or crash game, proper formula looks like this:
Code:
correctFurmula = function(a, b){
return ((a.atk * 2) + (a.mat * 3) - b.def) || 1;
}
then in skill formula field in database you just put
correctFormula(a,b);
explanation:
return x || y
means if
x is properly calculated (with no errors, syntax error) it will deal calculated damage, otherwise it will deal
y damage value (I recommend using a fixed value, using comma values (1.1 ex) causes hp/mp bars to sligthly glitch, so the enemy might have hp: 2000.89 - yes, it's calculated properly, but looks ugly.)
and another pro-tip, before return value in skill function you can use any script call available in MV and that code will execute, so you can do for example this:
Code:
correctFurmula = function(a, b){
$gameParty.gainGold(1000);
$gameActors.actor(1).recoverAll();
return ((a.atk * 2) + (a.mat * 3) - b.def) || 1;
}
this mean, your skill with this will give 1000 gold, recover HP and MP for actor #1 from database and deal damage according to your formula.
You can also reffer to current ability user, by using
a variable from function argument:
Code:
correctFurmula = function(a, b){
$gameParty.gainGold(1000);
a.recoverAll();
return ((a.atk * 2) + (a.mat * 3) - b.def) || 1;
}
and so on - limitation is only your imagination.
Edit 4:
I never checked how much you can nest return values in function such as:
Code:
function test(){
return 1 || 2 || 3 || 4 || 5; //be default it should show 1 in console.
}
Hope I get some time to check it later.
Here's working and secured plugin you can use to play/learn/use:
JavaScript:
(function(){
_skillFormula = function(a,b){
if (SceneManager._scene instanceof Scene_Battle){
//setup damage formula
let formula = (a.mat * 2) - b.def; //edit this line to define your formula. Nothing else.
return formula || 1;
}
// If player is outside the battle, let's force skill to
//return 0 damage since battles are occuring only
//in Scene_Battle scene. It'a a security purpose!
else return 0;
}
})();
and use it in skills database like in this image:
▶ Imgur image