MV Looking for a way to add a flat damage bonus upon hitting an elemental weakness

Hi. I set up my game in a way that numbers are very low. Buffs and states are all about small, flat numbers. I like it. It makes things easy for my brain to process while doing what matters: Designing an interesting game. But this game relies a lot on elements, and I really don't want to deal with multiplicative elemental bonuses.

So, I want to add +1 to attacks when hitting an elemental weakness, and -1 when hitting an elemental resistance.

I tried messing with some Pi/Sum stuff in the rpg_objects.js file (I ended up reverting the changes, because I had no idea what I was doing). Now I'm setting up a troop event that checks if the actor and the enemy are affected by specific states, and if they are, I'll see if I can add the flat damage bonus. This seems like an ugly solution, though.

Is there maybe something I can put in the damage formula that would check for states (since elements are applied to battles via states in my game)? Something like "if (a.isStateAffected(13) && b.isStateAffected(16))"? Perhaps there's a way I could emulate an elemental system, without relying on the vanila/baseline one that comes with the engine? I have Yanfly's ElementCore plugin, too, if that helps, but I wasn't able to find anything in the plugin settings that could help me with this situation.

I'm not a coder, so please be kind. No one is born knowing everything.

Thank you.
this is a sample you can use:
a.isStateAffected(13) && b.isStateAffected(13) ? (a.atk + 2) - (b.def - 1 ) : a.atk - b.def

or similar like this, depend if you use the default a.atk * 4 (which I do not).

but more samples can be found [here] to alter if needed.
I tried messing with some Pi/Sum stuff in the rpg_objects.js file
You shouldn't make changes to those files directly. Many plugins work on the assumption that those files are unchanged.

Do your skills themselves not have elements? Is it all just entirely state based?
this is a sample you can use:
a.isStateAffected(13) && b.isStateAffected(13) ? (a.atk + 2) - (b.def - 1 ) : a.atk - b.def

or similar like this, depend if you use the default a.atk * 4 (which I do not).

but more samples can be found [here] to alter if needed.
Thank you. Is there a way to check multiple states instead of just one? Like, a.isStateAffected(13 or 14 or 15) && b.isStateAffected(16 or 17 or 18)?

You shouldn't make changes to those files directly. Many plugins work on the assumption that those files are unchanged.

Do your skills themselves not have elements? Is it all just entirely state based?
Oh, I didn't edit the file directly. I made a new .js and put the edited code there. Thanks for the warning, though.

The skills are all set to "Normal Attack", and they take their Elemental value from states. If actor A has the state that gives them the Milkshake type, their moves will be of the Milkshake type.

--

So, I found this thread after I posted this one:


With the modified code suggested by bgillisp, I think setting the Elemental Rate of an enemy to 101% will make so they take 1 extra damage, and setting it to 99% would make so they take 1 less damage. I'm about to test it out.

Edit: It worked! I had to change the second 100 to 101 in this line of code, though:

JavaScript:
var value = baseValue + (this.calcElementRate(target) * 100 - 101)

The entire thing:

JavaScript:
Game_Action.prototype.makeDamageValue = function(target, critical) {
    var item = this.item();
    var baseValue = this.evalDamageFormula(target);
  //  var value = baseValue * this.calcElementRate(target);
    var value = baseValue + (this.calcElementRate(target) * 100 - 101)
    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;
};
it would be better for a function, or write it someone to have it readable
so you have:

(a.isStateAffected(13) || a.isStateAffected(15) || a.isStateAffected(16) &&
b.isStateAffected(16) || b.isStateAffected(17) || b.isStateAffected(18)) ?
a.atk * 4 - b.def *2 : a.atk - b.def

but if you can set it as function, you can make a list of different attack
and call it from the plugin.

otherwise, lunatic code.

Original thread: https://forums.rpgmakerweb.com/threads/looking-for-a-way-to-add-a-flat-damage-bonus-upon-hitting-an-elemental-weakness.169845/