查看: 9890|回复: 15

[已经解决] 关于物品得失提示插件

[复制链接]
梦石
0
星屑
3167
在线时间
1078 小时
注册时间
2015-1-13
回帖
316

开拓者

发表于 2015-12-17 02:11:16 | 显示全部楼层 |阅读模式

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

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

×
自带的TinyGetInfoWnd插件虽然提示得到的物品,但是不能提示金币的得失,功能也比较单一;
yanatsuki的CommonPopups插件虽然能做物品得失,但是存在着升级以及能力加成一并提示、升级语句出错、失去物品、遗忘技能有的提示有的不提示之类的问题,而且无法设置音效提示,画面也不暂停;

总之,感觉都没 taroxd 大写的VA物品得失提示插件好用……!(参考https://rpg.blue/forum.php?mod=viewthread&tid=372181)
@taroxd 大有空把这个脚本移植到MV来吗……

…あたしは天

梦石
0
星屑
2311
在线时间
4033 小时
注册时间
2010-10-4
回帖
10548

开拓者贵宾

发表于 2015-12-17 06:31:10 | 显示全部楼层
本帖最后由 taroxd 于 2015-12-17 06:34 编辑

懒癌发作中 = =  要移植的话,等我自己用得到这个脚本的时候吧 (逃

其实这脚本就是偷懒用的,完全可以用事件的显示文字做
回复

使用道具 举报

梦石
0
星屑
50
在线时间
40 小时
注册时间
2014-12-22
回帖
11
发表于 2015-12-17 10:25:12 | 显示全部楼层
taroxd 发表于 2015-12-17 06:31
懒癌发作中 = =  要移植的话,等我自己用得到这个脚本的时候吧 (逃

其实这脚本就是偷懒用的,完全可以用 ...

确实很多东西都不需要脚本。但就是懒得用事件
回复

使用道具 举报

梦石
0
星屑
1232
在线时间
1017 小时
注册时间
2011-4-30
回帖
1464
发表于 2015-12-17 12:26:45 | 显示全部楼层
本帖最后由 汪汪 于 2015-12-17 12:42 编辑

求教正则表达式!!!

  1. Taroxd ={}

  2. Taroxd.GainMessage={

  3.   // --- 设置 ---

  4.   // 信息格式

  5.   // 转义符:
  6.   // name    代表物品名称 / 金钱单位
  7.   // value   代表获得 / 失去的物品 / 金钱数量
  8.   // icon    绘制物品 / 金钱的图标
  9.   // action  代表“获得”或者“失去”。可在下面修改。
  10.   // 支持“显示文字”中的所有转义符。
  11.   //然后我不会 正则表达式什么的......所以做成了数组......
  12.   ITEM_FORMAT  : [ "action","了","name"," * ", "value"],
  13.   GOLD_FORMAT  : ["action", "了", "value" ,"name"],
  14.   ACTION_GAIN  : '获得',
  15.   ACTION_LOSE  : '失去',
  16.   GOLD_ICON_INDEX : 361   ,        // 金钱图标的索引

  17.   BACKGROUND   : 1       ,         // 窗口背景(0/1/2)
  18.   POSITION     : 1      ,          // 显示位置(0/1/2)

  19.   // 音效(不需要的话可以直接删去对应的行)
  20.   GAIN_GOLD_SE :{"name":"Shop2","pan":0,"pitch":100,"volume":90},    // 获得金钱
  21.   LOSE_GOLD_SE :{"name":"Shop2","pan":0,"pitch":100,"volume":90} ,   // 失去金钱
  22.   GAIN_ITEM_SE :{"name":"Shop2","pan":0,"pitch":100,"volume":90} ,      // 获得物品
  23.   LOSE_ITEM_SE :{"name":"Shop2","pan":0,"pitch":100,"volume":90},   // 失去物品
  24.   
  25. }
  26.   // 设置功能是否启用。
  27.   // true:启用。
  28.   // false:不启用。
  29.   // $game_switches[开关ID]: 对应开关打开时。
  30.   Taroxd.GainMessage.enabled = true;

  31.   // --- 设置结束 ---

  32.   // 显示提示信息。获得金钱时将 item 设为 nil。
  33.   Taroxd.GainMessage.show = function(value, item){
  34.           if (this.enabled){
  35.             this.item = item
  36.             this.value = value
  37.             $gameMessage.setBackground(this.BACKGROUND)
  38.             $gameMessage.setPositionType(this.POSITION)
  39.             var message = this.message()
  40.             $gameMessage.add(message)
  41.             this.play_se()
  42.           }
  43.   }


  44.   // 获取提示的消息
  45.   Taroxd.GainMessage.message =function () {
  46.                 var nr = {}
  47.                   if (this.item){
  48.               var format = this.ITEM_FORMAT
  49.               nr.icon=   '\\I['  +  this.item.iconIndex + "]"
  50.               nr.name = this.item.name
  51.                   }else{
  52.               var format = this.GOLD_FORMAT
  53.               nr.icon ="\\I[" + this.GOLD_ICON_INDEX + "]"
  54.               nr.name = TextManager.currencyUnit
  55.                   }
  56.             nr.action =  this.value > 0 ? this.ACTION_GAIN : this.ACTION_LOSE   
  57.           nr.value =Math.abs(this.value)
  58.           var message =""
  59.           for (var i=0 ;i< format.length ;i++ ){
  60.                   if (  format[i]  in  nr ){
  61.                       message += nr[format[i]]
  62.                   }else{
  63.                           message += format[i]
  64.                   }
  65.           }
  66.           
  67.           return message
  68.   }


  69.   Taroxd.GainMessage.play_se =function ( ) {
  70.                 var sem =""
  71.                   if (this.value>0 ){
  72.                           sem +="GAIN_"
  73.                   }else {
  74.                           sem +="LOSE_"
  75.                   }
  76.                   if(this.item){
  77.                           sem +="ITEM_"
  78.                   }else{
  79.                           sem +="GOLD_"
  80.                   }
  81.                   sem += "SE"

  82.                   if (sem in this){
  83.                         AudioManager.playSe(this[sem])
  84.                   }
  85.           return
  86.   }


  87. // Change Gold 改变金钱
  88. Game_Interpreter.prototype.command125 = function() {
  89.     var value = this.operateValue(this._params[0], this._params[1], this._params[2]);
  90.     $gameParty.gainGold(value);
  91.     Taroxd.GainMessage.show( value, false)
  92.     return true;
  93. };

  94. // Change Items 改变物品
  95. Game_Interpreter.prototype.command126 = function() {
  96.     var value = this.operateValue(this._params[1], this._params[2], this._params[3]);
  97.     $gameParty.gainItem($dataItems[this._params[0]], value);
  98.     Taroxd.GainMessage.show( value, $dataItems[this._params[0]])
  99.     return true;
  100. };

  101. // Change Weapons 改变武器
  102. Game_Interpreter.prototype.command127 = function() {
  103.     var value = this.operateValue(this._params[1], this._params[2], this._params[3]);
  104.     $gameParty.gainItem($dataWeapons[this._params[0]], value, this._params[4]);
  105.     Taroxd.GainMessage.show( value, $dataWeapons[this._params[0]])
  106.     return true;
  107. };

  108. // Change Armors 改变防具
  109. Game_Interpreter.prototype.command128 = function() {
  110.     var value = this.operateValue(this._params[1], this._params[2], this._params[3]);
  111.     $gameParty.gainItem($dataArmors[this._params[0]], value, this._params[4]);
  112.     Taroxd.GainMessage.show( value, $dataArmors[this._params[0]])
  113.     return true;
  114. };

  115.          





复制代码
额.....这个不算侵权吧....

点评

MIT License,不算侵权  发表于 2015-12-17 15:19

评分

参与人数 1梦石 +1 收起 理由
余烬之中 + 1 认可答案

查看全部评分

回复 1 0

使用道具 举报

梦石
0
星屑
3167
在线时间
1078 小时
注册时间
2015-1-13
回帖
316

开拓者

 楼主| 发表于 2015-12-17 12:49:35 | 显示全部楼层
taroxd 发表于 2015-12-17 06:31
懒癌发作中 = =  要移植的话,等我自己用得到这个脚本的时候吧 (逃

其实这脚本就是偷懒用的,完全可以用 ...

4楼那个……
回复

使用道具 举报

梦石
0
星屑
1232
在线时间
1017 小时
注册时间
2011-4-30
回帖
1464
发表于 2015-12-17 13:47:10 | 显示全部楼层
本帖最后由 汪汪 于 2015-12-19 16:35 编辑
  1. Taroxd ={}

  2. Taroxd.GainMessage={

  3.   // --- 设置 ---

  4.   // 信息格式

  5.   // 转义符:
  6.   // name    代表物品名称 / 金钱单位
  7.   // value   代表获得 / 失去的物品 / 金钱数量
  8.   // icon    绘制物品 / 金钱的图标
  9.   // action  代表“获得”或者“失去”。可在下面修改。
  10.   // 支持“显示文字”中的所有转义符。
  11.   //然后我不会 正则表达式什么的......所以做成了数组......  替换见下边 nr 那里
  12.   
  13.   ITEM_FORMAT  : [ "action","了","name"," * ", "value"],
  14.   GOLD_FORMAT  : ["action", "了", "value" ,"name"],
  15.   ACTION_GAIN  : '获得',
  16.   ACTION_LOSE  : '失去',
  17.   GOLD_ICON_INDEX : 361,        // 金钱图标的索引
  18.   
  19.   BACKGROUND   : 1,         // 窗口背景(0/1/2)
  20.   POSITION     : 1,          // 显示位置(0/1/2)

  21.   // 音效(不需要的话可以直接删去对应的行)
  22.   // 必须是这样的格式 {"name":"Shop2","pan":0,"pitch":100,"volume":90}
  23.   // name se音效名  , pan 移动(左右声道?) , pitch' 音调  volume 音量
  24.   GAIN_GOLD_SE :{"name":"Shop2","pan":0,"pitch":100,"volume":90},    // 获得金钱
  25.   LOSE_GOLD_SE :{"name":"Shop2","pan":0,"pitch":100,"volume":90} ,   // 失去金钱
  26.   GAIN_ITEM_SE :{"name":"Shop2","pan":0,"pitch":100,"volume":90} ,      // 获得物品
  27.   LOSE_ITEM_SE :{"name":"Shop2","pan":0,"pitch":100,"volume":90},   // 失去物品
  28.   
  29. }
  30.   // 设置功能是否启用。
  31.   // true:启用。
  32.   // false:不启用。
  33.   // $game_switches[开关ID]: 对应开关打开时。
  34.   Taroxd.GainMessage.enabled = function () {
  35.         //  这里的true 可以改成其他判断 ,比如 变量值啊,开关值啊什么
  36.         //  $gameVariables.value(id) 变量
  37.         //  $gameSwitches.value(id) 开关
  38.           return true;
  39.   }

  40.   // --- 设置结束 ---

  41.   // 显示提示信息。获得金钱时将 item 设为 nil。
  42.   Taroxd.GainMessage.show = function(value, item){
  43.           if (this.enabled()){
  44.             this.item = item
  45.             this.value = value
  46.             $gameMessage.setBackground(this.BACKGROUND)
  47.             $gameMessage.setPositionType(this.POSITION)
  48.             var message = this.message()
  49.             $gameMessage.add(message)
  50.             this.play_se()
  51.           }
  52.   }

  53.     //显示金钱
  54.         Taroxd.GainMessage.showGold = function(amount) {
  55.                 //实际改变数目
  56.             var value = ($gameParty.gold() + amount).clamp(0, $gameParty.maxGold()) - $gameParty.gold()
  57.             //显示
  58.             Taroxd.GainMessage.show( value, false)
  59.         };

  60.     //显示物品
  61.         Taroxd.GainMessage.showItem = function(item, amount, includeEquip) {
  62.             var container = $gameParty.itemContainer(item);
  63.             if (container) {
  64.                     //最后的数目
  65.                 var lastNumber = $gameParty.numItems(item);
  66.                         //添加后的数目
  67.                 var newNumber = lastNumber + amount;
  68.                 //实际改变数目
  69.                 var value =  newNumber.clamp(0, $gameParty.maxItems(item)) - lastNumber
  70.                 //如果包含装备 并且 添加后小于0(需要卸下装备)
  71.                 if (includeEquip && newNumber < 0) {
  72.                             $gameParty.members().forEach(function(actor) {
  73.                                     for ( var i =0 ; i<actor.equips().length;i++){
  74.                                             if(actor.equips()[i] == item){
  75.                                                     value--
  76.                                             }
  77.                                     }
  78.                             });
  79.                 }
  80.                 //显示信息
  81.                 Taroxd.GainMessage.show(value,item)
  82.             }
  83.         };









  84.   // 获取提示的消息
  85.   Taroxd.GainMessage.message =function () {
  86.           //在上边的 转义符 转换成的 内容
  87.                 var nr = {}
  88.                
  89.                   if (this.item){
  90.                   // format 设置为 ITEM_FORMAT
  91.               var format = this.ITEM_FORMAT
  92.              
  93.               //  icon 转换为 物品图标
  94.               nr.icon=   '\\I['  +  this.item.iconIndex + "]"
  95.               // name 转换为 物品名
  96.               nr.name = this.item.name
  97.                   }else{
  98.                   // format 设置为  GOLD_FORMAT
  99.               var format = this.GOLD_FORMAT

  100.               //  icon 转换为 GOLD_ICON_INDEX 对应图标
  101.               nr.icon ="\\I[" + this.GOLD_ICON_INDEX + "]"
  102.               // name 转换为  系统默认货币名
  103.               nr.name = TextManager.currencyUnit
  104.                   }
  105.           // action 转换为  (  大于0 ACTION_GAIN  的内容,小于0 ACTION_LOSE 的内容)
  106.             nr.action =  this.value > 0 ? this.ACTION_GAIN : this.ACTION_LOSE   
  107.             // value 转换为  value的绝对值
  108.           nr.value =Math.abs(this.value)
  109.           //生成信息
  110.           var message =""
  111.           //在 format (数组)里循环,获取数组内的一个个内容
  112.           for (var i=0 ;i< format.length ;i++ ){
  113.                   //如果 这个内容 在  nr里 (比如 内容为"icon",那么就是看 nr.icon (即nr["icon"])是否存在)
  114.                   if (  format[i]  in  nr ){
  115.                           //信息添加  nr[内容] ( 比如 内容为"icon" ,那么就添加 nr.icon (即nr["icon"]))
  116.                       message += nr[format[i]]
  117.                   }else{
  118.                           //信息添加  内容  ( 比如  内容为"了" ,而 nr["了"] (nr.了)不存在 ,那么就添加 "了"  )
  119.                           message += format[i]
  120.                   }
  121.           }
  122.         //返回 信息
  123.           return message
  124.   }

  125.   //播放se
  126.   Taroxd.GainMessage.play_se =function ( ) {
  127.             //通过一系列判断
  128.                 var sem =""
  129.                   if (this.value>0 ){
  130.                           sem +="GAIN_"
  131.                   }else {
  132.                           sem +="LOSE_"
  133.                   }
  134.                   if(this.item){
  135.                           sem +="ITEM_"
  136.                   }else{
  137.                           sem +="GOLD_"
  138.                   }
  139.                   sem += "SE"
  140.         //把sem 变成  GAIN_GOLD_SE LOSE_GOLD_SE  GAIN_ITEM_SE  LOSE_ITEM_SE ,
  141.         //如果 sem 在 this 里面 ( 见 音效(不需要的话可以直接删去对应的行)  下面那些  )
  142.                   if (sem in this){
  143.                           //播放 sem 对应的 se  (注意 ,se 是一个实例,需要有name,)
  144.                         AudioManager.playSe(this[sem])
  145.                   }
  146.           return
  147.   }


  148. // Change Gold 改变金钱
  149. Game_Interpreter.prototype.command125 = function() {
  150.     var value = this.operateValue(this._params[0], this._params[1], this._params[2]);
  151.     Taroxd.GainMessage.showGold(value)  //添加
  152.     $gameParty.gainGold(value);
  153.     return true;
  154. };

  155. // Change Items 改变物品
  156. Game_Interpreter.prototype.command126 = function() {
  157.     var value = this.operateValue(this._params[1], this._params[2], this._params[3]);
  158.     Taroxd.GainMessage.showItem($dataItems[this._params[0]], value)//添加
  159.     $gameParty.gainItem($dataItems[this._params[0]], value);
  160.     return true;
  161. };

  162. // Change Weapons 改变武器
  163. Game_Interpreter.prototype.command127 = function() {
  164.     var value = this.operateValue(this._params[1], this._params[2], this._params[3]);
  165.     Taroxd.GainMessage.showItem($dataWeapons[this._params[0]], value, this._params[4])//添加
  166.     $gameParty.gainItem($dataWeapons[this._params[0]], value, this._params[4]);

  167.     return true;
  168. };

  169. // Change Armors 改变防具
  170. Game_Interpreter.prototype.command128 = function() {
  171.     var value = this.operateValue(this._params[1], this._params[2], this._params[3]);
  172.     Taroxd.GainMessage.showItem($dataArmors[this._params[0]], value, this._params[4])//添加
  173.     $gameParty.gainItem($dataArmors[this._params[0]], value, this._params[4]);
  174.     return true;
  175. };
  176.    
复制代码

点评

抱走了。  发表于 2016-2-2 18:50
回复

使用道具 举报

梦石
0
星屑
3167
在线时间
1078 小时
注册时间
2015-1-13
回帖
316

开拓者

 楼主| 发表于 2015-12-17 14:03:35 | 显示全部楼层
汪汪 发表于 2015-12-17 13:47
上面那个不支持
2. 弹出的提示为实际得失的值。也就是说,如果某物品只持有两个,但事件指令要减少三个的 ...

是的,以前做的时候就是做成了实际得失的值。
感谢,回去后试试……
回复

使用道具 举报

…あたしは天

梦石
0
星屑
2311
在线时间
4033 小时
注册时间
2010-10-4
回帖
10548

开拓者贵宾

发表于 2015-12-17 15:21:41 | 显示全部楼层
汪汪 发表于 2015-12-17 12:26
求教正则表达式!!!额.....这个不算侵权吧....

我几乎没用正则表达式啊= =

就是单纯地把 \name 替换成名字,没用到什么正则表达式…… 用到的那一句也只是偷懒用的...

点评

好吧..反正我是对这种完全看不懂也搞不清楚效果....  发表于 2015-12-17 16:09
回复

使用道具 举报

梦石
0
星屑
3167
在线时间
1078 小时
注册时间
2015-1-13
回帖
316

开拓者

 楼主| 发表于 2015-12-18 01:46:14 | 显示全部楼层
汪汪 发表于 2015-12-17 13:47
上面那个不支持
2. 弹出的提示为实际得失的值。也就是说,如果某物品只持有两个,但事件指令要减少三个的 ...

唔,主要功能是实现了,但是奇怪的是……这边的句子显示是乱码,变成了 “方块方块方块 剁头斧*1” 了……

这个是哪里我没设置对么?以及,方不方便把一些参数设置成可配置的?比如获得音效之类……

点评

乱码……看看脚本的格式是不是什么utf8?音效直接在音效那里改名字就好。  发表于 2015-12-18 07:32
回复

使用道具 举报

梦石
0
星屑
3167
在线时间
1078 小时
注册时间
2015-1-13
回帖
316

开拓者

 楼主| 发表于 2015-12-19 14:44:42 | 显示全部楼层
本帖最后由 fyqinpku 于 2015-12-19 14:51 编辑
汪汪 发表于 2015-12-17 13:47
上面那个不支持
2. 弹出的提示为实际得失的值。也就是说,如果某物品只持有两个,但事件指令要减少三个的 ...

无标题.png
像这样。没有刻意去转什么utf8……都是直接复制用的,这样会出问题吗


顺便,还有其他的问题,游戏初始时会把所有数据库里的角色身上的装备全“得到”一次(尽管大部分人没有入队),进入标题画面时就开始听到大量的叮叮叮提示声,点击开始游戏后就慢慢刷出提示框来了。

你们用的时候没这个问题吗?@汪汪  
@taroxd  

点评

如果是文本文档,另存为时有选择编码的部分,选择utf8  发表于 2015-12-21 12:06
怎么转成utf-8?  发表于 2015-12-21 09:26
见6楼  发表于 2015-12-19 16:36
额,问题2的话.......我再改改  发表于 2015-12-19 15:29
我的意思是.....一定要用 utf-8...  发表于 2015-12-19 15:28
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部