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

Project1

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

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

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
85 小时
注册时间
2015-7-29
帖子
91
跳转到指定楼层
1
发表于 2016-6-2 13:06:30 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 余烬之中 于 2016-8-3 10:13 编辑

JAVASCRIPT 代码复制
  1. Taroxd ={}
  2.  
  3. Taroxd.GainMessage={
  4.  
  5.   // --- 设置 ---
  6.  
  7.   // 信息格式
  8.  
  9.   // 转义符:
  10.   // name    代表物品名称 / 金钱单位
  11.   // value   代表获得 / 失去的物品 / 金钱数量
  12.   // icon    绘制物品 / 金钱的图标
  13.   // action  代表“获得”或者“失去”。可在下面修改。
  14.   // 支持“显示文字”中的所有转义符。
  15.   //然后我不会 正则表达式什么的......所以做成了数组......  替换见下边 nr 那里
  16.  
  17.   ITEM_FORMAT  : [ "action","了","name"," * ", "value"],
  18.   GOLD_FORMAT  : ["action", "了", "value" ,"name"],
  19.   ACTION_GAIN  : '获得',
  20.   ACTION_LOSE  : '失去',
  21.   GOLD_ICON_INDEX : 361,        // 金钱图标的索引
  22.  
  23.   BACKGROUND   : 1,         // 窗口背景(0/1/2)
  24.   POSITION     : 1,          // 显示位置(0/1/2)
  25.  
  26.   // 音效(不需要的话可以直接删去对应的行)
  27.   // 必须是这样的格式 {"name":"Shop2","pan":0,"pitch":100,"volume":90}
  28.   // name se音效名  , pan 移动(左右声道?) , pitch' 音调  volume 音量
  29.   GAIN_GOLD_SE :{"name":"Shop2","pan":0,"pitch":100,"volume":90},    // 获得金钱
  30.   LOSE_GOLD_SE :{"name":"Shop2","pan":0,"pitch":100,"volume":90} ,   // 失去金钱
  31.   GAIN_ITEM_SE :{"name":"Shop2","pan":0,"pitch":100,"volume":90} ,      // 获得物品
  32.   LOSE_ITEM_SE :{"name":"Shop2","pan":0,"pitch":100,"volume":90},   // 失去物品
  33.  
  34. }
  35.   // 设置功能是否启用。
  36.   // true:启用。
  37.   // false:不启用。
  38.   // $game_switches[开关ID]: 对应开关打开时。
  39.   Taroxd.GainMessage.enabled = function () {
  40.         //  这里的true 可以改成其他判断 ,比如 变量值啊,开关值啊什么
  41.         //  $gameVariables.value(id) 变量
  42.         //  $gameSwitches.value(id) 开关
  43.           return true;
  44.   }
  45.  
  46.   // --- 设置结束 ---
  47.  
  48.   // 显示提示信息。获得金钱时将 item 设为 nil。
  49.   Taroxd.GainMessage.show = function(value, item){
  50.           if (this.enabled()){
  51.             this.item = item
  52.             this.value = value
  53.             $gameMessage.setBackground(this.BACKGROUND)
  54.             $gameMessage.setPositionType(this.POSITION)
  55.             var message = this.message()
  56.             $gameMessage.add(message)
  57.             this.play_se()
  58.           }
  59.   }
  60.  
  61.     //显示金钱
  62.         Taroxd.GainMessage.showGold = function(amount) {
  63.                 //实际改变数目
  64.             var value = ($gameParty.gold() + amount).clamp(0, $gameParty.maxGold()) - $gameParty.gold()
  65.             //显示
  66.             Taroxd.GainMessage.show( value, false)
  67.         };
  68.  
  69.     //显示物品
  70.         Taroxd.GainMessage.showItem = function(item, amount, includeEquip) {
  71.             var container = $gameParty.itemContainer(item);
  72.             if (container) {
  73.                     //最后的数目
  74.                 var lastNumber = $gameParty.numItems(item);
  75.                         //添加后的数目
  76.                 var newNumber = lastNumber + amount;
  77.                 //实际改变数目
  78.                 var value =  newNumber.clamp(0, $gameParty.maxItems(item)) - lastNumber
  79.                 //如果包含装备 并且 添加后小于0(需要卸下装备)
  80.                  if (includeEquip && newNumber < 0) {
  81.                             $gameParty.members().forEach(function(actor) {
  82.                                     for ( var i =0 ; i<actor.equips().length;i++){
  83.                                             if(actor.equips()[i] == item){
  84.                                                     value--
  85.                                             }
  86.                                     }
  87.                             });
  88.                 }
  89.                 //显示信息
  90.                 Taroxd.GainMessage.show(value,item)
  91.             }
  92.         };
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.   // 获取提示的消息
  103.   Taroxd.GainMessage.message =function () {
  104.           //在上边的 转义符 转换成的 内容
  105.                 var nr = {}
  106.  
  107.                   if (this.item){
  108.                   // format 设置为 ITEM_FORMAT
  109.               var format = this.ITEM_FORMAT
  110.  
  111.               //  icon 转换为 物品图标
  112.               nr.icon=   '\\I['  +  this.item.iconIndex + "]"
  113.               // name 转换为 物品名
  114.               nr.name = this.item.name
  115.                   }else{
  116.                   // format 设置为  GOLD_FORMAT
  117.               var format = this.GOLD_FORMAT
  118.  
  119.               //  icon 转换为 GOLD_ICON_INDEX 对应图标
  120.               nr.icon ="\\I[" + this.GOLD_ICON_INDEX + "]"
  121.               // name 转换为  系统默认货币名
  122.               nr.name = TextManager.currencyUnit
  123.                   }
  124.           // action 转换为  (  大于0 ACTION_GAIN  的内容,小于0 ACTION_LOSE 的内容)
  125.             nr.action =  this.value > 0 ? this.ACTION_GAIN : this.ACTION_LOSE   
  126.             // value 转换为  value的绝对值
  127.           nr.value =Math.abs(this.value)
  128.           //生成信息
  129.           var message =""
  130.           //在 format (数组)里循环,获取数组内的一个个内容
  131.           for (var i=0 ;i< format.length ;i++ ){
  132.                   //如果 这个内容 在  nr里 (比如 内容为"icon",那么就是看 nr.icon (即nr["icon"])是否存在)
  133.                   if (  format[i]  in  nr ){
  134.                           //信息添加  nr[内容] ( 比如 内容为"icon" ,那么就添加 nr.icon (即nr["icon"]))
  135.                       message += nr[format[i]]
  136.                   }else{
  137.                           //信息添加  内容  ( 比如  内容为"了" ,而 nr["了"] (nr.了)不存在 ,那么就添加 "了"  )
  138.                           message += format[i]
  139.                   }
  140.           }
  141.         //返回 信息
  142.           return message
  143.   }
  144.  
  145.   //播放se
  146.   Taroxd.GainMessage.play_se =function ( ) {
  147.             //通过一系列判断
  148.                 var sem =""
  149.                   if (this.value>0 ){
  150.                           sem +="GAIN_"
  151.                   }else {
  152.                           sem +="LOSE_"
  153.                   }
  154.                   if(this.item){
  155.                           sem +="ITEM_"
  156.                   }else{
  157.                           sem +="GOLD_"
  158.                   }
  159.                   sem += "SE"
  160.         //把sem 变成  GAIN_GOLD_SE LOSE_GOLD_SE  GAIN_ITEM_SE  LOSE_ITEM_SE ,
  161.         //如果 sem 在 this 里面 ( 见 音效(不需要的话可以直接删去对应的行)  下面那些  )
  162.                   if (sem in this){
  163.                           //播放 sem 对应的 se  (注意 ,se 是一个实例,需要有name,)
  164.                         AudioManager.playSe(this[sem])
  165.                   }
  166.           return
  167.   }
  168.  
  169.  
  170. // Change Gold 改变金钱
  171. Game_Interpreter.prototype.command125 = function() {
  172.     var value = this.operateValue(this._params[0], this._params[1], this._params[2]);
  173.     Taroxd.GainMessage.showGold(value)  //添加
  174.     $gameParty.gainGold(value);
  175.     return true;
  176. };
  177.  
  178. // Change Items 改变物品
  179. Game_Interpreter.prototype.command126 = function() {
  180.     var value = this.operateValue(this._params[1], this._params[2], this._params[3]);
  181.     Taroxd.GainMessage.showItem($dataItems[this._params[0]], value)//添加
  182.     $gameParty.gainItem($dataItems[this._params[0]], value);
  183.     return true;
  184. };
  185.  
  186. // Change Weapons 改变武器
  187. Game_Interpreter.prototype.command127 = function() {
  188.     var value = this.operateValue(this._params[1], this._params[2], this._params[3]);
  189.     Taroxd.GainMessage.showItem($dataWeapons[this._params[0]], value, this._params[4])//添加
  190.     $gameParty.gainItem($dataWeapons[this._params[0]], value, this._params[4]);
  191.  
  192.     return true;
  193. };
  194.  
  195. // Change Armors 改变防具
  196. Game_Interpreter.prototype.command128 = function() {
  197.     var value = this.operateValue(this._params[1], this._params[2], this._params[3]);
  198.     Taroxd.GainMessage.showItem($dataArmors[this._params[0]], value, this._params[4])//添加
  199.     $gameParty.gainItem($dataArmors[this._params[0]], value, this._params[4]);
  200.     return true;
  201. };
这个是物品得失提示,但是如果怪物掉落物品过多,就显示不全!像这样,其实后面还有东西,但是显示不出来!

QQ图片20160602130546.jpg (39.49 KB, 下载次数: 7)

QQ图片20160602130546.jpg
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-5-1 03:40

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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