Unable to make Yanfly's death nova work

Hello, everyone!

As the title says, I have certain problems with that skill made by Yanfly. "Death nova" works like this: if a character that has the death nova state dies, it immediately damages and poisons all the enemies. So you have to create a death nova state that bypasses death, then paste a code into the k.o. state that will damage and poison the enemies if the dying unit has the death nova state. This is the code that goes into the k.o. state:

<Custom Apply Effect>
var deathNovaId = 271;
if (target.isDead() && target.isStateAffected(deathNovaId)) {
var poisonId = 37;
var caster = target.stateOrigin(deathNovaId);
var dmg = caster.mat * 6;
var foes = target.opponentsUnit().aliveMembers();
for (var i = 0; i < foes.length; ++i) {
var foe = foes;
if (foe) {
foe.gainHp(-dmg);
foe.addState(poisonId);
foe.startDamagePopup();
if (foe.isDead()) {
foe.performCollapse();
}
foe.clearResult();
}
}
target.startAnimation(109);
target.removeState(deathNovaId);
}
</Custom Apply Effect>

Obviously I edited the fields that checks the "death nova" state and applies the poison to the enemies. The problem is that after the unit with the death nova state dies, nothing happens. The state bypasses death, so there problem occurs when trying to target the enemies.

This ability is made by using three different plugins; battle engine core, buffs & states core and state categories. (All of those plugins are working as intended, so that's not causing my problem.)

Thanks for reading!
Using any other plugins by other creators?
For me yanflys auto life did not work when i was using ramzas shield block plugin. The auto life state just got ignored...
Using any other plugins by other creators?
For me yanflys auto life did not work when i was using ramzas shield block plugin. The auto life state just got ignored...

Yeah, one of my plugins (one I'm not even using) was preventing the ability to work correctly. Thank you very much for your help, I couldn't have discovered the problem without it.
You are welcome. Glad I could help you.

Best Regards Nebu

Original thread: https://forums.rpgmakerweb.com/threads/unable-to-make-yanflys-death-nova-work.108239/