I have a retry function built into my game. The only piece it is missing is returning used items. My thought process is that I would need to create a temporary array to store the current item list on battle start and then on retry set the party's item list equal to whatever is in the temporary array. Can anyone help me with this. I don't know which functions from the source code I would need to pull into the plugin. I would like to call this function on battle start and presumable set the temp array equal to my current inventory within the common event that is the base of my retry function. Thanks in advanced for any help!
Anyone have any idea's on this?
If anyone doesn't have an answer to this, do they know if there is an easy way to restore a state before a battle or if there is a plugin that does this.
To copy the items, you'll want to do
currentItems = MVC.deepClone($gameParty._items);currentWeapons = MVC.deepClone($gameParty._weapons);currentArmors = MVC.deepClone($gameParty._armors);To set them back on a retry, you'll probably want to deep clone them again, in case they retry more than once. This way, currentItems and such will stay as a complete copy of what the party had before the battle. In this case, it'd look like this:
$gameParty._items = MVC.deepClone(currentItems);$gameParty._weapons = MVC.deepClone(currentWeapons);$gameParty._armors = MVC.deepClone(currentArmors);However, to make sure that the variables don't get deleted by the Garbage Collector, you might want to set them as properties to Game_Temp. This variable will be cleared each time the game is started, so the values won't linger between games, and you'll be pretty much guaranteed your variables will not get deleted.
(function(){ var _Game_Temp_initialize = Game_Temp.prototype.initialize; Game_Temp.prototype.initialize = function() { _Game_Temp_initialize.call(this); this._partyItems = null; this._partyWeapons = null; this._partyArmors = null; }})();This will alias Game_Temp's initialize function, and then add the _partyItems, Weapons, and Armors variables to the class. I started their initial values at Null, because Game_Temp is created before the title screen, so no game is loaded at this point. But, once a game is active, you can get and set these values by saying $gameTemp._partyItems = MVC.deepClone($gameParty._items) and such.