Random variables with no repeating.

Discussion in 'RPG Maker MV' started by Braxillian, Jul 11, 2018.

  1. Braxillian

    Braxillian Villager Member

    Messages:
    26
    Likes Received:
    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.
     
    #1
  2. Engr. Adiktuzmiko

    Engr. Adiktuzmiko Chemical Engineer, Game Developer, Using BlinkBoy' Veteran

    Messages:
    14,066
    Likes Received:
    2,610
    Location:
    Philippines
    First Language:
    Tagalog
    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
     
    #2

Share This Page