An empty "manabar" affecting a variable.

Got a weird one for you folks. I want to set up a system where if you get a zero in you manabar it adds a point to a variable. Could this be done, and if so how?
To make this completely clear: if mana is completely depleted, on any character, this would add a point to the variable.
there are many ways to do this, depending on how you want the mechanic to work in your game.

do you want to add the +1 once or per time unit?
how can your actors loose MP? if only by skill use just attach a common event checking mana
if by map events, have any map event that reduces MP check the effect.
if by enemy action in battle, have a troop event check for this

a bad shortcut would be using a parallel process checking MP - that might increase lag and is not needed as long as you can check each case of MP reduction itself.
Mana is only lost by choice, using abilities in combat, the trigger would only happen if the bar is completely emptied. I would want it to add a plus 1 to the variable each time this happens.
"Phantasm", the mana of my game is supposedly related to sanity, I want to add some checks where continuously emptying it adds some visual horrors to the game.
I think some kind of common event may be the way to go, I am just not sure how.
It would be something like "empty mana" adds +1, at 50 this adds some things here and there, at 100 even more etc.

Reading through what I wrote some enemies also try to "empty" your mana, which I think will work well with such a system.
there are many ways to do this, depending on how you want the mechanic to work in your game.

do you want to add the +1 once or per time unit?
how can your actors loose MP? if only by skill use just attach a common event checking mana
if by map events, have any map event that reduces MP check the effect.
if by enemy action in battle, have a troop event check for this

a bad shortcut would be using a parallel process checking MP - that might increase lag and is not needed as long as you can check each case of MP reduction itself.
there are many ways to do this, depending on how you want the mechanic to work in your game.

do you want to add the +1 once or per time unit?
how can your actors loose MP? if only by skill use just attach a common event checking mana
if by map events, have any map event that reduces MP check the effect.
if by enemy action in battle, have a troop event check for this

a bad shortcut would be using a parallel process checking MP - that might increase lag and is not needed as long as you can check each case of MP reduction itself.
Btw, in mz, where is the check mana function? I could not find it.
You can use my Eval Tags plugin, linked in my signature, or if you're already using VisuStella's Battle Core you can use notetags from that.

For my Eval Tags, the notetags on each actor would be:
Code:
<Turn Start Eval>
user.currMp = user.mp;
</Turn Start Eval>

<Action After Eval>
if (user.mp <= 0 && user.currMp > 0)
    $gameVariables.setValue(42, $gameVariables.value(42) + 1);
</Action After Eval>
where 42 is the ID of the variable.

That will add 1 to variable 42 every time the actor uses a skill that takes their MP to 0.

You can then do whatever you want with that, depending on the timing and what you want to happen. You could have a troop event every turn that checks the value of the variable and goes from there; you could add a few more lines to the After Eval notetag that checks the new value and calls a common event directly, whatever.
Btw, in mz, where is the check mana function? I could not find it.
control variable : game data : actor : MP or Max MP depending on which value you want
Thanks guys, think I have gotten what I need! Much appreciated.
You can use my Eval Tags plugin, linked in my signature, or if you're already using VisuStella's Battle Core you can use notetags from that.

For my Eval Tags, the notetags on each actor would be:
Code:
<Turn Start Eval>
user.currMp = user.mp;
</Turn Start Eval>

<Action After Eval>
if (user.mp <= 0 && user.currMp > 0)
    $gameVariables.setValue(42, $gameVariables.value(42) + 1);
</Action After Eval>
where 42 is the ID of the variable.

That will add 1 to variable 42 every time the actor uses a skill that takes their MP to 0.

You can then do whatever you want with that, depending on the timing and what you want to happen. You could have a troop event every turn that checks the value of the variable and goes from there; you could add a few more lines to the After Eval notetag that checks the new value and calls a common event directly, whatever.
Tried it out with an event, put the note tags on the actor and the plugin is active but the variable did not change. What could be the issue?
I am not using visustella battlecore but some other visustella stuff: full list of plugins:
1716060282109.png
With VisuStella Skills and States in there, you might have to use the Battle Core and its versions of the notetags.

My Eval Tags plugin is not compatible with VisuStella plugins and probably tries to overwrite functions already modified by Skills and States.
With VisuStella Skills and States in there, you might have to use the Battle Core and its versions of the notetags.

My Eval Tags plugin is not compatible with VisuStella plugins and probably tries to overwrite functions already modified by Skills and States.
That is unfortunate, I cannot use the battlecore plugin since it interferes to much with a bunch of other plugins. Guess I will have to figure this out in another way.
Well, there's troubleshooting that can be done to see where the Eval Tags code is failing you - for the most basic, during the game press F8 and go to the Console tab, make sure there are no errors being displayed.

But for anything more complex than that, I'm unfortunately not willing to devote my own time to trying to make it work with VisuStella.

Have you actually tested for the conflict? If you turn off all other plugins, save your project, start a New Game, does it work?

Original thread: https://forums.rpgmakerweb.com/threads/an-empty-manabar-affecting-a-variable.168783/