查看: 3025|回复: 0

[有事请教] 请问有路过的大佬知道怎么使用这个难度插件吗

[复制链接]
梦石
0
星屑
2457
在线时间
912 小时
注册时间
2014-10-14
回帖
1155

开拓者

发表于 2019-8-12 05:36:44 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 j296196585 于 2019-8-12 05:37 编辑

虽然汉化了但是就是不明白怎么使用好无语

  1. //=============================================================================
  2. // Vitsuno_Difficulty.js
  3. //-----------------------------------------------------------------------------
  4. // Copyright (c) 2016 Tsuno Ozumi
  5. // Released under the MIT license
  6. // [url]http://opensource.org/licenses/mit-license.php[/url]
  7. //=============================================================================

  8. var Vitsuno = Vitsuno || {};
  9. Vitsuno.Difficulty = {};
  10. Vitsuno.Difficulty.version = 1.00;

  11. /*:
  12. * @plugindesc 根据难易度可以变更能力值和报酬倍率。
  13. * @author 尾角 つの (Tsuno Ozumi)
  14. *
  15. * @param Init Difficulty ID
  16. * @desc 难度ID的初始值。
  17. * @default 2
  18. *
  19. * @param Use Option
  20. * @desc 选项是否修改难度。0:否1:
  21. * @default 1
  22. *
  23. * @param Option Name
  24. * @desc 选项中的显示名称。
  25. * @default 難易度
  26. *
  27. * @param --(Difficulty ID:1)--
  28. *
  29. * @param 1 : Name
  30. * @desc 难易度名。(如果不使用的话请无记入。)
  31. * @default イージー
  32. *
  33. * @param 1 : Param Rate
  34. * @desc 難易度によるステータス倍率です。
  35. * 最大HP,最大MP,攻撃力,防御力,魔法力,魔法防御,敏捷性,運
  36. * @default 0.7,0.7,0.7,0.7,0.7,0.7,0.7,0.7
  37. *
  38. * @param 1 : Drop Rate
  39. * @desc 難易度による報酬倍率です。
  40. * 経験値,お金,アイテム1,アイテム2,アイテム3
  41. * @default 1.0,1.0,1.0,1.0,1.0
  42. *
  43. * @param --(ID:2)-------------
  44. *
  45. * @param 2 : Name
  46. * @desc 難易度名です。(使用しない場合は無記入にしてください。)
  47. * @default ノーマル
  48. *
  49. * @param 2 : Param Rate
  50. * @desc 難易度によるステータス倍率です。
  51. * 最大HP,最大MP,攻撃力,防御力,魔法力,魔法防御,敏捷性,運
  52. * @default 1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0
  53. *
  54. * @param 2 : Drop Rate
  55. * @desc 難易度による報酬倍率です。
  56. * 経験値,お金,アイテム1,アイテム2,アイテム3
  57. * @default 1.0,1.0,1.0,1.0,1.0
  58. *
  59. * @param --(ID:3)-------------
  60. *
  61. * @param 3 : Name
  62. * @desc 難易度名です。(使用しない場合は無記入にしてください。)
  63. * @default ハード
  64. *
  65. * @param 3 : Param Rate
  66. * @desc 難易度によるステータス倍率です。
  67. * 最大HP,最大MP,攻撃力,防御力,魔法力,魔法防御,敏捷性,運
  68. * @default 1.3,1.3,1.3,1.3,1.3,1.3,1.3,1.3
  69. *
  70. * @param 3 : Drop Rate
  71. * @desc 難易度による報酬倍率です。
  72. * 経験値,お金,アイテム1,アイテム2,アイテム3
  73. * @default 1.2,1.2,1.2,1.2,1.2
  74. *
  75. * @param --(ID:4)-------------
  76. *
  77. * @param 4 : Name
  78. * @desc 難易度名です。(使用しない場合は無記入にしてください。)
  79. * @default ベリーハード
  80. *
  81. * @param 4 : Param Rate
  82. * @desc 難易度によるステータス倍率です。
  83. * 最大HP,最大MP,攻撃力,防御力,魔法力,魔法防御,敏捷性,運
  84. * @default 1.6,1.6,1.6,1.6,1.6,1.6,1.6,1.6
  85. *
  86. * @param 4 : Drop Rate
  87. * @desc 難易度による報酬倍率です。
  88. * 経験値,お金,アイテム1,アイテム2,アイテム3
  89. * @default 1.4,1.4,1.4,1.4,1.4
  90. *
  91. * @param --(ID:5)-------------
  92. *
  93. * @param 5 : Name
  94. * @desc 難易度名です。(使用しない場合は無記入にしてください。)
  95. * @default マニア
  96. *
  97. * @param 5 : Param Rate
  98. * @desc 難易度によるステータス倍率です。
  99. * 最大HP,最大MP,攻撃力,防御力,魔法力,魔法防御,敏捷性,運
  100. * @default 1.9,1.9,1.9,1.9,1.9,1.9,1.9,1.9
  101. *
  102. * @param 5 : Drop Rate
  103. * @desc 難易度による報酬倍率です。
  104. * 経験値,お金,アイテム1,アイテム2,アイテム3
  105. * @default 1.6,1.6,1.6,1.6,1.6
  106. *
  107. * @param --(ID:6)-------------
  108. *
  109. * @param 6 : Name
  110. * @desc 難易度名です。(使用しない場合は無記入にしてください。)
  111. *
  112. * @param 6 : Param Rate
  113. * @desc 難易度によるステータス倍率です。
  114. * 最大HP,最大MP,攻撃力,防御力,魔法力,魔法防御,敏捷性,運
  115. * @default 1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0
  116. *
  117. * @param 6 : Drop Rate
  118. * @desc 難易度による報酬倍率です。
  119. * 経験値,お金,アイテム1,アイテム2,アイテム3
  120. * @default 1.0,1.0,1.0,1.0,1.0
  121. *
  122. * @param --(ID:7)-------------
  123. *
  124. * @param 7 : Name
  125. * @desc 難易度名です。(使用しない場合は無記入にしてください。)
  126. *
  127. * @param 7 : Param Rate
  128. * @desc 難易度によるステータス倍率です。
  129. * 最大HP,最大MP,攻撃力,防御力,魔法力,魔法防御,敏捷性,運
  130. * @default 1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0
  131. *
  132. * @param 7 : Drop Rate
  133. * @desc 難易度による報酬倍率です。
  134. * 経験値,お金,アイテム1,アイテム2,アイテム3
  135. * @default 1.0,1.0,1.0,1.0,1.0
  136. *
  137. * @param --(ID:8)-------------
  138. *
  139. * @param 8 : Name
  140. * @desc 難易度名です。(使用しない場合は無記入にしてください。)
  141. *
  142. * @param 8 : Param Rate
  143. * @desc 難易度によるステータス倍率です。
  144. * 最大HP,最大MP,攻撃力,防御力,魔法力,魔法防御,敏捷性,運
  145. * @default 1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0
  146. *
  147. * @param 8 : Drop Rate
  148. * @desc 難易度による報酬倍率です。
  149. * 経験値,お金,アイテム1,アイテム2,アイテム3
  150. * @default 1.0,1.0,1.0,1.0,1.0
  151. *
  152. * @help
  153. *
  154. * プラグインコマンド:
  155. *    Difficulty SetID 難易度ID     # 更改难度ID
  156. *    Difficulty Next              # 提高难易度ID
  157. *    Difficulty Previous          # 降低难度ID
  158. */

  159. // ● プラグインの設定値を取得
  160. (function($) {
  161.     $.parameters = PluginManager.parameters('Vitsuno_Difficulty');
  162.     $.initDifficultyId = Number($.parameters['Init Difficulty ID']) || 2;
  163.     $.useOption = Number($.parameters['Use Option']) === 1;
  164.     $.optionName = $.parameters['Option Name'];
  165.     $.data = [];
  166.     $.data[0] = null;

  167.     // ● セットアップ用の一時関数
  168.     var setup = function(id) {
  169.         // 設定値の取得
  170.         var idText = '%1 : '.format(id);
  171.         var nameData = $.parameters[idText + 'Name'] || '';
  172.         var paramData = $.parameters[idText + 'Param Rate'];
  173.         var dropData = $.parameters[idText + 'Drop Rate'];
  174.         if (nameData === '' || paramData === undefined || dropData === undefined) {
  175.             return false;
  176.         }
  177.         // データの準備
  178.         var paramRate = paramData ? paramData.split(',').map(Number) : [];
  179.         var dropRate = dropData ? dropData.split(',').map(Number) : [];
  180.         var getRate = function(rate) {
  181.             return typeof rate === 'number' ? rate : 1.0;
  182.         };
  183.         // 難易度オブジェクトの作成
  184.         var difficulty = {};
  185.         difficulty.name = nameData;
  186.         difficulty.paramRate = [];
  187.         for (var i = 0; i < 8; i++) {
  188.             difficulty.paramRate[i] = getRate(paramRate[i]);
  189.         }
  190.         difficulty.expRate = getRate(dropRate[0]);
  191.         difficulty.goldRate = getRate(dropRate[1]);
  192.         difficulty.dropItemRate = [];
  193.         for (var i = 0;; i++) {
  194.             if (typeof dropRate[i + 2] === 'number' || i < 3) {
  195.                 difficulty.dropItemRate[i] = getRate(dropRate[i + 2]);
  196.             } else {
  197.                 break;
  198.             }
  199.         }
  200.         $.data[id] = difficulty;
  201.         return true;
  202.     };

  203.     for (var i = 1;; i++) {
  204.         if (!setup(i)) {
  205.             break;
  206.         }
  207.     }

  208. })(Vitsuno.Difficulty);

  209. //-----------------------------------------------------------------------------
  210. // DataManager
  211. //-----------------------------------------------------------------------------

  212. // ● ニューゲームのセットアップ
  213. Vitsuno.Difficulty.DataMgr_setupNewGame = DataManager.setupNewGame;
  214. DataManager.setupNewGame = function() {
  215.     Vitsuno.Difficulty.DataMgr_setupNewGame.call(this);
  216.     SceneManager.setDifficultyMutable();
  217. };

  218. // ● 戦闘テストのセットアップ
  219. Vitsuno.Difficulty.DataMgr_setupBattleTest = DataManager.setupBattleTest;
  220. DataManager.setupBattleTest = function() {
  221.     Vitsuno.Difficulty.DataMgr_setupBattleTest.call(this);
  222.     SceneManager.setDifficultyMutable();
  223. };

  224. // ● イベントテストのセットアップ
  225. Vitsuno.Difficulty.DataMgr_setupEventTest = DataManager.setupEventTest
  226. DataManager.setupEventTest = function() {
  227.     Vitsuno.Difficulty.DataMgr_setupEventTest.call(this);
  228.     SceneManager.setDifficultyMutable();
  229. };

  230. // ● ゲームのロード
  231. Vitsuno.Difficulty.DataMgr_loadGame = DataManager.loadGame;
  232. DataManager.loadGame = function(savefileId) {
  233.     var result = Vitsuno.Difficulty.DataMgr_loadGame.call(this, savefileId);
  234.     if (result) {
  235.         SceneManager.setDifficultyMutable();
  236.     }
  237.     return result;
  238. };

  239. //-----------------------------------------------------------------------------
  240. // TextManager
  241. //-----------------------------------------------------------------------------

  242. // ● 難易度表示名を取得
  243. Object.defineProperty(TextManager, 'difficulty', {
  244.     get: function() { return Vitsuno.Difficulty.optionName; },
  245.     configurable: true
  246. });

  247. //-----------------------------------------------------------------------------
  248. // SceneManager
  249. //-----------------------------------------------------------------------------

  250. // ● クラス変数
  251. SceneManager._isDifficultyMutable = false;

  252. // ● 難易度変更可能判定
  253. SceneManager.isDifficultyMutable = function() {
  254.     return SceneManager._isDifficultyMutable;
  255. };

  256. // ● 難易度変更可能に設定
  257. SceneManager.setDifficultyMutable = function() {
  258.     SceneManager._isDifficultyMutable = true;
  259. };

  260. // ● 難易度変更可能設定を削除
  261. SceneManager.removeDifficultyMutable = function() {
  262.     SceneManager._isDifficultyMutable = false;
  263. };

  264. //-----------------------------------------------------------------------------
  265. // Game_System
  266. //-----------------------------------------------------------------------------

  267. // ● 初期化
  268. Vitsuno.Difficulty.GSystem_initialize = Game_System.prototype.initialize;
  269. Game_System.prototype.initialize = function() {
  270.     Vitsuno.Difficulty.GSystem_initialize.call(this);
  271.     this._difficultyId = Vitsuno.Difficulty.initDifficultyId;
  272. };

  273. // ● 難易度IDの取得
  274. Game_System.prototype.difficultyId = function() {
  275.     if (this._difficultyId === undefined) {
  276.         this._difficultyId = Vitsuno.Difficulty.initDifficultyId;
  277.     }
  278.     return this._difficultyId;
  279. };

  280. // ● 難易度IDの設定
  281. Game_System.prototype.setDifficultyId = function(difficultyId) {
  282.     if (Vitsuno.Difficulty.data[difficultyId]) {
  283.         this._difficultyId = difficultyId;
  284.     }
  285. };

  286. // ● 難易度の設定
  287. Game_System.prototype.setDifficulty = function(difficulty) {
  288.     var id = Vitsuno.Difficulty.data.indexOf(difficulty);
  289.     if (id >= 0) {
  290.         this.setDifficultyId(id);
  291.     }
  292. };

  293. // ● 難易度オブジェクトの取得
  294. Game_System.prototype.difficultyObject = function() {
  295.     return Vitsuno.Difficulty.data[this.difficultyId()];
  296. };

  297. // ● 難易度名の取得
  298. Game_System.prototype.difficultyName = function() {
  299.     var difficulty = this.difficultyObject();
  300.     return difficulty ? difficulty.name : '';
  301. };

  302. // ● 難易度オブジェクト配列の取得
  303. Game_System.prototype.difficulties = function() {
  304.     return Vitsuno.Difficulty.data.filter(function(difficulty) {
  305.         return difficulty;
  306.     });
  307. };

  308. // ● 次の難易度に変更
  309. Game_System.prototype.nextDifficulty = function(wrap) {
  310.     var lastDifficulty = this.difficultyObject();
  311.     var difficulties = this.difficulties();
  312.     var index = difficulties.indexOf(lastDifficulty);
  313.     index = index < 0 ? 0 : index + 1;
  314.     index = wrap ? index % difficulties.length : index;
  315.     if (index >= 0 && index < difficulties.length) {
  316.         this.setDifficulty(difficulties[index]);
  317.     }
  318.     return lastDifficulty !== this.difficultyObject();
  319. };

  320. // ● 前の難易度に変更する
  321. Game_System.prototype.previousDifficulty = function(wrap) {
  322.     var lastDifficulty = this.difficultyObject();
  323.     var difficulties = this.difficulties();
  324.     var index = difficulties.indexOf(lastDifficulty);
  325.     index = index < 0 ? 0 : index - 1;
  326.     index = wrap ? index % difficulties.length : index;
  327.     if (index >= 0 && index < difficulties.length) {
  328.         this.setDifficulty(difficulties[index]);
  329.     }
  330.     return lastDifficulty !== this.difficultyObject();
  331. };

  332. //-----------------------------------------------------------------------------
  333. // Game_Enemy
  334. //-----------------------------------------------------------------------------

  335. // ● 能力値倍率の取得
  336. Vitsuno.Difficulty.GEnemy_paramRate = Game_Enemy.prototype.paramRate;
  337. Game_Enemy.prototype.paramRate = function(paramId) {
  338.     var rate = Vitsuno.Difficulty.GEnemy_paramRate ?
  339.         Vitsuno.Difficulty.GEnemy_paramRate.call(this, paramId) :
  340.         Game_Battler.prototype.paramRate.call(this, paramId);
  341.     var difficulty = $gameSystem.difficultyObject();
  342.     if (difficulty) {
  343.         rate *= difficulty.paramRate[paramId];
  344.     }
  345.     return rate;
  346. };

  347. // ● 経験値の取得
  348. Vitsuno.Difficulty.GEnemy_exp = Game_Enemy.prototype.exp;
  349. Game_Enemy.prototype.exp = function() {
  350.     var exp = Vitsuno.Difficulty.GEnemy_exp.call(this);
  351.     var difficulty = $gameSystem.difficultyObject();
  352.     if (difficulty) {
  353.         exp *= difficulty.expRate;
  354.     }
  355.     return Math.floor(exp);
  356. };

  357. // ● お金の取得
  358. Vitsuno.Difficulty.GEnemy_gold = Game_Enemy.prototype.gold;
  359. Game_Enemy.prototype.gold = function() {
  360.     var gold = Vitsuno.Difficulty.GEnemy_gold.call(this);
  361.     var difficulty = $gameSystem.difficultyObject();
  362.     if (difficulty) {
  363.         gold *= difficulty.goldRate;
  364.     }
  365.     return Math.floor(gold);
  366. };

  367. // ● ドロップアイテムの作成 (再定義)
  368. Game_Enemy.prototype.makeDropItems = function() {
  369.     return this.enemy().dropItems.reduce(function(r, di, i) {
  370.         if (di.kind > 0 && Math.random() * di.denominator < this.dropItemRateFromIndex(i)) {
  371.             return r.concat(this.itemObject(di.kind, di.dataId));
  372.         } else {
  373.             return r;
  374.         }
  375.     }.bind(this), []);
  376. };

  377. // ● インデック付きドロップアイテムレートの取得
  378. Game_Enemy.prototype.dropItemRateFromIndex = function(index) {
  379.     var rate = this.dropItemRate();
  380.     var difficulty = $gameSystem.difficultyObject();
  381.     if (difficulty) {
  382.         rate *= difficulty.dropItemRate[index];
  383.     }
  384.     return rate;
  385. };

  386. //-----------------------------------------------------------------------------
  387. // Game_Interpreter
  388. //-----------------------------------------------------------------------------

  389. // ● プラグインコマンドの実行
  390. Vitsuno.Difficulty.GInterpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  391. Game_Interpreter.prototype.pluginCommand = function(command, args) {
  392.     Vitsuno.Difficulty.GInterpreter_pluginCommand.call(this, command, args);
  393.     if (command === 'Difficulty') {
  394.         switch (args[0]) {
  395.             case 'SetID':
  396.                 $gameSystem.setDifficultyId(Number(args[1]));
  397.                 break;
  398.             case 'Next':
  399.                 $gameSystem.nextDifficulty(false);
  400.                 break;
  401.             case 'Previous':
  402.                 $gameSystem.previousDifficulty(false);
  403.                 break;
  404.         }
  405.     }
  406. };

  407. //-----------------------------------------------------------------------------
  408. // Window_Options
  409. //-----------------------------------------------------------------------------

  410. // ● コマンドリストの作成
  411. Vitsuno.Difficulty.WOptions_makeCommandList = Window_Options.prototype.makeCommandList;
  412. Window_Options.prototype.makeCommandList = function() {
  413.     Vitsuno.Difficulty.WOptions_makeCommandList.call(this);
  414.     this.addDifficultyOptions();
  415. };

  416. // ● 難易度を表示するか判定
  417. Window_Options.prototype.isDifficultyDisplayed = function() {
  418.     return Vitsuno.Difficulty.useOption;
  419. };

  420. // ● 難易度が有効かどうか
  421. Window_Options.prototype.isDifficultyEnabled = function() {
  422.     return $gameSystem && SceneManager.isDifficultyMutable();
  423. };

  424. // ● 難易度コマンドの追加
  425. Window_Options.prototype.addDifficultyOptions = function() {
  426.     if (this.isDifficultyDisplayed()) {
  427.         var enabled = this.isDifficultyEnabled();
  428.         this.addCommand(TextManager.difficulty, 'difficulty', enabled);
  429.     }
  430. };

  431. // ● 状態文字の取得
  432. Vitsuno.Difficulty.WOptions_statusText = Window_Options.prototype.statusText;
  433. Window_Options.prototype.statusText = function(index) {
  434.     if (this.commandSymbol(index) === 'difficulty') {
  435.         return this.isDifficultyEnabled() ? $gameSystem.difficultyName() : '';
  436.     } else {
  437.         return Vitsuno.Difficulty.WOptions_statusText.call(this, index);
  438.     }
  439. };

  440. // ● 決定時の処理
  441. Vitsuno.Difficulty.WOptions_processOk = Window_Options.prototype.processOk;
  442. Window_Options.prototype.processOk = function() {
  443.     if (this.commandSymbol(this.index()) === 'difficulty') {
  444.         if (this.isDifficultyEnabled()) {
  445.             if ($gameSystem.nextDifficulty(true)) {
  446.                 this.redrawItem(this.findSymbol('difficulty'));
  447.                 SoundManager.playCursor();
  448.             }
  449.         }
  450.     } else {
  451.         Vitsuno.Difficulty.WOptions_processOk.call(this);
  452.     }
  453. };

  454. // ● カーソルを右に移動
  455. Vitsuno.Difficulty.WOptions_cursorRight = Window_Options.prototype.cursorRight;
  456. Window_Options.prototype.cursorRight = function(wrap) {
  457.     if (this.commandSymbol(this.index()) === 'difficulty') {
  458.         if (this.isDifficultyEnabled()) {
  459.             if ($gameSystem.nextDifficulty(false)) {
  460.                 this.redrawItem(this.findSymbol('difficulty'));
  461.                 SoundManager.playCursor();
  462.             }
  463.         }
  464.     } else {
  465.         Vitsuno.Difficulty.WOptions_cursorRight.call(this, wrap);
  466.     }
  467. };

  468. // ● カーソルを左に移動
  469. Vitsuno.Difficulty.WOptions_cursorLeft = Window_Options.prototype.cursorLeft;
  470. Window_Options.prototype.cursorLeft = function(wrap) {
  471.     if (this.commandSymbol(this.index()) === 'difficulty') {
  472.         if (this.isDifficultyEnabled()) {
  473.             if ($gameSystem.previousDifficulty(false)) {
  474.                 this.redrawItem(this.findSymbol('difficulty'));
  475.                 SoundManager.playCursor();
  476.             }
  477.         }
  478.     } else {
  479.         Vitsuno.Difficulty.WOptions_cursorLeft.call(this, wrap);
  480.     }
  481. };

  482. //-----------------------------------------------------------------------------
  483. // Scene_Title
  484. //-----------------------------------------------------------------------------

  485. // ● シーン開始
  486. Vitsuno.Difficulty.STitle_start = Scene_Title.prototype.start;
  487. Scene_Title.prototype.start = function() {
  488.     Vitsuno.Difficulty.STitle_start.call(this);
  489.     SceneManager.removeDifficultyMutable();
  490. };
复制代码
------落尽红樱君不见,轻绘梨花泪沾衣。~~~
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

在本版发帖返回顶部