Simple randomizer

Here's the tutorial for a simple randomizer. It can be used if you want a chest to contain a random item, if you want your character to learn a random ability or whatever you want, but, for this tutorial, I'll teach you to create a chest that gives random items.

1 - Open the common events tab in the database and double click the empty line to show the event commands:

First%2Bstep.png


2 - Click "Control Variables", create a variable and check these options:

Second%2Bstep.png


3 - According to the percentage you want and the number of items/abilities, choose two values. To keep it simple, I'll use 1 and 4 and it'll be 4 items, 25% for each item. Click OK:

Third%2Bstep.png


4 - Now create conditional branches like this, create as many as the higher number you chose in the step #3, the constant in each branch should be equal to the branch's corresponding number (it may seem confusing now, but you'll understand it later):

Fourth%2Bstep.png


5 - The common event should look similar to this:

Fifth%2Bstep.png


6 - Create a chest or something to give you an item. Double click the chest to open the event editor, open the event commands and click "Common Event". Select the common event you just created:

Sixth%2Bstep.png


7 - And it's done. The final randomizer event should look like this:

Final%2Bstep.png


Good luck!  🙂  
This is great, thanks! I already see tons of uses. Is there a way to delete an option once it has been selected as a random item/event, etc? This way if you've received a potion once, you will never receive that item again?
Hi, you can do that with switch. Altrough it would use a lot of switch if you have a lot of items / skill / thing randomized. My engine is in french so i don't think it's usefull but here what it would look like :
286630Capture.png

In english :
Label : Begin
Control Variables : Randomizer = Random 0 to 2

  • If Randomizer = 2
  1. If Switch First= Off
    First Gain
    Switch First = On
  2. Else
    Go to Label : Begin

    end
  • If Randomizer = 1
  1. If Switch Second= Off
    Second Gain
    Switch Second = On
  2. Else
    Go to Label : Begin

    end
  • If Randomizer = 0
  1. If Switch Third = Off
    Third Gain
    Switch Third = On
  2. Else
    Go to Label : Begin

    end
Edit : Nope, It doesn't work with Selfswicht Plugin from Yanfly, sorry (The selfswitch are assigned to the event who launch the common event not the common event itself)


Edit 2 : Maybe it interest you , for going futher , you can change the "Control Variables : Randomizer = Random 0 to 2" by

If Swicht MidStoryOfTheGame = On
Control Variables : Randomizer = Random 10 to 19
Else
Control Variables : Randomizer = Random 0 to 9

Personnaly, I create a little more complicated randomizer for NPC-Talk, wich change in function of the female / male , age and even sun or rain. What do you want to do ?
Thanks, I'll play around with this to see if I can get it to work. Basically I want an event to occur each night, but if an event has already occurred then I dont want that event to occur again, select a different random event.
Thanks, this really helped me make an item called the "Random Potion", it can only be used in battle and when used, it will trigger a common event that performs a random battle effect, like TP being completely refilled, every enemy taking 5,000 damage, the EXP rate going up, etc. It will be sold in random towns for 6000 gold.
Thanks, I'll play around with this to see if I can get it to work. Basically I want an event to occur each night, but if an event has already occurred then I dont want that event to occur again, select a different random event.
You might want to consider using what I call a "bit progression" variable. If you understand how binary numbers work, it's easy to set up. If not, I will explain it.

Let's say that there are four events that you want to track and make sure once they've occurred, they never occur again. while other events not tracked have the same chance of occurring as before. Each of these events need to have a bit progression value:

Event1 = 1 [Binary 0001]
Event2 = 2 [Binary 0010]
Event3 = 4 [Binary 0100]
Event4 = 8 [Binary 1000]

We'll call the variable BitProgA.

When a tracked event occurs we use a control variable command to add its value to BitProgA

If events 2 and 3 have occurred, the value of BitProgA will be 6 (2 + 4).

You would use a second common event that gets called to check this variable

You want to set up the checks as follows

If
If BitProgA = 1 (event 1) [Binary 0001]
If BitProgA = 2 (event 2) [Binary 0010]
If BitProgA = 3 (events 1 and 2) [Binary 0011]
If BitProgA = 4 (event 3) [Binary 0100]
If BitProgA = 5 (events 1 and 3) [Binary 0101]
If BitProgA = 6 (events 2 and 3) [Binary 0110]
If BitProgA = 7 (events 1 2 and 3) [0111]
If BitProgA = 8 (event 4) [Binary 1000]
If BitProgA = 9 (events 1 and 4) [Binary 1001]
If BitProgA = 10 (events 2 and 4) [Binary 1010]
If BitProgA = 11 (events 1 2 and 4) [Binary 1011]
If BitProgA = 12 (events 3 and 4) [Binary 1100]
If BitProgA = 13 (events 1 3 and 4) [Binary 1101]
If BitProgA = 14 (events 2 3 and 4) [Binary 1110]
If BitProgA = 15 Events 1 2 3 and 4) [Binary 1111]
else

Because of the specific values each tracked event would increase the variable by, there is no way to arrive at the results unless the tracked event or events have occurred.

This common event needs to be called from within the randomizer common event, immediately after the Control Variable Random Stuff command

Nothing in the else branch will make it so no special treatment is given and the randomizer common event will continue as normal.

Now controlling the increase of BitProgA is handled when the tracked event occurs.

If anyone sees any holes in this approach, let me know. I haven't tested it yet.
Can someone redo the original post? The images are missing. Seems like a valuable "basic" post.

Original thread: https://forums.rpgmakerweb.com/threads/simple-randomizer.54008/