MV Adaptability State

So I would like to have a state that grants the affted individual the ability to gain greater defenses against an element each time they are hit by it.

For example: Mage A casts Fireball. Enemy takes normal damage. Mage B casts Fireball, Enemy takes 50% damage. Mage A casts fireball again, Enemy is now immune. Mage B casts Fireball, Enemy now absorbs it.

I'm using a lot of Yanfly plugins, and I'm pretty sure its possible with his plugins Eval Codes but I'm not very confident in using them.

Non-Yanfly solutions are appreciated too!
Moved to: Plugin Support

Ideas and Prototypes is for discussing design (of an individual project or mechanic), not asking for help with implementation in RPG Maker. Normally I'd move this to MV Support, but since the best solution is almost certainly a smart set of notetags in Yanfly's Buffs & States Core (or similar), I'll send it over to Plugin Support instead, where the notetag wizards hang out.
I'd use a State Counter to track how many times you've been hit by an elemental effect and base the element rate calculation off of that. Then use a Custom Respond Effect to see if incoming damage is elemental and increment the state counter if so.

Original thread: https://forums.rpgmakerweb.com/threads/adaptability-state.135694/