#==============================================================================#
# ** Enemy HP and SP bars Addon v1.0 ** #
#==============================================================================#
# Author: Diagostimo #
#------------------------------------------------------------------------------#
# Description: #
# #
# this script adds HP and SP bars below enemies while in battle, this #
# enables you to see the current state of the enemy. #
# this script will most likely be compatible with most custom battle #
# systems that use Sprite_battler to display the battler, note that the #
# size of the bars have been designed with the default system in mind. #
# #
#==============================================================================#
#==============================================================================
# ** Sprite_Battler
#==============================================================================
class Sprite_Battler < RPG::Sprite
#----------------------------------------------------------------------------
# * Object Initialization
#----------------------------------------------------------------------------
alias init_battle_bars initialize
def initialize(viewport, battler = nil)
init_battle_bars(viewport, battler)
if @battler.is_a?(Game_Enemy)
@bars_sprite = RPG::Sprite.new
@bars_sprite.x = @battler.screen_x - 26
@bars_sprite.y = @battler.screen_y + 7
@bars_sprite.z = 50
@bars_sprite.bitmap = Bitmap.new(54, 15)
@bars_sprite.opacity = 0
end
end
#----------------------------------------------------------------------------
# Frame Update
#----------------------------------------------------------------------------
alias update_battle_bars update
def update
update_battle_bars
if @battler.is_a?(Game_Enemy)
update_bars
end
end
#----------------------------------------------------------------------------
# * Frame update of bars
#----------------------------------------------------------------------------
def update_bars
@bars_sprite.opacity = self.opacity
if @bars_sprite.opacity > 0
@bars_sprite.bitmap.clear
#shell
rect = Rect.new(0, 0, 54, 15)
@bars_sprite.bitmap.fill_rect(rect, Color.new(0, 0, 0))
rect = Rect.new(1, 1, 52, 6)
@bars_sprite.bitmap.fill_rect(rect, Color.new(255, 255, 255))
rect = Rect.new(1, 8, 52, 6)
@bars_sprite.bitmap.fill_rect(rect, Color.new(255, 255, 255))
#draw hp
width = 50 * @battler.hp / @battler.maxhp
rect = Rect.new(2, 2, width, 4)
@bars_sprite.bitmap.fill_rect(rect, Color.new(255, 0, 0))
#draw sp
width = 50 * @battler.sp / (@battler.maxsp + 1)
rect = Rect.new(2, 9, width, 4)
@bars_sprite.bitmap.fill_rect(rect, Color.new(0, 0, 255))
end
end
#----------------------------------------------------------------------------
# * Collapse
#----------------------------------------------------------------------------
def collapse
super
if @battler.is_a?(Game_Enemy)
@bars_sprite.collapse
end
end
#----------------------------------------------------------------------------
# * Dispose
#----------------------------------------------------------------------------
def dispose
super
if @battler.is_a?(Game_Enemy)
@bars_sprite.dispose
end
end
end