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,682
Reaction score
3,003
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 Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,049
Members
137,570
Latest member
fgfhdfg
Top