make all critical hits treat b.def and b.mdf as 1

● ARCHIVED · READ-ONLY
Started by jonthefox 4 posts View original ↗
  1. i'd like the ability for critical hits to ignore defense. rather than a plugin to allow separate damage formulas for crits, which would have to be put in for every ability, i'd like a plugin that makes it so that: whenever a critical hit registers in battle, any damage formula that includes a value for b.def or b.mdf is calculated as 1, instead of the true value. This would effectively make it so that all critical strikes ignore a target's defense stats.
  2. You may try the plugin code below. It replaces defense and magic defense with 1 in the damage formulas. Damage is still multiplied by the critical multiplier afterwards. Did you want that multiplier turned off?
    Code:
    // CriticalDefense.js
    // Created on 9/20/2018
    
    /*:
    * @plugindesc This plugin is meant to change the defense
    * to 1 for critical hits.
    * @author Yethwhinger
    *
    * @help This plugin changes the defense, both physical and
    * magical, of a battler being hit by a critical hit to 1
    * for the purpose of calculating critical damage.
    */
    
    //----------------------------
    // Changes to Game_Action
    //----------------------------
    
    Game_Action.prototype.makeDamageValue = function (target, critical) {
        var item = this.item();
        var baseValue;
        if (critical) {
            baseValue = this.evalCriticalDamageFormula(target);
        }
        else {
            baseValue = this.evalDamageFormula(target);
        }
        var value = baseValue * this.calcElementRate(target);
        if (this.isPhysical()) {
            value *= target.pdr;
        }
        if (this.isMagical()) {
            value *= target.mdr;
        }
        if (baseValue < 0) {
            value *= target.rec;
        }
        if (critical) {
            value = this.applyCritical(value);
        }
        value = this.applyVariance(value, item.damage.variance);
        value = this.applyGuard(value, target);
        value = Math.round(value);
        return value;
    };
    
    Game_Action.prototype.evalCriticalDamageFormula = function (target) {
        try {
            var item = this.item();
            var a = this.subject();
            var b = target;
            var v = $gameVariables._data;
            var oldFormula = item.damage.formula;
            var sign = ([3, 4].contains(item.damage.type) ? -1 : 1);
            var oldParams = /b\.def|b\.mdf/g;
            var newFormula;
            var value;
            newFormula = oldFormula.replace(oldParams, '1');
            value = Math.max(eval(newFormula), 0) * sign;
            if (isNaN(value)) value = 0;
            return value;
        } catch (e) {
            return 0;
        }
    };
  3. thank you!! yes, i'd like the multiplier turned off
  4. The critical multiplier has been turned off in the version below.
    Code:
    // CriticalDefense.js
    // Created on 9/20/2018
    // Last modified on 9/24/2018 by Yethwhinger
    
    /*:
    * @plugindesc This plugin is meant to change the defense
    * to 1 for critical hits.
    * @author Yethwhinger
    *
    * @help This plugin changes the defense, both physical and
    * magical, of a battler being hit by a critical hit to 1
    * for the purpose of calculating critical damage. The
    * usual critical damage multiplier is then ignored.
    */
    
    //----------------------------
    // Changes to Game_Action
    //----------------------------
    
    Game_Action.prototype.makeDamageValue = function (target, critical) {
        var item = this.item();
        var baseValue;
        if (critical) {
            baseValue = this.evalCriticalDamageFormula(target);
        }
        else {
            baseValue = this.evalDamageFormula(target);
        }
        var value = baseValue * this.calcElementRate(target);
        if (this.isPhysical()) {
            value *= target.pdr;
        }
        if (this.isMagical()) {
            value *= target.mdr;
        }
        if (baseValue < 0) {
            value *= target.rec;
        }
        value = this.applyVariance(value, item.damage.variance);
        value = this.applyGuard(value, target);
        value = Math.round(value);
        return value;
    };
    
    Game_Action.prototype.evalCriticalDamageFormula = function (target) {
        try {
            var item = this.item();
            var a = this.subject();
            var b = target;
            var v = $gameVariables._data;
            var oldFormula = item.damage.formula;
            var sign = ([3, 4].contains(item.damage.type) ? -1 : 1);
            var oldParams = /b\.def|b\.mdf/g;
            var newFormula;
            var value;
            newFormula = oldFormula.replace(oldParams, '1');
            value = Math.max(eval(newFormula), 0) * sign;
            if (isNaN(value)) value = 0;
            return value;
        } catch (e) {
            return 0;
        }
    };