Yanfly Lunatic Scripting - Shin Megami Tensei-styled Instant Death?

Hello! I'm trying to get Shin Megami Tensei styled instant death abilities to work, and I'm having a bit of a doozy of a time since my scripting knowledge is lackluster, so any help would be appreciated.


By Shin Megami Tensei styled I mean that the instant death is elemental in nature - you have light elemental instant kills, and dark elemental instant kills, and these can be reflected, resisted, or nullified separately from a generic "apply state Death" ability - if I just made it so enemies nullified instant kills with state 0001, there wouldn't be a difference between using light elemental instant kills and dark ones, and I want there to be a difference. Connecting the state to the element isn't necessary (i.e if they have a resistance to Dark it wouldn't have to automatically resist Dark-Death either, I have no problem doing that manually), but just having the two separate elemental deaths would be great.


I tried repurposing the "Doom" code from Yanfly's Doom tips & tricks, but instead of being on expiry, it was on state application, and that didn't work. Then, I tried making it on Confirm effect, nothing, React effect, also nothing. The code I used is in the spoiler - the javascript itself is completely unmodified, the only thing I changed is that it was on apply (in state form), confirm, or react (on the spell itself). I also tried changing "user" to "target" for the variations where I coded it directly into the ability, but again, nada.

Spoiler
<Custom Leave Effect>


// Get the death state for the user.


var deathState = user.deathStateId();


// Check if the user is not immune to death nor resistant to it.


if (user.stateRate(deathState) > 0.01 && !user.isStateResist(deathState)) {


// Play animation on the user.


user.startAnimation(65);


// Set the user's HP to 0.


user.setHp(0);


// Check if the user is dead.


if (user.isDead()) {


// Make the user collapse.


user.performCollapse();


}


}


</Custom Leave Effect>



Any help would be appreciated! Thank you!
Maybe should you try using JavaScript on the skill. I haven't tried, but it can work:


<After Eval>


// Get the Death state for the target.


var deathState = target.deathStateId();


// Check if the target is not immune to death nor resistant to it.


if (target.stateRate(deathState) > 0.01 && !target.isStateResist(deathState)) {


  // Play animation on the target.


  target.startAnimation(65);


  // Set the target's HP to 0.


  target.setHp(0);


  // Check if the target is dead.


  if (target.isDead()) {


    // Make the target collapse.


    target.performCollapse();


  }


}


</After Eval>
Maybe should you try using JavaScript on the skill. I haven't tried, but it can work:


<After Eval>


// Get the Death state for the target.


var deathState = target.deathStateId();


// Check if the target is not immune to death nor resistant to it.


if (target.stateRate(deathState) > 0.01 && !target.isStateResist(deathState)) {


  // Play animation on the target.


  target.startAnimation(65);


  // Set the target's HP to 0.


  target.setHp(0);


  // Check if the target is dead.


  if (target.isDead()) {


    // Make the target collapse.


    target.performCollapse();


  }


}


</After Eval>

Didn't work, even though it seems like it should - maybe it's a conflict with my other plugins. I figured out a viable workaround, however, and one that I arguably like slightly better, so don't worry about it!

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-lunatic-scripting-shin-megami-tensei-styled-instant-death.71977/