Increasing maximum mp for an actor causes increased hp regeneration.

I found a pretty strange bug in my game that I can't figure out why this is happening. When I use a potion that increases pm max curiously it starts to regenerate that amount of hp per turn when I have armor equipped that provides a passive state of regeneration per turn. The status would only regenerate pm and not hp, but when I enter a battle it regenerates pm as appropriate from the armor but also regenerates hp. I tried deleting all the formula that I used in the state with <custom regen formula> leaving it empty and it still regenerates hp per turn. If I use another potion, the regeneration per turn accumulates, regenerating more and more. I don't understand why this happens. I tried everything, I deactivated all the plugins that I am using and I realized that the problem is in YEP_EQUIPCORE without that plugin everything works as it should (it does not increase the hp regeneration per turn when taking the pm max increase potion). I don't understand what relationship that add-on has with the maximum pm and hp regeneration per turn. This does not happen if I use a potion that increases max hp or physical strength or any other attribute, it only happens when it increases max hp. I'm going to show images of the potion itself, the armor and the passive pm regeneration state that the armor gives.
1717002935585.png



The common event and that <sort priority> is not the cause why the error occurs even if you do not use that.
1717003103384.png



In the notebox i write this:

<Info Text Top>

\c[24]Tipo de armadura: Tela.

\c[2]Regeneración de PV: \C[0]+10 para \c[30]Inventores\c[0].

\c[1]Regeneración de PE: \c[0]+6 para otras clases.

</Info Text Top>



<Passive State: 722>



<Augment Slots>

Cristal

Cristal

Cristal

Mitrilo

Mitrilo

Mitrilo

</Augment Slots>



<Percent Price Variable: 78>

1717003216056.png



In the notebox i write this:


<Custom Regen Formula>

if (user.isStateAffected(1) || $gameSwitches.value(49)) {

value = 0;

} else {

if (user.isClass($dataClasses[8]) || user.isClass($dataClasses[12]) || user.isClass($dataClasses[22])) {

value = 10;

element = 11;

variance = 50;

} else {

var variacion = Math.random() * (1.5 - 0.5 + 0.1) + 0.5;

var mpheal = Math.round(6 * user.elementRate(11) * variacion);

user.gainMp (+ mpheal);

user.startDamagePopup();

user.clearResult();

}

};

</Custom Regen Formula>



<Custom Turn End Effect>

$gameSwitches.setValue(49, false);

</Custom Turn End Effect>



The formula itself is not the cause because if I delete everything and write alone
<custom regen formula>
</custom regen formula>
It also regenerates hp per turn.


The plugins I am using are these:
1717003445286.png

1717003465361.png

1717003483400.png

1717003496260.png

1717003510018.png


If anyone can help me I would appreciate it.
A couple of tips to make it easier for people to help you:
- When you're posting screenshots, please change the editor into English so we can read the effects and settings. Right-click MV in your Steam library, go to Properties, and change it there.

- When posting code, put it in CODE tags (the </> on the edit bar). That preserves indentations and brackets.

Code:
var mpheal = Math.round(6 * user.elementRate(11) * variacion);

user.gainMp (+ mpheal);
You really don't need to declare a variable to use it just once - you can simply put all of that into the gainMp() function.
Code:
user.gainMp(Math.round(6 * user.elementRate(11) * variacion))
(you technically don't need the variacion variable, either, but that would be a very long line of code)

Whether or not you change that, you shouldn't have the + in there. That doesn't do anything.
Code:
user.gainMp(mpheal);

What does the potion's common event do?
Thanks for all those tips. I'll keep it in mind. As for the common event, it is not important, because the error occurs even if I do not use the common event. But if you still want to know what it does, I'll send you two screenshots.
1717007878783.png


1717007897035.png
Does anyone have any idea where the problem could be? It's something that makes no sense to me.
Well, trying to locate the problem and the problem persists even in a new file using only these plugins (necessary for the regeneration and passive state to work):
-Yep_BattleEngineCore
-Yep_X_BattleSysATB (Even if I disable the atb the error also occurs)
-Yep_BuffsStatesCore
-Yep_X_ExDot
-Yep_EquipCore
-Yep_AutoPassiveStates

Which seems extremely strange to me. The only thing I can tell for sure is that YEP_EQUIPCORE seems to be the problem. I also discovered that this regeneration per turn only occurs with any MP increase, with the potion, with a piece of equipment, etc. The number of hp that regenerates per turn is exactly equal to the number of pm that is increased. I'm trying to locate where the problem could be within the code. If someone can give me a guide as to what part of the code is part of the pm increase and the regeneration per turn. Another thing I also discovered is that when I don't use <custom regen formula> and use <regen formula: x> everything happens normally without a problem (it will regenerate the amount of hp written there without having anything to do with the increase in pm).

An alternative that occurs to me to solve this serious problem is to find a way to use the following code without using <custom regen formula>:

JavaScript:
if (user.isStateAffected(1) || $gameSwitches.value(49)) {
value = 0;
} else {
if (user.isClass($dataClasses[8]) || user.isClass($dataClasses[12]) || user.isClass($dataClasses[22])) {
value = 10;
element = 11;
variance = 50;
} else {
var variacion = Math.random() * (1.5 - 0.5 + 0.1) + 0.5;
var mpheal = Math.round(6 * user.elementRate(11) * variacion);
user.gainMp (+ mpheal);
user.startDamagePopup();
user.clearResult();
}
};

@ATT_Turan Do you know anything about this?
The number of hp that regenerates per turn is exactly equal to the number of pm that is increased. I'm trying to locate where the problem could be within the code. If someone can give me a guide as to what part of the code is part of the pm increase and the regeneration per turn.
There is no connection between adding to an actor's max MP parameter and equipment with an HP regeneration trait. The data for those two things isn't even stored in the same place on the actor.

The only thing I can suggest is for you to set up a test project that has the problem; give people the exact steps to follow to duplicate the problem; and share the project (do not leave any Yanfly plugins in the plugin folder).

Maybe someone might take a look at it and figure out what's going on.
I think I was able to solve the problem. At least in part (the error itself did not completely disappear). One of the types of armor that the game uses is cloth, and there are several classes that use cloth and those armors, unlike heavy and light armor, do not regenerate hp per turn, only regenerate pm, but since one of the classes does not use pm decided to compensate it with an "else" in <custom regen formula> so that it regenerates hp per turn and not pm.

The problem is solved when I add a "value = 0" after the "user.gainPm" line. It seems that by default hp regeneration is defined by the amount of pm increased. If I add that "value = 0" it kind of cancels all that. This is a relief for me but I am worried about this strange "error" about increase pm max = increase hp regeneration.

I'm going to continue investigating, if I really need to send you a new test project to help me, I'll send it to you. I thank you very much for your willingness att_turan.

Original thread: https://forums.rpgmakerweb.com/threads/increasing-maximum-mp-for-an-actor-causes-increased-hp-regeneration.169097/