/*---------------------------------------------------------------------------- * # Edit class: DataManager *----------------------------------------------------------------------------*/// Stores all extended and new functionsDoubleX_RMMV.Permanent_States.DataManager = { isDatabaseLoaded: DataManager.isDatabaseLoaded, // Extended function loadAllPermanentStateNotes: function() { var ps = DoubleX_RMMV.Permanent_States.DataManager; $dataStates.forEach(function(data) { if (data) { ps.loadPermanentStateNotes.call(this, data); } }, this); }, // loadAllPermanentStateNotes // data: The data to have its notetags read loadPermanentStateNotes: function(data) { var lines, ps; var asp = DoubleX_RMMV.Permanent_States.params.allStatesPermanent; data.meta.permanentStates = asp; if (asp === "persist" || asp === "revive") { return; } lines = data.note.split(/[\r\n]+/); ps = /< *permanent +state *: *(\w+) *>/i; for (var index = 0, length = lines.length; index < length; index++) { if (lines[index].match(ps)) { data.meta.permanentStates = RegExp.$1; return; } } } // loadPermanentStateNotes}; // DoubleX_RMMV.Permanent_States.DataManagerDataManager.isDatabaseLoaded = function() { var ps = DoubleX_RMMV.Permanent_States.DataManager; // Rewritten if (!ps.isDatabaseLoaded.apply(this, arguments)) { return false; } ps.loadAllPermanentStateNotes.call(this); return true; //}; // DataManager.isDatabaseLoaded/*---------------------------------------------------------------------------- * # Edit class: Game_BattlerBase *----------------------------------------------------------------------------*/// Stores all extended and new functionsDoubleX_RMMV.Permanent_States.Game_BattlerBase = { // Extended functions initMembers: Game_BattlerBase.prototype.initMembers, die: Game_BattlerBase.prototype.die, clearStates: Game_BattlerBase.prototype.clearStates, revive: Game_BattlerBase.prototype.revive, // /* New private instance variables * permanentStates: The id of all persist and revive permanent states * permanentStateTurns: The turns of all persist and revive permanent states */ initPermanentStates: function() { // v1.01h+ DoubleX_RMMV.Permanent_States.Game_BattlerBase[this] = { permanentStates: {}, permanentStateTurns: {} }; }, // initPermanentStates storePermanentStates: function() { var type, p; if (this._states) { p = DoubleX_RMMV.Permanent_States.Game_BattlerBase[this]; p.permanentStates = { persist: [], revive: [] }; p.permanentStateTurns = { persist: {}, revive: {} }; this.states().forEach(function(s) { type = s.meta.permanentStates; if (type === "persist" || type === "revive") { p.permanentStates[type].push(s.id); p.permanentStateTurns[type][s.id] = this._stateTurns[s.id]; } }, this); } }, // storePermanentStates // type: The permanent state type restorePermanentStates: function(type) { var ps = DoubleX_RMMV.Permanent_States.Game_BattlerBase[this]; if (ps.permanentStates[type] && ps.permanentStateTurns[type]) { this._states = this._states.concat(ps.permanentStates[type]); Object.keys(ps.permanentStateTurns[type]).forEach(function(id) { id = +id; this._stateTurns[id] = ps.permanentStateTurns[type][id]; }, this); ps.permanentStates[type] = ps.permanentStateTurns[type] = null; } } // restorePermanentStates}; // DoubleX_RMMV.Permanent_States.Game_BattlerBaseGame_BattlerBase.prototype.initMembers = function() { // v1.01h+ var ps = DoubleX_RMMV.Permanent_States.Game_BattlerBase; ps.initMembers.apply(this, arguments); ps.initPermanentStates.call(this); // Added}; // Game_BattlerBase.prototype.initMembersGame_BattlerBase.prototype.die = function() { // v1.01a+ var ps = DoubleX_RMMV.Permanent_States.Game_BattlerBase; ps.die.apply(this, arguments); ps.restorePermanentStates.call(this, "persist"); // Added}; // Game_BattlerBase.prototype.dieGame_BattlerBase.prototype.clearStates = function() { var ps = DoubleX_RMMV.Permanent_States.Game_BattlerBase; ps.storePermanentStates.call(this); // Added ps.clearStates.apply(this, arguments);}; // Game_BattlerBase.prototype.clearStatesGame_BattlerBase.prototype.revive = function() { var ps = DoubleX_RMMV.Permanent_States.Game_BattlerBase; ps.revive.apply(this, arguments); ps.restorePermanentStates.call(this, "revive"); // Added}; // Game_BattlerBase.prototype.revive