查看: 3026|回复: 1

[已经过期] 求大神帮改下脚本(简单脚本)

[复制链接]
梦石
0
星屑
50
在线时间
85 小时
注册时间
2015-7-29
回帖
69
发表于 2016-6-2 13:06:30 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 余烬之中 于 2016-8-3 10:13 编辑
  1. Taroxd ={}

  2. Taroxd.GainMessage={

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

  4.   // 信息格式

  5.   // 转义符:
  6.   // name    代表物品名称 / 金钱单位
  7.   // value   代表获得 / 失去的物品 / 金钱数量
  8.   // icon    绘制物品 / 金钱的图标
  9.   // action  代表“获得”或者“失去”。可在下面修改。
  10.   // 支持“显示文字”中的所有转义符。
  11.   //然后我不会 正则表达式什么的......所以做成了数组......  替换见下边 nr 那里

  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.   // 必须是这样的格式 {"name":"Shop2","pan":0,"pitch":100,"volume":90}
  21.   // name se音效名  , pan 移动(左右声道?) , pitch' 音调  volume 音量
  22.   GAIN_GOLD_SE :{"name":"Shop2","pan":0,"pitch":100,"volume":90},    // 获得金钱
  23.   LOSE_GOLD_SE :{"name":"Shop2","pan":0,"pitch":100,"volume":90} ,   // 失去金钱
  24.   GAIN_ITEM_SE :{"name":"Shop2","pan":0,"pitch":100,"volume":90} ,      // 获得物品
  25.   LOSE_ITEM_SE :{"name":"Shop2","pan":0,"pitch":100,"volume":90},   // 失去物品

  26. }
  27.   // 设置功能是否启用。
  28.   // true:启用。
  29.   // false:不启用。
  30.   // $game_switches[开关ID]: 对应开关打开时。
  31.   Taroxd.GainMessage.enabled = function () {
  32.         //  这里的true 可以改成其他判断 ,比如 变量值啊,开关值啊什么
  33.         //  $gameVariables.value(id) 变量
  34.         //  $gameSwitches.value(id) 开关
  35.           return true;
  36.   }

  37.   // --- 设置结束 ---

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

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

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









  81.   // 获取提示的消息
  82.   Taroxd.GainMessage.message =function () {
  83.           //在上边的 转义符 转换成的 内容
  84.                 var nr = {}

  85.                   if (this.item){
  86.                   // format 设置为 ITEM_FORMAT
  87.               var format = this.ITEM_FORMAT

  88.               //  icon 转换为 物品图标
  89.               nr.icon=   '\\I['  +  this.item.iconIndex + "]"
  90.               // name 转换为 物品名
  91.               nr.name = this.item.name
  92.                   }else{
  93.                   // format 设置为  GOLD_FORMAT
  94.               var format = this.GOLD_FORMAT

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

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


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

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

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

  162.     return true;
  163. };

  164. // Change Armors 改变防具
  165. Game_Interpreter.prototype.command128 = function() {
  166.     var value = this.operateValue(this._params[1], this._params[2], this._params[3]);
  167.     Taroxd.GainMessage.showItem($dataArmors[this._params[0]], value, this._params[4])//添加
  168.     $gameParty.gainItem($dataArmors[this._params[0]], value, this._params[4]);
  169.     return true;
  170. };
复制代码
这个是物品得失提示,但是如果怪物掉落物品过多,就显示不全!像这样,其实后面还有东西,但是显示不出来!
QQ图片20160602130546.jpg
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

在本版发帖返回顶部