Character Lvl Up Issue

Hey all,


My game has mercenaries that you can hire and switch out through the game. I want these mercenaries to always level up together even if they're not all in the party so you can switch them out and not have to worry about the new mercenary being a low level and having to grind him up to par.


Currently, I have a common event that sets each mercenary's level to a variable and whenever one merc's level is higher than another's, the lower level merc gains a level. This works sometimes but usually the mercs end up levelling twice when one of them levels up. I'm not 100% sure what causes this but I think it's just an order of operations / logic error in my event. Attached is the event I have.


If anyone has any solutions or ideas, I'd really appreciate any help.


Thanks

event.png
The first test and the last test in that screenshot are exactly the same.  If Trae's level is greater than Kris's level, you level Kris twice.  That's one problem.


The other problem is that you set the variables according to the levels at the start of the event, and then you change the levels but you don't change the variables.  So you compare Kris's level to Trae's using the variables, then you level Kris up, but the variable stays at what the previous level is.  And then you compare it again later, and Kris's original level is still less than Trae's original level (because the variables have not been changed), so you level him up again.
I see what you're saying but I don't think that's the issue because the variables get reset between each scan. So it sets Kris and Trae's levels in the variables on the first scan, then when Kris levels up, it'll set the new variables on the second scan. In this second scan, Trae's level is below Kris' level so it forces a level up. Then on the next scan, it sets the new levels into the variables before doing comparisons.


However, that dumb mistake of mine you caught is totally what's causing the issue. it's giving Kris a second level-up when he shouldn't get it and therefore giving everyone else a second level up. Thanks for the help, sometimes a second set of eyes is all it takes.
No, shaz is right - because you can level some of your actors twice in a single scan if the wrong combination of levels is there.


Example:


Assume Clint has level one and both Trae and Kris have level 2.


If the logic above starts with those numbers, Clint will be leveled twice in a single process, once because Trae-Level (2) is higher than Clint-Level (1) and the second time because Kris-Level (2) is higher than Clint-Level(1). And that will end Clint with level 3 in exactly your logic above.


And that is why you have to update the variables after each level change, to prevent that double effect.

Original thread: https://forums.rpgmakerweb.com/threads/character-lvl-up-issue.60945/