Element Rates bugged if 1 rate is set inside Actor's Traits and the other in a Class?

Hi.

I have following weird situation.

I don't use any plugins.

My Actors and Enemies have multiple element rates. Stats are the same (everything = 100) with no variance in damage for debugging. Base damage is 100 and element rates make last digit either 5 or 0. Max. Damage is 300. Element rates are either 50%, 150% or 200%.

Enemy elements are stored in their respective database entry.

My actors have Element Rates in Actor and Class Traits. Mainly for debugging purposes to quickly change stuff instead of making seperate actor. I setup Class Change NPCs that make you forget all previous learned skills.

One glich I noticed is that if enemies have different then their damage output is much higher. 313, 625, 938, 1875. 625 seems to be the base damage. Much higher. Meanwhile the Actors damage output is minimized. 22 and 24 base damage. The base damage output is totally different. The rates seem to work tho. If enemies and actors have the same attribute then everything seems fine however.

This is the formula:
JavaScript:
(a.atk * 100 / b.def) * b.elementRate(1) * b.elementRate(2)

b.elementRate(2) is a variable but making it a constant didn't fix the glitch.

Then I removed the Element Rates from the Class and put them in the Actor's traits. Solved the problem. Adding the Element Rates by Equipment also worked.

Hope you understand this situation.

Is this a known glitch or an error by me? It makes no sense to me.

Thanks in advance.
Is this a known glitch
Not as far as I know. The core engine does not check where traits come from: it collects all traits, then filters out irrelevant ones.

Only the actor's current class contributes traits. Are you certain you're looking at the correct class?

On class change, the engine only remembers the experience for the previous class. Every other non-permanent change is lost. Learning a skill (e.g. on level up, from a Learn Skill action effect, or through the Change Skill command) is a permanent change. By default, without script calls, learned skills can only be forgotten via the Change Skill command.
I setup Class Change NPCs that make you forget all previous learned skills.
I'm guessing you used Add Skill traits for this?
If you are adding one rate in an actor and one in a class, by default the engine is going to multiply both of those values and apply it to your damage anyways.

Also I believe b.elementrate(1) only returns the rate of the first element, so you are only checking elements 1 and 2 there. But adding that to your damage formula AND still using an element in your skill is applying it 2x, once in the formula and once later by the engine.
Only the actor's current class contributes traits. Are you certain you're looking at the correct class?
Pretty sure. All classes have no traits except adding skill type and Elemental Rate. Classes purpose are just adding an Elemental Rate. The "main" Elemental Rate can't be changed and therefor I put it in the Actor's Traits.

On class change, the engine only remembers the experience for the previous class. Every other non-permanent change is lost. Learning a skill (e.g. on level up, from a Learn Skill action effect, or through the Change Skill command) is a permanent change. By default, without script calls, learned skills can only be forgotten via the Change Skill command.
The skills aren't the problem. They work fine. It's just the damage calculation is off like I described above if the second Elemental Rate is added on the Class.

I'm guessing you used Add Skill traits for this?
I use a script to forget all previous learned skill so only the ones from that Class are usable.

JavaScript:
for (var i = 0; i < 999; ++i) {

    $gameActors.actor(10).forgetSkill(i)

};

Then it changes the Class of an Actor.

If you are adding one rate in an actor and one in a class, by default the engine is going to multiply both of those values and apply it to your damage anyways.

Also I believe b.elementrate(1) only returns the rate of the first element, so you are only checking elements 1 and 2 there. But adding that to your damage formula AND still using an element in your skill is applying it 2x, once in the formula and once later by the engine.
b.elementalrate(1) isn't really necessary cause I can add an Element to the Skill itself. If I'm adding it in the formula then it's a constant cause the skill's Element isn't variable. In this case I also remove the Element of the skill so it's only calculated in the formula.
I assume you know this already, based on your damage formula, but just in case: element rate multiplies incoming damage. E.g. if you have 25% Fire element rate and someone hits you with Fireball for 80 Fire damage, you will only take 20 damage (25% of 80). It has no effect on outgoing damage.

