MV help with Yanfly's Absorption Barrier (adding type weakness?)

hi! im currently making a game where i want all enemies to have some kind of damage mitigation barrier that only gets depleted if hit by an element its weak to, otherwise simply reducing incoming damage without depleting.

if any of you are familiar with hoyoverse's Honkai: Star Rail, think of it in the sense of the Toughness bar above the enemy. thats basically how i want it to work.

i have no experience in javascript so i was wondering if it was even possible to pull off something like this. ideally, once the barrier is gone, the enemy should also take increased damage, and the enemy's next turn the barrier regenerates in full unless their AGI is reduced, allowing the players to make another move within the turn.

i get theres probably gonna be quite a few "if; else" branches in the coding for it but i dont have the experience or the time to figure it out myself.
You're asking about a lot of stuff for an entire system that would not necessarily be in one state.

To answer the original question,
damage mitigation barrier that only gets depleted if hit by an element its weak to

To clarify, this can only work with Yanfly's plugin if "it" is referring to the battler. Barriers don't have any kind of stats or weaknesses associated with them, and you can't have more than one barrier at a time.

If that's what you mean (e.g. the snowman's barrier only decreases if it gets hit by fire), you'd put a passive state on the enemy that has the notetag:
Code:
<Custom Respond Effect>
if (target.barrierPoints() >= 0 && value > 0 && this.item().damage.elementId != 2)
    value = 0;
</Custom Respond Effect>

If the element of the incoming damage is not 2, and he still has any barrier, it does no damage.

Original thread: https://forums.rpgmakerweb.com/threads/help-with-yanflys-absorption-barrier-adding-type-weakness.170366/