I have 20 characters in my game, making up 5 different parties. When you switch worlds, you switch parties and I don't want to share gold, weapons, etc. Would I need a plugin to achieve this or is there another way?
Switching parties and not sharing items, gold, weapons, etc
RPG Maker MZ SupportTheoretically, one can achieve that using only pure eventing, but realistically, you should use a plugin. I think there are already a handful out there because this question is frequently asked.
there are certainly party switching plugins but I haven't found any that ables each party to have their own inventories
I dug up an old post of mine:
Chat gpt wrote me this plugin for inventory management. It works, I just have to Add and Remove characters manually which is not bad, just a bit more work
/*:
* @target MZ
* @plugindesc Separate inventories for different parties in RPG Maker MZ.
* @Help This plugin allows each party to have its own separate inventory,
* including gold, items, weapons, and armors.
*
* Plugin Commands:
* - SetPartyInventory partyId
* Switches to the inventory for the specified party ID.
*
* @command SetPartyInventory
* @text Set Party Inventory
* @desc Switches to the inventory for the specified party ID.
*
* @arg partyId
* @type number
* @min 1
* @desc The ID of the party you want to switch to.
*/
(() => {
const partyInventories = {};
const saveCurrentPartyInventory = (partyId) => {
partyInventories[partyId] = {
gold: $gameParty.gold(),
items: JSON.parse(JSON.stringify($gameParty._items)),
weapons: JSON.parse(JSON.stringify($gameParty._weapons)),
armors: JSON.parse(JSON.stringify($gameParty._armors))
};
};
const loadPartyInventory = (partyId) => {
const inventory = partyInventories[partyId];
if (inventory) {
$gameParty.gainGold(inventory.gold - $gameParty.gold());
$gameParty._items = JSON.parse(JSON.stringify(inventory.items));
$gameParty._weapons = JSON.parse(JSON.stringify(inventory.weapons));
$gameParty._armors = JSON.parse(JSON.stringify(inventory.armors));
} else {
// Initialize a new inventory if none exists for the party
partyInventories[partyId] = {
gold: 0,
items: {},
weapons: {},
armors: {}
};
loadPartyInventory(partyId);
}
};
PluginManager.registerCommand('SeparatePartyInventories', 'SetPartyInventory', args => {
const partyId = Number(args.partyId);
saveCurrentPartyInventory($gameParty._partyId);
loadPartyInventory(partyId);
$gameParty._partyId = partyId;
});
// Register the command in the plugin manager
PluginManager.registerCommand('SeparatePartyInventories', 'SetPartyInventory', args => {
const partyId = Number(args.partyId);
saveCurrentPartyInventory($gameParty._partyId);
loadPartyInventory(partyId);
$gameParty._partyId = partyId;
});
const _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
_Game_Interpreter_pluginCommand.apply(this, arguments);
if (command === 'SetPartyInventory') {
const partyId = Number(args[0]);
saveCurrentPartyInventory($gameParty._partyId);
loadPartyInventory(partyId);
$gameParty._partyId = partyId;
}
};
})();
/*:
* @target MZ
* @plugindesc Separate inventories for different parties in RPG Maker MZ.
* @Help This plugin allows each party to have its own separate inventory,
* including gold, items, weapons, and armors.
*
* Plugin Commands:
* - SetPartyInventory partyId
* Switches to the inventory for the specified party ID.
*
* @command SetPartyInventory
* @text Set Party Inventory
* @desc Switches to the inventory for the specified party ID.
*
* @arg partyId
* @type number
* @min 1
* @desc The ID of the party you want to switch to.
*/
(() => {
const partyInventories = {};
const saveCurrentPartyInventory = (partyId) => {
partyInventories[partyId] = {
gold: $gameParty.gold(),
items: JSON.parse(JSON.stringify($gameParty._items)),
weapons: JSON.parse(JSON.stringify($gameParty._weapons)),
armors: JSON.parse(JSON.stringify($gameParty._armors))
};
};
const loadPartyInventory = (partyId) => {
const inventory = partyInventories[partyId];
if (inventory) {
$gameParty.gainGold(inventory.gold - $gameParty.gold());
$gameParty._items = JSON.parse(JSON.stringify(inventory.items));
$gameParty._weapons = JSON.parse(JSON.stringify(inventory.weapons));
$gameParty._armors = JSON.parse(JSON.stringify(inventory.armors));
} else {
// Initialize a new inventory if none exists for the party
partyInventories[partyId] = {
gold: 0,
items: {},
weapons: {},
armors: {}
};
loadPartyInventory(partyId);
}
};
PluginManager.registerCommand('SeparatePartyInventories', 'SetPartyInventory', args => {
const partyId = Number(args.partyId);
saveCurrentPartyInventory($gameParty._partyId);
loadPartyInventory(partyId);
$gameParty._partyId = partyId;
});
// Register the command in the plugin manager
PluginManager.registerCommand('SeparatePartyInventories', 'SetPartyInventory', args => {
const partyId = Number(args.partyId);
saveCurrentPartyInventory($gameParty._partyId);
loadPartyInventory(partyId);
$gameParty._partyId = partyId;
});
const _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
_Game_Interpreter_pluginCommand.apply(this, arguments);
if (command === 'SetPartyInventory') {
const partyId = Number(args[0]);
saveCurrentPartyInventory($gameParty._partyId);
loadPartyInventory(partyId);
$gameParty._partyId = partyId;
}
};
})();
Unless I've missed something, that code stores the data per-session, rather than per-playthrough: it is only initialised on boot, not on new game, and is not stored in save files. This means:
- Recalling an inventory saved during the current session for a different playthrough is possible.
- Attempting to load any inventory saved in a different session will fail.
Thanks a bunch for pointing this out! Chat GPT revised the code to avoid that.
/*:
* @target MZ
* @plugindesc Separate inventories for each party with persistent storage.
* @Author YourName
*
* @param InventoryData
* @text Initial Inventory Data
* @type struct<Inventory>[]
* @Default []
*
* @command SetPartyInventory
* @text Set Party Inventory
* @desc Set the inventory for a specific party ID.
*
* @arg partyId
* @text Party ID
* @type number
* @Default 1
*
* @arg items
* @text Items
* @type string
* @Default ""
*
* @command GetPartyInventory
* @text Get Party Inventory
* @desc Retrieve the inventory for a specific party ID.
*
* @arg partyId
* @text Party ID
* @type number
* @Default 1
*
* @Help
* This plugin allows you to manage separate inventories for different parties.
*
* Each party can have its own inventory, which is saved across playthroughs.
*/
(() => {
const parameters = PluginManager.parameters('SeparatePartyInventory');
const inventoryData = JSON.parse(parameters['InventoryData'] || "[]");
// Store inventories in a global variable
const inventories = {};
// Load inventories from saved data
const loadInventories = () => {
const savedData = StorageManager.loadObject('PartyInventories');
return savedData || {};
};
// Save inventories to local storage
const saveInventories = () => {
StorageManager.saveObject('PartyInventories', inventories);
};
// Initialize inventories
const initInventories = () => {
for (let i = 1; i <= 20; i++) { // Assuming a max of 20 parties
if (!inventories) {
inventories = {
items: {},
weapons: {},
armors: {}
};
}
}
};
// Command to set party inventory
PluginManager.registerCommand('SeparatePartyInventory', 'SetPartyInventory', args => {
const partyId = Number(args.partyId);
const items = JSON.parse(args.items);
inventories[partyId].items = items; // Save the items for the party
saveInventories(); // Save to local storage
});
// Command to get party inventory
PluginManager.registerCommand('SeparatePartyInventory', 'GetPartyInventory', args => {
const partyId = Number(args.partyId);
const inventory = inventories[partyId];
// Do something with the retrieved inventory, like displaying it
console.log(`Inventory for Party ${partyId}:`, inventory);
});
// Initialize on game start
const startGame = () => {
inventories = loadInventories(); // Load inventories when the game starts
initInventories(); // Initialize inventories if not set
};
// Call startGame function when the game starts
const _Scene_Boot_start = Scene_Boot.prototype.start;
Scene_Boot.prototype.start = function() {
_Scene_Boot_start.call(this);
startGame();
};
// Add an alias for saving the game
const _DataManager_makeSaveContents = DataManager.makeSaveContents;
DataManager.makeSaveContents = function() {
const contents = _DataManager_makeSaveContents.call(this);
contents.partyInventories = inventories; // Save inventories to game data
return contents;
};
// Add an alias for loading the game
const _DataManager_extractSaveContents = DataManager.extractSaveContents;
DataManager.extractSaveContents = function(contents) {
_DataManager_extractSaveContents.call(this, contents);
inventories = contents.partyInventories || {}; // Load inventories from game data
};
})();
Hi. This plugin does exactly what you ask for, just in case.
forums.rpgmakerweb.com
InventorySwitch an RPG Maker MV & MZ Plugin
You ever wanted to have individual character inventories or you wanted to have a flashback scene and you didn't want your player able to access their original inventory? Well, I have the solution to the problem you have never had! These plugins are free for use in anything. I would like credits...
forums.rpgmakerweb.com
It does! I just wished a general plugin would exist to have Party iDs, so that you don't have to Add and Remove every character needed when you switch parties.
@sushibyte - I found this plugin with a quick search:
forums.rpgmakerweb.com
I skimmed its code: looks good but I haven't tested it. 👋
PS: in future, consider using the
Multiple Parties
Description: Very small plugin that allows creating multiple parties in your game and switching between them using plugin commands. Further parties, including their starting items and gold can be setup in the plugin parameters, so they are known right from the start of your game and you can...
forums.rpgmakerweb.com
You might want to test that revised Chat GPT code in the "new game" situation I described before. I would also suggest putting "Chat GPT" in the
Based on a quick look at its code, the MZ plugin @Mythik suggested looks like it would have a similar problem, storing data per-session rather than per-playthrough. I haven't tested it, though.
Script calls (
@author field of the plugin's header section.Based on a quick look at its code, the MZ plugin @Mythik suggested looks like it would have a similar problem, storing data per-session rather than per-playthrough. I haven't tested it, though.
Script calls (
eval) like I originally suggested may be sub-optimal, but I think the main goal should be to get things working with tried-and-tested solutions, rather than attempting to shave off a few milliseconds from a process that isn't happening frequently (e.g. every frame).</> button ("Code") to format any code that you post here~your problem is that different programmers use the term "Party Manager" differently, making it almost impossible to search for a specific variant.
Most party manager plugins are for managing the actors inside a single party (like yanfly's).
What you want is a party manager in Tsukihime's style for managing multiple parties (including different members and different inventories).
Officially Tsukihime's Party Manager on himeworks.com is only for MV, but I recently heard that it also works in MZ (might or might not need FOSSIL)
Also, I've been reminded (oops) that General Rule 4.4 prohibits posting of AI-generated responses without personal input or insight:
You're not in trouble this time, no worries. 👋
Please try to follow the rules in future, though.
Hopefully that Multiple Parties plugin I linked works out for you!
Thank you. I had no idea. I will refrain from posting chat gpt replies. Also, yes, your Multiple parties plugin works like intended. Thank you. Sorry for everything, post can be closed.
This thread is closed at OP’s request.
Original thread: https://forums.rpgmakerweb.com/threads/switching-parties-and-not-sharing-items-gold-weapons-etc.172406/