MZ Non-manual treasure system?

So I appreciate rpg maker games aren't MMO, but I was wondering if there was a way to create a treasure system of semi-randomised, allowing choice between a set of times, and chance of rare wares. Not including monster drops of course.
yes and no.

the computer can't read your mind - you always have to give commands to tell it what to do.
it simply does not know which item is common or rare or whatever.

In previous makers there were plugins that helped with this by allowing assignments of categories or probabilities and so on, but they still require the developer to set those values and to enter probability tables - and I don't know if any such plugin has already been written for MZ.
Yes, i got the idea from the NWN treasure system, where you'd have a room of treasure chests each one for a specific loot table.

Of course, it wouldn't work like that, but a list of item IDs maybe in a plugin?
Moved to: Plugin Requests
Moved to: Plugin Requests
well, appropriate.
but a list of item IDs maybe in a plugin?
there are half a dozen different ways to handle such an idea.
a loot table is one of the more flexible options, but also one that would require a lot of input from the developer to the plugin writer (or require the developer to be able to enter the loot table into the code).

a simpler approach would be to give each item two notetags, one for treasure category and one for random weight, and then have the plugin generate a table for each category.
but there are other ways and you either need to provide a system design for the plugin writer (increases the chance of finding one if it is a good design) or you'll have the plugin programmer decide on how to handle this (which means waiting until the request catches the fancy of someone)
there are half a dozen different ways to handle such an idea.
a loot table is one of the more flexible options, but also one that would require a lot of input from the developer to the plugin writer (or require the developer to be able to enter the loot table into the code).

a simpler approach would be to give each item two notetags, one for treasure category and one for random weight, and then have the plugin generate a table for each category.
but there are other ways and you either need to provide a system design for the plugin writer (increases the chance of finding one if it is a good design) or you'll have the plugin programmer decide on how to handle this (which means waiting until the request catches the fancy of someone)
A fancier option would also auto-display a message with the obtained items.

Of course, as I said, I kept this idea from a game which had a dynamic semi-persistent world, so not necessarily useful for RPG maker. But what can I say, I like it.
A simple and dumb solution would be to add/make your own loot table. Something like this in the script call...
Code:
loot = [1,1,1,2,2,2,3,3,3,4]
itemID = loot[Math.randomInt(loot.length)]
item = $dataItems[itemID]
$gameParty.gainItem(item, 1)
Item 1 = has a chance to spawn 3/10
Item 2 = has a chance to spawn 3/10
Item 3 = has a chance to spawn 3/10
Item 4 = has a chance to spawn 1/10
A simple and dumb solution would be to add/make your own loot table. Something like this in the script call...
Code:
loot = [1,1,1,2,2,2,3,3,3,4]
itemID = loot[Math.randomInt(loot.length)]
item = $dataItems[itemID]
$gameParty.gainItem(item, 1)
Item 1 = has a chance to spawn 3/10
Item 2 = has a chance to spawn 3/10
Item 3 = has a chance to spawn 3/10
Item 4 = has a chance to spawn 1/10
I think it needs to be a bit dumber for me as I have no idea where to start with that!
I think it needs to be a bit dumber for me as I have no idea where to start with that!
In short, what you need to do is to replace the loot = [] with item id.
The more you put the same id, has more chance to drop. Ignore the rest of 3 lines after that.

For example.
Code:
loot = [1,2,3,4,5,6,7,8,9]
This will drop item id 1 to 9.
You could do this with variables. Open a treasure chest, set a variable to a random number between X and Y - then reward an item based on what that variable is.

You could then have each of those variables relate to specific ranges of gear.
there was a thread with a loot table, some did it with a scriptcall
to get 1 item from range 1 -10 at random.

with a plugin, you can specify the loot or what item. which works really
well for those, let me see if I can find the thread.

EDIT:

while I cannot find it really, here are 4 options for a loot list:

Spoiler: option 1
control variables x = random 100...300
Script: let loot = $gameVariables.value(x);
$gameparty.gainItem($dataItems[loot], 1);

Show Animation player, x // optional if you want animation
text: you got \ii[\[v6]] //require YEP_Message core for \ii

Spoiler: Option 2
var possibleRewards = [
{ itemId: 1, min: 1, max: 3 },
{ itemId: 2, min: 1, max: 1 },
{ itemId: 9, min: 3, max: 5 }
];
var reward = possibleRewards[Math.randomInt(possibleRewards.length)];
var item = $dataItems[reward.itemId];
var amount = reward.min + Math.randomInt(reward.max - reward.min + 1);
$gameParty.gainItem(item, amount);
$gameVariables.setValue(123, item.name);
$gameVariables.setValue(124, amount);

Spoiler: Option 3
var items = $dataItems;
var weapons = $dataWeapons;
var armor = $dataArmor;

var possibleRewards = [
{ object: items[1], min: 1, max: 1 },
{ object: items[3], min: 1, max: 1 },
{ object: armor[3], min: 1, max: 1 },
{ object: weapons[3], min: 1, max: 1 },
null,
null,
0, // same as null, but shorter to write
null,
null,
null
];

var reward = possibleRewards[Math.randomInt(possibleRewards.length)];
if (reward) {
var amount = reward.min + Math.randomInt(reward.max - reward.min + 1);
$gameParty.gainItem(reward.object, amount);

$gameVariables.setValue(123, reward.object.name);
$gameVariables.setValue(124, amount);
} else {
$gameVariables.setValue(123, "nothing");
$gameVariables.setValue(124, 0);
}

Spoiler: Option 4 (using %)
var items = $dataItems;
var weapons = $dataWeapons;
var armor = $dataArmor;

var possibleRewards = [
{ object: items[1], p: 0.1 },
{ object: items[3], p: 0.2 },
{ object: items[13], p: 0.0001 }
];

var rewards = possibleRewards.map(function(i) { i.p >= Math.random() });
for (var reward of rewards) {
$gameParty.gainItem(reward.object, 1);
}

you can save it in a plugin and call the function to loot, which gives it at random.
but how you approach it, is up to you.
Thank you all for the suggestions, you are all wonderful and appreciated. Now, after I cry myself a little in mourning of my thinning hair, I'll try to get those working.
Yes, i got the idea from the NWN treasure system, where you'd have a room of treasure chests each one for a specific loot table.

Of course, it wouldn't work like that, but a list of item IDs maybe in a plugin?
When I read this post, my thought was... maybe it could just work like that.

What I mean is… you could make a plugin where you specify a map in the plugin parameters, and it reads events from that map and somehow builds a loot table from it (probably using Shop Processing to set probabilities, or something like that).
When I read this post, my thought was... maybe it could just work like that.

What I mean is… you could make a plugin where you specify a map in the plugin parameters, and it reads events from that map and somehow builds a loot table from it (probably using Shop Processing to set probabilities, or something like that).
Is that something you'd do?
Possibly. I don't have any plans to do it right now, though, so if some other plugin developer likes the idea, feel free to steal it.
Possibly. I don't have any plans to do it right now, though, so if some other plugin developer likes the idea, feel free to steal it.
Of course, I meant hypothetically.
So, hold on, can Javascript generate a random number between a specific interval?
Uhh… yes? Of course it can. Generating a random number is just math.
Uhh… yes? Of course it can. Generating a random number is just math.
My point is, can Javascript generate a number between two defined intervals, in this case, they'd be the two IDs of the first and last item that could be used as random treasure?

Original thread: https://forums.rpgmakerweb.com/threads/non-manual-treasure-system.143613/