The party gets robbed, and receive the stuff afterwards

Hi there,
following situation: the party encounters thiefes/robbers and loses all their money, later they meet them again and receive their money back (maybe a little less, but not more). I have no idea to set up such an event. Would be even more interesting if the weapons and armors get robbed and later re-received, anybody go an idea how to set such an event in MZ?
Thanks in advance!:LZSgrin:
1701457589889.png

Make a variable, set it to game data. Pick "Other>Gold" from the menu
1701457629909.png


You have now saved the current amount of gold your party has.

When it's time to add the gold back, use this:
1701457678008.png


If you want the player to not get everything back, you can do math before that like:
1701457737280.png



Now if you want more things to be stolen, it gets more complicated. You'd have to track the player's inventory in the same way. So for every item /weapon/armor the player could potentially have, you'd need a conditional banch saying if party> Item x Control variable "Player has item x" +1. Repeat for every possibility. Then you could remove them in the same way and add them back later. Not worth the effort I would say.
Would be even more interesting if the weapons and armors get robbed and later re-received, anybody go an idea how to set such an event in MZ?
untested, but these should work. replace the someVariablesIDs with the ids of game variables you'd reserve to store the items

Code:
//first event's script to take the items
$gameVariables.setValue(someVariableID1, $gameParty.items());
$gameVariables.setValue(someVariableID2, $gameParty.weapons());
$gameVariables.setValue(someVariableID3, $gameParty.armors());
$gameParty._items = {};
$gameParty._weapons = {};
$gameParty._armors = {};


//second event's script to give them back
$gameParty._items = $gameVariables.value(someVariableID1);
$gameParty._weapons = $gameVariables.value(someVariableID2);
$gameParty._armors = $gameVariables.value(someVariableID3);
I have moved this thread from Game Mechanics Design to RPG Maker MZ Support since it’s a “how to” question.
@Robro33 - no, items() etc get an array of database records corresponding to each unique Item etc in the inventory, e.g.

[$dataItems[1], $dataItems[2]]
By contrast, $gameParty._items etc are simple id: quantity maps, e.g.

{ 1: 3, 2: 1 }

The MV / MZ Script Call List has entries for Memorise Inventory and Restore Inventory, if you want that.

Original thread: https://forums.rpgmakerweb.com/threads/the-party-gets-robbed-and-receive-the-stuff-afterwards.163489/