Random variables with no repeating.

Braxillian

Villager
Member
Joined
May 12, 2013
Messages
26
Reaction score
2
First Language
English
Primarily Uses
RMMV
I've looked at multiple threads that seem to cover almost what I'm looking for but I have little to no knowledge of scripting.

I'm attempting to do a random roll to determine a number of spawns 0 to 3, then place an event at one of 11 different spots on a map based on the number. The problem I've ran into is when the roll determines there are more than 1 spawn. There is a chance the 2nd or 3rd spawn would be placed on the same random spot as the first. So I need help with how to have a random variable check if another number in an array has been used and if so, random it again until it gets one not used.

Right now I have the control variable random 1 to 11 and conditionals for 1 thru 11 to place the first event on the correct spot on the map, that works. But when i go to roll a second variable 1 to 11 it may end up selecting the same spot on the map that the first variable did. I hope I've explained it well enough.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,696
Reaction score
3,005
First Language
Tagalog
Primarily Uses
RMVXA
You should probably use a global array for this one, then you randomize a number from that array and remove that number from the array afterwards so that it wont get selected on the next randomization. You'd need to do some Script Call for that though
 

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

Latest Threads

Latest Profile Posts

Check out SpokenWord- my text-to-speech plugin for RPG Maker MV!
just watched spacex launch. was awesome.
Jumping and gravitation 0.1 build - RPG Maker MV
Currently playing final fantasy 3 on DS. It's an old one but its a classic.

Forum statistics

Threads
97,957
Messages
948,113
Members
129,203
Latest member
mizz
Top