MV YEP Buffs & States: Reducing total damage output by 50% AND removing if damage > 0

Hi everyone,

Okay, here it goes.

I'm trying to create a state that when applied to a target, reduces that whatever that total damage output of that target's action would have been by X percent, AND if the damage output is greater than 0, to then remove the state from that target.

I hope that's pretty clear. Here's an in-battle situation I would imagine it be used in:

1) Actor1 uses Skill1 on Enemy1
2) Skill1 applies State1 to Enemy1
3) When Enemy1 takes their next action against any actor in the party, State1 checks for:

Is this a Physical Elemental attack?

Ie:
Code:
if this.item().damage.elementId == 1 {

If so, reduce total output damage by 50% AFTER all other calculations are made.

Did this hit an actor with a total damage output greater than 0?

If so, remove the state from the user.

Ie:
Code:
user.removeState(16);

I hope that's pretty clear. I'll show you my garbled attempt at creating this, and I'd love for someone to point out all my mistakes.

Code:
<Custom Establish Effect>
if (value > 0 && this.item().damage.elementId == 1) {
user._dmgCount += value;
}
</Custom Establish Effect>

<Custom React Effect>
value *= 0.5
</Custom React Effect>

<Custom Action End Effect>
if (user._dmgCount > 0) {
user.removeState(16);
}
</Custom Action End Effect>

Thanks for any help you can provide on this!
Bump.

Original thread: https://forums.rpgmakerweb.com/threads/yep-buffs-states-reducing-total-damage-output-by-50-and-removing-if-damage-0.129831/