查看: 9697|回复: 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
星屑
2308
在线时间
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 编辑

[pre lang="JavaScript"]Taroxd ={}

Taroxd.GainMessage={

  // --- 设置 ---

  // 信息格式

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

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

  // --- 设置结束 ---

  // 显示提示信息。获得金钱时将 item 设为 nil。
  Taroxd.GainMessage.show = function(value, item){
          if (this.enabled()){
            this.item = item
            this.value = value
            $gameMessage.setBackground(this.BACKGROUND)
            $gameMessage.setPositionType(this.POSITION)
            var message = this.message()
            $gameMessage.add(message)
            this.play_se()
          }
  }

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

    //显示物品
        Taroxd.GainMessage.showItem = function(item, amount, includeEquip) {
            var container = $gameParty.itemContainer(item);
            if (container) {
                    //最后的数目
                var lastNumber = $gameParty.numItems(item);
                        //添加后的数目
                var newNumber = lastNumber + amount;
                //实际改变数目
                var value =  newNumber.clamp(0, $gameParty.maxItems(item)) - lastNumber
                //如果包含装备 并且 添加后小于0(需要卸下装备)
                if (includeEquip && newNumber < 0) {
                            $gameParty.members().forEach(function(actor) {
                                    for ( var i =0 ; i<actor.equips().length;i++){
                                            if(actor.equips() == item){
                                                    value--
                                            }
                                    }
                            });
                }
                //显示信息
                Taroxd.GainMessage.show(value,item)
            }
        };









  // 获取提示的消息
  Taroxd.GainMessage.message =function () {
          //在上边的 转义符 转换成的 内容
                var nr = {}
               
                  if (this.item){
                  // format 设置为 ITEM_FORMAT
              var format = this.ITEM_FORMAT
             
              //  icon 转换为 物品图标
              nr.icon=   '\\I['  +  this.item.iconIndex + "]"
              // name 转换为 物品名
              nr.name = this.item.name
                  }else{
                  // format 设置为  GOLD_FORMAT
              var format = this.GOLD_FORMAT

              //  icon 转换为 GOLD_ICON_INDEX 对应图标
              nr.icon ="\\I[" + this.GOLD_ICON_INDEX + "]"
              // name 转换为  系统默认货币名
              nr.name = TextManager.currencyUnit
                  }
          // action 转换为  (  大于0 ACTION_GAIN  的内容,小于0 ACTION_LOSE 的内容)
            nr.action =  this.value > 0 ? this.ACTION_GAIN : this.ACTION_LOSE   
            // value 转换为  value的绝对值
          nr.value =Math.abs(this.value)
          //生成信息
          var message =""
          //在 format (数组)里循环,获取数组内的一个个内容
          for (var i=0 ;i< format.length ;i++ ){
                  //如果 这个内容 在  nr里 (比如 内容为"icon",那么就是看 nr.icon (即nr["icon"])是否存在)
                  if (  format  in  nr ){
                          //信息添加  nr[内容] ( 比如 内容为"icon" ,那么就添加 nr.icon (即nr["icon"]))
                      message += nr[format]
                  }else{
                          //信息添加  内容  ( 比如  内容为"了" ,而 nr["了"] (nr.了)不存在 ,那么就添加 "了"  )
                          message += format
                  }
          }
        //返回 信息
          return message
  }

  //播放se
  Taroxd.GainMessage.play_se =function ( ) {
            //通过一系列判断
                var sem =""
                  if (this.value>0 ){
                          sem +="GAIN_"
                  }else {
                          sem +="LOSE_"
                  }
                  if(this.item){
                          sem +="ITEM_"
                  }else{
                          sem +="GOLD_"
                  }
                  sem += "SE"
        //把sem 变成  GAIN_GOLD_SE LOSE_GOLD_SE  GAIN_ITEM_SE  LOSE_ITEM_SE ,
        //如果 sem 在 this 里面 ( 见 音效(不需要的话可以直接删去对应的行)  下面那些  )
                  if (sem in this){
                          //播放 sem 对应的 se  (注意 ,se 是一个实例,需要有name,)
                        AudioManager.playSe(this[sem])
                  }
          return
  }


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

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

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

    return true;
};

// Change Armors 改变防具
Game_Interpreter.prototype.command128 = function() {
    var value = this.operateValue(this._params[1], this._params[2], this._params[3]);
    Taroxd.GainMessage.showItem($dataArmors[this._params[0]], value, this._params[4])//添加
    $gameParty.gainItem($dataArmors[this._params[0]], value, this._params[4]);
    return true;
};
   [/pre]

点评

抱走了。  发表于 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
星屑
2308
在线时间
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.

在本版发帖返回顶部