MZ Buff/Debuff HP Stacking States || Visustella

So I'm trying to create two effects I call Life and Death. They're both essentially opposite effects. Life increases Max Health by 10%, Death decreases Max Health by 10%. Each has a max of 10 stacks.

They also have a special interaction. Let's say for example you apply Death to a target, but the target already has 3 stacks of Life. I want to make it so they don't exist at the same time, so Death would remove itself and the target would have 2 stacks of Life with a 20% Max Health increase. So it's not much different than an HP Buff/Debuff, but the reason I'm going for a state is because the other buffs have a rate of 20%, and since some skills scale off HP, and that would make HP buffing/debuffing faster, I found that a bit too OP. I also will be making some of the bosses immune to these so they don't get cheesed or cheese the player in return.

I do have two issues though. The formula I'm going for is an additive/subtractive percentage, and from looking at the Core Engine, I only see the option for a flat or multiplicative percentage. I'm not sure if I'm missing something or if additive's just not possible. I don't mind settling for multiplicative per se if it's not a thing, but in terms of balance, additive would be much better.

The other issue is raising the HP itself. I know how to raise the stack count, but I'm not sure how to make it update with the formula as the stacks keep going up/down.

So I'm essentially asking for help on how to make state buffs stack.
So it's not much different than an HP Buff/Debuff, but the reason I'm going for a state is because the other buffs have a rate of 20%, and since some skills scale off HP, and that would make HP buffing/debuffing faster, I found that a bit too OP
does the visustella plugin that lets you set buff rates and stacks not let you specifically make hp's values different? Even with Yanfly's buffs and states core plugin, there was a variable for the paramId you could use to specify within the parameter that certain ones could scale differently

I do have two issues though. The formula I'm going for is an additive/subtractive percentage, and from looking at the Core Engine, I only see the option for a flat or multiplicative percentage. I'm not sure if I'm missing something or if additive's just not possible. I don't mind settling for multiplicative per se if it's not a thing, but in terms of balance, additive would be much better.
individual states by default are multiplicative with all other sources. If you wanted to have multiple "stacks" of a state and have them be additive without a plugin to just make all states additive, the closest youd get is making a separate state for each level that has the total value as a trait directly, make it so that each battler can have only one of each, and adding more life/death just adjusts which state the battler has.

The other issue is raising the HP itself. I know how to raise the stack count, but I'm not sure how to make it update with the formula as the stacks keep going up/down.
I... dont know what you mean by this. can you clarify? Im unsure of what you meant by stacks in general since states dont stack naturally and you didnt mean buffs. do you already have something working implemented?

Edit:
Eli's Dynamic Parameters could actually do it with a little setup. You could use properties to control the level and have the parameter adjust the hp based on the property
does the visustella plugin that lets you set buff rates and stacks not let you specifically make hp's values different? Even with Yanfly's buffs and states core plugin, there was a variable for the paramId you could use to specify within the parameter that certain ones could scale differently
Hm maybe I should read through it again? I didn't see anything like that but it could be possible I missed it. I mean, I do still want the benefit of bosses being able to immune from having their HP shot down, but it'd be good to know regardless.

I... dont know what you mean by this. can you clarify? Im unsure of what you meant by stacks in general since states dont stack naturally and you didnt mean buffs. do you already have something working implemented?
Yeah I'll reword it, sorry. I'm referring to how you can substitute a variable for the stacks. Take the following for example.


JavaScript:
<JS On Add State>
  target._stackingPoison ??= 0;
  target._stackingPoison++;
</JS On Add State>

<JS On Erase State>
  delete target._stackingPoison;
</JS On Erase State>

<JS Pre-Regenerate>
  target._stackingPoison ??= 0;
  const stacks = Math.min(5, target._stackingPoison);
  const damage = stacks * 100;
  $gameTemp.requestAnimation([target], 59);
  target.gainHp(-damage);
</JS Pre-Regenerate>

