| 赞 | 0 |
| VIP | |
| 好人卡 | |
| 积分 | 1 |
| 经验 | |
| 最后登录 | 2016-11-4 |
| 在线时间 | 85 小时 |
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 85 小时
- 注册时间
- 2015-7-29
- 回帖
- 69
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
本帖最后由 余烬之中 于 2016-8-3 10:13 编辑
- 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()[i] == 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[i] in nr ){
- //信息添加 nr[内容] ( 比如 内容为"icon" ,那么就添加 nr.icon (即nr["icon"]))
- message += nr[format[i]]
- }else{
- //信息添加 内容 ( 比如 内容为"了" ,而 nr["了"] (nr.了)不存在 ,那么就添加 "了" )
- message += format[i]
- }
- }
- //返回 信息
- 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;
- };
复制代码 这个是物品得失提示,但是如果怪物掉落物品过多,就显示不全!像这样,其实后面还有东西,但是显示不出来! |
-
|