FORK CONDITIONS, RANDOM ITEMS IN CHESTS, SHOWING THE ITEMS NAME
A tutorial on Fork Conditions and Random Items in Chests - Showing the Items Name
Aten- 07/29/2010 07:20 PM
- 1674 views
Written by Gemin-Eye
Difficulty - Advanced
Before you continue, make sure you understand how to make a Variable.
What this Fork Option will check for, is a Variable (that is randomly generated) and if its the same as another Variable (which will represent one of the items in the Database - Items).
The Random Variable:
In the Events Editor and select 'Change Variable', in the 'Variable Management Dialog' select the 'One' and select the Variable called "Chest-Rand-Item". Under 'Operation' select "Set", Under 'Operand' select "Rand." and change the first edit as the beginning number and the second edit as the ending number. These are the numbers between x to x, (example; 1 to 10). These numbers will be 'Item' numbers in the Database. So choose a x to x that is suitable to your Items list. I will use numbers (ie. items) 1 to 5 in this tutorial. Click 'Ok'.
Note: This event command can be placed in any event, so long as it is before they open the chest with the random item in it. Otherwise there won't be any random item.
The Common Event & it's Commands:
Place the following in a Common Event, so you can call on it every time you want to generate a random item. Make it a Parallel Process, called with a switch. Name the switch whatever you like. The switch will be placed in the chest event, every chest event you want a random item in that is.
The Variable:
Double click in the common events - event commands window and select the Change Variable command and create a new variable named "Rand-one" and set the 'Operand' 'Set' as "1". Then click 'OK' and double click again and select the "Fork Conditions" command (page 3). The fork condition will check to see if the random variable (Chest-Rand-item) is the same as the one just created (Rand-one).
You see when you create the random variable (Chest-Rand-one), the item has been chosen right there. Whatever that number is; is what the item is, just look in your Database to see the numbers beside the items listed there on the left.
The Fork Condition and it's Commands:
If Variable = number, then message = item name. These commands will run only if the two variables (Chest-Rand-one and Rand-one) match. If you don't know how to make a fork, click here. Each of the forks here will need to have an Else case.
Now to show the items name, you have to make a fork option for each item. You won't create a new (Rand-one) variable, you just set the Operation to + (add) 1. Thus making the (Rand-one) variable a 2 (and then a 3 and so on for each fork created). In the same Common Event, add the following forks:
<>Fork Optn:Varbl-VEquivl
This first fork condition checks if the random variable (Chest-Rand-one) is he same as (Rand-one) which is set to 1. So if (Chest-Rand-one) = (Rand-one)(1) then:
<>Messg:Found a POTION.
The Message:
For the first fork option, you will put the message, "You found a ." Where the item name is the first item in the Items list of the Database.
In the Second Fork option, you will put the message, "You found a ." Where the item name is the second item in the Items list of the Database.
Just do the same for the other fork options needed.
<>Change Switch::Rand-item-name]-OFF Set
The Switch:
You will then need to use a switch to shut off this common event. Whatever you named the switch that calls this event, shut that switch off with a Change Switch command. I called mine "Rand-item-name".
Thats it for the If variable = number, then message = item name.
Now for the If variable does not = number, then move to the next fork option and check again. These are the :ELSE Case commands.
:ELSE Case
<>Variable Ch: + , 1
The Variable: This refers to the Rand-one Variable created above (which is set to 1), at the first of the Common Event. Since the random variable is not a 1 then we need to check if it is a 2, so change the Rand-one variable to a 2 by adding 1 to it's current value of 1.
<>GO TO Label: 1No
The Goto Label:
The Goto Label command is needed to skip the Wait command and go straight to the next Fork Condition. Make the first Goto Label 1.
<>
<>End Case
<>Wait 1.2s
The Wait:
The Wait command here is need because the program rips through the script so quickly, it will actually run twice before the switch gets shut off, which means the player will get two message commands that they got items. The first is correct, the second is false.
Make the Wait about 1.2 seconds. Place it above each Label and after each Fork.
<>Label: 1No
The Label:
Place the Label after the wait every time. The first Label should be Label 1No and the second should be Label 2No and so on. I put the final label at the very top of the script just to be on the safe side.
Thats pretty much it. This will be your complete Common Event.
--Event Commands-----------------------------------------------------------------------
<>Label: 5No
<>Variable Op: Set, 1
<>Fork Optn:Varbl-VEquivl
<>Message:Found a POTION.
<>Change Switch: -OFF Set
<>
:ELSE Case
<>Variable Op:[0013:Rand-one + , 1
<>Goto Label: 1No
<>
:End Case
<>Wait: 1.2s.
<>Label: 1No
<>Fork Optn:Varbl-VEquivl
<>Message:Found a TEAR DROP item.
<>Change Switch: -OFF Set
<>
:ELSE Case
<>Variable Op:[0013:Rand-one + , 1
<>Goto Label: 2No
<>
:End Case
<>Wait: 1.2s.
<>Label: 2No
<>Fork Optn:Varbl-VEquivl
<>Message:Found a MAGIC ETHER item.
<>Change Switch: -OFF Set
<>
:ELSE Case
<>Variable Op:[0013:Rand-one + , 1
<>Goto Label: 3No
<>
:End Case
<>Wait: 1.2s.
<>Label: 3No
<>Fork Optn:Varbl-VEquivl
<>Message:Found a MIRACLE DROP item.
<>Change Switch: -OFF Set
<>
:ELSE Case
<>Variable Op:[0013:Rand-one + , 1
<>Goto Label: 4No
<>
:End Case
<>Wait: 1.2s.
<>Label: 4No
<>Fork Optn:Varbl-VEquivl
<>Message:Found a PHOENIX DOWN item. Now if someone
: :dies I can revive them.
<>Change Switch: -OFF Set
<>
:ELSE Case
<>Variable Op:[0013:Rand-one + , 1
<>Goto Label: 5No
<>
:End Case
<>Wait: 1.2s.
The :ELSE Case on this last Fork is really unnecessary, the script will go through each fork to check the variables and if it gets to this last one, thats it the script will be done. There should be no need for an else case, (I put it in just to mention that it is needed). Same goes for the commands within the excepting case, they are not needed. The Wait command at the end, however, is.
Difficulty - Advanced
Before you continue, make sure you understand how to make a Variable.
What this Fork Option will check for, is a Variable (that is randomly generated) and if its the same as another Variable (which will represent one of the items in the Database - Items).
The Random Variable:
In the Events Editor and select 'Change Variable', in the 'Variable Management Dialog' select the 'One' and select the Variable called "Chest-Rand-Item". Under 'Operation' select "Set", Under 'Operand' select "Rand." and change the first edit as the beginning number and the second edit as the ending number. These are the numbers between x to x, (example; 1 to 10). These numbers will be 'Item' numbers in the Database. So choose a x to x that is suitable to your Items list. I will use numbers (ie. items) 1 to 5 in this tutorial. Click 'Ok'.
Note: This event command can be placed in any event, so long as it is before they open the chest with the random item in it. Otherwise there won't be any random item.
The Common Event & it's Commands:
Place the following in a Common Event, so you can call on it every time you want to generate a random item. Make it a Parallel Process, called with a switch. Name the switch whatever you like. The switch will be placed in the chest event, every chest event you want a random item in that is.
The Variable:
Double click in the common events - event commands window and select the Change Variable command and create a new variable named "Rand-one" and set the 'Operand' 'Set' as "1". Then click 'OK' and double click again and select the "Fork Conditions" command (page 3). The fork condition will check to see if the random variable (Chest-Rand-item) is the same as the one just created (Rand-one).
You see when you create the random variable (Chest-Rand-one), the item has been chosen right there. Whatever that number is; is what the item is, just look in your Database to see the numbers beside the items listed there on the left.
The Fork Condition and it's Commands:
If Variable = number, then message = item name. These commands will run only if the two variables (Chest-Rand-one and Rand-one) match. If you don't know how to make a fork, click here. Each of the forks here will need to have an Else case.
Now to show the items name, you have to make a fork option for each item. You won't create a new (Rand-one) variable, you just set the Operation to + (add) 1. Thus making the (Rand-one) variable a 2 (and then a 3 and so on for each fork created). In the same Common Event, add the following forks:
<>Fork Optn:Varbl-VEquivl
This first fork condition checks if the random variable (Chest-Rand-one) is he same as (Rand-one) which is set to 1. So if (Chest-Rand-one) = (Rand-one)(1) then:
<>Messg:Found a POTION.
The Message:
For the first fork option, you will put the message, "You found a ." Where the item name is the first item in the Items list of the Database.
In the Second Fork option, you will put the message, "You found a ." Where the item name is the second item in the Items list of the Database.
Just do the same for the other fork options needed.
<>Change Switch::Rand-item-name]-OFF Set
The Switch:
You will then need to use a switch to shut off this common event. Whatever you named the switch that calls this event, shut that switch off with a Change Switch command. I called mine "Rand-item-name".
Thats it for the If variable = number, then message = item name.
Now for the If variable does not = number, then move to the next fork option and check again. These are the :ELSE Case commands.
:ELSE Case
<>Variable Ch: + , 1
The Variable: This refers to the Rand-one Variable created above (which is set to 1), at the first of the Common Event. Since the random variable is not a 1 then we need to check if it is a 2, so change the Rand-one variable to a 2 by adding 1 to it's current value of 1.
<>GO TO Label: 1No
The Goto Label:
The Goto Label command is needed to skip the Wait command and go straight to the next Fork Condition. Make the first Goto Label 1.
<>
<>End Case
<>Wait 1.2s
The Wait:
The Wait command here is need because the program rips through the script so quickly, it will actually run twice before the switch gets shut off, which means the player will get two message commands that they got items. The first is correct, the second is false.
Make the Wait about 1.2 seconds. Place it above each Label and after each Fork.
<>Label: 1No
The Label:
Place the Label after the wait every time. The first Label should be Label 1No and the second should be Label 2No and so on. I put the final label at the very top of the script just to be on the safe side.
Thats pretty much it. This will be your complete Common Event.
--Event Commands-----------------------------------------------------------------------
<>Label: 5No
<>Variable Op: Set, 1
<>Fork Optn:Varbl-VEquivl
<>Message:Found a POTION.
<>Change Switch: -OFF Set
<>
:ELSE Case
<>Variable Op:[0013:Rand-one + , 1
<>Goto Label: 1No
<>
:End Case
<>Wait: 1.2s.
<>Label: 1No
<>Fork Optn:Varbl-VEquivl
<>Message:Found a TEAR DROP item.
<>Change Switch: -OFF Set
<>
:ELSE Case
<>Variable Op:[0013:Rand-one + , 1
<>Goto Label: 2No
<>
:End Case
<>Wait: 1.2s.
<>Label: 2No
<>Fork Optn:Varbl-VEquivl
<>Message:Found a MAGIC ETHER item.
<>Change Switch: -OFF Set
<>
:ELSE Case
<>Variable Op:[0013:Rand-one + , 1
<>Goto Label: 3No
<>
:End Case
<>Wait: 1.2s.
<>Label: 3No
<>Fork Optn:Varbl-VEquivl
<>Message:Found a MIRACLE DROP item.
<>Change Switch: -OFF Set
<>
:ELSE Case
<>Variable Op:[0013:Rand-one + , 1
<>Goto Label: 4No
<>
:End Case
<>Wait: 1.2s.
<>Label: 4No
<>Fork Optn:Varbl-VEquivl
<>Message:Found a PHOENIX DOWN item. Now if someone
: :dies I can revive them.
<>Change Switch: -OFF Set
<>
:ELSE Case
<>Variable Op:[0013:Rand-one + , 1
<>Goto Label: 5No
<>
:End Case
<>Wait: 1.2s.
The :ELSE Case on this last Fork is really unnecessary, the script will go through each fork to check the variables and if it gets to this last one, thats it the script will be done. There should be no need for an else case, (I put it in just to mention that it is needed). Same goes for the commands within the excepting case, they are not needed. The Wait command at the end, however, is.













