- Joined
- Mar 15, 2015
- Messages
- 233
- Reaction score
- 27
- First Language
- English
- Primarily Uses
- RMMV
So I want to make a common event for a chest to be able to award one of say... 50 different items (blueprints to be exact), but to never overlap the items.
For example if someone opens a chest with this common event it awards a blueprint for a Tonic, but they'll never get that blueprint again from the common event chest. How would I do that? Alternatively if there's a plugin for that I'll take it. lol
*edit* The answer, thanks to Tsukihime. I'll more or less copy what Hime stated, but in an easier to read format. I have difficulty with scripts, so I'd like to help others who have the same difficulty.
Start by initializing a list of items somewhere using a script call. For simplicity I will say the items that we can get are 2, 4, 6, 8, and 12.
var list = [2, 4, 6, 8, 12];
$gameVariables.setValue(1, list);
The "var list" dictates the Item IDs of the items you wish to be able to be selected.
The "1" indicates the variable the list will be located in. In my case I used variable 31.
Now you've stored your list in variable 1. If you open the debug menu you can see a list.
Next, you will create your common event that will pick a random ID, add that to the party, and then remove the ID from the list.
var list = $gameVariables.value(1);
var numItems = list.length;
// pick random number
var index = Math.randomInt(numItems);
// gain item
var itemId = list[index];
$gameParty.gainItem($dataItems[itemId], 1)
// remove from list
list.splice(index, 1)
// update list again
$gameVariables.setValue(1, list)
The top line's "1" and the bottom line's "1" should match your variable list. In my case it was variable 31.
The "1" at the end of the line "$gameParty.gainItem($dataItems[itemId], 1)" indicates the amount of the item.
At this point you should create a conditional branch. On page 4 at the bottom you will see "Script". The script command you want is this:
$gameVariables.value(1).length === 0
If true, that means there are no items left to receive. The "1" indicates the variable list you chose. Again, in my case it was 31.
I hope this helps someone and helps to explain things that I had to use trial and error for.
Thanks for the answers, Tsukihime, and let me know if anything about this post concerns you.
For example if someone opens a chest with this common event it awards a blueprint for a Tonic, but they'll never get that blueprint again from the common event chest. How would I do that? Alternatively if there's a plugin for that I'll take it. lol
*edit* The answer, thanks to Tsukihime. I'll more or less copy what Hime stated, but in an easier to read format. I have difficulty with scripts, so I'd like to help others who have the same difficulty.
Start by initializing a list of items somewhere using a script call. For simplicity I will say the items that we can get are 2, 4, 6, 8, and 12.
var list = [2, 4, 6, 8, 12];
$gameVariables.setValue(1, list);
The "var list" dictates the Item IDs of the items you wish to be able to be selected.
The "1" indicates the variable the list will be located in. In my case I used variable 31.
Now you've stored your list in variable 1. If you open the debug menu you can see a list.
Next, you will create your common event that will pick a random ID, add that to the party, and then remove the ID from the list.
var list = $gameVariables.value(1);
var numItems = list.length;
// pick random number
var index = Math.randomInt(numItems);
// gain item
var itemId = list[index];
$gameParty.gainItem($dataItems[itemId], 1)
// remove from list
list.splice(index, 1)
// update list again
$gameVariables.setValue(1, list)
The top line's "1" and the bottom line's "1" should match your variable list. In my case it was variable 31.
The "1" at the end of the line "$gameParty.gainItem($dataItems[itemId], 1)" indicates the amount of the item.
At this point you should create a conditional branch. On page 4 at the bottom you will see "Script". The script command you want is this:
$gameVariables.value(1).length === 0
If true, that means there are no items left to receive. The "1" indicates the variable list you chose. Again, in my case it was 31.
I hope this helps someone and helps to explain things that I had to use trial and error for.
Thanks for the answers, Tsukihime, and let me know if anything about this post concerns you.
Last edited by a moderator:

