赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 4753 |
最后登录 | 2014-12-31 |
在线时间 | 133 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 133 小时
- 注册时间
- 2012-8-23
- 帖子
- 126
|
《转轮血条》
#转轮血条
#章半仙制作
module RollBar
ROLL_UNIT = 1 #每次转轮扣的血
ROLL_TIME = 0.05 #每次转轮花的秒数
DEFAULT_SYS= false #如果是默认系统设为true会略微提升一点效率- -b
VERSION = 0.92
end
class Game_Actor
include RollBar
def hp=(hp)
fucker_hp = [[hp, mhp].min, 0].max - @hp
rec = fucker_hp > 0
Thread.new do
(fucker_hp / ROLL_UNIT).truncate.abs.times do
rec ? @hp = [@hp + ROLL_UNIT, mhp].min : @hp = [@hp - ROLL_UNIT, 0].max
refresh
sleep(ROLL_TIME)
end
end
end
def mp=(mp)
fucker_mp = [[mp, mmp].min, 0].max - @mp
rec = fucker_mp > 0
Thread.new do
(fucker_mp / ROLL_UNIT).truncate.abs.times do
rec ? @mp = [@mp + ROLL_UNIT, mmp].min : @mp = [@mp - ROLL_UNIT, 0].max
refresh
sleep(ROLL_TIME)
end
end
end
def tp=(tp)
fucker_tp = [[tp, max_tp].min, 0].max - @tp
rec = fucker_tp > 0
Thread.new do
(fucker_tp / ROLL_UNIT).truncate.abs.times do
rec ? @tp = [@tp + ROLL_UNIT, max_tp].min : @tp = [@tp - ROLL_UNIT, 0].max
sleep(ROLL_TIME)
end
end
end
alias fucker_clear_actions clear_actions
def clear_actions
fucker_clear_actions
@actions.push Game_Action.new(self)
end
end
class Window_Base
include RollBar
alias fucker_draw_actor_hp draw_actor_hp
alias fucker_draw_actor_mp draw_actor_mp
alias fucker_draw_actor_tp draw_actor_tp
alias fucker_dispose dispose
def draw_actor_hp(actor, x, y, width = 124)
reg_window
unless DEFAULT_SYS
@hp_need_refresh.each_key do |i|
@hp_need_refresh.delete(i) if i[1] == x && i[2] == y
end
end
fucker_draw_actor_hp(actor, x, y, width)
end
def draw_actor_mp(actor, x, y, width = 124)
reg_window
unless DEFAULT_SYS
@mp_need_refresh.each_key do |i|
@mp_need_refresh.delete(i) if i[1] == x && i[2] == y
end
end
fucker_draw_actor_mp(actor, x, y, width)
end
def draw_actor_tp(actor, x, y, width = 124)
reg_window
unless DEFAULT_SYS
@tp_need_refresh.each_key do |i|
@tp_need_refresh.delete(i) if i[1] == x && i[2] == y
end
end
fucker_draw_actor_tp(actor, x, y, width)
end
def dispose
unreg_window
fucker_dispose
end
def reg_window
unless @reg
@reg = true
Graphics.reg_window(self)
return if DEFAULT_SYS
@hp_need_refresh = {}
@mp_need_refresh = {}
@tp_need_refresh = {}
class << self
def roll_bar_refresh
@hp_need_refresh.each_pair do |p,v|
next if p[0].hp == v
contents.clear_rect(p[1], p[2], p[3], line_height)
fucker_draw_actor_hp(*p)
end
@mp_need_refresh.each_pair do |p,v|
next if p[0].mp == v
contents.clear_rect(p[1], p[2], p[3], line_height)
fucker_draw_actor_mp(*p)
end
@tp_need_refresh.each_pair do |p,v|
next if p[0].tp == v
contents.clear_rect(p[1], p[2], p[3], line_height)
fucker_draw_actor_tp(*p)
end
end
def fucker_draw_actor_hp(*args)
@hp_need_refresh[args] = args[0].hp
#super
self.class.instance_method(:fucker_draw_actor_hp).bind(self).call(*args)
end
def fucker_draw_actor_mp(*args)
@mp_need_refresh[args] = args[0].mp
#super
self.class.instance_method(:fucker_draw_actor_mp).bind(self).call(*args)
end
def fucker_draw_actor_tp(*args)
@tp_need_refresh[args] = args[0].tp
#super
self.class.instance_method(:fucker_draw_actor_tp).bind(self).call(*args)
end
end
end
end
def unreg_window
@reg = false
Graphics.unreg_window(self)
end
end
class << Graphics
alias fucker_update update
def reg_window(window)
@need_refresh ||= []
@need_refresh.push window unless @need_refresh.include? window
end
def unreg_window(window)
@need_refresh.delete window if @need_refresh.is_a? Array
end
def update
fucker_update
unless @need_refresh.nil?
for i in @need_refresh
i.roll_bar_refresh if i.visible
end
end
end
end
if RollBar::DEFAULT_SYS
#以下解决效率问题,可能会造成冲突- -b
class Window_BattleStatus
def roll_bar_refresh
for i in 0...$game_party.battle_members.size
actor = $game_party.battle_members
x = gauge_area_rect(i).x
y = gauge_area_rect(i).y
height = line_height
@fucker_hp ||= []
if @fucker_hp != actor.hp
contents.clear_rect(x, y, 72, height)
draw_actor_hp(actor, x, y,72)
@fucker_hp = actor.hp
end
@fucker_mp ||= []
if @fucker_mp != actor.mp
contents.clear_rect(x + 82, y, 64, height)
draw_actor_mp(actor, x + 82, y, 64)
@fucker_mp = actor.mp
end
@fucker_tp ||= []
if @fucker_tp != actor.tp
contents.clear_rect( x + 156, y, 64, height)
draw_actor_tp(actor, x + 156, y, 64)
@fucker_tp = actor.tp
end
end
end
end
class Window_MenuStatus
def roll_bar_refresh
for i in 0...$game_party.battle_members.size
actor = $game_party.battle_members
x = item_rect(i).x + 108 + 120
y = item_rect(i).y + line_height / 2
width = 124
height = line_height
@fucker_hp ||= []
if @fucker_hp != actor.hp
contents.clear_rect(x, y + line_height, width, height)
draw_actor_hp(actor, x, y + line_height)
@fucker_hp = actor.hp
end
@fucker_mp ||= []
if @fucker_mp != actor.mp
contents.clear_rect(x, y + line_height * 2, width, height)
draw_actor_mp(actor, x, y + line_height * 2)
@fucker_mp = actor.mp
end
end
end
end
class Window_SkillStatus
def roll_bar_refresh
x = 108 + 120
y = line_height / 2
width = 124
height = line_height
if @fucker_hp != @actor.hp
contents.clear_rect(x, y + line_height, width, height)
draw_actor_hp(@actor, x, y + line_height)
@fucker_hp = @actor.hp
end
if @fucker_mp != @actor.mp
contents.clear_rect(x, y + line_height * 2, width, height)
draw_actor_mp(@actor, x, y + line_height * 2)
@fucker_mp = @actor.mp
end
end
end
class Window_Status
def roll_bar_refresh
x = 136
y = line_height * 3
width = 124
height = line_height
if @fucker_hp != @actor.hp
contents.clear_rect(x, y + line_height, width, height)
draw_actor_hp(@actor, x, y + line_height)
@fucker_hp = @actor.hp
end
if @fucker_mp != @actor.mp
contents.clear_rect(x, y + line_height * 2, width, height)
draw_actor_mp(@actor, x, y + line_height * 2)
@fucker_mp = @actor.mp
end
end
end
end |
|