Variable Tracking by Encounter

Howdy all! I was wondering if there was a way to make a variable tick after an encounter - the idea is that after an event trigger, the player in my game needs to complete a certain ammount of battles for the quest to progress. Kind of like the Cursed Shield -> Paladin's Shield in FF6, if some are familiar.

The thing is, I don't want encounters before this point to add to the variable. Any suggestions?
This can be done with pure events, I think.

When the event triggers, use a Control Variables command to put Game Data -> Other -> Battle Count (or Win Count) into a variable of your choice. Then, when you need to check how many battles they've done, use the same command but store it in a different variable, and check the difference between the two variables (use a Control Variables to subtract the first variable from the second, then a Conditional Branch on the second variable).
Seems easy enough! Should I set it up as a Common Event, so it tracks through the entire game, correct?
it depends on when you want the end effect to happen or if you have an active quest tracker of some sort.
the value of the variable for the battles won since accepting the quest doesnt matter until you're ready to use it. So if you only use that value when the player tries to turn it in, then you dont actually need to update every battle.

If you do track it or it autocompletes itself, then you might want to make it a common event and use a plugin to run it after every battle once the quest is active.
Seems easy enough! Should I set it up as a Common Event, so it tracks through the entire game, correct?
What? No. You put the first Control Variables in the initial event where the "must defeat N enemies" segment begins. The rest goes in whatever event checks if you've defeated enough enemies.

It works because RPGMaker MV already tracks how many battles the player has fought without you needing to do anything – all you need to do is store how many they fought before the segment began, and then at any point after that you'll be able to easily find out how many they fought during the segment.

If you have several similar segments during your game, it might make sense to use a pair of common events, but if it only happens once, I wouldn't suggest it.
What? No. You put the first Control Variables in the initial event where the "must defeat N enemies" segment begins. The rest goes in whatever event checks if you've defeated enough enemies.

It works because RPGMaker MV already tracks how many battles the player has fought without you needing to do anything – all you need to do is store how many they fought before the segment began, and then at any point after that you'll be able to easily find out how many they fought during the segment.

If you have several similar segments during your game, it might make sense to use a pair of common events, but if it only happens once, I wouldn't suggest it.
Okay, so, then, I'm definitely missing a step... Because when I have it set up, it's counting every victory I've had since the beginning as the variable, not from when the event trigger starts. Like... If I need the player to get 30 victories after the event/side quest starts.

And, well, I'd like the event to call up and be like 'Okay, you've done it' at the end of it, so the player is aware they've done it, rather than needing to check/keep track of it themselves.
What exactly have you set up so far?
1751228970798.png

Here's what I got right now.
So, that runs when the quest to win N battles begins, right? Where do you check if they've fought enough battles?
I wanted to test it so basically it's just 'Win Count > 1' for right now, but it's triggering even if there's been no battles since then.
Well, that's wrong. Like I said, you need two variables – one for the "old win count", which is the one you have now, and one for the "new win count".

Your event to check if they've fought enough battles should look like something like this:

Code:
◆Control Variables:#0002 BattlesFought = Win Count
◆Control Variables:#0002 BattlesFought -= ReferenceWinCount
◆If:BattlesFought > 1
  ◆Comment:Do stuff here...
  ◆
:End

Where ReferenceWinCount is the variable from your screenshot (variable #0083).
Well, that's wrong. Like I said, you need two variables – one for the "old win count", which is the one you have now, and one for the "new win count".

Your event to check if they've fought enough battles should look like something like this:

Code:
◆Control Variables:#0002 BattlesFought = Win Count
◆Control Variables:#0002 BattlesFought -= ReferenceWinCount
◆If:BattlesFought > 1
  ◆Comment:Do stuff here...
  ◆
:End

Where ReferenceWinCount is the variable from your screenshot (variable #0083).
I'll give it a shot as soon as I can, thank you.

Original thread: https://forums.rpgmakerweb.com/threads/variable-tracking-by-encounter.178605/