Changing a variable during battle

Hey so I'm pretty much a novice at RPGMaker. I've fiddled around with stuff like states, variables, switches etc and I'd like some help with something I was thinking about. Say you wanted this variable to trigger a state once it reaches a certain number. Is there a way to have that variable changed in the middle of battle depending on the actions of the party and/or the troop? For example if the variable was at 15, could you make it so if you took damage, the variable would go down to 5. Conversely, dealing damage would make the variable go up to 25. I'm thinking about having more scenarios where the variable will go up and down but I feel dealing and taking damage would be a decent place to start.
this kind of thing seems right down my alley. if you have it, I'd recommend adding me on discord, at Zerothedarklord#8459

If you're a novice, and using MV, odds are quite good there's a thing or two I could teach you.
In the Troops tab of the database is an event section. Those events can be triggered by a variety of combat situations, and there are plugins to allow additional conditions.

Once you make a condition, you can use a standard event command to change the variable.

Some things are doable in the troop events, but would be easier with some basic plugins. For example, changing the variable when you take damage is probably doable in a troop event by storing the HP of all the party members then checking to see if they change.

But it would be much easier using something like Yanfly's Buffs & States Core, and have a Custom Respond Effect that changes the variable whenever the actor takes damage, or a Custom Establish Effect whenever the actor deals damage.
Why did Turan give Zero a sad react?
Why did Turan give Zero a sad react?
because he could have written all this advice here on the forum for everyone to see instead of sending an invite to an unknown discord where no one else can read the advice.

and that goes double on a PG-13 forum like this one where a minor might follow links without thinking.
except that a quick look at the user's profile clearly indicates he is old enough to determine who to and not to add on discord.
But yes, discord can be a very efficient tool to use with others for helping to teach, showing them how to do things, etc.
After an hour or so call with the OP, he thanked me and said he looks forward to chatting again to see what more I can show him.
except that a quick look at the user's profile clearly indicates he is old enough to determine who to and not to add on discord.
But yes, discord can be a very efficient tool to use with others for helping to teach, showing them how to do things, etc.
After an hour or so call with the OP, he thanked me and said he looks forward to chatting again to see what more I can show him.
No one is saying OP is a child, but some random child might stumble upon this thread.
In the Troops tab of the database is an event section. Those events can be triggered by a variety of combat situations, and there are plugins to allow additional conditions.

Once you make a condition, you can use a standard event command to change the variable.

Some things are doable in the troop events, but would be easier with some basic plugins. For example, changing the variable when you take damage is probably doable in a troop event by storing the HP of all the party members then checking to see if they change.

But it would be much easier using something like Yanfly's Buffs & States Core, and have a Custom Respond Effect that changes the variable whenever the actor takes damage, or a Custom Establish Effect whenever the actor deals damage.
Oh I'll be sure to look into that. I've already downloaded Yanfly's basic plugins and been slowly messing with them to see what they do. I talked to darklord on discord and said that a possible way to adjust variables like that would be by using Yanfly's Enhanced TP plugin for if I wanted to add more possible conditions for the state to be triggered. He showed me a good amount of variety of ways to use variables inside and outside combat.

Original thread: https://forums.rpgmakerweb.com/threads/changing-a-variable-during-battle.143505/