Replace elemental resistances % by formulas

Hi everyone !

I'll try to explain the best I can.

So, by default, the « Poison » state is dealing 10%HP damage per turn.

Thanks to Yanfly's plugins, I can replace percentage by a formula.

I'd like to make the same things for elemental resistances, if it's possible.

By default, elemental resistances are set to 100%.

If set to 50%, spells of that element will deal - 50% damages.

Since I'm using low numbers in my game, percentages are not very convenient.

I'd like to replace all percentages by flat number.

Let's say 100% elemental resistance would be 0 → no change.

But instead to put an enemy resistance to 75% or 50%, I'd like to define a value reduction, for exemple 2 or 3.

Instead of reducing damages by 25%, it would be like reduce damage of that element by 2.

It is possible to do that ?
Anything is possible, but this has some additional effects that need to be checked.
By default, elemental damage rates are multiplicative. If you have an armor that gives an elemental rate of 50% and add a ring that also has 50%, then the result would be 50%*50 = 25%.

How should that be handled for you?
Anything is possible, but this has some additional effects that need to be checked.
By default, elemental damage rates are multiplicative. If you have an armor that gives an elemental rate of 50% and add a ring that also has 50%, then the result would be 50%*50 = 25%.

How should that be handled for you?

I guess a simple addition
so, instead of suffering
dmg = 100
result = dmg - (50% * dmg) = 50

you want it to be
dmg = 100
result = dmg - 3 = 97

something like that?
so, instead of suffering
dmg = 100
result = dmg - (50% * dmg) = 50

you want it to be
dmg = 100
result = dmg - 3 = 97

something like that?

Exactly 🙂
well, I fixed the percentage thing on my game by reverting the formula.
things like mp regen, would be mrg * 100 in the code, so that "1" in the editor would be "0.01 * 100" in the code, thus, 1.

if the plugin refers to the stock code, it should make a call for calcElementRate, which always works on percentage.

Code:
Game_Action.prototype.calcElementRate = function(target) {
    if (this.item().damage.elementId < 0) {
        return this.elementsMaxRate(target, this.subject().attackElements());
    } else {
        return target.elementRate(this.item().damage.elementId);
    }
};

Code:
return target.elementRate(this.item().damage.elementId) * 100
should return the editor value as integer
and then

Code:
Game_Action.prototype.makeDamageValue = function(target, critical) {
    var item = this.item();
    var 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;
};

Code:
var value = baseValue * this.calcElementRate(target);

change to

Code:
var value = baseValue + this.calcElementRate(target);

if that doesn't work, then the plugin is overwriting that specific function.
refer to the plugin's documentation.
well, I fixed the percentage thing on my game by reverting the formula.
things like mp regen, would be mrg * 100 in the code, so that "1" in the editor would be "0.01 * 100" in the code, thus, 1.

if the plugin refers to the stock code, it should make a call for calcElementRate, which always works on percentage.

Code:
Game_Action.prototype.calcElementRate = function(target) {
    if (this.item().damage.elementId < 0) {
        return this.elementsMaxRate(target, this.subject().attackElements());
    } else {
        return target.elementRate(this.item().damage.elementId);
    }
};

Code:
return target.elementRate(this.item().damage.elementId) * 100
should return the editor value as integer
and then

Code:
Game_Action.prototype.makeDamageValue = function(target, critical) {
    var item = this.item();
    var 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;
};

Code:
var value = baseValue * this.calcElementRate(target);

change to

Code:
var value = baseValue + this.calcElementRate(target);

if that doesn't work, then the plugin is overwriting that specific function.
refer to the plugin's documentation.

Well, the result is quite weird...

Let's say an enemy uses a spell that deals 10 fire damages

The damage output will be equal to 110 (10 base damages + 100% fire rate by default)

If I put element rate to 0%, the result will be 10 damages

But we can't go under 0%, so I can't make a damage reduction
then you probably need to fix the 0 at 500%, and anything below 500 would be reduction.
you'll then have a maximum of 500 and a minimum of -500
that's because the editor's controls can only go from 0 to 1000%

write the conversion down somewhere visible, so that you have it present while editing.
then you probably need to fix the 0 at 500%, and anything below 500 would be reduction.
you'll then have a maximum of 500 and a minimum of -500
that's because the editor's controls can only go from 0 to 1000%

write the conversion down somewhere visible, so that you have it present while editing.

I made some adjustments to make it work, but indeed, I'll write how to use it somewhere or I'll forget for sure 🙂

Thank you for your help 🙂

Original thread: https://forums.rpgmakerweb.com/threads/replace-elemental-resistances-by-formulas.87958/