○畫面:
○檢視:
#==============================================================================
#----------------------------------------------------------------------------
# ○ OSD - 腳本討論社
# Originality RGSS Discuss
# └http://guild.gamer.com.tw/guild.php?sn=4707
#----------------------------------------------------------------------------
#==============================================================================
#--------------------------------------------------------------------------
# ● 腳本名稱:漸變血條
#--------------------------------------------------------------------------
# ● 腳本效果:
# 改變血條的更新方法,
# 改成一點一點扣除,使用上可能影響效率
#--------------------------------------------------------------------------
# ● 腳本版本:1.00 版
#--------------------------------------------------------------------------
# ● 腳本更新區塊:
# 目前並無更新
#--------------------------------------------------------------------------
#==============================================================================
#----------------------------------------------------------------------------
# ○ OSD - 腳本討論社
# Originality RGSS Discuss
# └http://guild.gamer.com.tw/guild.php?sn=4707
#----------------------------------------------------------------------------
#==============================================================================
○使用方法:
※※※※※※※※※※※※※※※※※※※※
HP_Speed
控制 HP 漸減的速度。數字越大,漸減越慢。數字越小,漸減越快。
※※※※※※※※※※※※※※※※※※※※
SP_Speed
控制 SP 漸減的速度。數字越大,漸減越慢。數字越小,漸減越快。
※※※※※※※※※※※※※※※※※※※※
○腳本檢視:
○範例下載:
└ 下載點 1
└ 下載點 2
○檢視:
#==============================================================================
#----------------------------------------------------------------------------
# ○ OSD - 腳本討論社
# Originality RGSS Discuss
# └http://guild.gamer.com.tw/guild.php?sn=4707
#----------------------------------------------------------------------------
#==============================================================================
#--------------------------------------------------------------------------
# ● 腳本名稱:漸變血條
#--------------------------------------------------------------------------
# ● 腳本效果:
# 改變血條的更新方法,
# 改成一點一點扣除,使用上可能影響效率
#--------------------------------------------------------------------------
# ● 腳本版本:1.00 版
#--------------------------------------------------------------------------
# ● 腳本更新區塊:
# 目前並無更新
#--------------------------------------------------------------------------
#==============================================================================
#----------------------------------------------------------------------------
# ○ OSD - 腳本討論社
# Originality RGSS Discuss
# └http://guild.gamer.com.tw/guild.php?sn=4707
#----------------------------------------------------------------------------
#==============================================================================
○使用方法:
※※※※※※※※※※※※※※※※※※※※
HP_Speed
控制 HP 漸減的速度。數字越大,漸減越慢。數字越小,漸減越快。
※※※※※※※※※※※※※※※※※※※※
SP_Speed
控制 SP 漸減的速度。數字越大,漸減越慢。數字越小,漸減越快。
※※※※※※※※※※※※※※※※※※※※
○腳本檢視:
#============================================================================== #---------------------------------------------------------------------------- # ○ OSD - 腳本討論社 # Originality RGSS Discuss # └http://guild.gamer.com.tw/guild.php?sn=4707 #---------------------------------------------------------------------------- #============================================================================== #-------------------------------------------------------------------------- # ● 腳本名稱:漸變血條 #-------------------------------------------------------------------------- # ● 腳本效果: # 改變血條的更新方法, # 改成一點一點扣除,使用上可能影響效率 #-------------------------------------------------------------------------- # ● 腳本版本:1.00 版 #-------------------------------------------------------------------------- # ● 腳本更新區塊: # 目前並無更新 #-------------------------------------------------------------------------- #============================================================================== #---------------------------------------------------------------------------- # ○ OSD - 腳本討論社 # Originality RGSS Discuss # └http://guild.gamer.com.tw/guild.php?sn=4707 #---------------------------------------------------------------------------- #============================================================================== #-------------------------------------------------------------------------- # ● 漸變血條自定義區 #-------------------------------------------------------------------------- module Diminution_Bar # 控制 HP 的快慢 HP_Speed = 10 # 控制 SP 的快慢 SP_Speed = 10 end #============================================================================== # ■ Window_Base #------------------------------------------------------------------------------ # 遊戲中全部視窗的超級類別。 #============================================================================== class Window_Base < Window #-------------------------------------------------------------------------- # ● 描繪 HP # actor : 角色 # x : 描畫目標 X 座標 # y : 描畫目標 Y 座標 # width : 描畫目標的寬度 #-------------------------------------------------------------------------- alias draw_actor_hp_osd draw_actor_hp def draw_actor_hp(actor, x, y, width = 144) # 如果在沒有戰鬥中的情況下 if !$game_temp.in_battle # 描繪 HP 條 draw_actor_hp_bar(actor, x, y + 10, width, 12) end draw_actor_hp_osd(actor, x, y, width) end #-------------------------------------------------------------------------- # ● 描繪 HP 框 #-------------------------------------------------------------------------- def draw_actor_hp_bar(actor, x, y, width, height) # 描繪第一外框 self.contents.fill_rect(x, y, width, height, Color.new(50, 0, 0, 255)) # 描繪第二外框 self.contents.fill_rect(x + 1, y + 1, width - 2, height - 2, Color.new(200, 200, 200, 255)) # 描繪第三外框 self.contents.fill_rect(x + 2, y + 2, width - 4, height - 4, Color.new(50, 0, 0, 255)) # 獲取描繪程度 hp_width = actor.hp_real * (width - 4) / actor.maxhp # 描繪內框 (0...hp_width).each {|i| self.contents.fill_rect(x + i + 2, y + 2, 1, height - 4, Color.new(220, i, i / 2, 255)) } end #-------------------------------------------------------------------------- # ● 描繪 SP # actor : 角色 # x : 描畫目標 X 座標 # y : 描畫目標 Y 座標 # width : 描畫目標的寬度 #-------------------------------------------------------------------------- alias draw_actor_sp_osd draw_actor_sp def draw_actor_sp(actor, x, y, width = 144) # 如果在沒有戰鬥中的情況下 if !$game_temp.in_battle # 描繪 SP 條 draw_actor_sp_bar(actor, x, y + 10, width, 12) end draw_actor_sp_osd(actor, x, y, width) end #-------------------------------------------------------------------------- # ● 描繪 SP 框 #-------------------------------------------------------------------------- def draw_actor_sp_bar(actor, x, y, width, height) # 描繪第一外框 self.contents.fill_rect(x, y, width, height, Color.new(0, 0, 50, 255)) # 描繪第二外框 self.contents.fill_rect(x + 1, y + 1, width - 2, height - 2, Color.new(200, 200, 200, 255)) # 描繪第三外框 self.contents.fill_rect(x + 2, y + 2, width - 4, height - 4, Color.new(0, 0, 50, 255)) # 獲取描繪程度 sp_width = actor.sp_real * (width - 4) / actor.maxsp # 描繪內框 (0...sp_width).each {|i| self.contents.fill_rect(x + i + 2, y + 2, 1, height - 4, Color.new(i, i, 220, 255)) } end end #============================================================================== # ■ Game_Battler (第一部份) #------------------------------------------------------------------------------ # 處理戰鬥者的類別。這個類別作為 Game_Actor 類別與 Game_Enemy 類別總綱來使用。 #============================================================================== class Game_Battler #-------------------------------------------------------------------------- # ● 定義實例變量 #-------------------------------------------------------------------------- attr_writer :hp_space # HP儲存空間 attr_accessor :hp_real # HP儲存空間 attr_writer :sp_space # SP儲存空間 attr_accessor :sp_real # SP儲存空間 #-------------------------------------------------------------------------- # ● 初始化目標 #-------------------------------------------------------------------------- alias initialize_osd initialize def initialize initialize_osd @hp_space = 0 @hp_real = @hp @sp_space = 0 @sp_real = @sp end #-------------------------------------------------------------------------- # ● 獲取目前 HP 儲存空間 #-------------------------------------------------------------------------- def hp_space if @hp_real != @hp @hp_space = @hp_real - @hp else return @hp_space end end #-------------------------------------------------------------------------- # ● 獲取目前 SP 儲存空間 #-------------------------------------------------------------------------- def sp_space if @sp_real != @sp @sp_space = @sp_real - @sp else return @sp_space end end end #============================================================================== # ■ Window_Battle_HP #------------------------------------------------------------------------------ # 顯示戰鬥畫面同伴狀態的視窗。 #============================================================================== class Window_Battle_HP < Window_Base #-------------------------------------------------------------------------- # ● 初始化目標 #-------------------------------------------------------------------------- def initialize(battler) super(0, 320, 640, 160) self.contents = Bitmap.new(width - 32, height - 32) @battler = battler battler.each {|actor| hp_bar_refresh(actor) } self.opacity = 0 end #-------------------------------------------------------------------------- # ● 釋放所佔用的記憶體空間 #-------------------------------------------------------------------------- def dispose super end #-------------------------------------------------------------------------- # ● 刷新 HP 條 #-------------------------------------------------------------------------- def hp_bar_refresh(battler) draw_actor_hp_bar(battler, battler.index * 160 + 4, 44, 120, 12) end #-------------------------------------------------------------------------- # ● 刷新 HP 速度 #-------------------------------------------------------------------------- def hp_space_count(battler) return battler.hp_space / Diminution_Bar::HP_Speed end #-------------------------------------------------------------------------- # ● 更新 #-------------------------------------------------------------------------- def update super @battler.each {|actor| if actor.hp_space != 0 and !actor.dead? actor.hp_real -= hp_space_count(actor) actor.hp_space -= hp_space_count(actor) hp_bar_refresh(actor) elsif actor.hp_space != 0 and actor.dead? if actor.hp_space > 0 actor.hp_real -= hp_space_count(actor) actor.hp_space -= hp_space_count(actor) hp_bar_refresh(actor) end end } end end #============================================================================== # ■ Window_Battle_SP #------------------------------------------------------------------------------ # 顯示戰鬥畫面同伴狀態的視窗。 #============================================================================== class Window_Battle_SP < Window_Base #-------------------------------------------------------------------------- # ● 初始化目標 #-------------------------------------------------------------------------- def initialize(battler) super(0, 320, 640, 160) self.contents = Bitmap.new(width - 32, height - 32) @battler = battler battler.each {|actor| sp_bar_refresh(actor) } self.opacity = 0 end #-------------------------------------------------------------------------- # ● 釋放所佔用的記憶體空間 #-------------------------------------------------------------------------- def dispose super end #-------------------------------------------------------------------------- # ● 刷新 SP #-------------------------------------------------------------------------- def sp_bar_refresh(battler) draw_actor_sp_bar(battler, battler.index * 160 + 4, 76, 120, 12) end #-------------------------------------------------------------------------- # ● 刷新 SP 速度 #-------------------------------------------------------------------------- def sp_space_count(battler) return battler.sp_space / Diminution_Bar::SP_Speed end #-------------------------------------------------------------------------- # ● 更新 #-------------------------------------------------------------------------- def update super @battler.each {|actor| if actor.sp_space != 0 and !actor.dead? actor.sp_real -= sp_space_count(actor) actor.sp_space -= sp_space_count(actor) sp_bar_refresh(actor) elsif actor.sp_space != 0 and actor.dead? if actor.sp_space > 0 actor.sp_real -= sp_space_count(actor) actor.sp_space -= sp_space_count(actor) sp_bar_refresh(actor) end end } end end #============================================================================== # ■ Scene_Battle (第一部份) #------------------------------------------------------------------------------ # 處理戰鬥畫面的類別。 #============================================================================== class Scene_Battle alias main_osd main def main # 更新 HP $game_party.actors.each {|battler| battler.hp_real = battler.hp battler.sp_real = battler.sp } # 製作 HP 條 @battler_hp = Window_Battle_HP.new($game_party.actors) @battler_hp.z = 100 # 製作 SP 條 @battler_sp = Window_Battle_SP.new($game_party.actors) @battler_sp.z = 100 # 呼叫原有方法 main_osd # 釋放 @battler_hp.dispose @battler_sp.dispose end #-------------------------------------------------------------------------- # ● 更新畫面 #-------------------------------------------------------------------------- alias update_osd update def update # 更新 HP 條 @battler_hp.update # 更新 SP 條 @battler_sp.update # 呼叫原有方法 update_osd end end |
○範例下載:
└ 下載點 1
└ 下載點 2