Simple randomizer

Shenic

Villager
Member
Joined
Sep 25, 2015
Messages
29
Reaction score
5
First Language
English
Primarily Uses
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:



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



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:



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):



5 - The common event should look similar to this:



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:



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



Good luck!  :)  
 

WrathfulCupcake

Villager
Member
Joined
Jul 7, 2017
Messages
10
Reaction score
0
First Language
English
Primarily Uses
RMMV
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?
 

Pentacles

Lazy Creator
Veteran
Joined
Jul 5, 2016
Messages
47
Reaction score
21
First Language
French
Primarily Uses
RMMV
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 :

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 ?
 
Last edited:

WrathfulCupcake

Villager
Member
Joined
Jul 7, 2017
Messages
10
Reaction score
0
First Language
English
Primarily Uses
RMMV
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.
 

GLHSonicstar

Villager
Member
Joined
Jul 18, 2016
Messages
9
Reaction score
1
First Language
English
Primarily Uses
RMMV
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.
 

GBJackson

Veteran
Veteran
Joined
Dec 11, 2016
Messages
82
Reaction score
86
First Language
English
Primarily Uses
RMMV
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.
 
Last edited:

LordFleck

Villager
Member
Joined
Jun 12, 2013
Messages
9
Reaction score
0
First Language
English
Primarily Uses
Can someone redo the original post? The images are missing. Seems like a valuable "basic" post.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,853
Messages
1,016,986
Members
137,561
Latest member
visploo100
Top