Random Items From Treasure Chest
#1
Hello there again. This is your local Silne30 speaking and the process I am going over today will be if you want to open a chest but get random items. Now, scripting is not my forte. I asked my buddy Kain Nobel (you may know him) about a random item event and he told me in terms of scripting. He may as well had been speaking Flanknard to me because I couldn't understand it so I kinda came up with my own using an event and forks and it is actually really simple. First you start off with the number of items that you want to have to choose from. For all instructional purposes we will do 3.

Step one: We will go to Control Variables on the first page of your event editor. Now if you don't know where that is, take a look at your help file in RMXP and then refer back to this post. Once you do that we will give a new variable a name that we will remember. For my tutorial I will call the variable Random Item 1-3. I used the (1-3) because for this tutorial we will use items one through three in the database. Now for your operation we are going to Set and the operand will be random and you place the first number as one and the last as 3. What that will do is when you access the event via action button, the event will randomly set the variable Random Item 1-3 to a value that will either be 1, 2 , or 3.


Step 2: Now that we have what the value of Random Item 1-3 will be we have to use conditional branches. They basically mean if blah blah blah happens then do blank. So the first conditional you open up will bring you up to a page that has switch, variable, and some other options. So since the item in question is a variable (Random Item 1-3) select variable. Pick Random Item 1-3 from the list and then set the little drop-down to equal to and put a 1 where it says constant. So now the computer is thinking "If Random Item 1-3 is one...now you have to tell it what to do. But before you leave the conditional branch screen you are going to click the else case box at the bottom. The reason you are doing that is because you have other options as to what Random Item 1-3 can be.


Step 3: Now that we have our first conditional branch you will notice two things. There is a space under the condition and then there is a space under where it says else. Under the first space (Not the else) put what you want the first item to be. So here you can put a message like "You received potion." And add one potion to your inventory. Now that you have done that, under the else you are going to create another conditional branch. In this you will do the same as the first time but instead of setting the equal to to 1 it will be two. Make sure the else case is still checked and fill what item you will get if it is a 2. So this time it can be "You received an elixir."For the last else case you will create one more conditional branch and set the equal to to 3 but this time there will be no else case because we only have the options of 1, 2, or 3. Fill out the last item and then try your chest out. Should work pretty smoothly.


Your code should look something like this:
Content Hidden

Well, I hope this helps. My first tutorial ever. If you have any questions or if I explained something wrong...please let me know. Thanks for your time. :cheery:
Reply }
#2
:D thanks silne it works i have been trying to do something like this thanks .
Reply }


Possibly Related Threads…
Thread Author Replies Views Last Post
   Four Alternatives to Random Encounters Brickroad 2 5,642 11-26-2009, 01:09 PM
Last Post: MicKo



Users browsing this thread: 2 Guest(s)