查看: 5844|回复: 2

[原创发布] 多周目继承插件

[复制链接]
梦石
0
星屑
296
在线时间
217 小时
注册时间
2008-12-18
回帖
30
发表于 2018-10-10 11:25:37 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
国庆时候写的多周目插件,
一直犹豫着要不要发出来,
因为自我感觉还是半成品。
少了一些可制定化的设置。
[pre lang="javascript" file="Renews.js"]/*:
* Renews.js
* @plugindesc 多周目游戏
* @author 魏玉龙
* @since 2018.10.01
* @version 0.1
*
* @param clearCountVariable
* @desc 通关次数同步变量值。大于0时,相应变量值同步通关次数。等于0则无变量同步次数。
* @default 0
*
* @param inheritVariables
* @desc 需要被继承的变量ID 多个变量时用‘,’间隔
* @default 0
*
* @param inheritSwitches
* @desc 需要被继承的开关ID 多个开关时用‘,’间隔
* @default 0
*
* @help
* 此插件提供以下插件命令:
*
* 通关标记 [string]
*   对接下来的通关存档做标记
*
*/

(function () {
  var parameters = PluginManager.parameters('Renews');
  var clearCountVariable = Number(parameters['clearCountVariable']) || 0;
  var inheritVariables = parameters['inheritVariables'].split(',');
  var inheritSwitches = parameters['inheritSwitches'].split(',');

  var DataManager_makeSavefileInfo = DataManager.makeSavefileInfo;
  DataManager.makeSavefileInfo = function () {
    var info = DataManager_makeSavefileInfo.call(this);
    info.gameClear = $gameTemp.isGameClear();
    info.clearSign = $gameTemp.clearSign();
    return info;
  };

  DataManager.startRenewGame = function (savefileId) {
    var json = JsonEx.parse(StorageManager.load(savefileId));
    if (this.isThisGameFile(savefileId)) {
      this.createGameObjects();
      this.extractRenewContents(json);
      $gamePlayer.reserveTransfer($dataSystem.startMapId,
        $dataSystem.startX, $dataSystem.startY);
      $gameParty.setupStartingMembers();
      $gameVariables.setValue(clearCountVariable, $gameSystem.gameClearCount());
      return true;
    } else {
      return false;
    }
  }

  DataManager.extractRenewContents = function (contents) {
    $gameSystem = contents.system;
    $gameActors = contents.actors;
    $gameParty = contents.party;
    inheritVariables.forEach(function (value) {
      var variableId = Number(value) || 0;
      if (value > 0) {
        $gameVariables.setValue(variableId, contents.variables.value(variableId));
      }
    });
    inheritSwitches.forEach(function (value) {
      var variableId = Number(value) || 0;
      if (value > 0) {
        $gameSwitches.setValue(variableId, contents.Switches.value(variableId));
      }
    });
  }

  var Game_Temp_prototype_initialize = Game_Temp.prototype.initialize;
  Game_Temp.prototype.initialize = function () {
    Game_Temp_prototype_initialize.call(this);
    this._gameClear = false;
    this._clearSign = '';
  };

  Game_Temp.prototype.isGameClear = function () {
    return this._gameClear;
  };

  Game_Temp.prototype.clearSign = function () {
    return this._clearSign;
  };

  Game_Temp.prototype.setGameClear = function (sign) {
    this._gameClear = true;
    this._clearSign = sign;
    $gameSystem._gameClearCount += 1;
  };

  var Game_System_prototype_initialize = Game_System.prototype.initialize;
  Game_System.prototype.initialize = function () {
    Game_System_prototype_initialize.call(this);
    this._gameClearCount = 0;
  };

  Game_System.prototype.gameClearCount = function () {
    return this._gameClearCount;
  }

  Window_SavefileList.prototype.drawGameTitle = function (info, x, y, width) {
    if (info.title) {
      var title = info.title;
      if (info.gameClear && info.clearSign) {
        title += ' ' + info.clearSign;
      }
      this.drawText(title, x, y, width);
    }
  };

  function Window_RenewGame() {
    this.initialize.apply(this, arguments);
  }

  Window_RenewGame.prototype = Object.create(Window_Command.prototype);
  Window_RenewGame.prototype.constructor = Window_RenewGame;

  Window_RenewGame.prototype.initialize = function () {
    Window_Command.prototype.initialize.call(this, 0, 0);
    this.updatePlacement();
  };

  Window_RenewGame.prototype.windowWidth = function () {
    return 200;
  };

  Window_RenewGame.prototype.windowHeight = function () {
    return this.fittingHeight(2);
  };

  Window_RenewGame.prototype.updatePlacement = function () {
    this.x = (Graphics.boxWidth - this.width) / 2;
    this.y = (Graphics.boxHeight - this.height) / 2;
  };

  Window_RenewGame.prototype.makeCommandList = function () {
    this.addCommand('重新开始', 'renew');
    this.addCommand('取消', 'cancel');
  };

  var Scene_Load_prototype_create = Scene_Load.prototype.create;
  Scene_Load.prototype.create = function () {
    Scene_Load_prototype_create.call(this);
    this.createRenewWindow();
  }

  Scene_Load.prototype.createRenewWindow = function () {
    this._renewWindow = new Window_RenewGame();
    this._renewWindow.setHandler('renew', this.startRenewGame.bind(this));
    this._renewWindow.setHandler('cancel', this.cancelRenewGame.bind(this));
    this._renewWindow.deactivate();
    this._renewWindow.hide();
    this.addWindow(this._renewWindow);
  }

  Scene_Load.prototype.isRenewGame = function () {
    var info = DataManager.loadSavefileInfo(this.savefileId());
    return info.gameClear;
  }

  Scene_Load.prototype.startRenewGame = function () {
    this.onStartRenewGame();
  }

  Scene_Load.prototype.cancelRenewGame = function () {
    this._renewWindow.deactivate();
    this._renewWindow.hide();
    this.activateListWindow();
  }

  Scene_Load.prototype.onSavefileOk = function () {
    Scene_File.prototype.onSavefileOk.call(this);
    if (DataManager.isThisGameFile(this.savefileId())) {
      if (this.isRenewGame()) {
        this._renewWindow.show();
        this._renewWindow.activate();
      } else {
        DataManager.loadGame(this.savefileId())
        this.onLoadSuccess();
      }
    } else {
      this.onLoadFailure();
    }
  }

  Scene_Load.prototype.onStartRenewGame = function () {
    DataManager.startRenewGame(this.savefileId());
    SoundManager.playLoad();
    this.fadeOutAll();
    SceneManager.goto(Scene_Map);
    this._loadSuccess = true;
  }

  var Scene_Gameover_prototype_gotoTitle = Scene_Gameover.prototype.gotoTitle;
  Scene_Gameover.prototype.gotoTitle = function () {
    if ($gameTemp.isGameClear()) {
      SceneManager.push(Scene_Save);
    } else {
      Scene_Gameover_prototype_gotoTitle.call(this);
    }
  }

  var Scene_Save_prototype_popScene = Scene_Save.prototype.popScene;
  Scene_Save.prototype.popScene = function () {
    Scene_Save_prototype_popScene.call(this);
    if ($gameTemp.isGameClear()) {
      SceneManager.goto(Scene_Title);
    }
  }

  var Scene_Save_prototype_helpWindowText = Scene_Save.prototype.helpWindowText;
  Scene_Save.prototype.helpWindowText = function () {
    if ($gameTemp.isGameClear()) {
      return '将通关文档存储在哪个文件?';
    } else {
      return Scene_Save_prototype_helpWindowText.call(this);
    }
  };

  var Game_Interpreter_prototype_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  Game_Interpreter.prototype.pluginCommand = function (command, args) {
    Game_Interpreter_prototype_pluginCommand.call(this, command, args);
    if (command === "通关标记") {
      var sign = args[1] || '⚝';
      $gameTemp.setGameClear(sign);
    }
  };

})();[/pre]

