查看: 1701|回复: 4

[有事请教] MV显示简单消息插件适配MZ 求助

[复制链接]
梦石
0
星屑
613
在线时间
161 小时
注册时间
2020-10-11
回帖
30
发表于 2022-3-5 12:19:09 | 显示全部楼层 |阅读模式
悬赏300星屑已解决
本帖最后由 慕名景色 于 2022-3-7 03:48 编辑

找到一个简单的消息提醒插件,但是MZ使用会报错

因为插件比较符合我的需求,
相关代码应该比较简单,但是本人水平有限。
所以想悬赏求个高手帮忙适配一下该插件,万分感谢。




MV运行效果
Z}JGNX50@)(0~DD8Y7A1WH0.png
P3LMFB635_J5R}QFO3YLUJS.png

MZ报错情况

AE~{H[]4[`}A$%XT_63FZ@V.png

FCOP]}1~NV{WMVFZ%7{LONE.png


  1. /*---------------------------------------------------------------------------*
  2. * 2019/03/06 kido0617
  3. * http://kido0617.github.io/
  4. *---------------------------------------------------------------------------*/

  5. /*:
  6. * @plugindesc ティッカープラグイン
  7. * @author kido0617
  8. * @help
  9. *   这是一个显示简单消息的插件。
  10. *   使用方法:
  11. *   TickerManager.show('\\I[5]あいうえお');
  12. *   
  13. *   ・如果变量是正的,它会自动加上+。
  14. *   TickerManager.show('\\V[5]');
  15. *
  16. *   ・ 如果您不想添加+,请指定false,如下所示
  17. *   TickerManager.show('\\V[5]', false);
  18. *
  19. *   ・想全部消除的情况请如下所示
  20. *   TickerManager.hideAll();
  21. *
  22. *   ・道具·武器·防具的记事栏
  23. *   <ticker:あいうえお> : 作为项目的说明在获取/消失时显示。如果没有,则显示项目描述的第一行
  24. *   
  25. *   ・清除日志
  26. *    TickerManager.clearAllLog();
  27. *
  28. *   ・清除1个旧日志
  29. *    TickerManager.clearOldestLog();
  30. *
  31. *
  32. * @param Opacity
  33. * @desc 背景の透明度(0 - 255)
  34. * @type number
  35. * @min 0
  36. * @max 255
  37. * @default 127
  38. *
  39. * @param DisplayDuration
  40. * @desc 表示時間[frame]
  41. * @type number
  42. * @default 180
  43. *
  44. * @param ToggleDuration
  45. * @desc 显示和擦除的时间[frame]
  46. * @type number
  47. * @default 30
  48. *
  49. * @param y位置
  50. * @desc 如果输入y位置偏移(Pixel)10,则偏移10像素。
  51. * @type number
  52. * @default 0
  53. *
  54. * @param x位置
  55. * @desc 如果输入x位置偏移(Pixel)10,则偏移10像素。
  56. * @type number
  57. * @default 0
  58. *
  59. * @param 幻灯片动画开始位置
  60. * @desc 从左边滑动到什么像素的位置?
  61. * @type number
  62. * @default 100
  63. *
  64. * @param 幻灯片动画结束位置
  65. * @desc 从左边向几个像素的位置滑动
  66. * @type number
  67. * @default 0
  68. *
  69. * @param y位置合わせスピード
  70. * @desc 当有两个或更多个时,当第一个消失时调整y位置时的动画速度[pixel/frame]
  71. * @type number
  72. * @default 5
  73. *
  74. * @param 上か下か
  75. * @desc 在屏幕上显示还是在下面显示
  76. * @default 上
  77. * @type select
  78. * @option 上
  79. * @option 下
  80. *
  81. * @param ティッカー高さ
  82. * @desc 代码的高度
  83. * @type number
  84. * @default 36
  85. *
  86. * @param フォントサイズ
  87. * @desc 字体大小
  88. * @type number
  89. * @default 28
  90. *
  91. * @param アイコンサイズ
  92. * @desc 图标大小
  93. * @type number
  94. * @default 32
  95. *
  96. * @param 背景画像
  97. * @desc 背景画像
  98. * @default
  99. * @type file
  100. * @dir img/pictures/
  101. *
  102. * @param 最大表示個数
  103. * @desc 可以显示的个数。过了之后,旧的就消失了。
  104. * @type number
  105. * @min 1
  106. * @max 100
  107. * @default 10
  108. *
  109. * @param 日志功能 ON 开关
  110. * @desc 它是一个开关,当它打开时作为日志保留而不删除。
  111. * @type switch
  112. * @default 0
  113. *
  114. * @param イージング
  115. * @desc 更改幻灯片动画的缓动
  116. * @default easeOutSine
  117. * @type select
  118. * @option linear
  119. * @option swingFromTo
  120. * @option swingFrom
  121. * @option swingTo
  122. * @option easeFromTo
  123. * @option easeFrom
  124. * @option easeTo
  125. * @option easeInQuad
  126. * @option easeOutQuad
  127. * @option easeInOutQuad
  128. * @option easeInCubic
  129. * @option easeOutCubic
  130. * @option easeInOutCubic
  131. * @option easeInQuart
  132. * @option easeOutQuart
  133. * @option easeInOutQuart
  134. * @option easeInQuint
  135. * @option easeOutQuint
  136. * @option easeInOutQuint
  137. * @option easeInSine
  138. * @option easeOutSine
  139. * @option easeInOutSine
  140. * @option easeInExpo
  141. * @option easeOutExpo
  142. * @option easeInOutExpo
  143. * @option easeInCirc
  144. * @option easeOutCirc
  145. * @option easeInOutCirc
  146. * @option easeOutBounce
  147. * @option easeInBack
  148. * @option easeOutBack
  149. * @option easeInOutBack
  150. * @option bounce
  151. * @option bouncePast
  152. * @option elastic
  153. *
  154. * @param 状态自动显示开关
  155. * @desc 当此处指定的开关为 ON 时,状态改变时自动显示代码。
  156. * @type switch
  157. * @default 0
  158. *
  159. * @param 物品/金钱自动显示开关
  160. * @desc 当此处指定的开关为 ON 时,当物品、武器和盔甲以及金钱增加/减少时自动显示代码。
  161. * @type switch
  162. * @default 0
  163. *
  164. * @param 消失時にティッカーを表示
  165. * @desc 物品、武器、盔甲和金币消失时是否显示窗口
  166. * @type boolean
  167. * @default true
  168. *
  169. * @param アイテム・武器防具入手時テキスト
  170. * @desc 这是您获得物品/武器/盔甲时的文字。
  171. * %1图标、%2物品名称、%3が個数、%4が説明に変わります。
  172. * 可以使用消息窗口的控制命令。
  173. * @default %1 %2 x %3 GET %4
  174. *
  175. * @param アイテム・武器防具消失時テキスト
  176. * @desc 物品·武器防具消失时显示的文本。
  177. * %1图标、%2物品名称、%3が個数、%4が説明に変わります。
  178. * 可以使用消息窗口的控制命令。
  179. * @default %1 %2 x %3 消失 %4
  180. *
  181. * @param お金入手時テキスト
  182. * @desc お金を入手したときのテキストです
  183. * %1图标、%2が金額、%3が通貨単位に変わります。
  184. * 可以使用消息窗口的控制命令。
  185. * @default %1 %2%3入手!
  186. *
  187. * @param お金消失時テキスト
  188. * @desc お金をなくしたしたときのテキストです
  189. * %1图标、%2が金額、%3が通貨単位に変わります。
  190. * 可以使用消息窗口的控制命令。
  191. * @default %1 %2%3消失!
  192. *
  193. * @param お金アイコン
  194. * @desc 得失金币的图标
  195. * @default 1
  196. * @type number
  197. *
  198. *
  199. * @param アイテム・武器・防具入手時SE
  200. * @desc アイテム・武器・防具入手時SE
  201. * @type struct<seSetting>
  202. *
  203. * @param アイテム・武器・防具消失時SE
  204. * @desc アイテム・武器・防具消失時SE
  205. * @type struct<seSetting>
  206. *
  207. * @param お金入手時SE
  208. * @desc お金入手時SE
  209. * @type struct<seSetting>
  210. *
  211. * @param お金消失時SE
  212. * @desc お金消失時SE
  213. * @type struct<seSetting>
  214. *
  215. */

  216. /*~struct~seSetting:
  217. *
  218. * @param name
  219. * @desc ファイル名
  220. * @default
  221. * @dir audio/se/
  222. * @type file
  223. *
  224. * @param volume
  225. * @desc ボリューム
  226. * @default 90
  227. * @type number
  228. *
  229. * @param pitch
  230. * @desc ピッチ
  231. * @default 100
  232. * @type number
  233. *
  234. * @param pan
  235. * @desc パン
  236. * @default 0
  237. * @type number
  238. */


  239. (function () {

  240.   const parameters = PluginManager.parameters('Ticker');
  241.   let defaultTickerSetting = {
  242.     maxDisplay: Number(parameters['最大表示個数'] || 10),
  243.     backgroundOpacity: Number(parameters['Opacity'] || 127),
  244.     displayDuration: Number(parameters['DisplayDuration'] || 3 * 60),
  245.     toggleDuration: Number(parameters['ToggleDuration'] || 30),
  246.     xPosition: Number(parameters['x位置'] || 0),
  247.     yPosition: Number(parameters['y位置'] || 0),
  248.     fixYSpeed: Number(parameters['y位置合わせスピード'] || 100),
  249.     slideFromX: Number(parameters['スライドアニメーション開始位置'] || 0),
  250.     slideToX: Number(parameters['スライドアニメーション終了位置'] || 0),
  251.     height: Number(parameters['ティッカー高さ']),
  252.     fontSize: Number(parameters['フォントサイズ']),
  253.     iconSize: Number(parameters['アイコンサイズ']),
  254.     backgroundImg: parameters['背景画像'],
  255.     isBaseTop: parameters['上か下か'] == '上',
  256.     easingType: parameters['イージング'],
  257.     logOnSwitch: Number(parameters['ログ機能ONスイッチ']),
  258.     stateAutoEnableSWId: Number(parameters['ステート自動表示スイッチ']),
  259.     autoSetting: {
  260.       enableSWId: Number(parameters['アイテム・お金自動表示スイッチ']),
  261.       enableLose: parameters['消失時にティッカーを表示'] == 'true',
  262.       getItemText: parameters['アイテム・武器防具入手時テキスト'],
  263.       loseItemText: parameters['アイテム・武器防具消失時テキスト'],
  264.       getGoldText: parameters['お金入手時テキスト'],
  265.       loseGoldText: parameters['お金消失時テキスト'],
  266.       goldIcon: parameters['お金アイコン'],
  267.       getItemSE: parseSE(parameters['アイテム・武器・防具入手時SE']),
  268.       getGoldSE: parseSE(parameters['お金入手時SE']),
  269.       loseItemSE: parseSE(parameters['アイテム・武器・防具消失時SE']),
  270.       loseGoldSE: parseSE(parameters['お金消失時SE']),
  271.     }
  272.   };

  273.   const gameSystemInitialize = Game_System.prototype.initialize;
  274.   Game_System.prototype.initialize = function () {
  275.     //ゲーム内からパラメータを変更したいのでセーブデータに含める
  276.     gameSystemInitialize.call(this);
  277.     this.setDefaultTickerSetting();
  278.     this.tickerLogs = [];
  279.   };

  280.   Game_System.prototype.setDefaultTickerSetting = function () {
  281.     this.ticker = JsonEx.makeDeepCopy(defaultTickerSetting);
  282.   };

  283.   function parseSE(se) {
  284.     try {
  285.       se = JSON.parse(se);
  286.     } catch (e) {
  287.       return null;
  288.     }
  289.     if (!se || !se.name) return null;
  290.     se.pitch = Number(se.pitch);
  291.     se.volume = Number(se.volume);
  292.     se.pan = Number(se.pan);
  293.     return se;
  294.   }

  295.   window.TickerManager = function () { };

  296.   //パラメータをデフォルトに戻したいケースのため保持
  297.   TickerManager.param = defaultTickerSetting;

  298.   TickerManager.createTickerContainer = function () {
  299.     //通常ティッカー用のコンテナ
  300.     if (!SceneManager._scene._tickerContainer) {
  301.       let tc = new TickerContainer(false);
  302.       SceneManager._scene._tickerContainer = tc;
  303.       SceneManager._scene.addChild(tc);
  304.     }
  305.     //ログティッカー表示用のコンテナ
  306.     if (!SceneManager._scene._tickerLogContainer) {
  307.       let tc = new TickerContainer(true);
  308.       SceneManager._scene._tickerLogContainer = tc;
  309.       SceneManager._scene.addChild(tc);
  310.     }
  311.   };

  312.   TickerManager.show = function (text, needPlus = true) {
  313.     this.createTickerContainer();
  314.     if (this.isLogContainerEnable()) SceneManager._scene._tickerLogContainer.show(text, needPlus);
  315.     else SceneManager._scene._tickerContainer.show(text, needPlus);
  316.   };

  317.   TickerManager.hideAll = function () {
  318.     if (SceneManager._scene._tickerContainer) {
  319.       SceneManager._scene._tickerContainer.hideAll();
  320.     }
  321.   };

  322.   TickerManager.isLogContainerEnable = function () {
  323.     return this.isLogOn() && (SceneManager._scene.constructor == Scene_Map || SceneManager._scene.constructor == Scene_Battle);
  324.   };

  325.   TickerManager.isLogOn = function () {
  326.     return $gameSwitches.value($gameSystem.ticker.logOnSwitch);
  327.   };

  328.   TickerManager.isAutoDisplayEnabled = function () {
  329.     return $gameSystem.ticker.autoSetting.enableSWId > 0 && $gameSwitches.value($gameSystem.ticker.autoSetting.enableSWId);
  330.   };

  331.   TickerManager.clearAllLog = function () {
  332.     if (!$gameParty.inBattle()) $gameSystem.tickerLogs = [];

  333.     if (SceneManager._scene._tickerLogContainer) {
  334.       if ($gameParty.inBattle()) SceneManager._scene._tickerLogContainer.instantLog = [];
  335.       SceneManager._scene._tickerLogContainer.hideAll();
  336.     }
  337.   };

  338.   TickerManager.clearOldestLog = function () {
  339.     if (!$gameParty.inBattle()) $gameSystem.tickerLogs.shift();
  340.     if (SceneManager._scene._tickerLogContainer) {
  341.       if ($gameParty.inBattle()) SceneManager._scene._tickerLogContainer.instantLog.shift();
  342.       SceneManager._scene._tickerLogContainer.hideOldest();
  343.     }
  344.   };

  345.   var createDisplayObjects = Scene_Map.prototype.createDisplayObjects;
  346.   Scene_Map.prototype.createDisplayObjects = function () {
  347.     createDisplayObjects.call(this);
  348.     //メニューから戻ったり、ロードしたりしたときにログ用のティッカーを復元する
  349.     if ($gameSystem.tickerLogs.length > 0) {
  350.       TickerManager.createTickerContainer();
  351.       $gameSystem.tickerLogs.forEach((log) => {
  352.         SceneManager._scene._tickerLogContainer.showFromLog(log);
  353.       });
  354.       SceneManager._scene._tickerLogContainer.alpha = TickerManager.isLogOn() ? 1 : 0;
  355.     }
  356.   };

  357.   function TickerContainer(isLogMode) {
  358.     PIXI.Container.call(this);
  359.     this.isLogMode = isLogMode;
  360.     this.instantLog = [];  //そのシーンだけのログ
  361.   }

  362.   TickerContainer.prototype = Object.create(PIXI.Container.prototype);
  363.   TickerContainer.prototype.constructor = TickerContainer;

  364.   TickerContainer.prototype.update = function () {
  365.     this.displayFade();
  366.     for (var i = 0; i < this.children.length; i++) {
  367.       this.children[i].update();
  368.       if (this.children[i].tickerState == 'end') {
  369.         this.removeChildAt(i);
  370.         this.adjustY();
  371.         i--;
  372.       }
  373.     }
  374.   };

  375.   TickerContainer.prototype.displayFade = function () {
  376.     //ログと通常の切替時にフェード入れる
  377.     const duration = 0.1;
  378.     var direction = 1;
  379.     var logEnabled = TickerManager.isLogContainerEnable();
  380.     if (this.isLogMode && !logEnabled) direction = -1;
  381.     else if (!this.isLogMode && logEnabled) direction = -1;
  382.     this.alpha = (this.alpha + direction * duration).clamp(0, 1);
  383.   };

  384.   TickerContainer.prototype.show = function (text, needPlus) {
  385.     var ticker = this.makeTicker(text, needPlus);
  386.     if (this.isLogMode) {
  387.       //ログモードのとき画面切り替えやセーブに対応するため変換後のテキストを保存する。変換後でないと変数の値が変わる可能性がある
  388.       var logs = $gameParty.inBattle() ? this.instantLog : $gameSystem.tickerLogs;
  389.       logs.push(ticker.getCovertedText());
  390.       if (logs.length > $gameSystem.ticker.maxDisplay) {
  391.         logs.shift();
  392.       }
  393.     }
  394.     if (this.countDisplay() > $gameSystem.ticker.maxDisplay) this.hideOldest();
  395.   };

  396.   TickerContainer.prototype.showFromLog = function (text, needPlus) {
  397.     //ログを復帰するとき。表示アニメーションを飛ばして最初から表示にしたい
  398.     var ticker = this.makeTicker(text, needPlus);
  399.     ticker.setDisplayMode();
  400.   };

  401.   TickerContainer.prototype.makeTicker = function (text, needPlus) {
  402.     var ticker = new Ticker(text, needPlus, this.isLogMode);
  403.     ticker.setY(this.children.length);
  404.     this.addChild(ticker);
  405.     return ticker;
  406.   };

  407.   TickerContainer.prototype.adjustY = function () {
  408.     //y位置直し
  409.     for (var i = 0; i < this.children.length; i++) {
  410.       this.children[i].setToY(i);
  411.     }
  412.   };

  413.   TickerContainer.prototype.hideOldest = function () {
  414.     for (var i = 0; i < this.children.length; i++) {
  415.       if (this.children[i].isShowState()) {
  416.         this.children[i].hide();
  417.         return;
  418.       }
  419.     }
  420.   };

  421.   TickerContainer.prototype.countDisplay = function () {
  422.     return this.children.filter((child) => child.isShowState()).length;
  423.   };

  424.   TickerContainer.prototype.hideAll = function () {
  425.     for (var i = 0; i < this.children.length; i++)this.children[i].hide();
  426.   };

  427.   function Ticker() {
  428.     this.frameCount = 0;
  429.     this.tickerState = 'showing';
  430.     this.initialize.apply(this, arguments);
  431.   }

  432.   Ticker.prototype = Object.create(PIXI.Container.prototype);
  433.   Ticker.prototype.constructor = Ticker;

  434.   Ticker.prototype.initialize = function (text, addPlus, isLogMode) {
  435.     PIXI.Container.call(this);
  436.     this.x = $gameSystem.ticker.xPosition;
  437.     this.width = Graphics.width;
  438.     this.height = $gameSystem.ticker.height;
  439.     this.text = text;
  440.     this.isLogMode = isLogMode;
  441.     this.createBackground();
  442.     this.contents = new Window_Ticker(text, $gameSystem.ticker.slideFromX, 0, this._width, this._height, addPlus);
  443.     this.addChild(this.contents);
  444.   };

  445.   Ticker.prototype.setY = function (index) {
  446.     this.y = $gameSystem.ticker.isBaseTop ? this.height * index + $gameSystem.ticker.yPosition : Graphics.height - this.height * (index + 1) - $gameSystem.ticker.yPosition;
  447.   };

  448.   Ticker.prototype.setToY = function (index) {
  449.     this.toY = $gameSystem.ticker.isBaseTop ? this.height * index + $gameSystem.ticker.yPosition : Graphics.height - this.height * (index + 1) - $gameSystem.ticker.yPosition;
  450.   };

  451.   Ticker.prototype.createBackground = function () {
  452.     this._backSprite = new Sprite();
  453.     if ($gameSystem.ticker.backgroundImg) {
  454.       this._backSprite.bitmap = ImageManager.loadPicture($gameSystem.ticker.backgroundImg);
  455.     } else {
  456.       this._backSprite.bitmap = new Bitmap(this._width, this._height);
  457.       this._backSprite.bitmap.fillAll('rgba(0, 0, 0, 1)');
  458.     }
  459.     this._backSprite.opacity = 0;
  460.     this.addChild(this._backSprite);
  461.   };

  462.   Ticker.prototype.hide = function () {
  463.     if (!this.isShowState()) return;
  464.     this.tickerState = 'hiding';
  465.     this.frameCount = 0;
  466.   };

  467.   Ticker.prototype.isShowState = function () {
  468.     return this.tickerState == 'showing' || this.tickerState == 'display';
  469.   };

  470.   Ticker.prototype.setDisplayMode = function () {
  471.     //アニメなしで表示する(ログのとき画面切り替えしたときとかのため)
  472.     this._backSprite.opacity = $gameSystem.ticker.backgroundOpacity;
  473.     this.contents.contentsOpacity = 255;
  474.     this.contents.x = $gameSystem.ticker.slideToX;
  475.     this.tickerState = 'display';
  476.   };

  477.   Ticker.prototype.getCovertedText = function () {
  478.     return this.contents.convertEscapeCharacters(this.text);
  479.   };

  480.   Ticker.prototype.update = function () {
  481.     this.children.forEach(function (child) {
  482.       child.update();
  483.     });
  484.     this.frameCount++;
  485.     if (this.toY != null && this.y != this.toY) {
  486.       if (this.y > this.toY) {
  487.         this.y -= $gameSystem.ticker.fixYSpeed;
  488.         if (this.y < this.toY) this.y = this.toY;
  489.       } else {
  490.         this.y += $gameSystem.ticker.fixYSpeed;
  491.         if (this.y > this.toY) this.y = this.toY;
  492.       }

  493.     }
  494.     switch (this.tickerState) {
  495.       case 'showing':
  496.         var rate = easing[$gameSystem.ticker.easingType](this.frameCount / $gameSystem.ticker.toggleDuration);
  497.         this._backSprite.opacity = rate * $gameSystem.ticker.backgroundOpacity;
  498.         this.contents.contentsOpacity = rate * 255;
  499.         this.contents.x = $gameSystem.ticker.slideToX + (1 - rate) * $gameSystem.ticker.slideFromX;
  500.         if (this.frameCount == $gameSystem.ticker.toggleDuration) {
  501.           this.tickerState = 'display';
  502.           this.frameCount = 0;
  503.         }
  504.         break;
  505.       case 'display':
  506.         if (this.frameCount == $gameSystem.ticker.displayDuration) {
  507.           if (this.isLogMode) {
  508.             //ログ表示中は消去にいかない
  509.             return;
  510.           }
  511.           this.tickerState = 'hiding';
  512.           this.frameCount = 0;
  513.         }
  514.         break;
  515.       case 'hiding':
  516.         this._backSprite.opacity = (1 - this.frameCount / $gameSystem.ticker.toggleDuration) * $gameSystem.ticker.backgroundOpacity;
  517.         this.contents.contentsOpacity = (1 - this.frameCount / $gameSystem.ticker.toggleDuration) * 255;
  518.         if (this.frameCount == $gameSystem.ticker.toggleDuration) {
  519.           this.tickerState = 'end';
  520.         }
  521.         break;
  522.     }

  523.   };


  524.   function Window_Ticker() {
  525.     this.initialize.apply(this, arguments);
  526.   }

  527.   Window_Ticker.prototype = Object.create(Window_Base.prototype);
  528.   Window_Ticker.prototype.constructor = Window_Ticker;

  529.   Window_Ticker.prototype.initialize = function (text, x, y, width, height, addPlus) {
  530.     Window_Base.prototype.initialize.call(this, x, y, width, height);
  531.     this.opacity = 0;
  532.     this.contentsOpacity = 0;
  533.     this.addPlus = addPlus;
  534.     this.drawTextEx(text, 0, height / 2 - this.standardFontSize() / 2 - 4);
  535.   };

  536.   Window_Ticker.prototype.lineHeight = function () {
  537.     return $gameSystem.ticker.fontSize + 8;
  538.   };

  539.   Window_Ticker.prototype.standardPadding = function () {
  540.     return 0;
  541.   };

  542.   Window_Ticker.prototype.standardFontSize = function () {
  543.     return $gameSystem.ticker.fontSize;
  544.   };

  545.   //変数にプラス記号をつけるため
  546.   Window_Ticker.prototype.convertEscapeCharacters = function (text) {
  547.     text = text.replace(/\\/g, '\x1b');
  548.     text = text.replace(/\x1b\x1b/g, '\\');
  549.     text = text.replace(/\x1bV\[(\d+)\]/gi, function () {
  550.       var v = $gameVariables.value(parseInt(arguments[1]));
  551.       return (v > 0 && this.addPlus ? '+' : '') + v;
  552.     }.bind(this));
  553.     text = text.replace(/\x1bV\[\+*(\d+)\]/gi, function () {
  554.       var v = $gameVariables.value(parseInt(arguments[1]));
  555.       return (v > 0 && this.addPlus ? '+' : '') + v;
  556.     }.bind(this));
  557.     text = text.replace(/\x1bN\[(\d+)\]/gi, function () {
  558.       return this.actorName(parseInt(arguments[1]));
  559.     }.bind(this));
  560.     text = text.replace(/\x1bP\[(\d+)\]/gi, function () {
  561.       return this.partyMemberName(parseInt(arguments[1]));
  562.     }.bind(this));
  563.     text = text.replace(/\x1bG/gi, TextManager.currencyUnit);
  564.     return text;
  565.   };

  566.   Window_Ticker.prototype.processDrawIcon = function(iconIndex, textState) {
  567.     var size = this.getIconSize();
  568.     var y = ($gameSystem.ticker.height - size) / 2;
  569.     this.drawIcon(iconIndex, textState.x + 2, y);
  570.     textState.x += size + 4;
  571.   };

  572.   Window_Ticker.prototype.drawIcon = function(iconIndex, x, y) {
  573.     var bitmap = ImageManager.loadSystem('IconSet');
  574.     var pw = Window_Base._iconWidth;
  575.     var ph = Window_Base._iconHeight;
  576.     var sx = iconIndex % 16 * pw;
  577.     var sy = Math.floor(iconIndex / 16) * ph;
  578.     var size = this.getIconSize();
  579.     this.contents.blt(bitmap, sx, sy, pw, ph, x, y, size, size);
  580.   };

  581.   Window_Ticker.prototype.getIconSize = function() {
  582.     return $gameSystem.ticker.iconSize ? $gameSystem.ticker.iconSize : Window_Base._iconWidth;
  583.   };

  584.   //自動表示-----------------------------------------------------------------

  585.   function formatTickerText(text, strs) {
  586.     text = text.replace('%1', '\\I[' + strs[0] + ']');
  587.     for (var i = 1; i <= strs.length; i++) {
  588.       text = text.replace('%' + (i + 1), strs[i]);
  589.     }
  590.     return text;
  591.   }

  592.   function GetItemDescription(item) {
  593.     if (item.meta.ticker) {
  594.       return item.meta.ticker;
  595.     }
  596.     return item.description.replace(/[\r\n]+.*/m, '');
  597.   }

  598.   function showAutoTicker(getText, loseText, getSE, loseSE, strs, value) {
  599.     let format = '';
  600.     let se;
  601.     if (value > 0) {
  602.       format = getText;
  603.       se = getSE;
  604.     } else if ($gameSystem.ticker.autoSetting.enableLose && value < 0) {
  605.       format = loseText;
  606.       se = loseSE;
  607.     }
  608.     if (format) {
  609.       let formated = formatTickerText(format, strs);
  610.       TickerManager.show(formated);
  611.       if (se) {
  612.         AudioManager.playSe(se);
  613.       }
  614.     }
  615.   }

  616.   // Change Gold
  617.   const command125 = Game_Interpreter.prototype.command125;
  618.   Game_Interpreter.prototype.command125 = function () {
  619.     command125.call(this);
  620.     if (TickerManager.isAutoDisplayEnabled()) {
  621.       let value = this.operateValue(this._params[0], this._params[1], this._params[2]);
  622.       showAutoTicker($gameSystem.ticker.autoSetting.getGoldText, $gameSystem.ticker.autoSetting.loseGoldText,
  623.         $gameSystem.ticker.autoSetting.getGoldSE, $gameSystem.ticker.autoSetting.loseGoldSE,
  624.         [$gameSystem.ticker.autoSetting.goldIcon, Math.abs(value), $dataSystem.currencyUnit], value);
  625.     }
  626.     return true;
  627.   };

  628.   // Change Items
  629.   const command126 = Game_Interpreter.prototype.command126;
  630.   Game_Interpreter.prototype.command126 = function () {
  631.     command126.call(this);
  632.     if (TickerManager.isAutoDisplayEnabled()) {
  633.       let value = this.operateValue(this._params[1], this._params[2], this._params[3]);
  634.       let item = $dataItems[this._params[0]];
  635.       showAutoTicker($gameSystem.ticker.autoSetting.getItemText, $gameSystem.ticker.autoSetting.loseItemText,
  636.         $gameSystem.ticker.autoSetting.getItemSE, $gameSystem.ticker.autoSetting.loseItemSE,
  637.         [item.iconIndex, item.name, Math.abs(value), GetItemDescription(item)], value);
  638.     }
  639.     return true;
  640.   };


  641.   // Change Weapons
  642.   const command127 = Game_Interpreter.prototype.command127;
  643.   Game_Interpreter.prototype.command127 = function () {
  644.     command127.call(this);
  645.     if (TickerManager.isAutoDisplayEnabled()) {
  646.       let value = this.operateValue(this._params[1], this._params[2], this._params[3]);
  647.       let item = $dataWeapons[this._params[0]];
  648.       showAutoTicker($gameSystem.ticker.autoSetting.getItemText, $gameSystem.ticker.autoSetting.loseItemText,
  649.         $gameSystem.ticker.autoSetting.getItemSE, $gameSystem.ticker.autoSetting.loseItemSE,
  650.         [item.iconIndex, item.name, Math.abs(value), GetItemDescription(item)], value);
  651.     }
  652.     return true;
  653.   };

  654.   // Change Armors
  655.   const command128 = Game_Interpreter.prototype.command128;
  656.   Game_Interpreter.prototype.command128 = function () {
  657.     command128.call(this);
  658.     if (TickerManager.isAutoDisplayEnabled()) {
  659.       let value = this.operateValue(this._params[1], this._params[2], this._params[3]);
  660.       let item = $dataArmors[this._params[0]];
  661.       showAutoTicker($gameSystem.ticker.autoSetting.getItemText, $gameSystem.ticker.autoSetting.loseItemText,
  662.         $gameSystem.ticker.autoSetting.getItemSE, $gameSystem.ticker.autoSetting.loseItemSE,
  663.         [item.iconIndex, item.name, Math.abs(value), GetItemDescription(item)], value);
  664.     }
  665.     return true;
  666.   };

  667.   //ステート変化時の自動表示------------------------------------------------------

  668.   function NeedStateChangeDisplay(){
  669.     if($gameSystem.ticker.stateAutoEnableSWId != 0 && !$gameSwitches.value($gameSystem.ticker.stateAutoEnableSWId)) return false;

  670.     return  !(SceneManager._scene instanceof Scene_Battle) ||
  671.      ($gameTroop && $gameTroop.isEventRunning());
  672.   }

  673.   const _gameBattlerBaseAddNewState = Game_BattlerBase.prototype.addNewState;
  674.   Game_BattlerBase.prototype.addNewState = function(stateId) {
  675.     if(NeedStateChangeDisplay() && this._states && !this._states.contains(stateId)){
  676.       let state = $dataStates[stateId];
  677.       if(state.message1) TickerManager.show(this._name + state.message1);
  678.     }
  679.     _gameBattlerBaseAddNewState.apply(this, arguments);
  680.   };

  681.   const _gameBattlerBaseEraseState = Game_BattlerBase.prototype.eraseState;
  682.   Game_BattlerBase.prototype.eraseState = function(stateId) {
  683.     if(NeedStateChangeDisplay() && this._states && this._states.contains(stateId)){
  684.       let state = $dataStates[stateId];
  685.       if(state.message4) TickerManager.show(this._name + state.message4);
  686.     }
  687.     _gameBattlerBaseEraseState.apply(this, arguments);
  688.   };

  689.   const _gameBattlerBaseClearStates = Game_BattlerBase.prototype.clearStates;
  690.   Game_BattlerBase.prototype.clearStates = function() {
  691.     if(NeedStateChangeDisplay() && this._states){
  692.       this._states.forEach(function(stateId) {
  693.         let state = $dataStates[stateId];
  694.         if(state.message4) TickerManager.show(this._name + state.message4);
  695.       }.bind(this));
  696.     }
  697.     _gameBattlerBaseClearStates.apply(this, arguments);
  698.   };

  699.   
  700.   //歩行時のウィンドウでのステート表示を消す
  701.   Game_Actor.prototype.showAddedStates = function() {
  702.    
  703.   };

  704.   Game_Actor.prototype.showRemovedStates = function() {
  705.    
  706.   };


  707.   
  708.   //戦闘中のバトルログをTickerに流す-------------------------------------
  709.   const _windowBackLogInitialize = Window_BattleLog.prototype.initialize;
  710.   Window_BattleLog.prototype.initialize = function () {
  711.     _windowBackLogInitialize.call(this);
  712.     this.visible = false;
  713.   };

  714.   Window_BattleLog.prototype.drawLineText = function (index) {
  715.     if (this._actionIcon && this._lines[index].match('<SIMPLE>')) {
  716.       this._lines[index] = '\\I[' + this._actionIcon + ']' + this._lines[index];
  717.     }
  718.     TickerManager.show(this._lines[index].replace('<CENTER>', '').replace('<SIMPLE>', ''));
  719.     this._lines.pop();
  720.   };

  721.   //easing-------------------------------------------------------------
  722.   var easing = {
  723.     linear: function (pos) {
  724.       return pos;
  725.     },

  726.     easeInQuad: function (pos) {
  727.       return Math.pow(pos, 2);
  728.     },

  729.     easeOutQuad: function (pos) {
  730.       return -(Math.pow((pos - 1), 2) - 1);
  731.     },

  732.     easeInOutQuad: function (pos) {
  733.       if ((pos /= 0.5) < 1) return 0.5 * Math.pow(pos, 2);
  734.       return -0.5 * ((pos -= 2) * pos - 2);
  735.     },

  736.     easeInCubic: function (pos) {
  737.       return Math.pow(pos, 3);
  738.     },

  739.     easeOutCubic: function (pos) {
  740.       return (Math.pow((pos - 1), 3) + 1);
  741.     },

  742.     easeInOutCubic: function (pos) {
  743.       if ((pos /= 0.5) < 1) return 0.5 * Math.pow(pos, 3);
  744.       return 0.5 * (Math.pow((pos - 2), 3) + 2);
  745.     },

  746.     easeInQuart: function (pos) {
  747.       return Math.pow(pos, 4);
  748.     },

  749.     easeOutQuart: function (pos) {
  750.       return -(Math.pow((pos - 1), 4) - 1);
  751.     },

  752.     easeInOutQuart: function (pos) {
  753.       if ((pos /= 0.5) < 1) return 0.5 * Math.pow(pos, 4);
  754.       return -0.5 * ((pos -= 2) * Math.pow(pos, 3) - 2);
  755.     },

  756.     easeInQuint: function (pos) {
  757.       return Math.pow(pos, 5);
  758.     },

  759.     easeOutQuint: function (pos) {
  760.       return (Math.pow((pos - 1), 5) + 1);
  761.     },

  762.     easeInOutQuint: function (pos) {
  763.       if ((pos /= 0.5) < 1) return 0.5 * Math.pow(pos, 5);
  764.       return 0.5 * (Math.pow((pos - 2), 5) + 2);
  765.     },

  766.     easeInSine: function (pos) {
  767.       return -Math.cos(pos * (Math.PI / 2)) + 1;
  768.     },

  769.     easeOutSine: function (pos) {
  770.       return Math.sin(pos * (Math.PI / 2));
  771.     },

  772.     easeInOutSine: function (pos) {
  773.       return (-0.5 * (Math.cos(Math.PI * pos) - 1));
  774.     },

  775.     easeInExpo: function (pos) {
  776.       return (pos === 0) ? 0 : Math.pow(2, 10 * (pos - 1));
  777.     },

  778.     easeOutExpo: function (pos) {
  779.       return (pos === 1) ? 1 : -Math.pow(2, -10 * pos) + 1;
  780.     },

  781.     easeInOutExpo: function (pos) {
  782.       if (pos === 0) return 0;
  783.       if (pos === 1) return 1;
  784.       if ((pos /= 0.5) < 1) return 0.5 * Math.pow(2, 10 * (pos - 1));
  785.       return 0.5 * (-Math.pow(2, -10 * --pos) + 2);
  786.     },

  787.     easeInCirc: function (pos) {
  788.       return -(Math.sqrt(1 - (pos * pos)) - 1);
  789.     },

  790.     easeOutCirc: function (pos) {
  791.       return Math.sqrt(1 - Math.pow((pos - 1), 2));
  792.     },

  793.     easeInOutCirc: function (pos) {
  794.       if ((pos /= 0.5) < 1) return -0.5 * (Math.sqrt(1 - pos * pos) - 1);
  795.       return 0.5 * (Math.sqrt(1 - (pos -= 2) * pos) + 1);
  796.     },

  797.     easeOutBounce: function (pos) {
  798.       if ((pos) < (1 / 2.75)) {
  799.         return (7.5625 * pos * pos);
  800.       } else if (pos < (2 / 2.75)) {
  801.         return (7.5625 * (pos -= (1.5 / 2.75)) * pos + 0.75);
  802.       } else if (pos < (2.5 / 2.75)) {
  803.         return (7.5625 * (pos -= (2.25 / 2.75)) * pos + 0.9375);
  804.       } else {
  805.         return (7.5625 * (pos -= (2.625 / 2.75)) * pos + 0.984375);
  806.       }
  807.     },

  808.     easeInBack: function (pos) {
  809.       var s = 1.70158;
  810.       return (pos) * pos * ((s + 1) * pos - s);
  811.     },

  812.     easeOutBack: function (pos) {
  813.       var s = 1.70158;
  814.       return (pos = pos - 1) * pos * ((s + 1) * pos + s) + 1;
  815.     },

  816.     easeInOutBack: function (pos) {
  817.       var s = 1.70158;
  818.       if ((pos /= 0.5) < 1) return 0.5 * (pos * pos * (((s *= (1.525)) + 1) * pos - s));
  819.       return 0.5 * ((pos -= 2) * pos * (((s *= (1.525)) + 1) * pos + s) + 2);
  820.     },

  821.     elastic: function (pos) {
  822.       return -1 * Math.pow(4, -8 * pos) * Math.sin((pos * 6 - 1) * (2 * Math.PI) / 2) + 1;
  823.     },

  824.     swingFromTo: function (pos) {
  825.       var s = 1.70158;
  826.       return ((pos /= 0.5) < 1) ? 0.5 * (pos * pos * (((s *= (1.525)) + 1) * pos - s)) :
  827.         0.5 * ((pos -= 2) * pos * (((s *= (1.525)) + 1) * pos + s) + 2);
  828.     },

  829.     swingFrom: function (pos) {
  830.       var s = 1.70158;
  831.       return pos * pos * ((s + 1) * pos - s);
  832.     },

  833.     swingTo: function (pos) {
  834.       var s = 1.70158;
  835.       return (pos -= 1) * pos * ((s + 1) * pos + s) + 1;
  836.     },

  837.     bounce: function (pos) {
  838.       if (pos < (1 / 2.75)) {
  839.         return (7.5625 * pos * pos);
  840.       } else if (pos < (2 / 2.75)) {
  841.         return (7.5625 * (pos -= (1.5 / 2.75)) * pos + 0.75);
  842.       } else if (pos < (2.5 / 2.75)) {
  843.         return (7.5625 * (pos -= (2.25 / 2.75)) * pos + 0.9375);
  844.       } else {
  845.         return (7.5625 * (pos -= (2.625 / 2.75)) * pos + 0.984375);
  846.       }
  847.     },

  848.     bouncePast: function (pos) {
  849.       if (pos < (1 / 2.75)) {
  850.         return (7.5625 * pos * pos);
  851.       } else if (pos < (2 / 2.75)) {
  852.         return 2 - (7.5625 * (pos -= (1.5 / 2.75)) * pos + 0.75);
  853.       } else if (pos < (2.5 / 2.75)) {
  854.         return 2 - (7.5625 * (pos -= (2.25 / 2.75)) * pos + 0.9375);
  855.       } else {
  856.         return 2 - (7.5625 * (pos -= (2.625 / 2.75)) * pos + 0.984375);
  857.       }
  858.     },

  859.     easeFromTo: function (pos) {
  860.       if ((pos /= 0.5) < 1) return 0.5 * Math.pow(pos, 4);
  861.       return -0.5 * ((pos -= 2) * Math.pow(pos, 3) - 2);
  862.     },

  863.     easeFrom: function (pos) {
  864.       return Math.pow(pos, 4);
  865.     },

  866.     easeTo: function (pos) {
  867.       return Math.pow(pos, 0.25);
  868.     }
  869.   };

  870. })();
复制代码

Ticker.zip

7.3 KB, 下载次数: 9

最佳答案

查看完整内容

除了 window_base 的参数变了以外,commandXXX 的参数也变了,params 从函数参数里传了。
梦石
0
星屑
9917
在线时间
582 小时
注册时间
2017-9-28
回帖
207
发表于 2022-3-5 12:19:10 | 显示全部楼层
Ticker.zip (7.04 KB, 下载次数: 9) 除了 window_base 的参数变了以外,commandXXX 的参数也变了,params 从函数参数里传了。
喵喵喵
回复

使用道具 举报

梦石
0
星屑
9917
在线时间
582 小时
注册时间
2017-9-28
回帖
207
发表于 2022-3-6 10:39:27 | 显示全部楼层
随手修了几个地方,可能还有没修的: Ticker.zip (7.22 KB, 下载次数: 12)

diff:

  1. --- "a/Ticker.js"
  2. +++ b/Ticker.js
  3. @@ -4,6 +4,7 @@
  4.   *---------------------------------------------------------------------------*/

  5. /*:
  6. + * @target MZ
  7.   * @plugindesc ティッカープラグイン
  8.   * @author kido0617
  9.   * @help
  10. @@ -575,7 +576,7 @@
  11.    Window_Ticker.prototype.constructor = Window_Ticker;

  12.    Window_Ticker.prototype.initialize = function (text, x, y, width, height, addPlus) {
  13. -    Window_Base.prototype.initialize.call(this, x, y, width, height);
  14. +    Window_Base.prototype.initialize.call(this, new Rectangle(x, y, width, height));
  15.      this.opacity = 0;
  16.      this.contentsOpacity = 0;
  17.      this.addPlus = addPlus;
  18. @@ -586,8 +587,13 @@
  19.      return $gameSystem.ticker.fontSize + 8;
  20.    };
  21. -  Window_Ticker.prototype.standardPadding = function () {
  22. -    return 0;
  23. +  Window_Ticker.prototype.updatePadding = function () {
  24. +    this.padding = 0;
  25. +  };
  26. +
  27. +  Window_Ticker.prototype.resetFontSettings = function () {
  28. +    Window_Base.prototype.resetFontSettings.apply(this, arguments);
  29. +    this.contents.fontSize = this.standardFontSize();
  30.    };

  31.    Window_Ticker.prototype.standardFontSize = function () {
复制代码
喵喵喵
回复

使用道具 举报

梦石
0
星屑
613
在线时间
161 小时
注册时间
2020-10-11
回帖
30
 楼主| 发表于 2022-3-7 03:58:14 | 显示全部楼层
hyrious 发表于 2022-3-6 10:39
随手修了几个地方,可能还有没修的:

diff:

虽然还是会报错,金钱或者物品增加时候会报错,

ZNOT78(JPNF]~_[JQ4L)]FU.png
进入战斗也会报错,

GW0)`$T%XY)_IA~M4E_31]P.png
但是依旧万分感谢,

这插件代码挺多的,其实我需要的只是那个修改变量显示日志的功能,那功能MV战斗界面也能完美运行。

能推荐一个插件或者,避免无效修改把这个插件的其他比如获取物品提醒功能删了都行。

因为前天等了一天每看到回复,所以昨天也就没抱有期待进论坛回复慢了。万分抱歉。

点评

有空我再修修  发表于 2022-3-7 06:28
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部