Adding a variable if a skill used

Hello all,

I need some advice on increasing a variable whenever a magic skill is used.

In my game whenever a skill or magic is used, a variable(Let's call it magic skill points for now) will increase, then the player can use this magic skill points to upgrade their character.

In battle screen, I can make this work with a common event. But in menu screen, whenever a healing spell is used on the characters the game will exit the menu screen since the game can only execute common event on the map screen.

I tried to make the game return to skill screen with scene push command, but it lags and it feels awkward. Whenever I heal a character with a healing skill the game will return to map, stuck for a second, then back to the menu screen. If I use the healing skills multiple times in the menu screen this becomes noticeable.

Are there any alternative solutions to this?

I have been trying to connect magic skill point with MP use. Every 1 point of MP spent will increase magic skill points by 1. And the magic skill point check happens at Inn when characters go to bed(in this game, players can only upgrade their characters at Inn), this way magic skill points only increases when the players are on the map screen.

But I am not sure how to implement such system through common events. I tried to set Variable 1 = character Max MP, variable 2= character MP, variable 3(magic skill point)=Variable 1-Variable 2 but it's not working.
have you tried using the variable increase within the damage formula?

EDIT: also, here is a tutorial for doing what you want I think, but the tutorial requires using some of Yanfly plugins. I think they are free ones though.
You could try using a script like:
$gameActors.actor(actorId).mmp -= $gameActors.actor(actorId).mp = $gameVariable.value(variable id)
I'm pretty sure that this is the correct script, but if for some reason it doesn't work, tell me.
Maybe I am misunderstanding... Are you trying to come up with an alternative way to increase the variable when an actor uses the skill?

Or are you trying to come up with a common event that lets the player utilize the variable and increase a stat? Like some kind of upgrade system?
Maybe I am misunderstanding... Are you trying to come up with an alternative way to increase the variable when an actor uses the skill?

Or are you trying to come up with a common event that lets the player utilize the variable and increase a stat? Like some kind of upgrade system?


I am trying to increase the variable when the actor uses the skill in battle and menu screen. The upgrade is done(By using the variable) at the Inn when the character goes to bed.
It is my understanding that it is only when the magic is accessed from the menu that it is laggy, correct?
I think you could add:

$gameVariables.setValue(X, +1);

to the front of the skill damage formula, where is 'X' is the variable ID, and each time the skill is used the variable will increase by 1.
It is my understanding that it is only when the magic is accessed from the menu that it is laggy, correct?

That is correct, common event doesn't work very well with the menu 🙁

This is not an issue for attacking spells used in the battle but for healing spells that can be used outside of battle it doesn't work too well.
I've used Yanfly's Menu Plugin for one of my games, and I made an option that would trigger a common event. I've found no issue there, so maybe you could use the menu extension to make some sort of tab where the healing magic gets triggered but the tab also activates a common event increasing your variable.
I think you could add:

$gameVariables.setValue(X, +1);

to the front of the skill damage formula, where is 'X' is the variable ID, and each time the skill is used the variable will increase by 1.

Hi,

I tried this method but it seems that the variable only increase once after multiple skill were used.

What have I done wrong? 😩
Hi,

I tried this method but it seems that the variable only increase once after multiple skill were used.

What have I done wrong? 😩

Nevermind. I made it work with $gameVariables.setValue(n, $gameVariables.value(n)+10);

Testing now!
$gameVariables.setValue(X, +1);
What have I done wrong?
nothing, the original advice was wrong.

as the function says it sets the variable value to "+1", it doesn't add that number no matter how many mathematical signs are added at that position.
One of the possible solutions is what you used, providing a formula that reads the value and changing it before setting it.

However please keep in mind that the damage formula is only executed if the skill hits. if the skill is used but misses or is evedad, then that will NOT count up.

Original thread: https://forums.rpgmakerweb.com/threads/adding-a-variable-if-a-skill-used.120270/