Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=============================================================================
- // Maliki's Permadeath
- // MalPermadeath.js
- // version 1.2
- //=============================================================================
- /*:
- * @plugindesc Version 1.2 Allows you to render save files unusable upon
- * Game Over.
- * @author Maliki79
- * @help
- * After installing this plugin, use the script call
- * $gameSystem.enablePermadeath();
- * to activate. After making the call, saves will be treated
- * as permadeath or ironman saves.
- * What this means is that basically only one "current" save can be used for a
- * game's playthrough.
- * If the player attempts to make a subsequent save on a different slot, the
- * original save with no loger load.
- * Also, quitting a game mid-battle or on a Game Over will also not allow
- * that current session's saves to be used.
- *
- * If a new game is started with saves from an old playthrough still present,
- * those saves WILL still be active and usable.
- *
- * As of version 1.2 of this plugin, script calls were added to enable and
- * disable this plugin.
- *
- * $gameSystem.enablePermadeath();
- * Turns on funtionality of this plugin.
- *
- * $gameSystem.disablePermadeath();
- * Turns off functionality of this plugin.
- */
- var Mal_Config_PDMakeData = ConfigManager.makeData;
- ConfigManager.makeData = function() {
- var config = Mal_Config_PDMakeData.call(this);
- config.saveCheck = this.saveCheck || [];
- return config;
- };
- var Mal_PDConfig_applyData = ConfigManager.applyData;
- ConfigManager.applyData = function(config) {
- Mal_PDConfig_applyData.call(this, config);
- this.saveCheck = this.readSaveCheck(config, 'saveCheck');
- };
- ConfigManager.readSaveCheck = function(config, name) {
- var value = config[name];
- if (value !== undefined) {
- return value;
- } else {
- return 0;
- }
- };
- ConfigManager.makeSaveCheck = function(saveCheck) {
- var saveNum = saveCheck;
- if (!this.saveCheck) this.saveCheck = [];
- for(i = 0; i < this.saveCheck.length; i++) {
- var save = this.saveCheck[i];
- if(save[0] == $gameSystem._saveId) {
- save[1] = saveNum;
- ConfigManager.save();
- return;
- }
- }
- this.saveCheck.push([$gameSystem._saveId, saveNum])
- ConfigManager.save();
- };
- var Mal_DBSNG = DataManager.setupNewGame;
- DataManager.setupNewGame = function() {
- Mal_DBSNG.call(this);
- $gameSystem._saveId = (Math.randomInt(10000000) + 1);
- $gameSystem._bonuszZ = 0;
- ConfigManager.save();
- };
- Game_System.prototype.enablePermadeath = function() {
- $gameSystem._bonuszZ = 1;
- };
- Game_System.prototype.disablePermadeath = function(file) {
- if(!file) {
- $gameSystem._bonuszZ = 0;
- } else if(file > 0) {
- var globalInfo = DataManager.loadGlobalInfo();
- globalInfo[file].saveCheck[2] = 0;
- };
- };
- var Mal_PDonBeforeSave = Game_System.prototype.onBeforeSave;
- Game_System.prototype.onBeforeSave = function() {
- Mal_PDonBeforeSave.call(this);
- if (!BattleManager.isBattleTest()) {
- this._saveCheck = (Math.randomInt(10000000) + 1);
- ConfigManager.makeSaveCheck(this._saveCheck);
- };
- };
- var Mal_PDonBattleStart = Game_System.prototype.onBattleStart;
- Game_System.prototype.onBattleStart = function() {
- Mal_PDonBattleStart.call(this);
- ConfigManager.makeSaveCheck(0);
- };
- var Mal_PDupdateBE = BattleManager.updateBattleEnd;
- BattleManager.updateBattleEnd = function() {
- Mal_PDupdateBE.call(this);
- if (!this._escaped && $gameParty.isAllDead()) {
- if (this._canLose) {
- ConfigManager.makeSaveCheck($gameSystem._saveCheck);
- };
- };
- };
- var Mal_PDBM_processVictory = BattleManager.processVictory;
- BattleManager.processVictory = function() {
- Mal_PDBM_processVictory.call(this);
- ConfigManager.makeSaveCheck($gameSystem._saveCheck);
- };
- var Mal_PDBM_processAbort = BattleManager.processAbort;
- BattleManager.processAbort = function() {
- ConfigManager.makeSaveCheck($gameSystem._saveCheck);
- Mal_PDBM_processAbort.call(this);
- };
- var MalDataManager_makeSavefileInfo = DataManager.makeSavefileInfo;
- DataManager.makeSavefileInfo = function() {
- var info = MalDataManager_makeSavefileInfo.call(this);
- if(!info.saveCheck)info.saveCheck = [];
- info.saveCheck = [$gameSystem._saveId, $gameSystem._saveCheck, $gameSystem._bonuszZ];
- var fs = require('fs');
- var pathCon = StorageManager.localFileDirectoryPath() + 'config.rpgsave';
- var timeCon = fs.statSync(pathCon);
- if (!info.saveKey) info.saveKey = timeCon.atimeMs;
- return info
- };
- DataManager.isThisGameFile = function(savefileId) {
- var globalInfo = this.loadGlobalInfo();
- var fs = require('fs');
- var pathCon = StorageManager.localFileDirectoryPath() + 'config.rpgsave';
- var timeCon = fs.statSync(pathCon);
- if (globalInfo[savefileId] && globalInfo[savefileId].saveKey) {
- if(timeCon.atimeMs != globalInfo[savefileId].saveKey && globalInfo[savefileId].saveCheck[2] != 1) return false;
- };
- if (globalInfo && globalInfo[savefileId]) {
- if (StorageManager.isLocalMode()) {
- if(globalInfo[savefileId].saveCheck && this.globalMatch(globalInfo[savefileId].saveCheck, globalInfo[savefileId].saveCheck[2])) return true;
- } else {
- var savefile = globalInfo[savefileId];
- return (savefile.globalId === this._globalId &&
- savefile.title === $dataSystem.gameTitle);
- }
- } else {
- return false;
- }
- };
- DataManager.globalMatch = function(gSaveCheck, bypass) {
- if(!gSaveCheck) return false;
- if (bypass == 0) return true;
- for(i = 0; i < ConfigManager.saveCheck.length; i++) {
- var save = ConfigManager.saveCheck[i];
- if(save[0] == gSaveCheck[0]) {
- if (save[1] == gSaveCheck[1]) {
- return true;
- } else {
- return false;
- }
- ConfigManager.save();
- return false;
- }
- }
- return true;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement