#--------------------------------------------------------------------------
# ● 动态值槽脚本 Ver1.0 作者:Taroxd
# 可以实现值槽变化时的动态效果。
# 该脚本可能会有较大的不兼容性。如果产生问题,请删除此脚本
#
#--------此处是设置区域,如无必要无需改动---------
# ↓ 此处为战斗时值槽的设置
class Window_BattleStatus
def gauge_rolling_times
30 # 设置每次值槽变化的刷新次数。该数越大,滚动越慢。
end
def gauge_refresh_interval
1 # 设置两次滚动之间的间隔(单位:帧)。该数越大,滚动越慢且越不连续。
end # 增大此数可以提高性能。如果卡顿,可以尝试增大此数。
end
# ↑ 战斗场景设置完毕
# ↓ 此处为菜单中使用道具时值槽的设置
class Window_MenuStatus < Window_Selectable
def gauge_rolling_times
30 # 设置每次值槽变化的刷新次数。该数越大,滚动越慢。
end
def gauge_refresh_interval
2 # 设置两次滚动之间的间隔(单位:帧)。该数越大,滚动越慢且越不连续。
end # 增大此数可以提高性能。如果卡顿,可以尝试增大此数。
end
# ↑ 使用道具窗口设置完毕
# ↓ 此处为菜单中使用技能时值槽的设置
class Window_SkillStatus < Window_Base
def gauge_rolling_times
30 # 设置每次值槽变化的刷新次数。该数越大,滚动越慢。
end
def gauge_refresh_interval
2 # 设置两次滚动之间的间隔(单位:帧)。该数越大,滚动越慢且越不连续。
end # 增大此数可以提高性能。如果卡顿,可以尝试增大此数。
end
# ↑ 使用技能窗口设置完毕
#-------------------更新日志--------------------
# 3/16 修复了对队友使用技能时值槽会重新滚动的bug
#---------不理解脚本者请勿修改以下内容-----------
module RollingGauge
#--------------------------------------------------------------------------
# ● 值槽滚动所需的次数
#--------------------------------------------------------------------------
def gauge_rolling_times; 30; end
#--------------------------------------------------------------------------
# ● 每隔多少帧刷新一次值槽
#--------------------------------------------------------------------------
def gauge_refresh_interval; 1; end
#--------------------------------------------------------------------------
# ● 初始化
#--------------------------------------------------------------------------
def initialize(*)
@last_gauge_value = {}
@gauge_fiber = {}
@gauge_refresh_counting = 0
super
end
#--------------------------------------------------------------------------
# ● 更新
#--------------------------------------------------------------------------
def update
super
update_gauge_rolling
end
#--------------------------------------------------------------------------
# ● 更新值槽
#--------------------------------------------------------------------------
def update_gauge_rolling
@gauge_refresh_counting += 1 unless @gauge_fiber.empty?
if @gauge_refresh_counting >= gauge_refresh_interval
refresh
@gauge_refresh_counting = 0
end
end
#--------------------------------------------------------------------------
# ● 绘制值槽的方法模板
#--------------------------------------------------------------------------
def self.def_draw_actor_(sym)
module_eval %{
def draw_actor_#{sym}(actor, x, y, width = 124)
key = [x, y]
fiber = @gauge_fiber[key]
return fiber.resume if fiber
value = actor.#{sym}
@last_gauge_value[key] ||= value
last_value = @last_gauge_value[key]
if last_value == value
draw_#{sym}_by_value(actor, value, x, y, width)
return
end
@gauge_fiber[key] = fiber = Fiber.new do
value = last_value.to_f
(gauge_rolling_times - 1).times do |i|
value += (actor.#{sym} - value) / (gauge_rolling_times - i)
draw_#{sym}_by_value(actor, value.round, x, y, width)
Fiber.yield
end
@last_gauge_value[key] = value = actor.#{sym}
draw_#{sym}_by_value(actor, value, x, y, width)
@gauge_fiber.delete(key)
end
fiber.resume
end
}
end
#--------------------------------------------------------------------------
# ● 定义绘制值槽的方法
#--------------------------------------------------------------------------
def_draw_actor_ :hp
def_draw_actor_ :mp
def_draw_actor_ :tp
#--------------------------------------------------------------------------
# ● 按值绘制 HP
#--------------------------------------------------------------------------
def draw_hp_by_value(actor, value, x, y, width = 124)
draw_gauge(x, y, width, value.to_f / actor.mhp,
hp_gauge_color1, hp_gauge_color2)
change_color(system_color)
draw_text(x, y, 30, line_height, Vocab::hp_a)
draw_current_and_max_values(x, y, width, value, actor.mhp,
hp_color(actor), normal_color)
end
#--------------------------------------------------------------------------
# ● 按值绘制 MP
#--------------------------------------------------------------------------
def draw_mp_by_value(actor, value, x, y, width = 124)
draw_gauge(x, y, width, value.to_f / actor.mmp,
mp_gauge_color1, mp_gauge_color2)
change_color(system_color)
draw_text(x, y, 30, line_height, Vocab::mp_a)
draw_current_and_max_values(x, y, width, value, actor.mmp,
mp_color(actor), normal_color)
end
#--------------------------------------------------------------------------
# ● 按值绘制 TP
#--------------------------------------------------------------------------
def draw_tp_by_value(actor, value, x, y, width = 124)
draw_gauge(x, y, width, value.to_f / actor.max_tp,
tp_gauge_color1, tp_gauge_color2)
change_color(system_color)
draw_text(x, y, 30, line_height, Vocab::tp_a)
change_color(tp_color(actor))
draw_text(x + width - 42, y, 42, line_height, value.to_i, 2)
end
end
class Window_BattleActor < Window_BattleStatus
alias draw_actor_hp draw_actor_hp
alias draw_actor_mp draw_actor_mp
alias draw_actor_tp draw_actor_tp
end
class Window_BattleStatus < Window_Selectable
include RollingGauge
end
class Window_MenuStatus < Window_Selectable
include RollingGauge
end
class Window_SkillStatus < Window_Base
include RollingGauge
end