Yanfly's /Post-damage/ tag eval help

Hi!


I'mtring the following skill:

Deals magic damage and stacks 1 Ice Counter on target (max. 5). This skill deals 10% less damage for each Counter. When used in a target with 5 counters, it consumes all counter to deal a massive damage on it.



So I'm using the following tags:


<damage formula>
var target._iceCounters = target._iceCounters || 0;
var bonus = target._iceCounters * 0.1;
value = (50 + a.mat) * (1 - bonus);
</damage formula>
<Post-Damage Eval>
var dmg = Math.floor(a.mat * 1.5);
if (target._iceCounters < 5) {
target._iceCounters += 1;
target.addState(13);
} else {
if (target.isAlive()) {
target.removeState(13);
target.startAnimation(71);
target.gainHp(-dmg);
target.startDamagePopup();
target.clearResult();
target.removeState(13);
}
if (target.isDead()) {
target.performCollapse();
}
}
target._iceCounters = undefined;
}
</Post-Damage Eval>




but everytime the skill deals the base damage, plays the animation 71 (counters exploding). It does not add any counters, or apply the State (the state itself does nothing, only mark the counters), neither do the explosion damage >:


also, i want to make these counters accesible to other skills!


can someone help me?

Original thread: https://forums.rpgmakerweb.com/threads/yanflys-post-damage-tag-eval-help.65737/