查看: 1460|回复: 1

[有事请教] 经验自动得失窗口异常

[复制链接]
梦石
0
星屑
574
在线时间
80 小时
注册时间
2023-7-5
回帖
21
发表于 2025-9-19 23:42:40 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 君野飞火 于 2025-9-19 23:47 编辑

这个是模仿的代码现在出现的问题是:
多人获得经验时,窗口总会重复弹出,而且exp_uper似乎无法获取加经验的角色名
麻烦大家帮忙看看怎么改


[pre lang="ruby"]def command_315
# 获取操作值
value = operate_value(@parameters[1], @parameters[2], @parameters[3])
# 如果 不显示升级窗口开关 关闭,则初始化纪录升级角色和纪录角色学会特级的变量
if $game_switches[$不提示经验窗口] == false
level_uper = []
learned_skill = ""
exp_uper = []
end
#===============增加=============================
first_actor = true
#===============================
# 处理重复
iterate_actor(@parameters[0]) do |actor|
# 如果 不显示经验窗口开关 关闭
last_exp = actor.exp
last_level = actor.level
# 更改角色 EXP
actor.exp += value
if $game_switches[$不提示经验窗口]==false
# 如果是让角色加经验
if first_actor == true #限制多次循环
#============增加处====================
Audio.se_play("Audio/SE/"+"056-Right02",80,100)
# 等待 10 祯
for i in 0..10
Graphics.update
end
#==================================
if exp_uper.size == $game_party.actors.size and $game_party.actors.size > 1
then
#=========如果全体成员升经验,且全体不止一个人=============
# 生成提示窗口
exp_uper_window = Window_Base.new(215, 169, 234, 97)
exp_uper_window.contents = Bitmap.new(200, 64)
exp_uper_window.opacity = 160
# 描绘升级信息
exp_uper_window.contents.draw_text(0, 16, 200, 32, " 全体同伴 EXP + ")
exp_uper_window.contents.draw_text(0, 16, 200, 32, value , 2)
# 此外(如果只有部分角色升级或全队只有一人时)
else
# 生成提示窗口
height = exp_uper.size * 32 + 33
exp_uper_window = Window_Base.new(201, (435 - height) / 2, 262, height)
exp_uper_window.contents = Bitmap.new(230, height - 32)
exp_uper_window.opacity = 160
# 描绘升级信息
y = 0
for exp_up_actor in exp_uper
exp_uper_window.contents.draw_text(10, y, 210, 32, exp_up_actor)
exp_uper_window.contents.draw_text(10, y, 210, 32, "EXP +" , 2)
exp_uper_window.contents.draw_text(10, y, 210, 32, value , 3)
y += 32
end
end
###########################################
# 显示 30 祯
for i in 0..30
Graphics.update
end
# 用 10 祯过渡消失升级提示窗口
for i in 0..10
exp_uper_window.opacity -= 30
exp_uper_window.contents_opacity -= 30
Graphics.update
end
# 释放升级提示窗口
exp_uper_window.dispose
#======================额外增加的操作(避免重复弹窗)=======================
first_actor = false
end
#===================额外增加的操作============================
end
###################################
if $game_switches[$不提示经验窗口]==false
# 如果经验增加后角色升级
if actor.level > last_level
#恢复为满状态
actor.hp = actor.maxhp
actor.sp = actor.maxsp
# 在纪录升级角色的变量里纪录升级角色
level_uper.push(actor.name.split(/·/)[0])
# 如果因升级学会特技
for level in last_level+1..actor.level
for j in $data_classes[actor.class_id].learnings
if j.level == level
# 把角色的升级学会技能信息记录入变量
learned_skill += actor.name.split(/·/)[0] + "学会了新特技“" + $data_skills[j.skill_id].name + "”。\n"
end
end
end
else
end
# 此外(如果 不显示升级窗口开关 判断是否经验提示)
else
actor.exp += value
end
end #处理重复结束
# 如果 不显示升经验窗口开关 关闭,且有角色升级
if $game_switches[$不提示经验窗口] == false and level_uper.size > 0
# 播放升级提示 SE,可以自己改
Audio.se_play("Audio/SE/"+"056-Right02",80,100)
# 等待 10 祯
for i in 0..10
Graphics.update
end
# 如果所有同伴都升级了
if level_uper.size == $game_party.actors.size and $game_party.actors.size > 1
then
#=========如果全体成员升级,且队内不止一个人=============
# 生成升级提示窗口
level_uper_window = Window_Base.new(215, 169, 234, 97)
level_uper_window.contents = Bitmap.new(200, 64)
level_uper_window.opacity = 160
# 描绘升级信息
level_uper_window.contents.draw_text(0, 16, 200, 32, " 全体同伴 LEVEL UP! ")
# 此外(如果只有部分角色升级或队内只有一人时)
else
# 生成升级提示窗口
height = level_uper.size * 32 + 33
level_uper_window = Window_Base.new(201, (435 - height) / 2, 262, height)
level_uper_window.contents = Bitmap.new(230, height - 32)
level_uper_window.opacity = 160
# 描绘升级信息
y = 0
for level_up_actor in level_uper
level_uper_window.contents.draw_text(10, y, 210, 32, level_up_actor)
level_uper_window.contents.draw_text(10, y, 210, 32, " LEVEL UP!", 2)
y += 32
end
end
# 显示 30 祯
for i in 0..30
Graphics.update
end
# 用 10 祯过渡消失升级提示窗口
for i in 0..10
level_uper_window.opacity -= 30
level_uper_window.contents_opacity -= 30
Graphics.update
end
# 释放升级提示窗口
level_uper_window.dispose
# 如果有角色因为升级而学会技能
if learned_skill != ""
# 播放学会技能 ME,可以自己改
Audio.me_play("Audio/ME/"+"010-Item01",100,100)
# 更改对话框各个选项
$game_system.message_position = 2
$game_system.message_frame = 0
$mes_id = nil
$mes_name = ""
# 显示学会技能信息
@message_waiting = true
$game_temp.message_proc = Proc.new { @message_waiting = false }
# message_text 设置为 1 行
$game_temp.message_text = "\\c[4]" + learned_skill + "\n"
end
end
# 继续
return true
end #def结束
[/pre]
梦石
0
星屑
6295
在线时间
799 小时
注册时间
2019-1-20
回帖
223
发表于 2025-11-28 11:44:16 | 显示全部楼层
脚本96行删除重复的 actor.exp += value

