Finding the variable with the highest value

So, I need to have roughly ten variables all fire random numbers and then the one with the highest value called in a conditional branch. I know I can do this with a ton of conditional branches but for the sake of ease, and tidiness I was hoping there was a simpler way.
Exactly what are you trying to achieve?  Why are you using 10 random numbers and getting the highest?  Why not just use a single random number?  What are you doing with the 'losing' variables?


Understanding your goal will help us determine if you're using an appropriate method, and that will allow us to either help you perfect that method, or to offer you a better approach.
Thanks for the quick reply!


I am attempting to create a very complex (for my brain anyways) fishing system. Success and what you catch depend on location, bait, rod quality, time of day, weather, and how far you cast.


The formula I am setting up for the bait you use is each bait has a certain probability for a fish to bite. Some fish prefer certain baits. For example, a minnow has a high probability of catching a pike, a medium probability of catching a trout, and no chance of catching another minnow. After selecting the minnow as bait, numbers are rolled, 1-40 for the pike, and 1-25 for the trout. The one with highest number is the fish you catch. Obviously, more pike will be caught with minnows but some trout might bite as well. Except in many instances I would have more than two possible outcomes for fish you can catch. Again, I know I can make a ton of conditional branches comparing each variable, or a have one variable control the probability with a "if variable equals 1-20 than you get a pike, but if variable 21-25 then you get a trout", but both of those methods get messy and unorganized, especially when down the road I want to add a new fish, or remove an existing one. This method I would like to use (checking for the highest value of a range of of variables) would work best with integrating it with the other checks and variables involves (location, time of day, etc.)


Every other aspect of my complicated fishing system I have succesfully created, its just finding a smart way to handle which of the many lake dwelling creatures goes for which bait.


Fishing, and harvesting are big part of my project, so I am really hoping to find a simple work around, since I can't script at all. Any help is very much appreciated.
Here's what you might want instead. It will only take 3 variables.


Set two variables as temp and temp 2 (or whatever placeholder name you want), and set the third as ID of fish caught. Then, do the following:


At the start of your event, set temp to 0, and fish id to 0 (important, else this will only work the first time you ever use it, and never again).


Roll the first roll. Store it in temp 2.


Then, do a conditional check, and if temp < temp2, store your result in temp. At the same time, store in the variable for fish id a unique number so you know what fish was just caught (for example, 1 = trout, 2 = pike, etc).


Repeat as often as you need. When you are done, temp will hold the highest value of all the roles, and the variable with the id number of the fish will tell you which one you caught.


Though, as a side note, you can do this with only one variable if you are willing to weight the frequencies of each fish in advance, and adjust them based on your other factors. However, I can see that getting tricky if you want it to vary by too many outside factors as you'd have to recompute the weights on the fly, which would probably take either a complicated math formula or a script to compute it for you.
Actually, that is very clever yet simple way to handle something like this. Somewhat annoyed I never though of that myself, honestly.


I will have to re-event a bit of things to switch to this method, but that's no biggie.


Thank you for help, truly appreciated.

Original thread: https://forums.rpgmakerweb.com/threads/finding-the-variable-with-the-highest-value.56909/