查看: 5894|回复: 2

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

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

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

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

×
国庆时候写的多周目插件,
一直犹豫着要不要发出来,
因为自我感觉还是半成品。
少了一些可制定化的设置。
  1. /*:
  2. * Renews.js
  3. * @plugindesc 多周目游戏
  4. * @author 魏玉龙
  5. * @since 2018.10.01
  6. * @version 0.1
  7. *
  8. * @param clearCountVariable
  9. * @desc 通关次数同步变量值。大于0时,相应变量值同步通关次数。等于0则无变量同步次数。
  10. * @default 0
  11. *
  12. * @param inheritVariables
  13. * @desc 需要被继承的变量ID 多个变量时用‘,’间隔
  14. * @default 0
  15. *
  16. * @param inheritSwitches
  17. * @desc 需要被继承的开关ID 多个开关时用‘,’间隔
  18. * @default 0
  19. *
  20. * @help
  21. * 此插件提供以下插件命令:
  22. *
  23. * 通关标记 [string]
  24. *   对接下来的通关存档做标记
  25. *
  26. */

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

  32.   var DataManager_makeSavefileInfo = DataManager.makeSavefileInfo;
  33.   DataManager.makeSavefileInfo = function () {
  34.     var info = DataManager_makeSavefileInfo.call(this);
  35.     info.gameClear = $gameTemp.isGameClear();
  36.     info.clearSign = $gameTemp.clearSign();
  37.     return info;
  38.   };

  39.   DataManager.startRenewGame = function (savefileId) {
  40.     var json = JsonEx.parse(StorageManager.load(savefileId));
  41.     if (this.isThisGameFile(savefileId)) {
  42.       this.createGameObjects();
  43.       this.extractRenewContents(json);
  44.       $gamePlayer.reserveTransfer($dataSystem.startMapId,
  45.         $dataSystem.startX, $dataSystem.startY);
  46.       $gameParty.setupStartingMembers();
  47.       $gameVariables.setValue(clearCountVariable, $gameSystem.gameClearCount());
  48.       return true;
  49.     } else {
  50.       return false;
  51.     }
  52.   }

  53.   DataManager.extractRenewContents = function (contents) {
  54.     $gameSystem = contents.system;
  55.     $gameActors = contents.actors;
  56.     $gameParty = contents.party;
  57.     inheritVariables.forEach(function (value) {
  58.       var variableId = Number(value) || 0;
  59.       if (value > 0) {
  60.         $gameVariables.setValue(variableId, contents.variables.value(variableId));
  61.       }
  62.     });
  63.     inheritSwitches.forEach(function (value) {
  64.       var variableId = Number(value) || 0;
  65.       if (value > 0) {
  66.         $gameSwitches.setValue(variableId, contents.Switches.value(variableId));
  67.       }
  68.     });
  69.   }

  70.   var Game_Temp_prototype_initialize = Game_Temp.prototype.initialize;
  71.   Game_Temp.prototype.initialize = function () {
  72.     Game_Temp_prototype_initialize.call(this);
  73.     this._gameClear = false;
  74.     this._clearSign = '';
  75.   };

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

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

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

  87.   var Game_System_prototype_initialize = Game_System.prototype.initialize;
  88.   Game_System.prototype.initialize = function () {
  89.     Game_System_prototype_initialize.call(this);
  90.     this._gameClearCount = 0;
  91.   };

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

  95.   Window_SavefileList.prototype.drawGameTitle = function (info, x, y, width) {
  96.     if (info.title) {
  97.       var title = info.title;
  98.       if (info.gameClear && info.clearSign) {
  99.         title += ' ' + info.clearSign;
  100.       }
  101.       this.drawText(title, x, y, width);
  102.     }
  103.   };

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

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

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

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

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

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

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

  127.   var Scene_Load_prototype_create = Scene_Load.prototype.create;
  128.   Scene_Load.prototype.create = function () {
  129.     Scene_Load_prototype_create.call(this);
  130.     this.createRenewWindow();
  131.   }

  132.   Scene_Load.prototype.createRenewWindow = function () {
  133.     this._renewWindow = new Window_RenewGame();
  134.     this._renewWindow.setHandler('renew', this.startRenewGame.bind(this));
  135.     this._renewWindow.setHandler('cancel', this.cancelRenewGame.bind(this));
  136.     this._renewWindow.deactivate();
  137.     this._renewWindow.hide();
  138.     this.addWindow(this._renewWindow);
  139.   }

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

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

  147.   Scene_Load.prototype.cancelRenewGame = function () {
  148.     this._renewWindow.deactivate();
  149.     this._renewWindow.hide();
  150.     this.activateListWindow();
  151.   }

  152.   Scene_Load.prototype.onSavefileOk = function () {
  153.     Scene_File.prototype.onSavefileOk.call(this);
  154.     if (DataManager.isThisGameFile(this.savefileId())) {
  155.       if (this.isRenewGame()) {
  156.         this._renewWindow.show();
  157.         this._renewWindow.activate();
  158.       } else {
  159.         DataManager.loadGame(this.savefileId())
  160.         this.onLoadSuccess();
  161.       }
  162.     } else {
  163.       this.onLoadFailure();
  164.     }
  165.   }

  166.   Scene_Load.prototype.onStartRenewGame = function () {
  167.     DataManager.startRenewGame(this.savefileId());
  168.     SoundManager.playLoad();
  169.     this.fadeOutAll();
  170.     SceneManager.goto(Scene_Map);
  171.     this._loadSuccess = true;
  172.   }

  173.   var Scene_Gameover_prototype_gotoTitle = Scene_Gameover.prototype.gotoTitle;
  174.   Scene_Gameover.prototype.gotoTitle = function () {
  175.     if ($gameTemp.isGameClear()) {
  176.       SceneManager.push(Scene_Save);
  177.     } else {
  178.       Scene_Gameover_prototype_gotoTitle.call(this);
  179.     }
  180.   }

  181.   var Scene_Save_prototype_popScene = Scene_Save.prototype.popScene;
  182.   Scene_Save.prototype.popScene = function () {
  183.     Scene_Save_prototype_popScene.call(this);
  184.     if ($gameTemp.isGameClear()) {
  185.       SceneManager.goto(Scene_Title);
  186.     }
  187.   }

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

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

  204. })();
复制代码


犹豫了几天还是觉得先发出来吧,让各位小白鼠帮着测测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
星屑
5274
在线时间
733 小时
注册时间
2013-1-18
回帖
525
发表于 2022-4-11 16:25:14 | 显示全部楼层
@魏玉龙 大佬,这个多周目插件有更新吗?希望能有更多的功能。我很需要这个。
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部