Hmmm, try to put the below as plugin and then in the shop event make a script box with prepareLootShop(X);where X is the enemyId you want to reference. It seemed to work when I put an enemy with 1 random drop out of 3, but I didn't really check the plugin in depth.
function prepareLootShop(enemyId) {
let poolsToDrop = [];
let items = [];
for (let table of $dataEnemies[enemyId].dropTables) {
if (table.rate < Math.random()) continue;
let pool = dingk.Loot.getDropCategory(table);
if (pool) poolsToDrop.push(pool);
}
if (poolsToDrop.length) {
items = dingk.Loot.getItemsFromPool(poolsToDrop);
}
let shopItems = [];
let itemType = 0;
items.forEach(item => {
if (item.atypeId) {itemType = 2; shopItems.push([itemType, item.id, 0])}
if (item.wtypeId) {itemType = 1; shopItems.push([itemType, item.id, 0])}
if (item.itypeId) {itemType = 0; shopItems.push([itemType, item.id, 0])}
})
if (shopItems.length) {
SceneManager.push(Scene_Shop);
SceneManager.prepareNextScene(
shopItems, false
);
}
}
So I take it that everything worked properly? 😀
And yeah, to separate them, I guess put in the plugin file just (change X to variable id you want):
function prepareLootShop(enemyId) {
let poolsToDrop = [];
let items = [];
for (let table of $dataEnemies[enemyId].dropTables) {
if (table.rate < Math.random()) continue;
let pool = dingk.Loot.getDropCategory(table);
if (pool) poolsToDrop.push(pool);
}
if (poolsToDrop.length) {
items = dingk.Loot.getItemsFromPool(poolsToDrop);
}
$gameVariables.setValue(X, items);
}
Use the script in the earlier post to make shop loot, then use another script to call the shop with the loot (change X to same variable id):
let shopItems = [];
let itemType = 0;
$gameVariables.value(X).forEach(item => {
if (item.atypeId) {itemType = 2; shopItems.push([itemType, item.id, 0])}
if (item.wtypeId) {itemType = 1; shopItems.push([itemType, item.id, 0])}
if (item.itypeId) {itemType = 0; shopItems.push([itemType, item.id, 0])}
})
if (shopItems.length) {
SceneManager.push(Scene_Shop);
SceneManager.prepareNextScene(shopItems, false);
}