Also is there any way to create temrorary unique loot chest ID? At the moment it seems like I have to create multiple ID's of loot chest, otherwise loot will be stacked in every of the same container ID. Seems like atm I can't reuse ID X containter.
What I mean:
I'm doing random loot containers, once player interacts with the chest for the first time, there's a line of items being randomly added to container ID X.
Once items are added, chest switches to A page, where I put "Open Storage Container ID X" with the "generated" items inside. However, every next same ID opened chest will summarise items which were "generated" in previous container, stacking infinitely.
Is there any way to get rid of that issue without having to manually add dozens of container's IDs in plugin manager?
Adding possibility which allows to set temporal random loot ID container and add random items before opening.
Some tips which could be helpful:
Creating a method to generate unique container ID:
Game_Containers.prototype.createTemporaryContainer = function(name, maxStorage, storageIconId) {
const tempId = this._containers.length + 1; // Generate a new ID
this.createContainer(name, maxStorage, storageIconId, false);
return tempId;
};
Modifying 'openContainer' function:
Game_Containers.prototype.openContainer = function(id, isTemporary) {
if (isTemporary) {
// Create a temporary container with random items
const tempId = this.createTemporaryContainer('Temporary Container', 100, 210); // Example values
this.populateTemporaryContainer(tempId);
id = tempId;
}
this.tempId = id;
this.currentMaxAmount = this._containers[id - 1].maxStorage;
SceneManager.push(Scene_Container);
};
Adding a method to populate the temporary container with items
Game_Containers.prototype.populateTemporaryContainer = function(containerId) {
const randomItems = this.getRandomItems(); // Implement this function to return an array of random items
for (const item of randomItems) {
this.depositItem(containerId - 1, item.id, item.amount, item.name, item.iconIndex, item.etypeId, item.description, item.itemWeight, item.itypeId, item.categories, item.meta);
}
};
Game_Containers.prototype.getRandomItems = function() {
// Implement dev's logic to generate random items
// This is just an example
return [
{ id: 1, amount: 1, name: 'Potion', iconIndex: 16, etypeId: undefined, description: 'Restores HP', itemWeight: 1, itypeId: 1, categories: ['item'], meta: {} },
// Add more items as needed
];
};
etc
Thanks!