Skip to content

Instantly share code, notes, and snippets.

@HimeWorks
Created May 26, 2016 15:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HimeWorks/428d2357c7751f1438da2a760bfa2980 to your computer and use it in GitHub Desktop.
Save HimeWorks/428d2357c7751f1438da2a760bfa2980 to your computer and use it in GitHub Desktop.
MV Damage Formula Debug
// By default, RPG Maker MV simply returns 0 and pretends nothing wrong happened.
// We allow it to continue to return 0, but it should print out a stacktrace.
Game_Action.prototype.evalDamageFormula = function(target) {
try {
var item = this.item();
var a = this.subject();
var b = target;
var v = $gameVariables._data;
var sign = ([3, 4].contains(item.damage.type) ? -1 : 1);
var value = Math.max(eval(item.damage.formula), 0) * sign;
if (isNaN(value)) value = 0;
return value;
} catch (e) {
console.log(e.stack)
return 0;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment