查看: 4197|回复: 1

[搬运汉化] 行動予測[坐等汉化]

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

开拓者

发表于 2020-11-14 23:35:22 | 显示全部楼层 |阅读模式

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

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

×




使用方法:

在技能的笔记栏中用<fsText:预测文本>这样的标签设定行动预测请
在敌人的战斗画面中输入
重复显示预测文本。

此插件已在MIT许可证下发放,用于商业利益,
可自由使用改造、再发放等。

*笔记栏标签(技能):
*
*<fsText:预测文本>
*敌人使用该技能的回合的指令输入中,预测文本为
*显示为重叠在敌人图形上。
*没有这个标签时会代替技能名显示。
*
*通过中途对预测文本进行换行,行动预测的显示也变成多行。
超过设置的Linkma*行数
不能。
*
* <fsIcon:5>
*在预测文本的开头显示5号图标。
*没有这个标签的情况下用技能图标表示费用。
*
*showIcon为OFF(假)时不显示。
*
*
*笔记栏标签(敌人角色):
*
* <fsOffsetX:50>
*将该敌人的行动预测显示位置向右移动50点。向左移动时
请输入*的设置值。
*
* <fsOffsetY:80>
*将该敌人的行动预测显示位置向下移动80点。如果向上移动
*请设定负值。
*
*
*插件命令:
*
* fsStop
*使行动预测功能无效。游戏开始时行动预测机能有效
成为*。保存在动态数据中。
*
* fsStart
*有效地进行无效的行动预测功能。
*
*
*插件参数补充:
*
* maxLines
*设置行动予测表示的最大行数。行数越多,位图就越大
*为了生成,请不要设置超出必要的大值。
*
*1回合有多次行动的场合,需要行动回数的行数。
*在行动预测显示中利用换行符时,需要的行数会进一步增加。
*
*颜色/backColor/headerColor
*该参数包含黑色或蓝色等颜色名称,
可以设定像*#000000和#0000ff这样的彩色代码。
*
*标题文本
*活动预测器左上角显示的页眉文本。如果什么都不输入的话
*隐藏页眉文本。
*
* cornerRadius
* TMBitmapEx.js在这个插件之上的位置导入,
*通过将该参数的值设为1以上,可以确认行动预测的背景
在矩形中。
* /


