MV Yanfly's Tips&Tricks "Spell Shield" VS element shields from FFX

Hello 👋

I'm trying to recreate NulBlaze, NulTide, NulShock and NulFrost from FFX in RMMV. For this, I use Yanfly's Tips&Tricks "Spell Shield" and it works very well... for 1 element shield... not for 2, 3 or 4 that must work together.
The problem is that all the shields disappear together, while I would like only the fire shield to disappear after a fire attack, and not the water shield for example.
I don't know anything about coding, so I don't know how to modify the code to make it work the way I want.

Can someone help me?

Thanks for your attention. I am looking forward to your answers. 🙏

PS : Sorry for my English, I don't speak it and I use a translator.
We need to see the actual code that you're using.

The code you linked to from Yanfly is specifically one state that protects against multiple skills/types, but what you reference from Final Fantasy is specifically multiple states that protect against a specific element.

If you have them properly created as separate states, they shouldn't be able to get removed together unless you have typos someplace.

So please post screenshots or the text of the note fields for each state. If you paste it into a forum post, make sure to put it inside CODE tags (the </> on the edit bar).
Thank you for these indications.

Here is the code I used for the "anti-fire" state:
JavaScript:
<Custom Select Effect>
if (this.item() && DataManager.isSkill(this.item()) && this.isForOpponent()) {
  var blockedskills = [];
  blockedskills.push(13, 14, 15);
  if (blockedskills.contains(this.item().id)) {
    this._formerItemSuccessRate = this.item().successRate;
    this.item().successRate = 0;
    target.startAnimation(53);
  }
}
</Custom Select Effect>
 
<Custom Deselect Effect>
if (this._formerItemSuccessRate !== undefined) {
  this.item().successRate = this._formerItemSuccessRate;
  target.removeState(stateId);
}
</Custom Deselect Effect>

I copied it identically on the "anti-water" state, except the skill's id (blockedskills.push(13, 14, 15)) that I changed to match my database (blockedskills.push(19, 20, 21)).
Independently, they work very well, but when the character has the 2 states, and he takes a fire spell (or a water spell), the 2 states disappear at the same time...
I copied it identically on the "anti-water" state, except the skill's id
If you copied the rest of it identically, that's why they're all being removed.

Reading through the lines, the way the state knows that it took effect is by setting a variable on the battler: _formerItemSuccessRate

Then the Deselect Effect checks that variable to see whether the state did something and should go away.

If you left that variable name the same on all of your states, then, logically, they're all setting and referencing the same trigger to go away.

Each of your states needs to use a unique variable name.
Thank you for your answer. I understand a little better.

I changed the name of the variable _formerItemSuccessRate .
Here is the new code for the "anti-fire" state :
JavaScript:
<Custom Select Effect>
if (this.item() && DataManager.isSkill(this.item()) && this.isForOpponent()) {
  var blockedskills = [];
  blockedskills.push(13, 14, 15);
  if (blockedskills.contains(this.item().id)) {
    this._formerItemSuccessRate1 = this.item().successRate;
    this.item().successRate = 0;
    target.startAnimation(53);
  }
}
</Custom Select Effect>

<Custom Deselect Effect>
if (this._formerItemSuccessRate1 !== undefined) {
  this.item().successRate = this._formerItemSuccessRate1;
  target.removeState(stateId);
}
</Custom Deselect Effect>

For the "anti-water" state, I put _formerItemSuccessRate2 and it works. The states disappear independently of each other.

Thanks a lot for your help. My problem is solved. 😂

Original thread: https://forums.rpgmakerweb.com/threads/yanflys-tips-tricks-spell-shield-vs-element-shields-from-ffx.155804/