Randomised Loot but no Duplicates

I know how to make randomised loot in treasure chests, but I want to add a system in place where you never get the same item twice unless you don't have it.

Is there a way to make the randomised loot reshuffle to a different item so you don't get duplicates?
Someone made a loot table plugin that you should be able to find if you Google it, which I believe could remove items from the table once they'd been gotten.

Here, don't have to Google:
you can use script calls at the start of the dungeon to set a variable to an array of item IDs or item/weapon/armor references and then have your chests pick a random one, remove it from the array, and give the party the item
I do random treasure chests by common events. First, the treasure chest calls an event "Random Treasure" to determine what kind of contents (gold, weapon, armour or potion) is in the chest. It does this by setting a variable to a random number, and, depending on the value, calls another common event ("Random Gold", "Random Weapon, "Random Armour" etc.).

The weapons that can be found in treasure chests are in the database in a set pattern. Each type of weapon ("Sword", "Spear", "Axe" etc.) has a band of 6 weapons of that type, running from weakest to most powerful. Armour is organised in a similar way.
RandomWeaponTop.png


RandomWeaponBottom.png

I use Yanfly's Message Core, which makes it a lot easier to tell the player what they found, although you could use a lot of conditional branches instead.
@Piyan Glupak Just to point it out, this method does not appear to satisfy one of the OP's conditions, that each time you receive an item it's removed from the loot pool.

It only tracks the single last item received.

I use Yanfly's Message Core, which makes it a lot easier to tell the player what they found
One could do it without that plugin by doing this after your gainItem() script call:
Control Variables -> 2 -> Script: $dataWeapons[$gameVariables.value(2)].name

Then your Show Text can just reference \V[2] for the name.

(I imagine almost any project can find a use for the Message Core, I'm just putting the alternative out there)
Declare Control Variable 12 as Script: [1, 3, 15]
//where 1, 3, 15 are your possible chest item ids. Call the variable Chest Item Pool or whatever

Then in the chest events put
Code:
var randomIndex = Math.floor(Math.random() * $gameVariables.value(12).length);
if($gameVariables.value(12).length>0){
 $gameParty.gainItem($dataItems[$gameVariables.value(12)[randomIndex]], 1);
 $gameVariables.value(12).splice(randomIndex, 1);
}
@Piyan Glupak Just to point it out, this method does not appear to satisfy one of the OP's conditions, that each time you receive an item it's removed from the loot pool.

It only tracks the single last item received.
I do hope that you are not suggesting that OP should use switches to check whether the player has received any particular piece of loot instead of my "not the same weapon as last time" mechanism? That would be nearly as bad as saying that they consider doing some code to check whether or not they have too many treasure chests compared to items, such as incrementing a variable every time the player successfully opens a chest, and checking that there is at least one item still available. 😛
I do hope that you are not suggesting that OP should use switches to check whether the player has received
he didnt

Original thread: https://forums.rpgmakerweb.com/threads/randomised-loot-but-no-duplicates.172015/