exp_uper是[],当然无法获取加经验的角色名
在19-20行中间加上 exp_uper.push(actor.name.split(/·/)[0])

至于 多人获得经验时,窗口总会重复弹出,不懂你的意思。

看完脚本,觉得你应该先想想,
到底想要什么样的表现效果,
保留必要的,合并可能的,去掉多余或者不必要的,
之后再去写脚本。

其实可以在升级时保存必要信息,
等升级后,再执行文字和升级效果等。

提高解决问题的方法:
查看对应版本的帮助文件或者默认脚本中可能相似的部分 看有没有思路能照搬(不是)
改变问题为更有可能的,常见的,系统性的 如:天气自动变化成下雨→天气系统 要多想几种可能
使用论坛的搜索功能查找相关问题 咦?这跟我想的不一样啊!讨厌啦~\(≧□≦)/~啦啦啦
清楚说明实际上你想解决的问题  想看坛友的女装,想看!  
脚本自己有改过的地方要尽量标明  提高除BUG效率 ... ...
脚本有问题但不是默认脚本的要全部贴出来 大胆点,尽情发,我说的是女装照!
三包原则:包有BUG,包甩锅,包咕咕 长期下线,急事换人!难事换人!啥事都换人!换人换人换人!!!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

在本版发帖返回顶部