Poison that brings health to a certain percentage

Hello there.

I'm trying to create a state similar to the "TRANCED" effect from Deltarune Chapter 2, where a character loses health over time down to a percentage of their max HP (from 166 to 55, for instance) but no further without external forces like an enemy.
Any way to recreate this state? Preferably in vanilla MZ, but I'm not opposed to using plugins if required.
If you're not already using any plugins, you can use my Eval Tags for this.

You didn't actually say how much health the target should be losing, nor what percentage they should stop at, so it's impossible to give you exact code - you'll have to edit the below.

But you would give the state the notetag:
Code:
<Regenerate Eval>
// Lose 10% of Max HP unless you're already <= 30%
let damage = Math.min(Math.floor(user.mhp / 10), user.hp - Math.floor(user.mhp * .3));

if (damage > 0)
{
    user.gainHp(-damage);
    user.startDamagePopup();
}
</Regenerate Eval>

If you're using VisuStella plugins, you'd do this with one of their Skills and States notetags instead.
If you're using a state plugin, you just create a state Tranced that has negative HP regeneration, and has a condition of being above a certain percentage of HP.
If you're using a state plugin, you just create a state Tranced that has negative HP regeneration, and has a condition of being above a certain percentage of HP.
1 - What state plugin has conditions for states being active? That's a feature exclusive to passive states as far as I've ever seen.

2 - That would not stop the negative regeneration from damaging the battler below the required percent of their HP, assuming they started above it (e.g. if the state is supposed to only take them down to 30% of HP, and they're at 32/100, the negative regeneration would trigger and take them below 30%). The code I provided accounts for that in its math.
If you're using a state plugin
i think its safe to assume they didnt by them preferring a vanilla solution but being open to plugin use, but...
you just create a state Tranced that has negative HP regeneration, and has a condition of being above a certain percentage of HP.
When you suggest plugins for specific issues, link them. AFAIK, all the ones that allow for state conditions use them for passive states and wouldnt do anything for applied states

Edit: I see he hasnt lost any ninja skill despite the lack of recent practice 🤣
Following a few replies here, I'm assuming it's impossible to do in vanilla. Alas.
You didn't actually say how much health the target should be losing, nor what percentage they should stop at
Right, yes... Sorry ^-^
I'm looking for the health loss to stop at 27.5% (55HP if the afflicted has 200 M.HP). I don't really mind how fast it drains, but just for examples sake lets just say 25HP per turn.
If you're using VisuStella plugins, you'd do this with one of their Skills and States notetags instead.
I was actually using VisuMZ because the messageCore they provide is pretty cool, so I guess I'll use that. Is it SkillsStates, ElementStatus, or battleCore I should be looking at? (quick edit, I'm dumb)
Following a few replies here, I'm assuming it's impossible to do in vanilla. Alas.

Not impossible. You could add a Troop Event into every troop that tests every actor and enemy for this state and hits them with a reduction in hp if they are above a certain threshold. Painful, yes, but not impossible.

Even doing it with plugins is probably going to require a snippet of custom code. I'm probably not the person to get the syntax right, but here's the idea. If you were using Visustella Skills and States, you would use a notetag like this:

Code:
<JS type Slip Damage>
 code
 code
 damage = code;
</JS type Slip Damage>

For your damage formula, it could be any amount or percentage you want, but if the damage would take the total below 27.5%, you want to subtract that difference from the damage dealt (and to a minimum of 0 damage).
Not impossible. You could add a Troop Event into every troop that tests every actor and enemy for this state and hits them with a reduction in hp if they are above a certain threshold. Painful, yes, but not impossible.
The problem with that approach is there's no troop event timing for the end of a battler's action. Doing it this way would make your poison state not match any other states in your game that have regeneration/DoT.

If that doesn't bother a person, it's absolutely a functional approach - to me, that difference in the UX would look janky so I wouldn't recommend it.

Even doing it with plugins is probably going to require a snippet of custom code. I'm probably not the person to get the syntax right, but here's the idea.
You could use the correct code that I gave in the first reply.

Also, Slip Damage is the wrong notetag to use for this kind of effect. Per the VisuStella documentation, the slip damage is calculated once when the state is first applied, so it would not account for any of the OP's requirements vis-a-vis stopping at the percentage of max health.

You would want to use the Battle Core's JS Pre-Regenerate (or Post-Regenerate) notetag, and the code I already supplied should work the same.
Also, Slip Damage is the wrong notetag to use for this kind of effect.

Sorry about that!

You would want to use the Battle Core's JS Pre-Regenerate (or Post-Regenerate) notetag, and the code I already supplied should work the same.

Well, there you go. I actually dug around in Battle Core and somehow missed that section.

EDIT: Does that actually work? It looks like it just doesn't do damage if the reduction would take them below the threshold. We want to go right to the threshold, right? So maybe more like

Code:
let marginaldamage = Math.max (user.hp - Math.floor(user.mhp*.3), 0);

let damage = Math.min(Math.floor(user.mhp / 10), marginaldamage));

if (damage > 0)
{
    user.gainHp(-damage);
    user.startDamagePopup();
}

Something like that?

Original thread: https://forums.rpgmakerweb.com/threads/poison-that-brings-health-to-a-certain-percentage.179997/