Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=============================================================================
- // Bug Fix - Fix Damage Evaluation returning Not-A-Number.
- // DamageEvalNotANumberFix.js
- // Version: 1.0
- //=============================================================================
- //=============================================================================
- /*:
- * @plugindesc Fixes an issue when evaluating damage formulas that would return
- * value of NaN when no damage formula is entered. Thus fixing a bug that would
- * cause a crash/exception when attempting to draw the hp/mp gauges.
- * @author Liquidize
- */
- //=============================================================================
- (function() {
- // Overwrites the damage evaluation function to include checking if the returned value is Not-a-Number.
- 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 (Number.isNaN(value)) {
- return 0;
- }
- return value;
- } catch (e) {
- return 0;
- }
- };
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement