Stacking elemental resistance?

Im having a few problems with my armors and items. I want to create pieces of armor and augments that increase fire resistance by 10%. To the point if you stack enough you can become fully immune.

I created a state Resist Fire:
Code:
<Custom Apply Effect>
user._stackingresfire = user._stackingresfire || 0;
user._stackingresfire += 1;
user._stackingresfire = Math.min(user._stackingresfire, 10);
user.setStateCounter(stateId, user._stackingresfire);
</Custom Apply Effect>

<Custom React Effect>
target._stackingresfire = target._stackingresfire || 1;
var stacks = target._stackingresfire;
var elements = this.getItemElements();
var fireId = 2;
if (elements.contains(fireId) && this.isHpEffect() && value > 0)
var resfiremultiplier = 1 - (stacks * .1);
value = math.ceil(value * resfiremultiplier);
</Custom React Effect>


<Custom Remove Effect>
user._stackingresfire = 0;
</Custom Remove Effect>

It does not work I dont understand why not.
I'm assuming you've set this as a passive state: passive states are always present, so custom apply effects don't trigger because they're never applied.
I'm assuming you've set this as a passive state: passive states are always present, so custom apply effects don't trigger because they're never applied.

Actually the damage reduction didnt work but I finally figured it out.

You are correct I just realised it does not work. Im using passive states and attachable augments

Code:
<Augment: Orb>
Add Passive State: fireresiststate(id)
</Augment: Orb>

It only applies the state once even if I add 5 fire resist orbs, also if I cast a skill that would add a stack it does not add. :S I guess its passive states the problem?
I found another thread

Code:
<Augment Attach Eval: Orb>
text += '2, 90%';
ItemManager.applyAugmentElement(item, text, true);
</Augment Attach Eval: Orb>

Im not sure if I fully understand it but I set it to 90% equip 5x orbs and the damage taken from fire was about half. So I think this is the solution? No states required.

Original thread: https://forums.rpgmakerweb.com/threads/stacking-elemental-resistance.124868/