Choosing a number at random?

So, one of the events I want in my game is a randomized boss. The boss fought will be randomized from one of five potential bosses. I know there is a way to set up an event to pull a random number and then assign outcomes to each number, but not how I would do so. Does anyone else know? I can't find it in the event command 🙁
Control Variable > Random.


Then use Conditional Branches to check its value.
So, one of the events I want in my game is a randomized boss. The boss fought will be randomized from one of five potential bosses. I know there is a way to set up an event to pull a random number and then assign outcomes to each number, but not how I would do so. Does anyone else know? I can't find it in the event command 🙁

1agbr.png
You can do it in Javascript like this (script on the bottom right of page 3 and just copy paste this)
 


var num = Math.floor(Math.random()*(5)+1);
$gameVariables.setValue(1, num);


This will generate a random number between 1 and 5 and then set variable 1 to it's value


Change the 1 in $gameVariables.setValue(1, num) to whatever variable number you want the value set to.

You can then use a conditional branch to run a different battle depending on whether the variable is 1,2,3,4, or 5.

Edit: Or just use Control Variables > Random that seems much easier.
Control Variable > Random.


Then use Conditional Branches to check its value.



That worked, thank you 🙂

Original thread: https://forums.rpgmakerweb.com/threads/choosing-a-number-at-random.69053/