Creating a barrier that increases MAX HP while active?

Hi, trying to make a skill that increases the target's max HP but formula uses the users ATK+DEF stat. Also it creates a barrier using same gain in max HP, however id like the max HP gain be removed when the barrier is gone. Im doing this because I have a character whos damage is based on their max HP, so this serves as a dps boost and shield.

I did some research and copied/tried to learn how to get it working for my purposes; here's what I have:

Skill:
Adds State 46
<Custom Target Barrier>
value = a.atk + a.def;
</Custom Target Barrier>


State 46
*Remove at Battle End
<Custom Apply Effect>
var boost = a.atk + a.def;
user.addParam(0, boost); // mhp up
</Custom Apply Effect>

<Custom Remove Effect>
target._boostDmg = target._boostDmg || a.atk + a.def;
if (target._boostDmg < 0) {
value = 0;
}
var boost = a.atk + a.def;
user.gainHp(-value); // hp down
user.addParam(0, -boost); // mhp down
target._boostDmg = undefined;
</Custom Remove Effect>

<Custom React Effect>
if (user.barrierPoints() <= 0) {
user.removeState(46);
}
</Custom React Effect>

So it kinda works, if I cast it on user, it applies the buff and barrier and when barrier is gone it removes state.
A few issues is when I have the barrier on another character, the state does not go away.
Also oddly after battle the user loves the state but keeps the max HP gain..
In <React Effect>, you must use "target", not "user" because "user" is referred to the attacker, while "target" is referred to the defender. So if you want your state to be removed when the barrier disappears, it must be the defender (target), not attacker (user).
In <React Effect>, you must use "target", not "user" because "user" is referred to the attacker, while "target" is referred to the defender. So if you want your state to be removed when the barrier disappears, it must be the defender (target), not attacker (user).
I tried this;

<Custom Apply Effect>
var boost = a.atk + a.def;
target.addParam(0, boost); // mhp up
</Custom Apply Effect>

<Custom Remove Effect>
target._boostDmg = target._boostDmg || a.atk + a.def;
if (target._boostDmg < 0) {
value = 0;
}
var boost = a.atk + a.def;
target.gainHp(-value); // hp down
target.addParam(0, -boost); // mhp down
target._boostDmg = undefined;
</Custom Remove Effect>

<Custom React Effect>
if (target.barrierPoints() <= 0) {
target.removeState(46);
}
</Custom React Effect>

However it still does not work and gives inconsistent results. Issues being:
-I would like the increase to be based off of caster's stats not target.
Edit: Im also unsure how it would work with re-casting while barrier is up. Is there a way to make sure all HP Gain is removed either at end of combat or when barrier = 0, currently it removes only 1 instance of the MHP gain, so casting more then 1 time per battle breaks game, keeping the MHP.

-Takes a round to refresh sometimes. The shield will break but the state remains until takes damage or is healed.
EDIT2: Learning is FUN! <Custom Deselect Effect>, applies after damage so it can remove state right after barrier.
Oh, that's right. I just forgot that <Deselect Effect> happens right after the damage is done to the defender, so checking the barrier points at that time is better. I'm glad you have found a solution.
Oh, that's right. I just forgot that <Deselect Effect> happens right after the damage is done to the defender, so checking the barrier points at that time is better. I'm glad you have found a solution.

I still cant figure out the formula that would increase MHP based off of caster's stats not target.
Also any idea how to make it stack able 3 times? or at least unable to be cast because right now I have it breaking the game, it permanently increases HP if cast a second time.
I have never toyed with a state which increases max HP, so I have no idea what it should be. But I think this can be done better with another plugin from Yanfly: The Base Parameters Control
I have never toyed with a state which increases max HP, so I have no idea what it should be. But I think this can be done better with another plugin from Yanfly: The Base Parameters Control

At first glace it doesnt look like it will work how I need, that or I have absolutely no idea how to go about it. Im already pretty trash at this so I don't even know where to begin with this plugin.

Alternatively I need to learn to how stack states and then maybe I can make the MHP lose formula stack * atk+def. I right now dont know how to do stacks so its an issue in itself lol.
I often do stackable states on my own using just Buffs & States Core. But it can only deal with some certain things, like increasing/decreasing damage dealt/taken, or regenerating HP/MP. I still cannot make a stackable state which increases/decreases parameters. This can be done with Yanfly's Parameter Control plugins, but I have not tried yet (too lazy to do, because it requires me to manually add/remove parameters each time the state is added/removed).

I've moved this thread to Plugin Support. Thank you.

