MZ Variable won't update until after the battle event is complete

Trying to code something akin to Limbus Company's Event Checks, where each party member has varying sin stats. These stats being used for many things, though mainly for my issue it's when there are the event checks. You can choose from your current party members, and it uses their stats in order to see if you succeed the event check and get a reward or punishment.

1779134727070.png

I thought I was managing to get it done correctly, but nope! It worked up until I tried to set it to show me the variable and use the variable that is stored. It ended up showing a 0 and seemingly using a 0 in the check. I checked the variable afterwards in-game and it showed the correct variable.

I am unsure of what might be causing this, but from what I've found it might be that the variable isn't updating until AFTER the full battle event? Any ideas on how to fix it?

This is the code for reference

Code:
◆Plugin Command:VisuMZ_0_CoreEngine, Text Popup: Show Text
:              :Text = "It's blood is boiling."
◆Label:Return
◆Show Choices:\P[1], \P[2], \P[3], \P[4], \P[5] (Window, Left, #1, -)
:When \P[1]
  ◆Control Variables:#0001 Party Leader = Actor ID of party member #1
  ◆Control Variables:#0013 Chosen Canvas = Actor ID of party member #1
  ◆Script:$gameTemp.reserveCommonEvent($gameVariables.value(1))
  ◆
:When \P[2]
  ◆Control Variables:#0002 Second Position = Actor ID of party member #2
  ◆Control Variables:#0013 Chosen Canvas = Actor ID of party member #2
  ◆Script:$gameTemp.reserveCommonEvent($gameVariables.value(2))
  ◆
:When \P[3]
  ◆Control Variables:#0003 Third Position = Actor ID of party member #3
  ◆Control Variables:#0013 Chosen Canvas = Actor ID of party member #3
  ◆Script:$gameTemp.reserveCommonEvent($gameVariables.value(3))
  ◆
:When \P[4]
  ◆Control Variables:#0004 Fourth Position = Actor ID of party member #4
  ◆Control Variables:#0013 Chosen Canvas = Actor ID of party member #4
  ◆Script:$gameTemp.reserveCommonEvent($gameVariables.value(4))
  ◆
:When \P[5]
  ◆Control Variables:#0005 Fifth Posiion = Actor ID of party member #5
  ◆Control Variables:#0013 Chosen Canvas = Actor ID of party member #5
  ◆Script:$gameTemp.reserveCommonEvent($gameVariables.value(5))
  ◆
:End
◆Text:None, None, Window, Middle
:    :Threshold - \c[18] 10
:    :\c[0]
:    :Predicted - \v[6]
◆Text:None, None, Window, Bottom
:    :Are you Sure?
◆Show Choices:Proceed., Rethink. (Window, Right, #1, #2)
:When Proceed.
  ◆If:Wrath > 10
    ◆Text:None, None, Window, Bottom
    :    :Check Passed!
    ◆Plugin Command:VisuMZ_1_BattleCore, BTLOG: Add Text
    :              :Text = Burning is weakened
    :              :Copy to Combat Log? = true
    :              :Combat Log Icon = 87
    ◆Change Enemy HP:#1 Burning, - 20
    ◆
  :Else
    ◆Text:None, None, Window, Bottom
    :    :Check Failed!
    ◆Change HP:{Chosen Canvas}, - 25
    ◆
  :End
  ◆
:When Rethink.
  ◆Jump to Label:Return
  ◆
:End

Plugins I am using are all Visuastella, Tier 0 and Tier 1.

Edit: Since I think it might be useful to add, the way the variables are decided are via Common Event. The code calls for a Common Event equaling the variable of a party member, the common event setting the stat variables.
We're missing too many information here to help.

1) where is variable 6 set? It's not inside the event you gave, the only place where it is used there is the show text with it.

2) how are the events called or started?
conditions and properties of any event are extremely important for solving timing problems with them.
We're missing too many information here to help.

1) where is variable 6 set? It's not inside the event you gave, the only place where it is used there is the show text with it.

2) how are the events called or started?
conditions and properties of any event are extremely important for solving timing problems with them.
Ah, sorry. I had a feeling I didn't add enough detail...

1. Variable 6 is set by one of nine common events, but for this specific test it was Common events one and two.
1779136627435.png
1779136653651.png













2. The battle event is called within a test troop event, it is the second battle event. The first has the criteria of being the first turn. This specific battle event being the second, with it's criteria being the only enemy present being at half health.

There is a third battle event, with it being triggered if the stat check in battle event two is a failure.
and how are those common events called?
because if those are not called, then nothing updates the variables
and please give screenshots of the troop events
and how are those common events called?
because if those are not called, then nothing updates the variables
and please give screenshots of the troop events
The way the common events are called are from the script commands in the battle event window "$gameTemp.reserveCommonEvent($gameVariables.value(1))" calls the common event that matches the current first party member.

1779137735261.png
1779137751238.png
1779137818497.png
1779137863681.png
1779137891530.png
1779137912010.png
1779137939766.png

A seperate issue that is slightly related that I'll bring up since it is in the screenshots? Even though the party member is marked with the variable of "Chosen Canvas" it will not lead to the party member getting damaged. I imagine the issue will have the same solution.
Your problem is how you start the common events.

By default events that are started this way are always executed last in any battleturn, so the variables are updated only at the end of the turn.

it's even in the name of the script function:
RESERVEcommonevent

basically the function only places the common event into the queue to be executed, but does not start it automatically. it allows the general handler to start the CE when it comes to processing the events at the end of the turn.

you either need to call the event directly (without using that script command) or you need to install a plugin that has options for calling events at specific times, like for example most of the events that install action sequences.

but that script command cannot be used for time-critical calls, and there is no alternative in the default engine.
Your problem is how you start the common events.

By default events that are started this way are always executed last in any battleturn, so the variables are updated only at the end of the turn.

it's even in the name of the script function:
RESERVEcommonevent

basically the function only places the common event into the queue to be executed, but does not start it automatically. it allows the general handler to start the CE when it comes to processing the events at the end of the turn.

you either need to call the event directly (without using that script command) or you need to install a plugin that has options for calling events at specific times, like for example most of the events that install action sequences.

but that script command cannot be used for time-critical calls, and there is no alternative in the default engine.
I do perhaps have an Idea actually, what if I make it so once the decision is made. It'll flip a switch, that switch starting a new battle event to allow the Variables to update. I will have to sacrifice a easy way to show the victory chance to the player, but it will lead to the stat check proceeding.

EDIT: The Idea worked! Thanks for the help, since I doubt I could've figured it out without you, Andar.

Original thread: https://forums.rpgmakerweb.com/threads/variable-wont-update-until-after-the-battle-event-is-complete.183690/