MV Weird interaction in Yanfly's Element Core

This happens while having the Multi-Element Ruling set to "Multiply". When I have a battler whose elemental rate towards element 1 is 0%, but their elem rate towards element 2 is NOT 0%, and they get hit with a skill which utilizes both elements together, the final damage should be 0, but the rates get ignored and the battler takes normal damage.
Looking at the code, I get why this happens. Because the battler nulls one of the elements, the final rate becomes 0, but when a skill does not use multiple elements, final rate is not calculated so it also returns a 0, and it defaults to 1 in both cases. I did find a wacky workaround already, but I was wondering if something can be done about it.

1700487772700.png
are you YEP plugins in the correct order?
and 0% element rate = 0 dmg either if the skill dmg could still affect them.
element rate is more for their weakness/strong against the element rate.

are you sure you have it correctly? you can share the attack of the element
rate or notetag used.

if you YEP plugins are in the incorrect order, it behavior can cause this.
They are very much in correct order, I've double-checked this more than once.
Because the battler nulls one of the elements, the final rate becomes 0, but when a skill does not use multiple elements, final rate is not calculated so it also returns a 0, and it defaults to 1 in both cases. I did find a wacky workaround already, but I was wondering if something can be done about it.
Try sorting the array.
Before the while loop starts on line 741, put this:
Code:
  elements.sort(function(target.elementRate(a), target.elementRate(b)) {return b-a});

That should put the elements into order of decreasing effectiveness on the target, so it will be impossible for the first one to be 0 unless they all are.

The rest of the loop should then function as intended.

Let me know if that has any issues, I'll include it in my thread of fixes.
Code:
elements.sort(function(target.elementRate(a), target.elementRate(b)) {return b-a});
That doesn't seem to work, unfortunately. Full damage is still taken.
That's odd.

Put a console log after it, so now the line looks like this:
Code:
elements.sort(function(target.elementRate(a), target.elementRate(b)) {return b-a}); console.log(elements);

Then press F8, go to the Console tab, take a screenshot of what the array looks like when you do the attack.
1700501999205.png

Besides an error, nothing happens.

1700502147640.png

Just to make sure, am I putting everything in the right places?
So that error is saying the entire plugin isn't getting loaded because of a typo in JavaScript. I didn't think this mattered, but let's change it around to this:
Code:
elements.sort(function(a, b) {return target.elementRate(b)-target.elementRate(a)});
It's throwing the same error, but says "token {" instead of "token .", I then added a missing circle bracket, now it's telling me there's an unexpected identifier. Tried removing both circle brackets, it goes back to "token {".
lol, I am batting 0 here. I dunno what my brain did in that last post, but it's not JavaScript.

Corrected.

Code:
elements.sort(function(a, b) {return target.elementRate(b)-target.elementRate(a)});
1700503276302.png

This did work! In this specific case, my battler is immune to element 2 but not element 1. Still taking full damage though.
Do you have a sample project with the element rates and skill already configured that you can send to me?
No, but I can make one very quickly. Shouldn't take too long.

Edit: After fiddling around, now everything suddenly works the way it should, even on my past projects which had the same issue beforehand? Besides turning some plugins off and on in one of my projects, I haven't touched anything. This is the second time something just rewrites itself deep in the engine's code (I guess) and begins working on my end after I playtest things. I'm beginning to think my copy of this program is cursed.

Edit: ...nevermind? I don't understand what's going on. But things work the way they should in my sample project, which only has these plugins.
1700507149308.png

Original thread: https://forums.rpgmakerweb.com/threads/weird-interaction-in-yanflys-element-core.163104/