I often do stackable states on my own using just Buffs & States Core. But it can only deal with some certain things, like increasing/decreasing damage dealt/taken, or regenerating HP/MP. I still cannot make a stackable state which increases/decreases parameters. This can be done with Yanfly's Parameter Control plugins, but I have not tried yet (too lazy to do, because it requires me to manually add/remove parameters each time the state is added/removed).

Ah laziness the enemy of us all. I understand, so if im correct in theory we could just do a replaceable state instead of stackable, Buff1 if cast again will remove Buff1 and add Buff2 and so on each with a tag that
Buff 1
<maxhp Plus: +a.atk+a.def>
Buff 2
<maxhp Plus: +a.atk+a.def>
Would this even work, the more I think about it the less I understand or over complicate it, first does formulas even work in the note tag box or its only static numbers? Also im unclear how to go about the reduction, another state that when Buff 2 expires adds a new state that lowers the stats, or simply the maxhp gain from state is only temporary and will auto reduce upon expiry.

Sorry for all the questions! I appreciate the help from you! I seen posts from you before and your very helpful!
Personally, I do not prefer this way. It wastes so many state slots (the database is limited though). I prefer using only one state, with the help of flags, and some script calls from the plugin. It may look like this:
Code:
<Custom Apply Effect>
target.addMaxHp(100);
target._stackMhp += 1;
target.setStateCounter(x, target._stackMhp);
</Custom Apply Effect>

<Custom Remove Effect>
var hpminus = user._stackMhp * 100;
user.minusMaxHp(hpminus);
user._stackMhp = undefined;
</Custom Remove Effect>

By this way, each time the state is applied, the max HP increases by 100. And when the state is removed, minus the max HP by 100 per stack. However, I was too lazy to remove parameters manually, especially on some stackable states like this. So I have not decided to mess with parameters yet, even though it makes the game more interesting.
Personally, I do not prefer this way. It wastes so many state slots (the database is limited though). I prefer using only one state, with the help of flags, and some script calls from the plugin. It may look like this:
Code:
<Custom Apply Effect>
target.addMaxHp(100);
target._stackMhp += 1;
target.setStateCounter(x, target._stackMhp);
</Custom Apply Effect>

<Custom Remove Effect>
var hpminus = user._stackMhp * 100;
user.minusMaxHp(hpminus);
user._stackMhp = undefined;
</Custom Remove Effect>

By this way, each time the state is applied, the max HP increases by 100. And when the state is removed, minus the max HP by 100 per stack. However, I was too lazy to remove parameters manually, especially on some stackable states like this. So I have not decided to mess with parameters yet, even though it makes the game more interesting.

Cool thanks! Ill give it another try, spent way to much time on things that dont end up working! I need a win lol.

What do you mean when you said remove parameters manually? Im not sure I follow where the laziness comes in. I agree having too many states clutter is not the direction I want to go towards, already I have or will have a ton of states.

Also I think I understand most of it but what does "user._stackMhp = undefined;" do?, is this the reset stacks to zero? Why or what does undefined do?
You can set the user._stackMhp back to 0 if you prefer. I just learned this from Yanfly tips & tricks. In some cases, I want to check if the flags are undefined or not to do something else.

And to clarify my laziness, I have lots of stackable states in my game. And if some of them affect one actor at the same time, things might get messy. Or if I just forget to remove the parameters in some states, it will be hard to identify which causes the issue.
You can set the user._stackMhp back to 0 if you prefer. I just learned this from Yanfly tips & tricks. In some cases, I want to check if the flags are undefined or not to do something else.

And to clarify my laziness, I have lots of stackable states in my game. And if some of them affect one actor at the same time, things might get messy. Or if I just forget to remove the parameters in some states, it will be hard to identify which causes the issue.

Okay cool good to know, not sure the difference or when to apply it but its good to pick up good habits.

So are you saying that if this state stacks on one guy and you apply a different state that will state things goto hell?

Edit: Tried stacks using your code and it crashed so im going to just make it like this, it works well enough and unable to be cast on the same target.
Code:
<State Animation: 175>

<Custom Apply Effect>
target.addMaxHp(100);
</Custom Apply Effect>

<Custom Deselect Effect>
if (target.barrierPoints() <= 0) {
target.removeState(46);
}
</Custom Deselect Effect>

<Custom Remove Effect>
user.minusMaxHp(100);
</Custom Remove Effect>
I was just giving you an example of how it should be. It is not the detailed codes, so don't take it seriously haha.

Original thread: https://forums.rpgmakerweb.com/threads/creating-a-barrier-that-increases-max-hp-while-active.120461/