设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2117|回复: 2
打印 上一主题 下一主题

[已经解决] MOG的treasurepop问题

[复制链接]

Lv1.梦旅人

梦石
0
星屑
138
在线时间
304 小时
注册时间
2014-4-11
帖子
419
跳转到指定楼层
1
发表于 2016-9-24 13:37:42 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
这个脚本主要是一个得失物品的提示
用了这个脚本之后
用事件脚本直接写的得失物品不会显示出来 只有事件得失物品会显示

  1. var s=Math.floor(Math.random()*15)-1;
  2. var n=Math.floor(Math.random()*5)+1;
  3. $gameParty.gainItem($dataItems[s], n);
复制代码

↑这个写出来之后得失物品并不会监视到并显示出来

我想问一下这是为何
我并没有在原脚本里发现重写gainitem方法的语句
以下代码

  1. //=============================================================================
  2. // MOG_TreasurePopup.js
  3. //=============================================================================
  4. /*:
  5. * @plugindesc (v1.0) Apresenta o ícone e o nome do tesouro ganho.
  6. * @author Moghunter
  7. *
  8. * @param Duration
  9. * @desc Duração de apresentação do tesouro.
  10. * @default 15
  11. *
  12. * @param Fade Speed
  13. * @desc Velocidade de Fade.
  14. * @default 5
  15. *
  16. * @param X - Axis
  17. * @desc Posição X-Axis.
  18. * @default 0
  19. *
  20. * @param Y - Axis
  21. * @desc Posição Y-Axis.
  22. * @default -32
  23. *
  24. * @param Random Movement
  25. * @desc Movimento aleatório.
  26. * @default false
  27. *
  28. * @param X Speed
  29. * @desc Velocidade de movimento X-Axis.
  30. * @default 0
  31. *
  32. * @param Y Speed
  33. * @desc Velocidade de movimento Y-Axis.
  34. * @default 1
  35. *
  36. * @param Font Size
  37. * @desc Definição do tamanho da fonte.
  38. * @default 16
  39. *
  40. * @param Icon Scale
  41. * @desc Zoom do ícone de 0.10 a 3.00.
  42. * @default 0.60
  43. *
  44. * @param Treasure Space Y-Axis
  45. * @desc Espaço entre um tesouro e outro.
  46. * @default 20
  47. *
  48. * @param Zoom Effect
  49. * @desc Ativar efeito de zoom.
  50. * @default false
  51. *
  52. * @param Gold Popup
  53. * @desc Apresentar o dinheiro.
  54. * @default true
  55. *
  56. * @param Gold Icon Index
  57. * @desc Index do ícone do ouro na imagem de ícones.
  58. * @default 163
  59. *
  60. * @help  
  61. * =============================================================================
  62. * +++ MOG - Treasure Popup (v1.0) +++
  63. * By Moghunter
  64. * https://atelierrgss.wordpress.com/
  65. * =============================================================================
  66. * Apresenta o ícone e o nome do tesouro ganho.
  67. * =============================================================================
  68. * PLUGIN COMMAND
  69. * =============================================================================
  70. * Para ativar ou desativar o sistema use os comandos abaixo.
  71. *
  72. * hide_treasure_popup
  73. *
  74. * show_treasure_popup
  75. *
  76. */

  77. //=============================================================================
  78. // ** PLUGIN PARAMETERS
  79. //=============================================================================
  80.   var Imported = Imported || {};
  81.   Imported.MOG_TreasurePopup = true;
  82.   var Moghunter = Moghunter || {};

  83.    Moghunter.parameters = PluginManager.parameters('MOG_TreasurePopup');
  84.     Moghunter.trpopup_X = Number(Moghunter.parameters['X - Axis'] || 0);
  85.         Moghunter.trpopup_Y = Number(Moghunter.parameters['Y - Axis'] || 0);
  86.         Moghunter.trpopup_GoldVisible = String(Moghunter.parameters['Gold Popup'] || "true");
  87.         Moghunter.trpopup_Random = String(Moghunter.parameters['Random Movement'] || "false");
  88.     Moghunter.trpopup_SX = Number(Moghunter.parameters['X Speed'] || 0);
  89.         Moghunter.trpopup_SY = Number(Moghunter.parameters['Y Speed'] || 1);
  90.         Moghunter.trpopup_IconScale = Number(Moghunter.parameters['Icon Scale'] || 0.60);
  91.         Moghunter.trpopup_ItemSpace = Number(Moghunter.parameters['Treasure Space Y-Axis'] || 20);
  92.         Moghunter.trpopup_waitD = Number(Moghunter.parameters['Duration'] || 15);
  93.         Moghunter.trpopup_Zoom = String(Moghunter.parameters['Zoom Effect'] || "false");
  94.         Moghunter.trpopup_fadeSpeed = Number(Moghunter.parameters['Fade Speed'] || 5);
  95.     Moghunter.trpopup_goldIconIndex = Number(Moghunter.parameters['Gold Icon Index'] || 163);
  96.     Moghunter.trpopup_fontSize = Number(Moghunter.parameters['Font Size'] || 16);       
  97.        
  98. //=============================================================================
  99. // ** Game System
  100. //=============================================================================

  101. //==============================
  102. // * Initialize
  103. //==============================
  104. var _mog_treapopup_Gsys_initialize = Game_System.prototype.initialize;
  105. Game_System.prototype.initialize = function() {
  106.     _mog_treapopup_Gsys_initialize.call(this);
  107.         this._trspupData = [];
  108.         this._trspupSprData = null;
  109.         this._trspupVisible = true;
  110.         this._trspupMapID = 0;
  111. };       

  112. //=============================================================================
  113. // ** Scene Map
  114. //=============================================================================

  115. //==============================
  116. // * Terminate
  117. //==============================
  118. var _mog_treapopup_scMap_terminate = Scene_Map.prototype.terminate;
  119. Scene_Map.prototype.terminate = function() {
  120.     _mog_treapopup_scMap_terminate.call(this);
  121.         if (this._spriteset) {this._spriteset.recordTreasureData()};
  122. };

  123. //=============================================================================
  124. // ** Game Interpreter
  125. //=============================================================================

  126. //==============================
  127. // * Command 125
  128. //==============================
  129. var _mog_treaPopUP_gint_command125 = Game_Interpreter.prototype.command125;
  130. Game_Interpreter.prototype.command125 = function() {
  131.         _mog_treaPopUP_gint_command125.call(this);
  132.         if ((Moghunter.trpopup_GoldVisible) === "true") {
  133.          this.checkTreasurePopup(3);
  134.         };
  135.         return true;       
  136. };

  137. //==============================
  138. // * Command 126
  139. //==============================
  140. var _mog_treaPopUP_gint_command126 = Game_Interpreter.prototype.command126;
  141. Game_Interpreter.prototype.command126 = function() {
  142.     _mog_treaPopUP_gint_command126.call(this);
  143.     this.checkTreasurePopup(0);
  144.         return true;       
  145. };

  146. //==============================
  147. // * command 127
  148. //==============================
  149. var _mog_treaPopUP_gint_command127 = Game_Interpreter.prototype.command127;
  150. Game_Interpreter.prototype.command127 = function() {
  151.         _mog_treaPopUP_gint_command127.call(this);
  152.     this.checkTreasurePopup(1);
  153.         return true;
  154. };

  155. //==============================
  156. // * command 128
  157. //==============================
  158. var _mog_treaPopUP_gint_command128 = Game_Interpreter.prototype.command128;
  159. Game_Interpreter.prototype.command128 = function() {
  160.         _mog_treaPopUP_gint_command128.call(this);
  161.     this.checkTreasurePopup(2);
  162.         return true;
  163. };

  164. //==============================
  165. // * command 128
  166. //==============================
  167. Game_Interpreter.prototype.checkTreasurePopup = function(type) {
  168.         if ($gameSystem._trspupVisible) {
  169.                 if (type > 2) {
  170.                    var amount = this.operateValue(this._params[0], this._params[1], this._params[2]);
  171.                 } else {
  172.                    var amount = this.operateValue(this._params[1], this._params[2], this._params[3]);
  173.                 };
  174.                if (amount > 0 && SceneManager._scene.constructor.name === "Scene_Map") {
  175.                         for (i = 0; i < $gameMap.events().length; i++){
  176.                                 var eve = $gameMap.events()[i];
  177.                                 if (eve && (this._eventId === eve._eventId)) {
  178.                                         var x = eve.screenX();
  179.                                         var y = eve.screenY();
  180.                                         $gameSystem._trspupData.push([this.trPopupType(type),amount,x,y]);
  181.                                 };
  182.                         };
  183.            };
  184.         };
  185. };

  186. //==============================
  187. // * Tr popup Type
  188. //==============================
  189. Game_Interpreter.prototype.trPopupType = function(type) {
  190.         if (type === 0) {return $dataItems[this._params[0]]};
  191.         if (type === 1) {return $dataWeapons[this._params[0]]};
  192.         if (type === 2) {return $dataArmors[this._params[0]]};
  193.         return null;
  194. };

  195. //==============================
  196. // * PluginCommand
  197. //==============================
  198. var _alias_mog_theaPopUP_pluginCommand = Game_Interpreter.prototype.pluginCommand
  199. Game_Interpreter.prototype.pluginCommand = function(command, args) {
  200.         _alias_mog_theaPopUP_pluginCommand.call(this,command, args);
  201.         if (command === "show_treasure_popup")  {$gameSystem._trspupVisible = true};
  202.         if (command === "hide_treasure_popup")  {$gameSystem._trspupVisible = false};
  203.         return true;
  204. };

  205. //=============================================================================
  206. // ** Spriteset Map
  207. //=============================================================================

  208. //==============================
  209. // * create Upper Layer
  210. //==============================
  211. var _mog_treapopup_sprmap_createUpperLayer = Spriteset_Map.prototype.createUpperLayer;
  212. Spriteset_Map.prototype.createUpperLayer = function() {
  213.     _mog_treapopup_sprmap_createUpperLayer.call(this);
  214.         this.createTreasureField();
  215.         if ($gameSystem._trspupSprData && $gameSystem._trspupMapID === $gameMap._mapId) {
  216.                 this.loadTreasureIcons()
  217.         } else {
  218.                 $gameSystem._trspupData = [];
  219.                 $gameSystem._trspupSprData = null;               
  220.         };
  221.         $gameSystem._trspupMapID = $gameMap._mapId;
  222. };

  223. //==============================
  224. // * record Treasure Data
  225. //==============================
  226. Spriteset_Map.prototype.recordTreasureData = function() {
  227.      if (!this._treasureIcons || this._treasureIcons.length === 0) {return};
  228.          $gameSystem._trspupSprData = [];
  229.          for (i = 0; i < this._treasureIcons.length; i++){
  230.                  $gameSystem._trspupSprData[i] = {};
  231.                  $gameSystem._trspupSprData[i]._item = this._treasureIcons[i]._item;
  232.                  $gameSystem._trspupSprData[i]._amount = this._treasureIcons[i]._amount;
  233.                  $gameSystem._trspupSprData[i].x = this._treasureIcons[i].x;
  234.                  $gameSystem._trspupSprData[i].y = this._treasureIcons[i].y;
  235.                  $gameSystem._trspupSprData[i].opacity = this._treasureIcons[i].opacity;
  236.                  $gameSystem._trspupSprData[i].scale = this._treasureIcons[i].scale.x;
  237.                  $gameSystem._trspupSprData[i]._sx = this._treasureIcons[i]._sx;
  238.                  $gameSystem._trspupSprData[i]._sy = this._treasureIcons[i]._sy;
  239.                  $gameSystem._trspupSprData[i]._cx = this._treasureIcons[i]._cx;
  240.                  $gameSystem._trspupSprData[i]._cy = this._treasureIcons[i]._cy;
  241.                  $gameSystem._trspupSprData[i]._wait = this._treasureIcons[i]._wait;                 
  242.          };
  243. };

  244. //==============================
  245. // * create Treasure Field
  246. //==============================
  247. Spriteset_Map.prototype.createTreasureField = function() {
  248.         this._treasureIcons = [];
  249.     this._treasureField = new Sprite();
  250.         this.addChild(this._treasureField);
  251. };

  252. //==============================
  253. // * create Upper Layer
  254. //==============================
  255. var _mog_treapopup_sprmap_update = Spriteset_Map.prototype.update;
  256. Spriteset_Map.prototype.update = function() {
  257.     _mog_treapopup_sprmap_update.call(this);
  258.         if (this._treasureField) {this.updateTreasureIcons()};
  259. };

  260. //==============================
  261. // * load Treasure Icons
  262. //==============================
  263. Spriteset_Map.prototype.loadTreasureIcons = function() {
  264.         for (i = 0; i < $gameSystem._trspupSprData.length; i++){
  265.          this._treasureIcons.push(new TreasureIcons(null,$gameSystem._trspupSprData[i],i,$gameSystem._trspupSprData.length));
  266.              this._treasureField.addChild(this._treasureIcons[i]);
  267.         };
  268.         $gameSystem._trspupSprData = null;
  269. };

  270. //==============================
  271. // * refresh Treasure Icons
  272. //==============================
  273. Spriteset_Map.prototype.refreshTreasureIcons = function() {
  274.         for (i = 0; i < $gameSystem._trspupData.length; i++){
  275.         this._treasureIcons.push(new TreasureIcons($gameSystem._trspupData[i],null,i,$gameSystem._trspupData.length));
  276.                 this._treasureField.addChild(this._treasureIcons[this._treasureIcons.length - 1])
  277.         };
  278.         $gameSystem._trspupData = [];
  279. };

  280. //==============================
  281. // * need Refresh Treasure Icons
  282. //==============================
  283. Spriteset_Map.prototype.needRefreshTreasureIcons = function() {
  284.         if ($gameSystem._trspupData.length > 0) {return true};
  285.     return false;
  286. };

  287. //==============================
  288. // * create Treasure Icons
  289. //==============================
  290. Spriteset_Map.prototype.updateTreasureIcons = function() {
  291.      if (this.needRefreshTreasureIcons()) {this.refreshTreasureIcons()};
  292.          for (i = 0; i < this._treasureIcons.length; i++){
  293.                   if (this._treasureIcons[i].opacity === 0 && this._treasureIcons[i]._wait[1] <= 0) {
  294.                           this._treasureField.removeChild(this._treasureField[i]);
  295.                           this._treasureIcons.splice(i, 1);
  296.                   };
  297.          };
  298. };

  299. //=============================================================================
  300. // * Treasure Icons
  301. //=============================================================================
  302. function TreasureIcons() {
  303.     this.initialize.apply(this, arguments);
  304. };

  305. TreasureIcons.prototype = Object.create(Sprite.prototype);
  306. TreasureIcons.prototype.constructor = TreasureIcons;

  307. //==============================
  308. // * Initialize
  309. //==============================
  310. TreasureIcons.prototype.initialize = function(data,dataOld,fx,fmax) {
  311.     Sprite.prototype.initialize.call(this);       
  312.     this._fadeSpeed = Math.min(Math.max(Moghunter.trpopup_fadeSpeed,1),100);
  313.         this._waitR = Math.min(Math.max(Moghunter.trpopup_waitD,1),999);
  314.         this._zoomAn = String(Moghunter.trpopup_Zoom) === "true" ? true : false;
  315.         this._fx = fx;
  316.         this._fmax = fmax * this.waitD();
  317.     this.createName();
  318.         this.createIcon();
  319.     if (dataOld) {
  320.            this.setupOld(dataOld);
  321.         } else {
  322.            this.setupNew(data);
  323.     }
  324.         this.refreshIcon();
  325.         this.refreshName();
  326.         this.x = -this.screenX() + this._cx;
  327.         this.y = -this.screenY() + this._cy;       
  328. };

  329. //==============================
  330. // * SetupOld
  331. //==============================
  332. TreasureIcons.prototype.setupOld = function(data) {
  333.         this._item = data._item;
  334.         this._amount = data._amount;
  335.         this.x = data.x;
  336.         this.y = data.y;
  337.         this.scale.x = data.scale;
  338.         this.scale.y = data.scale;
  339.         this.opacity = data.opacity;
  340.         this._sx = data._sx;
  341.         this._sy = data._sy;
  342.         this._cx = data._cx;
  343.         this._cy = data._cy;       
  344.         this._wait = data._wait;
  345. };       


  346. //==============================
  347. // * wait D
  348. //==============================
  349. TreasureIcons.prototype.waitD = function() {
  350.         return this._waitR;
  351. };

  352. //==============================
  353. // * SetupNew
  354. //==============================
  355. TreasureIcons.prototype.setupNew = function(data) {
  356.         this._item = data[0];
  357.         this._amount = data[1];
  358.         var name = this._item ? this._item.name + " x " + this._amount : this._amount;
  359.         var wd = this._name.bitmap.measureTextWidth(name);
  360.         this._cx = data[2] - ((Window_Base._iconWidth + 12 + wd) / 2) + Moghunter.trpopup_X + this.screenX() ;
  361.         this._cy = data[3] - Window_Base._iconHeight + Moghunter.trpopup_Y + this.screenY();
  362.         this._cy -= (this._fx * Moghunter.trpopup_ItemSpace);
  363.         var iw = this._fx * this.waitD();
  364.         var iw2 = this.waitD() + (this._fmax - iw);
  365.         this._wait = [15,iw2];
  366.         this.opacity = 0;
  367.         if (String(Moghunter.trpopup_Random) === "true") {
  368.                 var d = Math.randomInt(2);
  369.                 var sx = (Math.random() * this.sxi() + this.sxi());
  370.                 this._sx = d === 0 ? sx : -sx
  371.                 this._sy = -(Math.random() + this.syi());
  372.         } else {
  373.                 this._sx = this.sxi()
  374.                 this._sy = -this.syi();               
  375.         };
  376. };       

  377. //==============================
  378. // * sxi
  379. //==============================
  380. TreasureIcons.prototype.sxi = function() {
  381.         return Moghunter.trpopup_SX;
  382. };

  383. //==============================
  384. // * syi
  385. //==============================
  386. TreasureIcons.prototype.syi = function() {
  387.         return Moghunter.trpopup_SY;
  388. };

  389. //==============================
  390. // * createIcon
  391. //==============================
  392. TreasureIcons.prototype.createIcon = function() {
  393.         this._iconImg = ImageManager.loadSystem("IconSet");
  394.     this._icon = new Sprite(this._iconImg);
  395.         this._icon.scale.x = Math.min(Math.max(Moghunter.trpopup_IconScale,0.10),3.00);;
  396.         this._icon.scale.y = this._icon.scale.x;
  397.         this._icon.anchor.x = 0.5;
  398.         this._icon.anchor.y = 0.5;
  399.         this._icon.x = Window_Base._iconWidth / 2;
  400.         this._icon.y = Window_Base._iconHeight / 2;
  401.         this.addChild(this._icon);
  402. };

  403. //==============================
  404. // * refresh Icon
  405. //==============================
  406. TreasureIcons.prototype.refreshIcon = function() {
  407.         var w = Window_Base._iconWidth;
  408.         var h = Window_Base._iconHeight;
  409.         var iconindex = this._item ? this._item.iconIndex : Moghunter.trpopup_goldIconIndex;
  410.         var sx = iconindex % 16 * w;
  411.         var sy = Math.floor(iconindex / 16) * h;
  412.     this._icon.setFrame(sx,sy,w,h);       
  413. };

  414. //==============================
  415. // * create Name
  416. //==============================
  417. TreasureIcons.prototype.createName = function() {
  418.         this._name = new Sprite(new Bitmap(150,32));
  419.         this._name.x = Window_Base._iconWidth + 4;
  420.         this._name.bitmap.fontSize = Moghunter.trpopup_fontSize;
  421.         this.addChild(this._name);
  422. };

  423. //==============================
  424. // * refresh Name
  425. //==============================
  426. TreasureIcons.prototype.refreshName = function() {
  427.         this._name.bitmap.clear();
  428.         var name = this._item ? this._item.name + " x " + this._amount : this._amount;
  429.         this._name.bitmap.drawText(name,0,0,145,32);
  430. };

  431. //==============================
  432. // * screen Y
  433. //==============================
  434. TreasureIcons.prototype.screenX = function() {
  435.         return $gameMap.displayX() * $gameMap.tileWidth();
  436. };

  437. //==============================
  438. // * screen Y
  439. //==============================
  440. TreasureIcons.prototype.screenY = function() {
  441.         return $gameMap.displayY() * $gameMap.tileHeight();
  442. };

  443. //==============================
  444. // * Update Position
  445. //==============================
  446. TreasureIcons.prototype.updatePosition = function() {
  447.         this.x = -this.screenX() + this._cx;
  448.         this.y = -this.screenY() + this._cy;
  449. };

  450. //==============================
  451. // * Update Movement
  452. //==============================
  453. TreasureIcons.prototype.updateMovement = function() {
  454.         this._cx += this._sx;
  455.         this._cy += this._sy;
  456. };

  457. //==============================
  458. // * Update Other
  459. //==============================
  460. TreasureIcons.prototype.updateOther = function() {
  461.     this.opacity -= this._fadeSpeed;
  462.         if (this._zoomAn) {
  463.             this.scale.x += 0.01;
  464.             this.scale.y = this.scale.x
  465.         };
  466. };

  467. //==============================
  468. // * Update
  469. //==============================
  470. TreasureIcons.prototype.update = function() {
  471.     Sprite.prototype.update.call(this);         
  472.         if (this._wait[0] > 0) {this._wait[0]--;
  473.                 this.opacity += 17;
  474.                 this.updatePosition();
  475.                 if (this._wait[1] <= 0) {this.opacity += 255;this._wait[0] = 0};
  476.             return
  477.         };
  478.         if (this._wait[1] > 0) {
  479.                 this._wait[1]--;
  480.                 this.updatePosition();
  481.             return
  482.         };
  483.         this.updateMovement();
  484.     this.updateOther();
  485.         this.updatePosition();
  486. };
复制代码
人生是一场漫长的自杀。

Lv1.梦旅人

梦石
0
星屑
55
在线时间
407 小时
注册时间
2011-4-10
帖子
359
2
发表于 2016-9-24 20:39:17 | 只看该作者
我记得脚本控制得失物品本来就没有提示的,通过事件页里面的指令得失物品才有提示。

点评

嗯……我就是想知道原因,然后看看如何书写可以显示出来  发表于 2016-9-25 09:17
回复 支持 反对

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-29 17:08

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表