[RMXP] Determining which variable amongst 4 is the largest?

Hi, first of all thank you for your time, it is much appreciated!

I am working on a game in XP where the player's class is decided by how he/she answers a quiz at the beginning.  To do this I've made 4 variables which are added to and multiplied etc every time you answer a question.

All I really need to know is how to make an event figure out which one of the four variables, Electric, Dark, Grass, and Normal are the biggest, and then change the players's class depending on which one is the biggest.

I've read the XP manual but my vision makes it near impossible to read through the whole thing. (When I see lots of text, my eyes go unfocused making it hard to read, it often means I must use my hands to block all but a couple lines at a time, which takes a very long time)

Thank you in advance for all the help, and I fully apologize if this would be considered an advanced event and should be in the event subforum, I am making the assumption that checking variables and returning a result based on the largest variable can be done with a simple function I am simply glancing over or something
Without getting into scripting or script calls, the only way would be a series of conditional branches. Comparing 4 variables, to see which one is larger than the other 3, could be quite extensive.

Using a 5th variable and a script call would shorten the process.

Since you didn't say, I'll assume your variables are 1, 2, 3 and 4, and use variable 5 to store the final result. This finds the highest VALUE of those 4 variables, then determines which one has that value. Note, if several variables hold the same number, it'll select randomly from them - thought that might be more interesting than always choosing the first.

Script: v = $game_variablesm = [v[1], v[2], v[3], v[4]].maxr = []r.push(1) if v[1] == mr.push(2) if v[2] == mr.push(3) if v[3] == mr.push(4) if v[4] == m$game_variables[5] = r[rand(r.size)]I'm sure it can be condensed, but I don't have XP with me so I can't test.After this, variable 5 will contain 1, 2, 3, or 4 - whichever variable # has the highest value. Then you just need to do a conditional branch saying if var 5 is 1, choose class 1, etc.

Original thread: https://forums.rpgmakerweb.com/threads/rmxp-determining-which-variable-amongst-4-is-the-largest.43617/