Random Death interval with Yanfly Buff&States Core

In my project, I'm using Yanfly's Buff&States core plugin and I have a state that acts like poison to an actor's MP, but I also want this state to possibly kill the actor based on a random interval.

Say for example, it generates a random number between 1-50 and if the number is >= 40, it kills the actor.

Does anyone know how I can do this with the Lunatic Mode?
You will need to use one of the notetags listed here or in the plugin's help file. I recommend doing an effect like this on Turn Start - so use the
<Custom Turn Start Effect> notetag on your State. (Turn End could also be fine.)

I think the notetag would go something like this:
<Custom Turn Start Effect>
var ko_pick = Math.random() * 50;
if (ko_pick >= 40) {
self.addState(1);
}
</Custom Turn Start Effect>

This assumes your KO/Death State is 1. If not, replace "1" with the State ID of the KO State.
sounds good, although the game also uses the ATB battle system and has a Tick-based regen system. I was more thinking it would do it on Regeneration.
<Custom Regenerate Effect>
You think this could work?
sounds good, although the game also uses the ATB battle system and has a Tick-based regen system. I was more thinking it would do it on Regeneration.
<Custom Regenerate Effect>
You think this could work?
Maybe! I've never done a deep dive on the way that Yanfly's core scripts handle the timing of Regeneration. Try it for yourself and see what happens!
I tried inputting the code into the notebox of the state, but it doesn't appear to be doing anything. I even set it to just add the state upon regen and it's not doing anything. Is there something I'm missing?

Original thread: https://forums.rpgmakerweb.com/threads/random-death-interval-with-yanfly-buff-states-core.112335/