For completeness, the default action damage calculation is as follows:
  1. Evaluate the formula (clamps to minimum of 0, returns 0 on error).
  2. Multiply the result by the target's rate for the element of the Skill/Item.
  3. If the Skill/Item is Physical Hit: multiply by the target's Physical Damage (PDR) Sp-param.
  4. If the Skill/Item is Magical Hit: multiply by the target's Magic Damage (MDR) Sp-param.
  5. If this is healing: multiply by the target's Recovery Effect (REC) Sp-param.
  6. If this was a critical hit: apply the critical damage modifier (default is x3).
  7. Apply variance based on Skill/Item setting.
  8. Apply guard-based damage scaling.
  9. Return the result, rounded to the nearest integer.
This is the formula:
JavaScript:
(a.atk * 100 / b.def) * b.elementRate(1) * b.elementRate(2)
To be clear: this means "(100 times the attacker's ATK, divided by the target's DEF) multiplied by the target's element rates for elements 1 and 2". So the result is dependent on 4 different values. Let's say those values are:
  • Attacker ATK: 20
  • Target DEF: 100
  • Target's rate vs element 1: 150%
  • Target's rate vs element 2: 50%
Then evaluating the formula (step 1, above) gives: (20 * 100 / 100) * 1.5 * 0.5 = 15.

Like bgillisp said, element rate traits get multiplied together. E.g. if you have two 150% Fire element rate traits, they multiply to yield 225% rate vs Fire. The engine automatically multiplies the result by the target's element rate for the skill's Element, so unless your skill is set to Element: None, it's possible the element rate will apply twice for one element. (If it's set to Element: Normal Attack, that opens a new range of possibilities.)

Screenshots of relevant database pages might help:
  • Types - to see what names you've given your elements.
  • Skill - to check any skill settings that might affect the damage calculation.
  • Enemy - to check vs the actor's class, to see what kind of ATK/DEF values they have.
  • Actor & Class - to check for anything you might've missed.
Bear in mind that if you're using Battle Test, the actors may not be equipped with their starting gear.


You can check element rates, e.g. copy+paste this into the Console tab of the dev tools (F8 or F12 during test), then press Enter:
Spoiler: click to view - check element rates
JavaScript:
(() => {
  const M = $gameParty.members(), A = $dataSystem.elements, r = {};
  for (let n = 0; ++n < A.length;)
    r[A[n]] = M.map(a => a.elementRate(n));
  console.table(r);
})();
Doing so should display a table of values in the console: one row per element, one column per party member. Alternatively, specifically for your damage formula:
Spoiler: click to view - check formula values
JavaScript:
(() => {
  const M = $gameParty.members(), r = { atk: {}, def: {}, rate1: {}, rate2: {} };
  for (const battler of M) {
    const k = battler.name();
    r.atk[k] = battler.atk;
    r.def[k] = battler.def;
    r.rate1[k] = battler.elementRate(1);
    r.rate2[k] = battler.elementRate(2);
  }
  console.table(r);
})();
To check enemies with either of these, simply replace $gameParty with $gameTroop.
Well, I guess my lack of experience is the true glitch.

The Class Change NPC was the culprit. I didn't tick "Save EXP" cause I didn't know what it excactly does and didn't think of checking it. My initial Levels are 50 and it reseted it to 1. Never thought of an effect like this and so my debugging overlooked this change. That caused higher damage output on enemy side. The Element Rates work fine. Still stupid that changing class can reset levels but doesn't make you forget/disable previous learned skills with old class.

Thanks to console debugging I saw the problems. Another powerful tool I discovered.
No worries, good to hear you solved it! And yes, the console can be very helpful. 👋

Original thread: https://forums.rpgmakerweb.com/threads/element-rates-bugged-if-1-rate-is-set-inside-actors-traits-and-the-other-in-a-class.160456/