Choosing a number at random?

Feliaria

Good with Ideas, Bad with Execution
Veteran
Joined
Feb 4, 2016
Messages
364
Reaction score
50
First Language
English
Primarily Uses
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 :(
 

YoraeRasante

Veteran
Veteran
Joined
Jun 6, 2014
Messages
1,643
Reaction score
420
First Language
Portuguese
Primarily Uses
RMMV
Control Variable > Random.


Then use Conditional Branches to check its value.
 

Jonforum

Veteran
Veteran
Joined
Mar 28, 2016
Messages
1,623
Reaction score
1,437
First Language
French
Primarily Uses
RMMV
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 :(
 

bomblord

Veteran
Veteran
Joined
Apr 13, 2016
Messages
87
Reaction score
11
First Language
English
Primarily Uses
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.
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

YES! officially released my games soundtrack on Itunes, Spotify, and Amazon..... kinda cool!

Another old age version of Reid. Trying out different style.
Hey everyone! Not sure how many people know about Cafofo Music on Itch.io, but I highly recommend their Sound Effects! It is amazing quality AND quantity and best of all, they are having a 50% sale! I can't express how much I love sales.
Wow.... My last map GIF got 47 likes, 16 retweet and 2,105 views on Twitter in 24 hours. My game thread here's only got 3k views in 6-7 months. I guess building my Twitter was insanely worth it. :LZSexcite:

Forum statistics

Threads
105,594
Messages
1,014,878
Members
137,264
Latest member
ZeoValinferno
Top