that was my worry in fact, but if I can use variables in Damage Formulas, then I guess I could leave luck where it is and simply create a new one! Could you tell me where to look for how?
I'm not sure what you mean by "where to look for how", but everything you need to know about the RPG Maker engine is located in the
.js files in the
/js folder of your project.
Specifically, damage formulas are evaluated in
Game_Action.prototype.evalDamageFormula() found in the
rmmz_objects.js file:
JavaScript:
Game_Action.prototype.evalDamageFormula = function(target) {
try {
const item = this.item();
const a = this.subject(); // eslint-disable-line no-unused-vars
const b = target; // eslint-disable-line no-unused-vars
const v = $gameVariables._data; // eslint-disable-line no-unused-vars
const sign = [3, 4].includes(item.damage.type) ? -1 : 1;
const value = Math.max(eval(item.damage.formula), 0) * sign;
return isNaN(value) ? 0 : value;
} catch (e) {
return 0;
}
};
And just now I realized that you actually
do have convenient access to variables in damage formulas, through
v[x] (where
x is a number that represents the ID of the variable, for example
v[42] for variable #0042)
Would I be able to assign this new variable value to monsters as well?
Yes, you could. But I'm guessing you'd want every monster to have its own unique value, so using a new variable for each monster could be a lot of work. It'd be a lot more manageable to put the value in a notetag, but accessing the value in the notetag is going to be a bit of a pain.
I'm sure there must be a plugin somewhere that allows to store values in a notetag on enemies that can then easily be retrieved from within a damage formula, but I don't really know much about plugins except for the ones I make myself.