The damage is based on the variable "stackingPoison." This is sort of what I had in mind, once the variable that tracks "Life" or "Death" changes, the Max Health would change with it.
Count the stacks like above, so you can check for max stacks and then on add states you use the change parameter script +/- to change the maxhp (save the battlers' maxhp at the start of battle to battler._maxHp if you want it to compare to the original value) target.addParam(0, target._maxHP*0.1);
On erase state you set the battler's maxhp back to battler._maxHp
You can use battler.gainHp(value) stuff to change the hp along with that.
The damage is based on the variable "stackingPoison."
Alternatively, this is what I thought you might have had in mind when I mentioned Eli's Dynamic Traits. You'd be able to use properties such as that _stackingPoison inside a dynamic trait for HP to adjust it additively with each stack.
Count the stacks like above, so you can check for max stacks and then on add states you use the change parameter script +/- to change the maxhp (save the battlers' maxhp at the start of battle to battler._maxHp if you want it to compare to the original value) target.addParam(0, target._maxHP*0.1);
On erase state you set the battler's maxhp back to battler._maxHp
You can use battler.gainHp(value) stuff to change the hp along with that.
So I probably did something wrong. The code itself does try to change the Max Health, but it comes out as NaN. I removed the target._death part earlier to see if I messed that up, but it seems to be just the add Param.

JavaScript:
<JS On Add State>
if (target._death > 0) {
target._death--;
} else {
target._life ??= 0;
target._life++;
}
const stacks = Math.min(10, target._life);
target.addParam(0, target._maxHP*0.1);
</JS On Add State>

<JS On Erase State>
delete target._life;
target._maxHP = battler._maxHp;
</JS On Erase State>

And this is my state for checking Max Health.

Screenshot - 7_22_2025 , 12_04_19 PM.png
target._maxHP*0.1);
replace all ._maxHP's with .mhp
replace all ._maxHP's with .mhp
Clearly I need to get more familiar with the script calls.

Alright, everything is now working except the removal interaction. I tried adding to it to recognize when the other existed, but I can't get it to work. I'm not sure if maybe I should add it to the actual state being removed instead of the one targeting it, though I don't know what that would look like.

JavaScript:
<JS On Add State>
if (target._death > 0) {
target._death--;
if (target._death == 0) {
remove.state(44);
}
}
else {
target._life ??= 0;
target._life++;
const stacks = Math.min(10, target._life);
target.addParam(0, target.mhp*0.1);
}
</JS On Add State>

<JS On Erase State>
delete target._life;
target.mhp = battler._maxHp;
</JS On Erase State>

JavaScript:
<JS On Add State>
if (target._life > 0) {
target._life--;
if (target._life == 0) {
target.removeState(44);
}
}
else {
target._death ??= 0;
target._death++;
const stacks = Math.min(10, target._death);
target.addParam(0, target.mhp*-0.1);
}
</JS On Add State>

<JS On Erase State>
delete target._death;
target.mhp = battler._maxHp;
</JS On Erase State>

Edit: Sorry, I just realized the Death state was removing itself instead of the Life state. Fixing it did get it to remove the opposite state. Though now the effect of Life isn't going away once the state is removed.
the effects wouldnt leave.
target.mhp = battler._maxHp;
a battler's mhp isnt a value you can just set (also battler isnt a variable in that tag and ._maxHP wouldnt be a property unless you defined it prior. battler was just given as an example for any battler).
you alter the battler's max hp with addParam, but the thing is that you need to track their original max hp and do a little math using their current stacks to add/deduct the correct amount of max hp each time. That is the reason why I ended up suggesting Eli's Dynamic Parameters. if you make a rule for both life and death and had HP's value use your current properties then it'd handle that automatically
I finally got it! I was so focused on setting a variable to check the base Max Health, I didn't realize one already existed.

I also found the reason the state wasn't being removed was because I made it conditional to 0 stacks only, so if I had more than one stacks, the Max Health wouldn't change.

@rpgLord69 and @Robro33 thank you both for your help! I'll leave the code here just in case someone else needs a reference for buffing stats through states, as there's not a lot when you search for it.

The Life state for increasing Max Health:

JavaScript:
<JS On Add State>
if (target._death > 0) {
target._death--;
target.addParam(0, target.paramBase(0)*0.1);
target.gainHp(target.paramBase(0)*0.1);
target.removeState(43);
if (target._death == 0) {
target.removeState(44);
}
}
else {
target._life ??= 0;
if (target._life < 10) {
target._life++;
target.addParam(0, target.paramBase(0)*0.1);
target.gainHp(target.paramBase(0)*0.1);
}
}
</JS On Add State>

<JS On Erase State>
delete target._life;
</JS On Erase State>

The Death state for decreasing Max Health:

JavaScript:
<JS On Add State>
if (target._life > 0) {
target._life--;
target.addParam(0, target.paramBase(0)*-0.1);
target.removeState(44);
if (target._life == 0) {
target.removeState(43);
}
}
else {
target._death ??= 0;
if (target._death <= 10) {
target._death++;
const stacks = Math.min(10, target._death);
target.addParam(0, target.paramBase(0)*-0.1);
}
}
</JS On Add State>

<JS On Erase State>
delete target._death;
</JS On Erase State>

Original thread: https://forums.rpgmakerweb.com/threads/buff-debuff-hp-stacking-states-visustella.179067/