[XP] Script or event that displays enemy HP in battle?

level2janitor

Veteran
Veteran
Joined
Feb 8, 2018
Messages
47
Reaction score
13
First Language
English
Primarily Uses
RMXP
Not reliant on using a skill or anything, no need for a fancy HP bar, but I'd like my game to just show enemies' HP above their heads or below them, with or without max HP.
 

Lord Vectra

Master Eventer
Veteran
Joined
Dec 6, 2015
Messages
300
Reaction score
390
First Language
English
Primarily Uses
RMVXA
Can't find it online, but here is one I use:

Ruby:
#==============================================================================#
# ** 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
 

Latest Threads

Latest Posts

Latest Profile Posts

Debugging multiplayer issues... I'm having fun, right?
yay_streaming.jpg

For just starting streaming on the 10th... Definitely not the worst. :LZScheeze:

Granted I need 333.34 hours a month on average to achieve money. So I don't really expect that, but it sure has helped my game dev go much faster.
Proud on how this map turned out.

FnmhDLIXgAAOvIC
I just finally fixed a huge problem that wouldn’t let my game load and would crash it.. I thought that I was gonna have to trash the project and start over lol
The feeling when you finally found and killed that one gamebreaker that you could not really grasp before.:kaojoy:

Forum statistics

Threads
128,327
Messages
1,193,626
Members
168,808
Latest member
snotery
Top