12

  1. //=============================================================================
  2. // TMPlugin - エネミー行動予測
  3. // バージョン: 1.1.0
  4. // 最終更新日: 2018/08/21
  5. // 配布元    : [url]http://hikimoki.sakura.ne.jp/[/url]
  6. //-----------------------------------------------------------------------------
  7. // Copyright (c) 2016 tomoaky
  8. // Released under the MIT license.
  9. // [url]http://opensource.org/licenses/mit-license.php[/url]
  10. //=============================================================================

  11. /*:
  12. * @plugindesc 敵キャラの次の行動のヒントなどをテキストで表示します。
  13. * より戦略的なターンバトルが実現できるかもしれません。
  14. *
  15. * @author tomoaky ([url]http://hikimoki.sakura.ne.jp/[/url])
  16. *
  17. * @param width
  18. * @type number
  19. * @desc 行動予測表示の横幅
  20. * 初期値: 240
  21. * @default 240
  22. *
  23. * @param maxLines
  24. * @type number
  25. * @desc 行動予測表示の最大行数
  26. * 初期値: 3
  27. * @default 3
  28. *
  29. * @param lineHeight
  30. * @type number
  31. * @desc 行動予測表示の 1 行の高さ
  32. * 初期値: 36
  33. * @default 36
  34. *
  35. * @param fontSize
  36. * @type number
  37. * @desc 行動予測表示のフォントサイズ
  38. * 初期値: 28
  39. * @default 28
  40. *
  41. * @param color
  42. * @desc 行動予測表示の文字色
  43. * 初期値: white
  44. * @default white
  45. *
  46. * @param backColor
  47. * @desc 行動予測表示の背景の色
  48. * 初期値: black
  49. * @default black
  50. *
  51. * @param backOpacity
  52. * @type number
  53. * @max 255
  54. * @desc 行動予測表示の背景の不透明度
  55. * 初期値: 128 ( 0 ~ 255 )
  56. * @default 128
  57. *
  58. * @param textAlign
  59. * @type select
  60. * @option left
  61. * @option center
  62. * @option right
  63. * @desc 行動予測表示の行揃え
  64. * @default center
  65. *
  66. * @param showIcon
  67. * @type boolean
  68. * @desc スキル名の頭にアイコンも表示する
  69. * 初期値: ON( ON = 表示 / OFF = 非表示 )
  70. * @default true
  71. *
  72. * @param headerText
  73. * @desc 行動予測表示のヘッダーテキスト
  74. * 初期値: Next
  75. * @default Next
  76. *
  77. * @param headerHeight
  78. * @type number
  79. * @desc 行動予測表示のヘッダーの高さ
  80. * 初期値: 20
  81. * @default 20
  82. *
  83. * @param headerFontSize
  84. * @type number
  85. * @desc 行動予測表示のヘッダーのフォントサイズ
  86. * 初期値: 16
  87. * @default 16
  88. *
  89. * @param headerColor
  90. * @desc 行動予測表示のヘッダーの文字色
  91. * 初期値: red
  92. * @default red
  93. *
  94. * @param cornerRadius
  95. * @type number
  96. * @desc TMBitmapEx.js導入時の、角丸矩形の丸部分の半径
  97. * 初期値: 6
  98. * @default 6
  99. *
  100. * @help
  101. * TMPlugin - エネミー行動予測 ver1.1.0
  102. *
  103. * 使い方:
  104. *
  105. *   スキルのメモ欄に <fsText:予測テキスト> のようなタグで行動予測の設定を
  106. *   してください。
  107. *   戦闘シーンでパーティのコマンドを入力している間、敵グラフィックに
  108. *   重なるように予測テキストが表示されるようになります。
  109. *
  110. *   このプラグインは RPGツクールMV Version 1.6.1 で動作確認をしています。
  111. *
  112. *   このプラグインはMITライセンスのもとに配布しています、商用利用、
  113. *   改造、再配布など、自由にお使いいただけます。
  114. *
  115. *
  116. * メモ欄タグ(スキル):
  117. *
  118. *   <fsText:予測テキスト>
  119. *     敵がこのスキルを使用するターンのコマンド入力中に、予測テキストが
  120. *     敵グラフィックに重なるように表示されます。
  121. *     このタグがない場合はスキル名を代わりに表示します。
  122. *
  123. *     予測テキストを途中で改行することで、行動予測の表示も複数行になります。
  124. *     ただしプラグインパラメータ maxLines で設定した行数を超えることは
  125. *     できません。
  126. *
  127. *   <fsIcon:5>
  128. *     予測テキストの頭に 5 番のアイコンを表示します。
  129. *     このタグがない場合はスキルアイコンを代わりに表示します。
  130. *
  131. *     プラグインパラメータ showIcon がOFF(false)の場合は表示しません。
  132. *
  133. *
  134. * メモ欄タグ(敵キャラ):
  135. *
  136. *   <fsOffsetX:50>
  137. *     この敵の行動予測の表示位置を右に 50 ドットずらします。左にずらす場合は
  138. *     負の値を設定してください。
  139. *
  140. *   <fsOffsetY:80>
  141. *     この敵の行動予測の表示位置を下に 80 ドットずらします。上にずらす場合は
  142. *     負の値を設定してください。
  143. *
  144. *
  145. * プラグインコマンド:
  146. *
  147. *   fsStop
  148. *     行動予測機能を無効にします。ゲーム開始時は行動予測機能が有効に
  149. *     なっています。行動予測機能の状態はセーブデータに保存されます。
  150. *
  151. *   fsStart
  152. *     無効にした行動予測機能を有効にします。
  153. *
  154. *
  155. * プラグインパラメータ補足:
  156. *
  157. *   maxLines
  158. *     行動予測表示の最大行数を設定します。行数が多いほど大きなビットマップが
  159. *     生成されるため、必要以上に大きな値は設定しないでください。
  160. *
  161. *     1ターンに複数回の行動がある場合、行動回数分の行数が必要になります。
  162. *     行動予測表示に改行を利用する場合はさらに必要な行数が増えます。
  163. *
  164. *   color / backColor / headerColor
  165. *     このパラメータには、black や blue といったカラーネームと、
  166. *     #000000 や #0000ff のようなカラーコードを設定することができます。
  167. *
  168. *   headerText
  169. *     行動予測の左上に表示するヘッダーテキストです。何も入力しなければ
  170. *     ヘッダーテキストは非表示になります。
  171. *
  172. *   cornerRadius
  173. *     TMBitmapEx.js をこのプラグインよりも上の位置に導入しつつ、
  174. *     このパラメータの値を 1 以上にすることで、行動予測の背景を
  175. *     角丸の矩形にすることができます。
  176. */

  177. var Imported = Imported || {};
  178. Imported.TMFutureSight = true;

  179. (function() {

  180.         var parameters = PluginManager.parameters('TMFutureSight');
  181.         var SightWidth = +(parameters['width'] || 240);
  182.         var SightMaxLines = +(parameters['maxLines'] || 3);
  183.         var SightLineHeight = +(parameters['lineHeight'] || 36);
  184.         var SightFontSize = +(parameters['fontSize'] || 28);
  185.         var SightColor = parameters['color'] || 'white';
  186.         var SightBackColor = parameters['backColor'] || 'black';
  187.         var SightBackOpacity = +(parameters['backOpacity'] || 128);
  188.         var SightCornerRadius = +(parameters['cornerRadius'] || 6);
  189.         var SightTextAlign = parameters['textAlign'] || 'center';
  190.         var SightShowIcon = JSON.parse(parameters['showIcon'] || 'true');
  191.         var SightHeaderText = parameters['headerText'];
  192.         var SightHeaderHeight = +(parameters['headerHeight'] || 20);
  193.         var SightHeaderFontSize = +(parameters['headerFontSize'] || 16);
  194.         var SightHeaderColor = parameters['headerColor'] || 'red';
  195.   
  196.         //-----------------------------------------------------------------------------
  197.         // Game_System
  198.         //

  199.         Game_System.prototype.isFutureSightEnabled = function() {
  200.                 if (this._futureSightEnabled == null) {
  201.                         this._futureSightEnabled = true;
  202.                 }
  203.                 return this._futureSightEnabled;
  204.         };

  205.         Game_System.prototype.disableFutureSight = function() {
  206.                 this._futureSightEnabled = false;
  207.         };

  208.         Game_System.prototype.enableFutureSight = function() {
  209.                 this._futureSightEnabled = true;
  210.         };

  211.         //-----------------------------------------------------------------------------
  212.         // Game_Enemy
  213.         //

  214.         Game_Enemy.prototype.setFutureSightTexts = function() {
  215.                 this._futureSightTexts = [];
  216.                 this._futureSightIcons = [];
  217.                 for (var i = 0; i < this._actions.length; i++) {
  218.                         if (this._actions[i]) {
  219.                                 var skill = this._actions[i].item();
  220.                                 if (skill) {
  221.                                         if (skill.meta.fsText) {
  222.                                                 this._futureSightTexts.push(skill.meta.fsText);
  223.                                         } else {
  224.                                                 this._futureSightTexts.push(skill.name);
  225.                                         }
  226.                                         this._futureSightIcons.push(this.fsIconIndex(skill));
  227.                                 }
  228.                         }
  229.                 }
  230.         };

  231.         Game_Enemy.prototype.fsIconIndex = function(skill) {
  232.                 if (!SightShowIcon) {
  233.                         return 0;
  234.                 }
  235.                 if (skill.meta.fsIcon) {
  236.                         return +skill.meta.fsIcon;
  237.                 }
  238.                 return skill.iconIndex;
  239.         };

  240.         Game_Enemy.prototype.resetFutureSightTexts = function() {
  241.                 this._futureSightTexts = [];
  242.         };

  243.         Game_Enemy.prototype.futureSightTexts = function() {
  244.                 return this._futureSightTexts || [];
  245.         };

  246.         Game_Enemy.prototype.futureSightIcons = function() {
  247.                 return this._futureSightIcons || [];
  248.         };
  249.   
  250.         //-----------------------------------------------------------------------------
  251.         // Game_Troop
  252.         //

  253.         var _Game_Troop_makeActions = Game_Troop.prototype.makeActions;
  254.         Game_Troop.prototype.makeActions = function() {
  255.                 _Game_Troop_makeActions.call(this);
  256.                 if ($gameSystem.isFutureSightEnabled() && !BattleManager._preemptive) {
  257.                         this.members().forEach(function(member) {
  258.                                 member.setFutureSightTexts();
  259.                         });
  260.                 }
  261.         };

  262.         var _Game_Troop_increaseTurn = Game_Troop.prototype.increaseTurn;
  263.         Game_Troop.prototype.increaseTurn = function() {
  264.                 _Game_Troop_increaseTurn.call(this);
  265.                 this.members().forEach(function(member) {
  266.                         member.resetFutureSightTexts();
  267.                 });
  268.         };

  269.         //-----------------------------------------------------------------------------
  270.         // Game_Interpreter
  271.         //

  272.         var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  273.         Game_Interpreter.prototype.pluginCommand = function(command, args) {
  274.                 _Game_Interpreter_pluginCommand.call(this, command, args);
  275.                 if (command === 'fsStart') {
  276.                         $gameSystem.enableFutureSight();
  277.                 } else if (command === 'fsStop') {
  278.                         $gameSystem.disableFutureSight();
  279.                 }
  280.         };
  281.   
  282.         //-----------------------------------------------------------------------------
  283.         // Sprite_Enemy
  284.         //

  285.         var _Sprite_Enemy_update = Sprite_Enemy.prototype.update;
  286.         Sprite_Enemy.prototype.update = function() {
  287.                 _Sprite_Enemy_update.call(this);
  288.                 if (this._enemy) {
  289.                         this.updateFutureSight();
  290.                 }
  291.         };

  292.         Sprite_Enemy.prototype.updateFutureSight = function() {
  293.                 if (!this._futureSightSprite && this.parent) {
  294.                         this._futureSightSprite = new Sprite_FutureSight(this);
  295.                         this.parent.addChild(this._futureSightSprite);
  296.                 }
  297.         };

  298.         //-----------------------------------------------------------------------------
  299.         // Sprite_FutureSight
  300.         //

  301.         function Sprite_FutureSight() {
  302.                 this.initialize.apply(this, arguments);
  303.         }

  304.         Sprite_FutureSight.prototype = Object.create(Sprite.prototype);
  305.         Sprite_FutureSight.prototype.constructor = Sprite_FutureSight;

  306.         Sprite_FutureSight.prototype.initialize = function(enemySprite) {
  307.                 Sprite.prototype.initialize.call(this);
  308.                 this._enemySprite = enemySprite;
  309.                 var width = SightWidth;
  310.                 var height = SightLineHeight * SightMaxLines + SightHeaderHeight;
  311.                 this.bitmap = new Bitmap(width, height);
  312.                 this.anchor.x = 0.5;
  313.                 this.anchor.y = 1;
  314.                 this.z = 10;
  315.                 this._texts = [];
  316.                 this._icons = [];
  317.         };

  318.         Sprite_FutureSight.prototype.refresh = function() {
  319.                 this.bitmap.clear();
  320.                 if (this._texts.length > 0) {
  321.                         var lines = this._texts.reduce(function(r, text) {
  322.                                 return r + text.split('\n').length;
  323.                         }, 0);
  324.                         var y = SightHeaderHeight;
  325.                         var width = this.bitmap.width;
  326.                         var height = SightLineHeight * lines;
  327.                         this.drawSightBack(0, y, width, height);
  328.                         this.drawSightHeader(0, 0, width, SightHeaderHeight);
  329.                         this.drawSightText(4, y, width - 8, SightLineHeight);
  330.                 }
  331.         };

  332.         Sprite_FutureSight.prototype.drawSightBack = function(x, y, width, height) {
  333.                 this.bitmap.paintOpacity = SightBackOpacity;
  334.                 if (Imported.TMBitmapEx && SightCornerRadius) {
  335.                         this.bitmap.fillRoundRect(x, y, width, height, SightCornerRadius, SightBackColor);
  336.                 } else {
  337.                         this.bitmap.fillRect(x, y, width, height, SightBackColor);
  338.                 }
  339.                 this.bitmap.paintOpacity = 255;
  340.         };

  341.         Sprite_FutureSight.prototype.drawSightHeader = function(x, y, width, height) {
  342.                 if (SightHeaderText) {
  343.                         this.bitmap.fontSize = SightHeaderFontSize;
  344.                         this.bitmap.textColor = SightHeaderColor;
  345.                         this.bitmap.drawText(SightHeaderText, x, y, width, height);
  346.                 }
  347.         };

  348.         Sprite_FutureSight.prototype.drawSightText = function(x, y, width, height) {
  349.                 this.bitmap.fontSize = SightFontSize;
  350.                 this.bitmap.textColor = SightColor;
  351.                 for (var i = 0; i < this._texts.length; i++) {
  352.                         var text = this._texts[i];
  353.                         var iconIndex = this._icons[i];
  354.                         var dx = x;
  355.                         var dw = width;
  356.                         if (iconIndex > 0) {
  357.                                 var iconX = this.sightIconX(text, width);
  358.                                 if (iconX <= 0) {
  359.                                         iconX = 0;
  360.                                         dx += SightLineHeight;
  361.                                         dw -= SightLineHeight;
  362.                                 }
  363.                                 this.drawSightIcon(iconIndex, x + iconX, y);
  364.                         }
  365.                         var arr = text.split('\n');
  366.                         for (var j = 0; j < arr.length; j++) {
  367.                                 this.bitmap.drawText(arr[j], dx, y, dw, height, SightTextAlign);
  368.                                 y += SightLineHeight;
  369.                         }
  370.                 }
  371.         };

  372.         Sprite_FutureSight.prototype.sightIconX = function(text, width) {
  373.                 var textWidth = this.bitmap.measureTextWidth(text);
  374.                 if (SightTextAlign === 'left') {
  375.                         return 0;
  376.                 } else if (SightTextAlign === 'center') {
  377.                         return (width - textWidth) / 2 - SightLineHeight;
  378.                 } else {
  379.                         return width - textWidth - SightLineHeight;
  380.                 }
  381.         };

  382.         Sprite_FutureSight.prototype.drawSightIcon = function(iconIndex, x, y) {
  383.                 var bitmap = ImageManager.loadSystem('IconSet');
  384.                 var pw = Window_Base._iconWidth;
  385.                 var ph = Window_Base._iconHeight;
  386.                 var sx = iconIndex % 16 * pw;
  387.                 var sy = Math.floor(iconIndex / 16) * ph;
  388.                 var dw = SightLineHeight - 4;
  389.                 var dh = SightLineHeight - 4;
  390.                 this.bitmap.blt(bitmap, sx, sy, pw, ph, x + 2, y + 2, dw, dh);
  391.         };

  392.         Sprite_FutureSight.prototype.update = function() {
  393.                 Sprite.prototype.update.call(this);
  394.                 var futureSightTexts = this._enemySprite._enemy.futureSightTexts().concat();
  395.                 var futureSightIcons = this._enemySprite._enemy.futureSightIcons().concat();
  396.                 if (this._texts.toString() !== futureSightTexts.toString() ||
  397.                                 this._icons.toString() !== futureSightIcons.toString()) {
  398.                         this._texts = futureSightTexts;
  399.                         this._icons = futureSightIcons;
  400.                         this.refresh();
  401.                 }
  402.                 var enemy = this._enemySprite._enemy.enemy();
  403.                 this.x = this._enemySprite.x + (+enemy.meta.fsOffsetX || 0);
  404.                 this.y = this._enemySprite.y + (+enemy.meta.fsOffsetY || 0);
  405.         };

  406. })();
复制代码
------落尽红樱君不见,轻绘梨花泪沾衣。~~~
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

在本版发帖返回顶部