查看: 1932|回复: 3

[有事请教] 请问这个脚本应该怎么改呢

[复制链接]
梦石
0
星屑
296
在线时间
78 小时
注册时间
2015-7-17
回帖
6
发表于 2023-4-4 17:35:02 | 显示全部楼层 |阅读模式

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

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

×
这是GALV的互动提示插件代码,在人物面前的事件会弹出动态图标提示。怎么实现人物不朝向事件方向也能弹出提示呢?另外能不能扩大提示的范围,相距两格的时候就进行提示?
  1. //-----------------------------------------------------------------------------
  2. //  Galv's Action Indicators
  3. //-----------------------------------------------------------------------------
  4. //  For: RPGMAKER MV
  5. //  GALV_ActionIndicators.js
  6. //-----------------------------------------------------------------------------
  7. //  2017-05-26 - Version 1.4 - fixed a bug when looking at same icon indicator
  8. //                           - wouldn't do popup effect
  9. //  2015-03-06 - Version 1.3 - now works with events 'under' the player as well
  10. //                           - as counters
  11. //  2015-12-08 - Version 1.2 - added opacity, z and hiding options.
  12. //  2015-12-07 - Version 1.1 - fixed a crash when you deleted events.
  13. //  2015-12-04 - Version 1.0 - release
  14. //-----------------------------------------------------------------------------
  15. // Terms can be found at:
  16. // galvs-scripts.com
  17. //-----------------------------------------------------------------------------

  18. var Imported = Imported || {};
  19. Imported.Galv_ActionIndicators = true;

  20. var Galv = Galv || {};        // Galv's main object
  21. Galv.pCmd = Galv.pCmd || {};  // Plugin Command manager
  22. Galv.AI = Galv.AI || {};      // Galv's plugin stuff

  23. //-----------------------------------------------------------------------------
  24. /*:
  25. * @plugindesc 当玩家能够与事件交互时显示图标。
  26. *
  27. * @author Galv - galvs-scripts.com
  28. *
  29. * @param Y Offset
  30. * @desc 图标Y位置的像素偏移
  31. * @default 0
  32. *
  33. * @param Z Position
  34. * @desc Z位置(controls if it appears over/under map objects)
  35. * @default 5
  36. *
  37. * @param Auto Hide
  38. * @desc true or false. If true, 事件运行时图标将消失
  39. * @default true
  40. *
  41. * @param Icon Opacity
  42. * @desc 0-255. 图标的不透明度
  43. * @default 255
  44. *
  45. * @help
  46. *   Galv's Action Indicators
  47. * ----------------------------------------------------------------------------
  48. * This plugin will enable you to display an icon when the player is facing an
  49. * event that has the below code in a 'comment' command anywhere in the active
  50. * event page.
  51. *
  52. *   <actionIcon: id>       // The code to use in a COMMENT within and event.
  53. *                          // id = the icon ID to use for the indicator.
  54. *
  55. * ----------------------------------------------------------------------------
  56. *  插件命令
  57. * ----------------------------------------------------------------------------
  58. *
  59. *   AIVISIBLE FALSE        // 禁用动作指示器
  60. *   AIVISIBLE TRUE         // 启用动作指示器
  61. *   
  62. */

  63. //-----------------------------------------------------------------------------
  64. //  CODE STUFFS
  65. //-----------------------------------------------------------------------------

  66. (function() {

  67. Galv.AI.y = Number(PluginManager.parameters('Galv_ActionIndicators')["Y Offset"]);
  68. Galv.AI.z = Number(PluginManager.parameters('Galv_ActionIndicators')["Z

  69. Position"]);
  70. Galv.AI.opacity = Number(PluginManager.parameters('Galv_ActionIndicators')["Icon

  71. Opacity"]);

  72. Galv.AI.autoHide = eval(PluginManager.parameters('Galv_ActionIndicators')["Auto

  73. Hide"]);
  74. Galv.AI.needRefresh = false;

  75. // GALV'S PLUGIN MANAGEMENT. INCLUDED IN ALL GALV PLUGINS THAT HAVE PLUGIN COMMAND

  76. CALLS, BUT ONLY RUN ONCE.
  77. if (!Galv.aliased) {
  78.         var Galv_Game_Interpreter_pluginCommand =

  79. Game_Interpreter.prototype.pluginCommand;
  80.         Game_Interpreter.prototype.pluginCommand = function(command, args) {
  81.                 if (Galv.pCmd[command]) {
  82.                         Galv.pCmd[command](args);
  83.                         return;
  84.                 };
  85.                 Galv_Game_Interpreter_pluginCommand.call(this, command, args);
  86.         };
  87.         Galv.aliased = true; // Don't keep aliasing for other Galv scripts.
  88. };

  89. // Direct to Plugin Object
  90. Galv.pCmd.AIVISIBLE = function(arguments) {
  91.         var status = eval(arguments[0].toLowerCase())
  92.         $gameSystem.actionIndicatorVisible = status;
  93. };
  94. // END GALV'S PLUGIN MANAGEMENT




  95. //-----------------------------------------------------------------------------
  96. // Game_System

  97. var Galv_Game_System_initialize = Game_System.prototype.initialize;
  98. Game_System.prototype.initialize = function() {
  99.         Galv_Game_System_initialize.call(this);
  100.         this.actionIndicatorVisible = true;
  101. };

  102. //-----------------------------------------------------------------------------
  103. // Game_Map

  104. var Galv_Game_Map_requestRefresh = Game_Map.prototype.requestRefresh;
  105. Game_Map.prototype.requestRefresh = function(mapId) {
  106.         Galv_Game_Map_requestRefresh.call(this,mapId);
  107.         Galv.AI.needRefresh = true;
  108. };


  109. //-----------------------------------------------------------------------------
  110. // Game_Player

  111. var Galv_Game_CharacterBase_moveStraight =

  112. Game_CharacterBase.prototype.moveStraight;
  113. Game_CharacterBase.prototype.moveStraight = function(d) {
  114.         Galv_Game_CharacterBase_moveStraight.call(this,d);
  115.         Galv.AI.needRefresh = true;
  116. };

  117. Galv.AI.checkActionIcon = function() {
  118.         var x2 = $gameMap.roundXWithDirection($gamePlayer._x,

  119. $gamePlayer._direction);
  120.     var y2 = $gameMap.roundYWithDirection($gamePlayer._y, $gamePlayer._direction);
  121.         var action = null;
  122.        
  123.        
  124.         // CHECK EVENT STANDING ON
  125.         $gameMap.eventsXy($gamePlayer._x, $gamePlayer._y).forEach(function(event)

  126. {
  127.                 action = Galv.AI.checkEventForIcon(event);
  128.         });
  129.        
  130.         // CHECK EVENT IN FRONT
  131.         if (!action) {
  132.                 $gameMap.eventsXy(x2, y2).forEach(function(event) {
  133.                         if (event.isNormalPriority()) {
  134.                                 action = Galv.AI.checkEventForIcon(event);
  135.                         };
  136.                 });
  137.         };
  138.        
  139.         // CHECK COUNTER
  140.         if (!action && $gameMap.isCounter(x2, y2)) {
  141.                 var direction = $gamePlayer.direction();
  142.                 var x3 = $gameMap.roundXWithDirection(x2, direction);
  143.                 var y3 = $gameMap.roundYWithDirection(y2, direction);
  144.                  $gameMap.eventsXy(x3, y3).forEach(function(event) {
  145.                         if (event.isNormalPriority()) {
  146.                                 action = Galv.AI.checkEventForIcon(event);
  147.                         };
  148.                 });
  149.         };
  150.         action = action || {'eventId': 0, 'iconId': 0};
  151.         $gamePlayer.actionIconTarget = action;
  152. };



  153. Galv.AI.checkEventForIcon = function(event) {
  154.         var icon = 0;
  155.                        
  156.         if (event.page()) {
  157.                 var listCount = event.page().list.length;
  158.                
  159.                 for (var i = 0; i < listCount; i++) {
  160.                         if (event.page().list[i].code === 108) {
  161.                                 var iconCheck = event.page().list[i].parameters

  162. [0].match(/<actionIcon: (.*)>/i);
  163.                                 if (iconCheck) {
  164.                                         // create target object
  165.                                         return {'eventId':

  166. event._eventId,'iconId': Number(iconCheck[1])};
  167.                                         break;
  168.                                 };
  169.                         };
  170.                 };
  171.         };
  172.         return null;
  173. };


  174. //-----------------------------------------------------------------------------
  175. // Spriteset_Map

  176. var Galv_Spriteset_Map_createLowerLayer =

  177. Spriteset_Map.prototype.createLowerLayer;
  178. Spriteset_Map.prototype.createLowerLayer = function() {
  179.         Galv_Spriteset_Map_createLowerLayer.call(this);
  180.         this.createActionIconSprite();
  181. };

  182. Spriteset_Map.prototype.createActionIconSprite = function() {
  183.         this._actionIconSprite = new Sprite_ActionIcon();
  184.         this._tilemap.addChild(this._actionIconSprite);
  185. };


  186. //-----------------------------------------------------------------------------
  187. // Sprite_ActionIcon

  188. function Sprite_ActionIcon() {
  189.     this.initialize.apply(this, arguments);
  190. }

  191. Sprite_ActionIcon.prototype = Object.create(Sprite.prototype);
  192. Sprite_ActionIcon.prototype.constructor = Sprite_ActionIcon;

  193. Sprite_ActionIcon.prototype.initialize = function() {
  194.     Sprite.prototype.initialize.call(this);
  195.         $gamePlayer.actionIconTarget = $gamePlayer.actionIconTarget || {'eventId':

  196. 0, 'iconId': 0};
  197.         this._iconIndex = 0;
  198.         this.z = Galv.AI.z;
  199.         this.changeBitmap();
  200.         this._tileWidth = $gameMap.tileWidth();
  201.         this._tileHeight = $gameMap.tileHeight();
  202.         this._offsetX = -(Window_Base._iconWidth / 2);
  203.         this._offsetY = -38 + Galv.AI.y;
  204.         this.anchor.y = 1;
  205.         this._float = 0.1;
  206.         this.mod = 0.2;
  207.         Galv.AI.needRefresh = true;
  208. };

  209. Sprite_ActionIcon.prototype.changeBitmap = function() {
  210.         if ($gamePlayer.actionIconTarget.eventId <= 0) {
  211.                 this._iconIndex = 0;
  212.         } else {
  213.                 this._iconIndex = $gamePlayer.actionIconTarget.iconId;
  214.         };

  215.         var pw = Window_Base._iconWidth;
  216.     var ph = Window_Base._iconHeight;
  217.         var sx = this._iconIndex % 16 * pw;
  218.     var sy = Math.floor(this._iconIndex / 16) * ph;
  219.        
  220.         this.bitmap = new Bitmap(pw,ph);
  221.         if (this._iconIndex <= 0) return;
  222.     var bitmap = ImageManager.loadSystem('IconSet');
  223.     this.bitmap.blt(bitmap, sx, sy, pw, ph, 0, 0);
  224.        
  225.         Galv.AI.needRefresh = false;
  226. };

  227. Sprite_ActionIcon.prototype.initPopVars = function() {
  228.         this.scale.y = 0.1;
  229.         this.opacity = 0;
  230.         this.mod = 0.2;
  231.         this._float = 0.1;
  232. };

  233. if (Galv.AI.autoHide) {
  234.         Sprite_ActionIcon.prototype.updateOpacity = function() {
  235.                 if ($gameMap.isEventRunning()) {
  236.                         this.opacity -= 40;
  237.                 } else {
  238.                         this.opacity = $gameSystem.actionIndicatorVisible ?

  239. Galv.AI.opacity : 0;
  240.                 };
  241.         };
  242. } else {
  243.         Sprite_ActionIcon.prototype.updateOpacity = function() {
  244.                 this.opacity = $gameSystem.actionIndicatorVisible ?

  245. Galv.AI.opacity : 0;
  246.         };
  247. };

  248. Sprite_ActionIcon.prototype.update = function() {
  249.     Sprite.prototype.update.call(this);
  250.        
  251.         if (Galv.AI.needRefresh) Galv.AI.checkActionIcon();
  252.        
  253.         if ($gamePlayer.actionIconTarget.eventId != this._eventId) {
  254.                 this.initPopVars();
  255.                 this._eventId = $gamePlayer.actionIconTarget.eventId;
  256.         }
  257.        
  258.         if (this._iconIndex !== $gamePlayer.actionIconTarget.iconId)

  259. this.changeBitmap();
  260.         if (this._iconIndex <= 0) return;

  261.        
  262.         this.x = $gameMap.event($gamePlayer.actionIconTarget.eventId).screenX() +

  263. this._offsetX;
  264.         this.y = $gameMap.event($gamePlayer.actionIconTarget.eventId).screenY() +

  265. this._offsetY + this._float;

  266.         this.scale.y = Math.min(this.scale.y + 0.1,1);
  267.        
  268.         this.updateOpacity();

  269.         this._float += this.mod;
  270.         if (this._float < -0.1) {
  271.                 this.mod = Math.min(this.mod + 0.01,0.2);
  272.         } else if (this._float >= 0.1) {
  273.                 this.mod = Math.max(this.mod + -0.01,-0.2);
  274.         };

  275. };

  276. })();
复制代码

梦石
0
星屑
296
在线时间
78 小时
注册时间
2015-7-17
回帖
6
 楼主| 发表于 2023-4-6 17:07:29 | 显示全部楼层
求助
回复

使用道具 举报

梦石
0
星屑
7089
在线时间
722 小时
注册时间
2021-3-5
回帖
731
发表于 2023-4-6 19:20:13 | 显示全部楼层
根据楼主的需求来看,根本不适合使用这个插件
我建议楼主去使用MOG_EventIndicators
回复

使用道具 举报

梦石
0
星屑
296
在线时间
78 小时
注册时间
2015-7-17
回帖
6
 楼主| 发表于 2023-4-6 21:05:13 | 显示全部楼层
RyanYe 发表于 2023-4-6 19:20
根据楼主的需求来看,根本不适合使用这个插件
我建议楼主去使用MOG_EventIndicators ...

好的,感谢
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部