#================================================================
# 转轮血条
#
# 章半仙制作
#================================================================
=begin
1.03版
修正默认系统失效的问题
1.02版
增加与XAS系统的兼容
修正整队后的显示问题
修正事件注解中的一些笔误
修正与YEA::BATTLE脸图战斗系统共用时的一些显示问题
1.01版
修正一处方法名写错导致的bug - -b
1.00版更新说明
滚动的计时单位改为帧数,增加更为通俗易懂的转轮速度设置
增加致命伤害时,显示特别信息和播放特别音效的功能
增加预览血条的显示,使损血更为直观
增加更改回血速度和瞬间回血等的事件指令
增加RollBarManager方便整合到自己的系统
增加了各种兼容性检测以保证和其他脚本共同工作,代价是代码的可读性更加诡异了- -b
增加兼容模式,此状态下可以解决大部分血条的显示问题,但效率比较坑爹
增加与YEA::BATTLE脸图战斗系统的兼容
解决部分窗口状态刷新不及时的问题
原本的线程替换为纤程应该可以解决一些战场中途死亡造成的诡异问题- -b
ps:报错的童鞋最好提供冲突工程链接以便排错...
为了最佳的兼容性,建议把脚本插在main以前的最后一个位置
=end
module RollBar
VERSION = 1.03
#转轮的速度
ROLL_SPEED = 1
#对hp、mp和tp转轮速度的分别设置
ROLL_SPEED_FOR_HP = ROLL_SPEED
ROLL_SPEED_FOR_MP = ROLL_SPEED
ROLL_SPEED_FOR_TP = ROLL_SPEED
#每次转轮扣的血(新版建议修改ROLL_SPEED)
ROLL_UNIT = 0.5
#每次转轮花的帧数,数值加大可以增加fps,不过血条显示会变得不流畅(新版建议修改ROLL_SPEED)
ROLL_TIME = 2
#受到致命的攻击时显示的信息(不需要的话设为nil)
KILL_MSG = {
:hp => "快要不行了",
:mp => nil,
:tp => nil
}
#受到致命的攻击时播放的音效(设为数字时播放系统声音,设为字符串时指定路径的音效,设为nil时不播放)
KILL_SOUND = {
:hp => "audio/se/Collapse2.ogg",
:mp => nil,
:tp => nil
}
#是否开启预览条,有预览条可以更清晰的表明损血的状况
PRE_BAR_ENABLE = true
#预览条的颜色设置,只有开启PRE_BAR_ENABLE才有效,颜色格式为Color.new(R,G,B,A),R代表红色值,G代表绿色值,B代表蓝色值,A代表透明值
#受到伤害时的预览条颜色,第一个颜色为渐变初始值,第二个为结束值,设为nil则采用默认色彩
PRE_BAR_COLOR_DAMAGE = {
:hp => [Color.new(200,0,0),Color.new(255,0,0)],
:mp => [Color.new(200,0,0),Color.new(255,0,0)],
:tp => [Color.new(200,0,0),Color.new(255,0,0)]
}
#恢复时的预览条颜色
PRE_BAR_COLOR_RECOVER = {
:hp => [Color.new(0,150,0),Color.new(0,200,0)],
:mp => [Color.new(0,150,0),Color.new(0,200,0)],
:tp => [Color.new(0,150,0),Color.new(0,200,0)]
}
#如果需要战斗结束时停止血条的滚动并抛弃伤害的话设为true
STOP_ROLL_AND_CLEAR_DAMGE_WHEN_BATTLE_END = true
#如果需要战斗结束时停止血条的滚动并结算的话设为true
STOP_ROLL_AND_EVAL_DAMGE_WHEN_BATTLE_END = false
#如果读档时需要继续存档之前的滚动状态的话设为true
RESUME_ROLL_WHEN_LOAD = true
#如果血条不显示时就同时暂停血条的滚动(如果你想在对话时停止血条的话就设为true)
PAUSE_ROLL_WHEN_WINDOW_INVISIBLE = false
#兼容模式,可以解决一些血条显示上的问题,效率比较坑爹- -b
SLOW_MODE_ENABLE = false
module RollBarFunc
#事件脚本接口列表(在事件的脚本框中输入以下内容即可达到相应效果)
# 速度式回血(值,速度,角色id)
# 效果:以特定的速度回血
# 参数表:值 数值型 要加的血
# 速度 数值型 为0时无视滚动直接加血
# 角色id 数值型 0或负数时则指代队伍中的id
# 例如-1时就指代队伍中的第二个人
# 使用范例:(注意全半角- -b)
# 速度式回血(100,2,1)
def recover_hp_with_speed(val,speed,actor_id=0)
get_actor(actor_id).send(:hp=,get_actor(actor_id).hp+val,speed)
end
# 速度式扣血(值,速度,角色id)
# 效果:以特定的速度扣血
# 参数表:值 数值型
# 速度 数值型
# 角色id 数值型
def damage_hp_with_speed(val,speed,actor_id=0)
recover_hp_with_speed(-val,speed,actor_id)
end
# 直接回血(值,角色id)
# 效果:无视滚动直接回血
# 参数表:值 数值型
# 角色id 数值型
def recover_hp_straight(val,actor_id=0)
get_actor(actor_id).will_hp = nil
recover_hp_with_speed(val,0,actor_id)
end
# 直接扣血(值,角色id)
# 效果:无视滚动直接扣血
# 参数表:值 数值型
# 角色id 数值型
def damage_hp_straight(val,actor_id=0)
recover_hp_straight(-val,actor_id)
end
# 速度式回魔(值,速度,角色id)
# 效果:以特定的速度回魔
# 参数表:值 数值型
# 速度 数值型
# 角色id 数值型
def recover_mp_with_speed(val,speed,actor_id=0)
get_actor(actor_id).send(:mp=,get_actor(actor_id).mp+val,speed)
end
# 速度式扣魔(值,速度,角色id)
# 效果:以特定的速度扣魔
# 参数表:值 数值型
# 速度 数值型
# 角色id 数值型
def damage_mp_with_speed(val,speed,actor_id=0)
recover_mp_with_speed(-val,speed,actor_id)
end
# 直接回魔(值,角色id)
# 效果:无视滚动直接回魔
# 参数表:值 数值型
# 角色id 数值型
def recover_mp_straight(val,actor_id=0)
get_actor(actor_id).will_mp = nil
recover_mp_with_speed(val,0,actor_id)
end
# 直接扣魔(值,角色id)
# 效果:无视滚动直接扣魔
# 参数表:值 数值型
# 角色id 数值型
def damage_mp_straight(val,actor_id=0)
drecover_mp_straight(-val,actor_id)
end
# 瞬间全恢复(角色序列)
# 效果:无视滚动回满血蓝
# 参数表:角色序列 数值型 角色在队伍中的序列
# -1代表全体队员,可省略
# 使用范例:
# 瞬间全恢复
def all_recover_straight(index=-1)
get_party(index) do |i|
i.will_hp = nil;i.send(:hp=,i.mhp,0)
i.will_mp = nil;i.send(:mp=,i.mmp,0)
i.will_tp = nil;i.send(:tp=,i.max_tp,0)
end
end
# 设置滚动暂停标志(角色序列,血条类型,标志)
# 效果:暂停相应角色的血条滚动(暂停状态下减血不会立即显示但会计入)
# 参数表:角色序列 数值型 角色在队伍中的序列
# -1代表全体队员,可省略
# 血条类型 :hp #=>对应hp条
# :mp #=>对应mp条
# :tp #=>对应tp条
# 标志 布尔型 决定是暂停还是继续
# 使用范例:
# 设置滚动暂停标志(-1,:mp,true)
def set_roll_pause_flag(index=-1,type=:hp,flag=true)
get_party(index) do |i|
case type
when :hp
i.hp_rollbar_pause = flag
when :mp
i.mp_rollbar_pause = flag
when :tp
i.tp_rollbar_pause = flag
end
end
end
# 暂停滚动
# 效果:暂停所有的滚动中的血条
# 参数表:无
# 使用范例:
# 暂停滚动
# 显示文章 : 因为我在说话就给你们休息一下
# 恢复滚动
def pause_roll
set_roll_pause_flag(-1,:hp,true)
set_roll_pause_flag(-1,:mp,true)
set_roll_pause_flag(-1,:tp,true)
end
# 恢复滚动
# 效果:恢复所有的滚动中的血条
# 参数表:无
def resume_roll
set_roll_pause_flag(-1,:hp,false)
set_roll_pause_flag(-1,:mp,false)
set_roll_pause_flag(-1,:tp,false)
end
# 清除伤害(角色序列,血条类型)
# 效果:让某个角色当前滚动的血条不再滚动
# 参数表:角色序列 数值型 角色在队伍中的序列
# -1代表全体队员,可省略
# 血条类型 :hp #=>对应hp条
# :mp #=>对应mp条
# :tp #=>对应tp条
def clear_roll_damage(index=-1,type=:hp)
get_party(index) do |i|
case type
when :hp
i.will_hp = i.hp
when :mp
i.will_mp = i.mp
when :tp
i.will_tp = i.tp
end
end
end
# 清除所有伤害(角色序列)
# 效果:让某个角色当前滚动的所有血条不再滚动
# 参数表:角色序列 数值型 角色在队伍中的序列
# -1代表全体队员,可省略
def clear_all_roll_damage(index=-1)
clear_roll_damage(-1,:hp)
clear_roll_damage(-1,:mp)
clear_roll_damage(-1,:tp)
end
# 结算伤害(角色序列,血条类型)
# 效果:让某个角色当前滚动的血条直接到达目标血量
# 参数表:角色序列 数值型 角色在队伍中的序列
# -1代表全体队员,可省略
# 血条类型 :hp #=>对应hp条
# :mp #=>对应mp条
# :tp #=>对应tp条
def eval_roll_damage(index=-1,type=:hp)
get_party(index) do |i|
case type
when :hp
huaka = i.will_hp;i.will_hp = nil;i.send(:hp=,huaka,0)
when :mp
huaka = i.will_mp;i.will_mp = nil;i.send(:mp=,huaka,0)
when :tp
huaka = i.will_tp;i.will_tp = nil;i.send(:tp=,huaka,0)
end
end
end
# 结算所有伤害(角色序列,血条类型)
# 效果:让某个角色当前滚动的血条不再滚动
# 参数表:角色序列 数值型 角色在队伍中的序列
# -1代表全体队员,可省略
# 血条类型 :hp #=>对应hp条
# :mp #=>对应mp条
# :tp #=>对应tp条
def eval_all_roll_damage(index=-1)
eval_roll_damage(-1,:hp)
eval_roll_damage(-1,:mp)
eval_roll_damage(-1,:tp)
end
# 改变角色滚动速度(速度,角色id,血条类型)
# 效果:改变对应角色id的相应血条的滚动速度(正在滚动的血条速度不变)
# 参数表:速度 数值型 为0时无视滚动直接加血
# 为负数时可以让以后的一切扣血变为加血
# 角色id 数值型
# 血条类型 :hp #=>对应hp条
# :mp #=>对应mp条
# :tp #=>对应tp条
# 使用范例:
# 改变角色滚动速度(2,1,:hp)
# 增减hp : 全体队友, +100
# 恢复角色滚动速度(1,:hp)
def change_roll_speed_for_actor(speed,actor_id=0,type=:hp)
case type
when :hp
get_actor(actor_id).hp_rollbar_speed = speed
when :mp
get_actor(actor_id).mp_rollbar_speed = speed
when :tp
get_actor(actor_id).tp_rollbar_speed = speed
end
end
# 恢复角色滚动速度(角色id,血条类型)
# 效果:恢复对应角色id的相应血条的滚动速度
# 参数表:角色id 数值型
# 血条类型 :hp #=>对应hp条
# :mp #=>对应mp条
# :tp #=>对应tp条
def recover_roll_speed_for_actor(actor_id=0,type=:hp)
change_roll_speed_for_actor(nil,actor_id,type)
end
def get_actor(actor_id)
actor_id > 0 ? $game_actors[actor_id] : $game_party.members[actor_id.abs]
end
def get_party(index)
party = index == -1 ? $game_party.members : [$game_party.members[index]]
party.each{|i|yield i}
end
#速查表- -b
alias 速度式回血 recover_hp_with_speed
alias 速度式扣血 damage_hp_with_speed
alias 直接回血 recover_hp_straight
alias 直接扣血 damage_hp_straight
alias 速度式回魔 recover_mp_with_speed
alias 速度式扣魔 damage_mp_with_speed
alias 直接回魔 recover_mp_straight
alias 直接扣魔 damage_mp_straight
alias 瞬间全恢复 all_recover_straight
alias 设置滚动暂停标志 set_roll_pause_flag
alias 暂停滚动 pause_roll
alias 恢复滚动 resume_roll
alias 暂停滚动 pause_roll
alias 清除伤害 clear_roll_damage
alias 清除所有伤害 clear_all_roll_damage
alias 结算伤害 eval_roll_damage
alias 结算所有伤害 eval_all_roll_damage
alias 改变角色滚动速度 change_roll_speed_for_actor
alias 恢复角色滚动速度 recover_roll_speed_for_actor
end
module RollBarManager
class << self
def init
@roll_bar_missions = []
@roll_bar_visible_missions = []
@roll_bar_windows = []
@huaka_classes = {}
@default_rollbar_speed = {:hp => RollBar::ROLL_SPEED_FOR_HP,
:mp => RollBar::ROLL_SPEED_FOR_MP,
:tp => RollBar::ROLL_SPEED_FOR_TP
}
end
#sample:
#roll_bar_item RollBarActor, :hp
#@hp,@will_hp,@hp_rollbar_speed,@hp_rollbar_pause
def roll_bar_item(actor_class,item,
max_name="m"+item.to_s,
will_name="will_"+item.to_s,
speed_name=item.to_s+"_rollbar_speed",
pause_name=item.to_s+"_rollbar_pause")
method_name = huaka_name = item.to_s + "="
each_huaka_class(actor_class) do
attr_writer speed_name
attr_accessor pause_name
attr_accessor will_name
define_huaka_method method_name do |val,speed=self.send(speed_name)|
return unless val
now_p = instance_variable_get("@"+item.to_s)
will_p = instance_variable_get("@"+will_name)
instance_variable_set("@"+will_name,will_p = now_p) unless will_p
huaka_p = val - now_p
return if huaka_p == 0
roll_unit = (speed == 0) ? huaka_p : ROLL_UNIT * speed
huaka_p = - huaka_p if speed < 0
rec = huaka_p > 0
roll_unit = - roll_unit if rec ^ (speed > 0)
instance_variable_set("@"+will_name,[[will_p+huaka_p,send(max_name)].min, 0].max.round)
RollBarManager.reg_roll_bar_mission huaka_fiber = Fiber.new {
(huaka_p / roll_unit).round.abs.times do
will_p = instance_variable_get("@"+will_name)
now_p = instance_variable_get("@"+item.to_s)
break if will_p == now_p || (will_p > now_p) ^ rec
Fiber.yield while instance_variable_get("@"+pause_name)
instance_variable_set("@"+item.to_s,[[now_p+roll_unit.round,send(max_name)].min, 0].max.round)
refresh
Fiber.yield
end
RollBarManager.unreg_roll_bar_mission(huaka_fiber)
}
end
define_method speed_name do
huaka = instance_variable_get("@"+speed_name)
huaka ? huaka : RollBarManager.default_rollbar_speed[item]
end
end
end
#sample:
#draw_roll_bar RollBarVisibleObject, :hp
#hook_metod: draw_actor_hp , draw_gauge
#callback_method: hp_bar_flag , hp_pre_bar_args , hp_clear_args
def draw_roll_bar(window_class,type,
bar_method="draw_actor_"+type.to_s,
pre_bar_method=:draw_gauge,
slow_mode=false,
pre_repeat_method=:def_pre_repeat,
bar_flag_method=type.to_s+"_bar_flag",
pre_bar_args_method=type.to_s+"_pre_bar_args",
clear_args_method=type.to_s+"_clear_args",
contents_method=false)
bar_method = bar_method.to_s
pre_bar_method = PRE_BAR_ENABLE ? pre_bar_method.to_s : false
define_huaka_method_for_classes(window_class,bar_method) do |*args|
fiber = Fiber.new {
until disposed?
break unless RollBarManager.roll_bar_visible_missions.include? fiber
flag ||= false
huaka_flag = bar_flag_method ? send(bar_flag_method,*args) : true
if !huaka_flag || flag == huaka_flag
Fiber.yield !close? && visible
next
end
flag = bar_flag_method ? send(bar_flag_method,*args) : true
clear_args = clear_args_method ? send(clear_args_method,*args) : args[1,4]
x,y,width,height = *clear_args
huaka_bitmap ||= save_bitmap(x,y,width,height) if slow_mode
contents.clear_rect(x,y,width,height)
load_bitmap(x,y,huaka_bitmap) if slow_mode
if pre_bar_method
define_singleton_method pre_bar_method do |*a|
super(*a)
pre_bar_args = send(pre_bar_args_method,*args)
return unless pre_bar_args
rate = pre_bar_args[0]
color = pre_bar_args[1] ? PRE_BAR_COLOR_DAMAGE[type] : PRE_BAR_COLOR_RECOVER[type]
x = a[0] + (a[2] * [rate,a[3]].min).round
y = a[1] + line_height - 8
width = (a[2] * ([rate,a[3]].max - [rate,a[3]].min)).round
color1 = color[0] ? color[0] : a[4]
color2 = color[1] ? color[1] : a[5]
contents.gradient_fill_rect(x, y, width, 6, color1,color2)
end
end
call_meta_method(bar_method,*args)
if pre_bar_method
(class << self;self;end).send(:remove_method,pre_bar_method)
end
Fiber.yield !close? && visible
end
huaka_bitmap.dispose if slow_mode && huaka_bitmap
@roll_bars_pre_repeat.delete fiber
RollBarManager.unreg_roll_bar_visible_mission(fiber)
}
@roll_bars_pre_repeat ||= {}
pre_repeat = send(:def_pre_repeat,*args)
@roll_bars_pre_repeat.each_pair do |f,p|
RollBarManager.unreg_roll_bar_visible_mission(f) if pre_repeat == p
end
@roll_bars_pre_repeat[fiber] = pre_repeat
RollBarManager.reg_roll_bar_visible_mission fiber
fiber.resume
end
end
def reg_roll_bar_mission(fiber)
@roll_bar_missions.push fiber unless @roll_bar_missions.include? fiber
end
def unreg_roll_bar_mission(fiber)
@roll_bar_missions.delete fiber
end
def reg_roll_bar_visible_mission(fiber)
@roll_bar_visible_missions.push fiber unless @roll_bar_missions.include? fiber
end
def unreg_roll_bar_visible_mission(fiber)
@roll_bar_visible_missions.delete fiber
end
def find_huaka_class(klass)
return klass if @huaka_classes.has_value?(klass)
unless @huaka_classes[klass]
return klass if klass.name == ""
@huaka_classes[klass] = Class.new(klass)
klass_name = klass.name.split("::")
const_name = klass_name.pop
nesting = klass_name.empty? ? Object : eval(klass_name.join("::"))
nesting.const_set(const_name,@huaka_classes[klass])
end
@huaka_classes[klass]
end
def each_huaka_class(type,&def_proc)
ObjectSpace.each_object(Class) do |i|
next if !i.include?(type)
huaka_class = find_huaka_class(i)
def huaka_class.define_huaka_method(method_name,&proc)
RollBarManager.define_huaka_method(self,method_name,&proc)
end
huaka_class.module_eval &def_proc
end
end
def define_huaka_method_for_classes(type,method_name,&proc)
ObjectSpace.each_object(Class) do |i|
next if !i.include?(type)
define_huaka_method(i,method_name,&proc)
end
end
def define_huaka_method(klass,method_name,&proc)
klass = find_huaka_class(klass)
unless klass.method_defined? :call_meta_method
klass.send(:define_method,:call_meta_method) do |method_name,*args|
RollBarManager.call_meta_method(self,method_name,*args)
end
end
klass.send(:define_method,method_name,&proc)
end
def call_meta_method(object,method_name,*args)
klass = ::Object.instance_method(:class).bind(object).call
@huaka_classes.key(klass).instance_method(method_name).bind(object).call(*args)
end
attr_reader :roll_bar_missions
attr_reader :roll_bar_visible_missions
attr_accessor :default_rollbar_speed
end
end
module RollBarActor
def self.included(klass)
RollBarManager.roll_bar_item self, :hp,:mhp
RollBarManager.roll_bar_item self, :mp,:mmp
RollBarManager.roll_bar_item self, :tp,:max_tp
end
end
module RollBarScene
def self.included(klass)
RollBarManager.define_huaka_method_for_classes(self,:refresh_status){}
RollBarManager.define_huaka_method_for_classes(self,:update_basic) do
super()
@frame_count ||=0
@frame_count += 1
return unless @frame_count > ROLL_TIME
@frame_count = 0
for i in RollBarManager.roll_bar_visible_missions
needroll |= i.resume
end
if PAUSE_ROLL_WHEN_WINDOW_INVISIBLE
return unless needroll
end
for i in RollBarManager.roll_bar_missions
i.resume
end
if is_a?(Scene_Battle) && BattleManager.actor
if BattleManager.actor.input.nil?
BattleManager.actor.make_actions
next_command
end
end
end
RollBarManager.define_huaka_method_for_classes(self,:terminate) do
super()
case self
when Scene_Battle
if STOP_ROLL_AND_CLEAR_DAMGE_WHEN_BATTLE_END
clear_all_roll_damage
elsif STOP_ROLL_AND_EVAL_DAMGE_WHEN_BATTLE_END
eval_all_roll_damage
end
when Scene_Load
if RESUME_ROLL_WHEN_LOAD
get_party(-1) do |i|
will_hp = i.will_hp
will_mp = i.will_mp
will_tp = i.will_tp
(i.will_hp = nil;i.hp = will_hp) if will_hp
(i.will_mp = nil;i.mp = will_mp) if will_mp
(i.will_tp = nil;i.tp = will_tp) if will_tp
end
end
end
end
end
end
module RollBarVisibleObject
def self.included(klass)
RollBarManager.draw_roll_bar self, :hp, :draw_actor_hp, :draw_gauge, SLOW_MODE_ENABLE || defined? YEA::BATTLE
RollBarManager.draw_roll_bar self, :mp, :draw_actor_mp, :draw_gauge ,SLOW_MODE_ENABLE || defined? YEA::BATTLE
RollBarManager.draw_roll_bar self, :tp, :draw_actor_tp, :draw_gauge, SLOW_MODE_ENABLE || defined? YEA::BATTLE
RollBarManager.draw_roll_bar self, :name, :draw_actor_name, false, SLOW_MODE_ENABLE || defined? YEA::BATTLE
RollBarManager.draw_roll_bar self, :state,:draw_actor_icons, false, SLOW_MODE_ENABLE || defined? YEA::BATTLE
if defined? YEA::BATTLE
RollBarManager.draw_roll_bar self, :yea_action,:draw_actor_action,false,true
end
end
def save_bitmap(x, y, width,height=line_height)
bitmap = Bitmap.new(width,height)
rect = Rect.new(x, y, width,height)
bitmap.blt(0, 0, contents, rect)
bitmap
end
def load_bitmap(x,y,bitmap)
rect = Rect.new(0, 0, bitmap.width,bitmap.height)
contents.blt(x, y,bitmap, rect)
end
#callback系列
def hp_bar_flag(actor, x, y, width=124)
actor.hp
end
def mp_bar_flag(actor, x, y, width=124)
actor.mp
end
def tp_bar_flag(actor, x, y, width=124)
actor.tp
end
def name_bar_flag(actor, x, y, width=112)
[actor.hp == 0,(actor.hp < actor.mhp / 4)]
end
def state_bar_flag(actor, x, y, width=96)
return false if actor.is_a?(Game_Enemy) && actor.dead?
actor.state_icons | actor.buff_icons
end
def hp_clear_args(actor, x, y, width=124)
if defined? YEA::BATTLE
if SceneManager.scene_is?(Scene_Battle)
contents.font.size = YEA::BATTLE::BATTLESTATUS_TEXT_FONT_SIZE
end
end
[x, y, width, line_height]
end
alias mp_clear_args hp_clear_args
alias tp_clear_args hp_clear_args
def name_clear_args(actor, x, y, width=112)
if defined? YEA::BATTLE
if SceneManager.scene_is?(Scene_Battle)
(x += 24;width -= 24)
end
end
[x, y, width, line_height]
end
def state_clear_args(actor, x, y, width=96)
[x, y, width, line_height]
end
def hp_pre_bar_args(actor, x, y, width=124)
return false if actor.will_hp.nil?
return false if actor.will_hp == actor.hp
[actor.will_hp.to_f / actor.mhp,actor.will_hp < actor.hp]
end
def mp_pre_bar_args(actor, x, y, width=124)
return false if actor.will_mp.nil?
return false if actor.will_mp == actor.mp
[actor.will_mp.to_f / actor.mmp,actor.will_mp < actor.mp]
end
def tp_pre_bar_args(actor, x, y, width=124)
return false if actor.will_tp.nil?
return false if actor.will_tp == actor.tp
[actor.will_tp.to_f / actor.max_tp,actor.will_tp < actor.tp]
end
def def_pre_repeat(actor, x, y, width=96)
[x,y,width]
end
if defined? YEA::BATTLE
def yea_action_bar_flag(actor, dx, dy)
action_icon(actor)
end
def yea_action_clear_args(actor, dx, dy)
[dx, dy, 24, 24]
end
end
end
module RollBarActionResult
def kill?(type=:hp)
case type
when :hp
return false unless @battler.will_hp
@hp_damage > 0 && @battler.will_hp <= 0
when :mp
return false unless @battler.will_mp
@mp_damage > 0 && @battler.will_mp <= 0
when :tp
return false unless @battler.will_tp
@tp_damage > 0 && @battler.will_tp <= 0
end
end
end
module RollBarBattleLog
def self.included(klass)
KILL_MSG.each_pair do |sym,msg|
method_name = "display_" + sym.to_s + "_damage"
RollBarManager.define_huaka_method_for_classes(self,method_name) do |target, item|
super(target, item)
return unless target.is_a?(Game_Actor)
return unless target.result.kill?(sym)
add_text(target.name+msg) unless msg.nil?
if KILL_SOUND[sym].is_a?(Integer)
Sound.play_system_sound(KILL_SOUND[sym])
elsif KILL_SOUND[sym].is_a?(String)
Audio.se_play(KILL_SOUND[sym])
end
wait unless msg.nil?
end
end
end
end
RollBarManager.init
end
class Game_Interpreter
include RollBar
include RollBarFunc
end
class Window_Base
include RollBar
include RollBarVisibleObject
end
class Game_Actor
include RollBar
include RollBarActor
end
class Scene_Base
include RollBar
include RollBarFunc
include RollBarScene
end
class Game_ActionResult
include RollBar
include RollBarActionResult
end
class Window_BattleLog
include RollBar
include RollBarBattleLog
end
if defined? XAS_SYSTEM
class Active_Hud
include RollBar
RollBarManager.define_huaka_method(self,:hp_flow_update) do
super()
if @actor.will_hp && @actor.hp != @actor.will_hp
will_hp_width = @hp_range * @actor.will_hp / @actor.mhp
color = @actor.will_hp < @actor.hp ? PRE_BAR_COLOR_DAMAGE[:hp] : PRE_BAR_COLOR_RECOVER[:hp]
color1 = color[0] ? color[0] : @hp_sprite.bitmap.get_pixel(0, 0)
color2 = color[1] ? color[1] : @hp_sprite.bitmap.get_pixel(0, 0)
width = [@hp_width,will_hp_width].max - [@hp_width,will_hp_width].min
@hp_sprite.bitmap.gradient_fill_rect([@hp_width,will_hp_width].min, 0, width, @hp_height, color1,color2)
end
end
RollBarManager.define_huaka_method(self,:sp_flow_update) do
super()
if @actor.will_mp && @actor.mp != @actor.will_mp
will_sp_width = @sp_range * @actor.will_mp / @actor.mmp
color = @actor.will_mp < @actor.mp ? PRE_BAR_COLOR_DAMAGE[:mp] : PRE_BAR_COLOR_RECOVER[:mp]
color1 = color[0] ? color[0] : @sp_sprite.bitmap.get_pixel(0, 0)
color2 = color[1] ? color[1] : @sp_sprite.bitmap.get_pixel(0, 0)
width = [@sp_width,will_sp_width].max - [@sp_width,will_sp_width].min
@sp_sprite.bitmap.gradient_fill_rect([@sp_width,will_sp_width].min, 0, width, @sp_height, color1,color2)
end
end
end
end