- 累计送礼:
- 0 个
- 累计收礼:
- 0 个
TA的每日心情 | 开心 2025-2-4 02:05 |
---|
签到天数: 110 天 连续签到: 2 天 [LV.6]常住居民II

管理员
  
- VIP
- 6
- 卡币
- 10470
- OK点
- 16
- 推广点
- 0
- 同能卷
- 0
- 积分
- 13220


|
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) 开关
- returntrue;
- }
- // --- 设置结束 ---
- // 显示提示信息。获得金钱时将 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 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 inthis){
- //播放 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);
- returntrue;
- };
- // 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);
- returntrue;
- };
- // 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]);
- returntrue;
- };
- // 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]);
- returntrue;
- };
复制代码这个是物品得失提示,但是如果怪物掉落物品过多,就显示不全!像这样,其实后面还有东西,但是显示不出来!

本帖来自P1论坛作者六道神话,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址: https://rpg.blue/forum.php?mod=viewthread&tid=393836 若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。 |
|