犹豫了几天还是觉得先发出来吧,让各位小白鼠帮着测测BUG也好啊!

用法很简单!游戏结束前插入指令:通关标记
就可以了!插件可以设定记录通关次数的变量ID
并且可以设置需要下个周目要保存的变量及开关!
通关存档后,存档文件会有标记!就可以从哪个通关档开始新游戏!
继承全部人物属性及物品装备!少了黑名单功能,所以有些不应该被继承的暂时在结局前手动删一下吧!
等有空了继续完善吧!
目前在写一个超级Debug的插件用来调试和测试游戏用,这个插件没有重大BUG暂时不会更新!
小白鼠们可以在该贴下提BUG或需要加入的功能,我有空了就完善一下!

TIM截图20181010111912.png

评分

参与人数 2赞 +2 收起 理由
白嫩白嫩的 + 1 精品文章
j296196585 + 1 精品文章

查看全部评分

梦石
0
星屑
2457
在线时间
912 小时
注册时间
2014-10-14
回帖
1155

开拓者

发表于 2018-10-10 22:56:23 | 显示全部楼层
不知道怎么设置 二周目 多一些 要素
------落尽红樱君不见,轻绘梨花泪沾衣。~~~
回复

使用道具 举报

梦石
0
星屑
5269
在线时间
733 小时
注册时间
2013-1-18
回帖
525
发表于 2022-4-11 16:25:14 | 显示全部楼层
@魏玉龙 大佬,这个多周目插件有更新吗?希望能有更多的功能。我很需要这个。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部