Variable in Battle Processing Different

Hello! Yet another question for the same event as my past two posts. This relates somewhat to the battle processing option "designation with a variable." From what I understand, whatever the integer for that variable is, the battle will be with the troop of the same number.

My problem is that I have an event that chooses a graphic depending on a random number that was chosen for a variable (The control variable command is set on a separate event than the graphic, but I doubt that matters). The graphics are all labeled to match the troop they represent (If the variable is set at 1, the graphic is of troop 1, same with the variable set at 2, etc.). However, when I go into the fight, the troop is completely different from what their graphic is shown to be.

Am I misunderstanding the purpose of the variable option in battle processing? Or is something else causing this issue?

Thanks for taking the time to read!

Picture of event graphic:
Graphic

Picture of event for battle processing and setting the variable:
Battle Processing
Are you sure your troops IDs in the database match the graphic ones?
what does the one event have to do with the other?

your battle processing is based on variable 12, which is set to random 1-6 in the same event as the battle processing.
which means that no matter what value it had before triggering the event with the battle processing, it will be randomly rolled again before the battle processing happens.

as for your other picture of the graphic choice: the highest priority is on the highest page number, so that says nothing
Are you sure your troops IDs in the database match the graphic ones?
Yep they match.

which means that no matter what value it had before triggering the event with the battle processing, it will be randomly rolled again before the battle processing happens.
I didn't realize it rolls again when the battle processing happens. I thought it just kept whatever it was before. I'll probably change how the battle plays out then.
as for your other picture of the graphic choice: the highest priority is on the highest page number, so that says nothing
Each page has a different set of conditions (there's too many pages so I didn't bother to attach each one) so displaying the graphic worked fine. I mostly put that picture up just to show that it had the variable set as a condition for the event. But since the variable is rolled again for the fight, this ends up being moot. ¯\_ (ツ)_/¯
it will be randomly rolled again before the battle processing happens.
Actually, now that I reread your comment, could you clarify this? When you say reroll, do you mean it will reroll when the battle begins? Or do you mean it'll take the value of the first command at the top of the event?
I didn't realize it rolls again when the battle processing happens.
no, it does not - it is only rolled when the control variable command happens, but that is in the same event as the battle processing. and since that is an autorun, no other event can happen between those two commands.

I should have worded my first answer better.

Each page has a different set of conditions (there's too many pages so I didn't bother to attach each one) so displaying the graphic worked fine.
again that was not the point I was trying to make.

there are two other points that can go wrong here.

1) the variable condition on that page is variable 5, not variable 12, so what does it have to do with either?
2) even when using the correct variable, the order of the pages and order of conditions is very important because the condition is greater than, not equal to.
1) the variable condition on that page is variable 5, not variable 12, so what does it have to do with either?
Whoops, I posted the wrong picture- The actual event I meant to reference has the variable set as 12. Here's the picture I meant to post: 1
2) even when using the correct variable, the order of the pages and order of conditions is very important because the condition is greater than, not equal to.
Ohhh I see now. Basically, I'll just have to reverse the order of the pages then. Thank you for pointing that out!
2) even when using the correct variable, the order of the pages and order of conditions is very important because the condition is greater than, not equal to.
Actually, I have a follow-up question considering this. I'm basically running this event 3 times. The first time runs just fine, but the other two don't. The conditions are basically structured the same way, the first one just doesn't have the switch condition. Any possible reason for this?
I'm not so sure about reversing the order - if what we see now (event page 1) is last, that will be checked first and the variable will always be greater than one, so it will not get to the other opponent graphics. Maybe try a test event in which you only use three opponents (so that two remain for round 2), that way you might find the problem faster.
I wanted to suggest integrating the opponent graphic event into the battle processing event, if it's not too complicated (set up the conditions and begin the first move route with change graphic).

Edited to add: Andar mentions that while an autorun event runs, no other events would. That would mean that the switch in the graphics event doesn't turn on - that's why putting it all in the autorun event could solve your problem. Or?
Maybe try a test event in which you only use three opponents (so that two remain for round 2), that way you might find the problem faster.
I think I might do that. The only thing I could think of is maybe switching the order of the pages based on the switch condition? Like, have all of the "team 2 fought" switches grouped together in numerical order rather than the "variable is 1" grouped together.
I wanted to suggest integrating the opponent graphic event into the battle processing event, if it's not too complicated (set up the conditions and begin the first move route with change graphic).
If I went this route, do you mean setting it up as something like a conditional branch? I could definitely try this version.
Edited to add: Andar mentions that while an autorun event runs, no other events would. That would mean that the switch in the graphics event doesn't turn on - that's why putting it all in the autorun event could solve your problem. Or?
Do you mean switch 12? That switches on in a parallel process event that takes place earlier.

Edited to add: The graphics event seems to work, I believe. I haven't had a test run where the graphics on the map show up twice. What seems to be a problem is the enemy in the battle doesn't match up with the graphic shown on the map.
I think I might do that. The only thing I could think of is maybe switching the order of the pages based on the switch condition? Like, have all of the "team 2 fought" switches grouped together in numerical order rather than the "variable is 1" grouped together.

You might try grouping them according to the switch, although I don't think it should matter (it checks both conditions and if one is not there, it should move on regardless, but I'm not 100% sure).


Do you mean switch 12? That switches on in a parallel process event that takes place earlier.

I meant the switch that turns on when the opponent graphic is chosen (e.g. Team 2 Fought 2).


If I went this route, do you mean setting it up as something like a conditional branch? I could definitely try this version.

Adding the graphic to the autorun event - the conditions should copy those that were in the separate graphics event, if it makes sense. Also, the graphic event checks whether the opponent has been fought already, but for the battle processing, it just takes the variable that was generated, which could also give you an opponent that was already fought, no? Maybe that's why the graphic and the troop didn't match?

I finally learned to use quotes :-D
This'll be my last reply for now since it's 3 am here now and I should sleep lol
I meant the switch that turns on when the opponent graphic is chosen (e.g. Team 2 Fought 2).
That may be possible. But that would end up affecting round 3's graphics which also work. Graphics for each round seem fine, it's literally just the battle for round 2 and 3 that seems to mess everything up lol.
Maybe that's why the graphic and the troop didn't match?
That... would make a lot of sense. I didn't even realize the battle wouldn't take that into account. I was just so focused on the variable. It'll take some time, but I think I'll try to set that up the best I can and see how it goes. Considering how many conditions are set, this is gonna be one huge conditional branch lol.
I finally learned to use quotes :-D
Congrats! 😂
yes, it is possible to have events display sprites based on a variable - but as said above that means that you have to take both the variable value and the page number to account with the greater or equal condition.

basically any page is active if the condition is fulfilled AND no higher priority page is active.

to change the sprites based on variable and on condition that you don't skip any number, it is easiest to handle with the rule of page number = variable condition number = troop ID number.

you can shift or skip numbers if you know what you're doing, but for the first experimentation make a new project and follow the equation above, and only experiment with skipping or shifting numbers after you got that basically stable.
basically any page is active if the condition is fulfilled AND no higher priority page is active.
Just to confirm, say each page has different setup conditions. (E.g. Page 1 has switch 1 active and the variable is set to 1. Page 2 has switch 1 active but the variable is set to 2. Page 3 has switch 2 active and variable is set to 1. Page 4 has switch 2 active and the variable is set to 2. Etc.) Wouldn't only one of those pages end up being active since it's the only one with the right conditions fulfilled?

Each page on the graphics has a completely different switch and variable condition. Does the higher priority page matter if each page's conditions are just completely different from each other?

I might end up just going with the change graphic technique mentioned earlier, but I just want to make sure so I don't end up doing the same mistake again.
The higher priorities matter because the computer doesn't care if you made a mistake.

only one page can be active at any given time, and the computer starts checking them from the highest page on.
and as soon as it finds a page where all conditions are true, that one will become active and further search will be aborted.

so if you made a mistake and the logic doesn't work as you assumed, or if you simply forgot to set conditions on a higher page,then that higher page will be active.

there is a reason why only experienced developers mix conditions and every new user should try to keep conditions and logic as clean as possible - and that reason are the thousands of hours lost to bughunting because one event had wrong values for its condition and no one could find where that changed.
The higher priorities matter because the computer doesn't care if you made a mistake.
Makes sense, which is probably why I won't try the old way I did it since it was way too many pages that it became too complex.

But I meant my question more so to ask if it would work, not if I should do it. I was just curious if it would still run correctly if conditions were set right.

In the future, I will stick to the rule of page number=variable number since it's a good rule. Thanks for the info.
But I meant my question more so to ask if it would work, not if I should do it.
yes, it can work - as I said if you know what you're doing you can make the conditions as complex as you want.
it only becomes problematic if you make mistakes - and that depends on your care and experience in handling those things.
I wanted to suggest integrating the opponent graphic event into the battle processing event, if it's not too complicated (set up the conditions and begin the first move route with change graphic).

Hello! I know it's been like a month, but I finally got around to finishing up working on this event. This idea worked perfectly, and I wanted to say thank you for the suggestion! It's working great now! 😂

Original thread: https://forums.rpgmakerweb.com/threads/variable-in-battle-processing-different.148420/