FinnishEngineer

Veteran
Veteran
Joined
Oct 20, 2021
Messages
65
Reaction score
15
First Language
finnish
Primarily Uses
RMVXA
I already have a perfect script for the hp, but it would be very neat to have sp and tp with it.
does anyone know where i could get one?
hp.png also here is the image of the hp bar
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
4,819
Reaction score
1,368
First Language
English
Primarily Uses
RMVXA
If this is not a custom script that you wrote and don't want to share or a commission script , then tell us what the script is and we can probably add on those options or perhaps you would like to try others. I'm pretty sure I have one that does HP & MP but not TP.
 

FinnishEngineer

Veteran
Veteran
Joined
Oct 20, 2021
Messages
65
Reaction score
15
First Language
finnish
Primarily Uses
RMVXA
If this is not a custom script that you wrote and don't want to share or a commission script , then tell us what the script is and we can probably add on those options or perhaps you would like to try others. I'm pretty sure I have one that does HP & MP but not TP.
Well, the tp is not that important
Code:
#==============================================================================
#
# ▼ Yanfly Engine Ace - Battle Engine Add-On: Enemy HP Bars v1.10
# -- Last Updated: 2012.02.10
# -- Level: Easy, Normal
# -- Requires: YEA - Ace Battle Engine v1.00+.
#
#==============================================================================

$imported = {} if $imported.nil?
$imported["YEA-EnemyHPBars"] = true

#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2012.02.10 - Bug Fixed: AoE selection doesn't reveal hidden enemies.
# 2012.02.01 - Bug Fixed: Back and front of gauge randomly don't appear.
# 2012.01.11 - Efficiency update.
# 2012.01.04 - Compatibility Update: Area of Effect
# 2011.12.28 - Efficiency update.
#            - Bug Fixed: HP bars didn't disappear after a heal.
# 2011.12.26 - Bug Fixed: HP bars were not depleting.
# 2011.12.23 - Efficiency update.
# 2011.12.10 - Bug Fixed: HP bars no longer appear when dead and an AoE skill
#              has been selected.
# 2011.12.08 - New feature. Hide HP Bars until defeated once.
# 2011.12.06 - Started Script and Finished.
#
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script shows HP gauges on enemies as they're selected for targeting or
# whenever they're damaged. The HP gauges will actually slide downward or
# upward as the enemies take damage.
#
# Included in v1.01 is the option to require the player having slain an enemy
# once before enemies of that type will show their HP gauge.
#
#==============================================================================
# ▼ Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
#
# -----------------------------------------------------------------------------
# Enemy Notetags - These notetags go in the enemy notebox in the database.
# -----------------------------------------------------------------------------
# <back gauge: x>
# Changes the colour of the enemy HP back gauge to x where x is the text colour
# used from the "Window" skin image under Graphics\System.
#
# <hp gauge 1: x>
# <hp gauge 2: x>
# Changes the colour of the enemy HP HP gauge to x where x is the text colour
# used from the "Window" skin image under Graphics\System.
#
# <hide gauge>
# <show gauge>
# Hides/shows HP gauge for enemies in battle. These gauges appear whenever the
# enemy is targeted for battle or whenever the enemy takes HP damage. Note that
# using the <show gauge> tag will bypass the requirement for needing to defeat
# an enemy once if that setting is enabled.
#
#==============================================================================
# ▼ Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjusting.
#
# This script requires Yanfly Engine Ace - Ace Battle Engine v1.00+ and the
# script must be placed under Ace Battle Engine in the script listing.
#
#==============================================================================

module YEA
  module BATTLE
  
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # - Enemy HP Gauges -
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # Adjust the settings for the enemy HP gauges. You can choose to show the
    # enemy HP gauges by default, the size of the gauge, the colour of the
    # gauge, and the back colour of the gauge.
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    SHOW_ENEMY_HP_GAUGE    = true   # Display Enemy HP Gauge?
    ANIMATE_HP_GAUGE       = false   # Animate the HP gauge?
    DEFEAT_ENEMIES_FIRST   = false  # Must defeat enemy first to show HP?
    ENEMY_GAUGE_WIDTH      = 92    # How wide the enemy gauges are.
    ENEMY_GAUGE_HEIGHT     = 12     # How tall the enemy gauges are.
    ENEMY_HP_GAUGE_COLOUR1 = 28     # Colour 1 for HP.
    ENEMY_HP_GAUGE_COLOUR2 = 29     # Colour 2 for HP.
    ENEMY_BACKGAUGE_COLOUR = 19     # Gauge Back colour.
  
  end # BATTLE
end # YEA

#==============================================================================
# ▼ Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death, and/or
# halitosis so edit at your own risk.
#==============================================================================

if $imported["YEA-BattleEngine"]

module YEA
  module REGEXP
  module ENEMY
  
    HIDE_GAUGE = /<(?:HIDE_GAUGE|hide gauge)>/i
    SHOW_GAUGE = /<(?:SHOW_GAUGE|show gauge)>/i
  
    BACK_GAUGE = /<(?:BACK_GAUGE|back gauge):[ ]*(\d+)>/i
    HP_GAUGE_1 = /<(?:HP_GAUGE_1|hp gauge 1):[ ]*(\d+)>/i
    HP_GAUGE_2 = /<(?:HP_GAUGE_2|hp gauge 2):[ ]*(\d+)>/i
  
  end # ENEMY
  end # REGEXP
end # YEA

#==============================================================================
# ■ DataManager
#==============================================================================

module DataManager
 
  #--------------------------------------------------------------------------
  # alias method: load_database
  #--------------------------------------------------------------------------
  class <<self; alias load_database_ehpb load_database; end
  def self.load_database
    load_database_ehpb
    load_notetags_ehpb
  end
 
  #--------------------------------------------------------------------------
  # new method: load_notetags_ehpb
  #--------------------------------------------------------------------------
  def self.load_notetags_ehpb
    groups = [$data_enemies]
    for group in groups
      for obj in group
        next if obj.nil?
        obj.load_notetags_ehpb
      end
    end
  end
 
end # DataManager

#==============================================================================
# ■ RPG::Enemy
#==============================================================================

class RPG::Enemy < RPG::BaseItem
 
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :show_gauge
  attr_accessor :require_death_show_gauge
  attr_accessor :back_gauge_colour
  attr_accessor :hp_gauge_colour1
  attr_accessor :hp_gauge_colour2
 
  #--------------------------------------------------------------------------
  # common cache: load_notetags_ehpb
  #--------------------------------------------------------------------------
  def load_notetags_ehpb
    @show_gauge = YEA::BATTLE::SHOW_ENEMY_HP_GAUGE
    @require_death_show_gauge = YEA::BATTLE::DEFEAT_ENEMIES_FIRST
    @back_gauge_colour = YEA::BATTLE::ENEMY_BACKGAUGE_COLOUR
    @hp_gauge_colour1 = YEA::BATTLE::ENEMY_HP_GAUGE_COLOUR1
    @hp_gauge_colour2 = YEA::BATTLE::ENEMY_HP_GAUGE_COLOUR2
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when YEA::REGEXP::ENEMY::HIDE_GAUGE
        @show_gauge = false
      when YEA::REGEXP::ENEMY::SHOW_GAUGE
        @show_gauge = true
        @require_death_show_gauge = false
      when YEA::REGEXP::ENEMY::BACK_GAUGE
        @back_gauge_colour = [$1.to_i, 31].min
      when YEA::REGEXP::ENEMY::HP_GAUGE_1
        @hp_gauge_colour1 = [$1.to_i, 31].min
      when YEA::REGEXP::ENEMY::HP_GAUGE_2
        @hp_gauge_colour2 = [$1.to_i, 31].min
      end
    } # self.note.split
    #---
  end
 
end # RPG::Enemy

#==============================================================================
# ■ Sprite_Battler
#==============================================================================

class Sprite_Battler < Sprite_Base
 
  #--------------------------------------------------------------------------
  # alias method: initialize
  #--------------------------------------------------------------------------
  alias sprite_battler_initialize_ehpb initialize
  def initialize(viewport, battler = nil)
    sprite_battler_initialize_ehpb(viewport, battler)
    create_enemy_gauges
  end
 
  #--------------------------------------------------------------------------
  # alias method: dispose
  #--------------------------------------------------------------------------
  alias sprite_battler_dispose_ehpb dispose
  def dispose
    sprite_battler_dispose_ehpb
    dispose_enemy_gauges
  end
 
  #--------------------------------------------------------------------------
  # alias method: update
  #--------------------------------------------------------------------------
  alias sprite_battler_update_ehpb update
  def update
    sprite_battler_update_ehpb
    update_enemy_gauges
  end
 
  #--------------------------------------------------------------------------
  # new method: create_enemy_gauges
  #--------------------------------------------------------------------------
  def create_enemy_gauges
    return if @battler.nil?
    return if @battler.actor?
    return unless @battler.enemy.show_gauge
    @back_gauge_viewport = Enemy_HP_Gauge_Viewport.new(@battler, self, :back)
    @hp_gauge_viewport = Enemy_HP_Gauge_Viewport.new(@battler, self, :hp)
  end
 
  #--------------------------------------------------------------------------
  # new method: dispose_enemy_gauges
  #--------------------------------------------------------------------------
  def dispose_enemy_gauges
    @back_gauge_viewport.dispose unless @back_gauge_viewport.nil?
    @hp_gauge_viewport.dispose unless @hp_gauge_viewport.nil?
  end
 
  #--------------------------------------------------------------------------
  # new method: update_enemy_gauges
  #--------------------------------------------------------------------------
  def update_enemy_gauges
    @back_gauge_viewport.update unless @back_gauge_viewport.nil?
    @hp_gauge_viewport.update unless @hp_gauge_viewport.nil?
  end
 
  #--------------------------------------------------------------------------
  # new method: update_enemy_gauge_value
  #--------------------------------------------------------------------------
  def update_enemy_gauge_value
    @back_gauge_viewport.new_hp_updates unless @back_gauge_viewport.nil?
    @hp_gauge_viewport.new_hp_updates unless @hp_gauge_viewport.nil?
  end
 
end # Sprite_Battler

#==============================================================================
# ■ Game_BattlerBase
#==============================================================================

class Game_BattlerBase
 
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :hidden
 
  #--------------------------------------------------------------------------
  # alias method: refresh
  #--------------------------------------------------------------------------
  alias game_battlerbase_refresh_ehpb refresh
  def refresh
    game_battlerbase_refresh_ehpb
    return unless SceneManager.scene_is?(Scene_Battle)
    return if actor?
    sprite.update_enemy_gauge_value
  end
 
end # Game_BattlerBase

#==============================================================================
# ■ Game_Battler
#==============================================================================

class Game_Battler < Game_BattlerBase
 
  #--------------------------------------------------------------------------
  # alias method: die
  #--------------------------------------------------------------------------
  alias game_battler_die_ehpb die
  def die
    game_battler_die_ehpb
    return if actor?
    $game_party.add_defeated_enemy(@enemy_id)
  end
 
  #--------------------------------------------------------------------------
  # alias method: hp=
  #--------------------------------------------------------------------------
  alias game_battlerbase_hpequals_ehpb hp=
  def hp=(value)
    game_battlerbase_hpequals_ehpb(value)
    return unless SceneManager.scene_is?(Scene_Battle)
    return if actor?
    return if value == 0
    sprite.update_enemy_gauge_value
  end
 
end # Game_Battler

#==============================================================================
# ■ Game_Party
#==============================================================================

class Game_Party < Game_Unit
 
  #--------------------------------------------------------------------------
  # alias method: init_all_items
  #--------------------------------------------------------------------------
  alias game_party_init_all_items_ehpb init_all_items
  def init_all_items
    game_party_init_all_items_ehpb
    @defeated_enemies = []
  end
 
  #--------------------------------------------------------------------------
  # new method: defeated_enemies
  #--------------------------------------------------------------------------
  def defeated_enemies
    @defeated_enemies = [] if @defeated_enemies.nil?
    return @defeated_enemies
  end
 
  #--------------------------------------------------------------------------
  # new method: add_defeated_enemy
  #--------------------------------------------------------------------------
  def add_defeated_enemy(id)
    @defeated_enemies = [] if @defeated_enemies.nil?
    @defeated_enemies.push(id) unless @defeated_enemies.include?(id)
  end
 
end # Game_Party

#==============================================================================
# ■ Enemy_HP_Gauge_Viewport
#==============================================================================

class Enemy_HP_Gauge_Viewport < Viewport
 
  #--------------------------------------------------------------------------
  # initialize
  #--------------------------------------------------------------------------
  def initialize(battler, sprite, type)
    @battler = battler
    @base_sprite = sprite
    @type = type
    dw = YEA::BATTLE::ENEMY_GAUGE_WIDTH
    dw += 2 if @type == :back
    @start_width = dw
    dh = YEA::BATTLE::ENEMY_GAUGE_HEIGHT
    dh += 2 if @type == :back
    rect = Rect.new(0, 0, dw, dh)
    @current_hp = @battler.hp
    @current_mhp = @battler.mhp
    @target_gauge_width = target_gauge_width
    @gauge_rate = 1.0
    setup_original_hide_gauge
    super(rect)
    self.z = 125
    create_gauge_sprites
    self.visible = false
    update_position
  end
 
  #--------------------------------------------------------------------------
  # dispose
  #--------------------------------------------------------------------------
  def dispose
    @sprite.bitmap.dispose unless @sprite.bitmap.nil?
    @sprite.dispose
    super
  end
 
  #--------------------------------------------------------------------------
  # update
  #--------------------------------------------------------------------------
  def update
    super
    self.visible = gauge_visible?
    @sprite.ox += 4 if YEA::BATTLE::ANIMATE_HP_GAUGE
    update_position
    update_gauge
    @visible_counter -= 1
  end
 
  #--------------------------------------------------------------------------
  # setup_original_hide_gauge
  #--------------------------------------------------------------------------
  def setup_original_hide_gauge
    @original_hide = @battler.enemy.require_death_show_gauge
    return unless @original_hide
    if YEA::BATTLE::DEFEAT_ENEMIES_FIRST
      enemy_id = @battler.enemy_id
      @original_hide = !$game_party.defeated_enemies.include?(enemy_id)
    end
  end
 
  #--------------------------------------------------------------------------
  # create_gauge_sprites
  #--------------------------------------------------------------------------
  def create_gauge_sprites
    @sprite = Plane.new(self)
    dw = self.rect.width * 2
    @sprite.bitmap = Bitmap.new(dw, self.rect.height)
    case @type
    when :back
      colour1 = Colour.text_colour(@battler.enemy.back_gauge_colour)
      colour2 = Colour.text_colour(@battler.enemy.back_gauge_colour)
    when :hp
      colour1 = Colour.text_colour(@battler.enemy.hp_gauge_colour1)
      colour2 = Colour.text_colour(@battler.enemy.hp_gauge_colour2)
    end
    dx = 0
    dy = 0
    dw = self.rect.width
    dh = self.rect.height
    @gauge_width = target_gauge_width
    @sprite.bitmap.gradient_fill_rect(dx, dy, dw, dh, colour1, colour2)
    @sprite.bitmap.gradient_fill_rect(dw, dy, dw, dh, colour2, colour1)
    @visible_counter = 0
  end
 
  #--------------------------------------------------------------------------
  # update_visible
  #--------------------------------------------------------------------------
  def gauge_visible?
    update_original_hide
    return false if @original_hide
    return false if case_original_hide?
    return true if @visible_counter > 0
    return true if @gauge_width != @target_gauge_width
    if SceneManager.scene_is?(Scene_Battle)
      return false if SceneManager.scene.enemy_window.nil?
      unless @battler.dead?
        if SceneManager.scene.enemy_window.active
          return false if @battler.enemy? && @battler.hidden
          return true if SceneManager.scene.enemy_window.enemy == @battler
          return true if SceneManager.scene.enemy_window.select_all?
          return true if highlight_aoe?
        end
      end
    end
    return false
  end
 
  #--------------------------------------------------------------------------
  # highlight_aoe?
  #--------------------------------------------------------------------------
  def highlight_aoe?
    return false unless $imported["YEA-AreaofEffect"]
    return false if @battler.enemy? && @battler.hidden
    return SceneManager.scene.enemy_window.hightlight_aoe?(@battler)
  end
 
  #--------------------------------------------------------------------------
  # new_hp_updates
  #--------------------------------------------------------------------------
  def new_hp_updates
    return if @current_hp == @battler.hp && @current_mhp == @battler.mhp
    @current_hp = @battler.hp
    @current_mhp = @battler.mhp
    return if @gauge_rate == target_gauge_rate
    @gauge_rate = target_gauge_rate
    @target_gauge_width = target_gauge_width
    @visible_counter = 60
  end
 
  #--------------------------------------------------------------------------
  # case_original_hide?
  #--------------------------------------------------------------------------
  def case_original_hide?
    return false if !@battler.enemy.require_death_show_gauge
    if YEA::BATTLE::DEFEAT_ENEMIES_FIRST
      enemy_id = @battler.enemy_id
      return true unless $game_party.defeated_enemies.include?(enemy_id)
    end
    return false
  end
 
  #--------------------------------------------------------------------------
  # update_original_hide
  #--------------------------------------------------------------------------
  def update_original_hide
    return unless @original_hide
    return if @battler.dead?
    enemy_id = @battler.enemy_id
    @original_hide = false if $game_party.defeated_enemies.include?(enemy_id)
  end
 
  #--------------------------------------------------------------------------
  # update_position
  #--------------------------------------------------------------------------
  def update_position
    dx = @battler.screen_x - @start_width / 2
    dy = @battler.screen_y
    self.rect.x = dx
    self.rect.y = dy
    dh = self.rect.height + 1
    dh += 2 unless @type == :back
    dy = [@battler.screen_y, Graphics.height - dh - 120].min
    dy += 1 unless @type == :back
    self.rect.y = dy
  end
 
  #--------------------------------------------------------------------------
  # update_gauge
  #--------------------------------------------------------------------------
  def update_gauge
    return if @gauge_width == @target_gauge_width
    rate = 3
    @target_gauge_width = target_gauge_width
    if @gauge_width > @target_gauge_width
      @gauge_width = [@gauge_width - rate, @target_gauge_width].max
    elsif @gauge_width < @target_gauge_width
      @gauge_width = [@gauge_width + rate, @target_gauge_width].min
    end
    @visible_counter = @gauge_width == 0 ? 10 : 60
    return if @type == :back
    self.rect.width = @gauge_width
  end
 
  #--------------------------------------------------------------------------
  # target_gauge_rate
  #--------------------------------------------------------------------------
  def target_gauge_rate
    return @current_hp.to_f / @current_mhp.to_f
  end
 
  #--------------------------------------------------------------------------
  # target_gauge_width
  #--------------------------------------------------------------------------
  def target_gauge_width
    return [@current_hp * @start_width / @current_mhp, @start_width].min
  end
 
end # Enemy_HP_Gauge_Viewport

end # $imported["YEA-BattleEngine"]

#==============================================================================
#
# ▼ End of File
#
#==============================================================================

Code:
#==============================================================================|
#  ** DoubleX RMVXA Percentage Addon v1.03a to Yanfly Engine Ace - Battle      |
#     Engine Add-On: Enemy HP Bars                                             |
#------------------------------------------------------------------------------|
#  * Changelog                                                                 |
#    v1.03a(GMT 0200 6-4-2015):                                                |
#    - Added CRISIS_TEXT_COLOR and KNOCKOUT_TEXT_COLOR                         |
#    v1.02a(GMT 0300 4-9-2014):                                                |
#    - Added hp texts x and y offsets relative to respective bars              |
#    - Added TEXT_COLOR and FIX_LARGE_TEXT                                     |
#    v1.01a(GMT 1400 21-7-2014):                                               |
#    - Lets users shows actual hp numbers instead of percentages               |
#    - Lets users sets the size of the text shown on enemy hp bars             |
#    v1.00a(GMT 0400 1-7-2014):                                                |
#    - 1st version of this script finished                                     |
#------------------------------------------------------------------------------|
#  * Author                                                                    |
#    DoubleX:                                                                  |
#    - This script                                                             |
#    Yanfly:                                                                   |
#    - Yanfly Engine Ace - Battle Engine Add-On: Enemy HP Bars                 |
#------------------------------------------------------------------------------|
#  * Terms of use                                                              |
#    Same as that of Yanfly Engine Ace - Battle Engine Add-On: Enemy HP Bars   |
#    except that you're not allowed to give DoubleX or his alias credit        |
#------------------------------------------------------------------------------|
#  * Prerequisites                                                             |
#    Scripts:                                                                  |
#    - Yanfly Engine Ace - Battle Engine Add-On: Enemy HP Bars                 |
#    Knowledge:                                                                |
#    - That of using the script                                                |
#    Yanfly Engine Ace - Battle Engine Add-On: Enemy HP Bars                   |
#------------------------------------------------------------------------------|
#  * Functions                                                                 |
#    - Displays the current percentage of the hp bar filled                    |
#------------------------------------------------------------------------------|
#  * Manual                                                                    |
#    To use this script, open the script editor and put this script into an    |
#    open slot between the script                                              |
#    Yanfly Engine Ace - Battle Engine Add-On: Enemy HP Bars and ▼ Main.       |
#    Save to take effect.                                                      |
#------------------------------------------------------------------------------|
#  * Compatibility                                                             |
#    - Same as that of Yanfly Engine Ace - Battle Engine Add-On: Enemy HP Bars |
#==============================================================================|

($imported ||= {})["DoubleX RMVXA Percentage Addon to YEA-EnemyHPBars"] = true

#==============================================================================|
#  ** You only need to edit this part as it's about what this script does      |
#------------------------------------------------------------------------------|

module DoubleX_RMVXA
  module YEA_EnemyHPBars_Percentage_Addon

    # (v1.01a+)ACTUAL_NUMBER, default = false
    # Shows the actual hp numbers instead of the percentages
    ACTUAL_NUMBER = true

    # (v1.01a+)TEXT_SIZE, default = YEA::BATTLE::ENEMY_GAUGE_HEIGHT
    # Sets the size of the text shown on enemy hp bars as TEXT_SIZE
    TEXT_SIZE = 21

    # (v1.03a+)CRISIS_TEXT_COLOR, default = 17
    # Sets the text color of the text shown on enemy hp bars with hp crisis as
    # CRISIS_TEXT_COLOR
    CRISIS_TEXT_COLOR = 0

    # (v1.03a+)KNOCKOUT_TEXT_COLOR, default = 17
    # Sets the text color of the text shown on enemy hp bars with 0 hp as
    # KNOCKOUT_TEXT_COLOR
    KNOCKOUT_TEXT_COLOR = 18

    # (v1.02a+)TEXT_COLOR, default = 16
    # Sets the text color of the text shown on enemy hp bars as TEXT_COLOR
    TEXT_COLOR = 0

    # (v1.02a+)FIX_LARGE_TEXT, default = false
    # Fixes issues when TEXT_SIZE is much larger than ENEMY_GAUGE_HEIGHT
    FIX_LARGE_TEXT = true

    # (v1.02a+)TEXT_X_OFFSET, TEXT_Y_OFFSET, default = 0, 0
    # Sets the x and y offsets of the hp text relative to the hp bar
    TEXT_X_OFFSET = 5
    TEXT_Y_OFFSET = 0

  end # YEA_EnemyHPBars_Percentage_Addon
end # DoubleX_RMVXA

#==============================================================================|

#==============================================================================|
#  ** You need not edit this part as it's about how this script works          |
#------------------------------------------------------------------------------|

if $imported["YEA-BattleEngine"] && $imported["YEA-EnemyHPBars"]

#------------------------------------------------------------------------------|

class Sprite_Battler < Sprite_Base

  #----------------------------------------------------------------------------|
  #  Alias method: create_enemy_gauges                                         |
  #----------------------------------------------------------------------------|
  alias create_enemy_gauges_percentage_addon create_enemy_gauges
  def create_enemy_gauges
    create_enemy_gauges_percentage_addon
    # Added to create the percentage text
    return unless @battler && !@battler.actor? && @battler.enemy.show_gauge
    @percent_gauge_viewport = Enemy_HP_Gauge_Viewport.new(@battler, self,
    :percent)
    #
  end # create_enemy_gauges

  #----------------------------------------------------------------------------|
  #  Alias method: dispose_enemy_gauges                                        |
  #----------------------------------------------------------------------------|
  alias dispose_enemy_gauges_percentage_addon dispose_enemy_gauges
  def dispose_enemy_gauges
    dispose_enemy_gauges_percentage_addon
    # Added to dispose the percentage text
    @percent_gauge_viewport.dispose if @percent_gauge_viewport
    #
  end # dispose_enemy_gauges

  #----------------------------------------------------------------------------|
  #  Alias method: update_enemy_gauges                                         |
  #----------------------------------------------------------------------------|
  alias update_enemy_gauges_percentage_addon update_enemy_gauges
  def update_enemy_gauges
    update_enemy_gauges_percentage_addon
    # Added to update the percentage text
    @percent_gauge_viewport.update if @percent_gauge_viewport
    #
  end # update_enemy_gauges

  #----------------------------------------------------------------------------|
  #  Alias method: update_enemy_gauge_value                                    |
  #----------------------------------------------------------------------------|
  alias update_enemy_gauge_value_percentage_addon update_enemy_gauge_value
  def update_enemy_gauge_value
    update_enemy_gauge_value_percentage_addon
    # Added to update the percentage text
    @percent_gauge_viewport.new_hp_updates if @percent_gauge_viewport
    #
  end # update_enemy_gauge_value

end # Sprite_Battler

class Enemy_HP_Gauge_Viewport < Viewport

  include DoubleX_RMVXA::YEA_EnemyHPBars_Percentage_Addon
  #----------------------------------------------------------------------------|
  #  Rewrite method: initialize                                                |
  #----------------------------------------------------------------------------|
  def initialize(battler, sprite, type)
    @battler = battler
    @base_sprite = sprite
    @type = type
    dw = YEA::BATTLE::ENEMY_GAUGE_WIDTH
    # Rewritten to setup the percentage text
    if @type == :percent && FIX_LARGE_TEXT
      dh = [TEXT_SIZE, YEA::BATTLE::ENEMY_GAUGE_HEIGHT].max
    else
      dh = YEA::BATTLE::ENEMY_GAUGE_HEIGHT
    end
    if @type != :hp
      dw += 2
      dh += 2
    end
    #
    @start_width = dw
    rect = Rect.new(0, 0, dw, dh)
    @current_hp = @battler.hp
    @current_mhp = @battler.mhp
    @target_gauge_width = target_gauge_width
    @gauge_rate = 1.0
    setup_original_hide_gauge
    super(rect)
    self.z = 125
    create_gauge_sprites
    self.visible = false
    update_position
    self.rect.width = @gauge_width if @type == :hp
  end # initialize

  #----------------------------------------------------------------------------|
  #  Rewrite method: create_gauge_sprites                                      |
  #----------------------------------------------------------------------------|
  def create_gauge_sprites
    @sprite = Plane.new(self)
    @sprite.bitmap = Bitmap.new(rect.width * 4, rect.height)
    enemy = @battler.enemy
    if @type == :back
      colour = Colour.text_colour(enemy.back_gauge_colour)
      colour1 = colour2 = colour
    elsif @type == :hp
      colour1 = Colour.text_colour(enemy.hp_gauge_colour1)
      colour2 = Colour.text_colour(enemy.hp_gauge_colour2)
    # Added to create the percentage text
    elsif @type == :percent
      colour1 = colour2 = Color.new(0, 0, 0, 0)
    end
    #
    dw = rect.width
    dh = rect.height
    @gauge_width = target_gauge_width
    @sprite.bitmap.gradient_fill_rect(0, 0, dw, dh, colour1, colour2)
    @sprite.bitmap.gradient_fill_rect(dw, 0, dw, dh, colour2, colour1)
    @visible_counter = 0
  end # create_gauge_sprites

  #----------------------------------------------------------------------------|
  #  Rewrite method: update_position                                           |
  #----------------------------------------------------------------------------|
  def update_position
    dx = @battler.screen_x
    dy = @battler.screen_y
    # Added to update the positions only if the battler positions change
    @update_position = false
    return if @last_x == dx && @last_y == dy
    @last_x = dx
    @last_y = dy
    @update_position = true
    #
    dx -= @start_width / 2
    # Added to set the x and y offset of percentage text
    if @type == :percent
      dx += TEXT_X_OFFSET
      dy += TEXT_Y_OFFSET
    end
    #
    rect.x = dx
    rect.y = dy
    dh = rect.height + 1
    # Rewritten to ensure the percentage text won't overlap with the status
    # window
    dh += 2 if @type == :hp
    dy = [dy, Graphics.height - dh - 120].min
    dy += 1 if @type == :hp
    #
    rect.y = dy
  end # update_position

  #----------------------------------------------------------------------------|
  #  Rewrite method: update_gauge                                              |
  #----------------------------------------------------------------------------|
  def update_gauge
    return if @gauge_width == @target_gauge_width
    rate = 3
    @target_gauge_width = target_gauge_width
    if @gauge_width > @target_gauge_width
      @gauge_width = [@gauge_width - rate, @target_gauge_width].max
    elsif @gauge_width < @target_gauge_width
      @gauge_width = [@gauge_width + rate, @target_gauge_width].min
    end
    @visible_counter = @gauge_width == 0 ? 10 : 60
    rect.width = @gauge_width if @type == :hp
  end # update_gauge

  #----------------------------------------------------------------------------|
  #  (v1.02a+)Alias method: dispose                                            |
  #----------------------------------------------------------------------------|
  alias dispose_percentage_addon dispose
  def dispose
    # Rewritten to dispose sprite only if it's not disposed
    dispose_percentage_addon unless @sprite.disposed?
    #
  end # dispose

  #----------------------------------------------------------------------------|
  #  Alias method: update                                                      |
  #----------------------------------------------------------------------------|
  alias update_percentage_addon update
  def update
    update_percentage_addon
    # Added to draw the percentage text
    return if @type != :percent
    @sprite.ox -= 4 if YEA::BATTLE::ANIMATE_HP_GAUGE
    update_percentage
    #
  end # update

  #----------------------------------------------------------------------------|
  #  New method: set_percentage_font                                           |
  #----------------------------------------------------------------------------|
  def set_percentage_font
    crisis_percent = $imported["YEA-CoreEngine"] ? YEA::CORE::HP_CRISIS : 0.25
    if @current_hp <= 0
      n = KNOCKOUT_TEXT_COLOR
    elsif @current_hp < @current_mhp * crisis_percent
      n = CRISIS_TEXT_COLOR
    else
      n = TEXT_COLOR
    end
    @sprite.bitmap.font.color = Cache.system("Window").get_pixel(
    64 + (n % 8) * 8, 96 + (n / 8) * 8)
    @sprite.bitmap.font.size = TEXT_SIZE
  end # set_percentage_font

  #----------------------------------------------------------------------------|
  #  New method: update_percentage                                             |
  #----------------------------------------------------------------------------|
  def update_percentage
    return if @last_hp == @current_hp
    @last_hp = @current_hp
    set_percentage_font
    if ACTUAL_NUMBER
      percent = @current_hp.to_i.to_s
    else
      percent = "#{(target_gauge_rate * 100).to_i.to_s}%"
    end
    dw = @sprite.bitmap.text_size(percent).width
    @sprite.bitmap.clear
    @sprite.bitmap.draw_text(YEA::BATTLE::ENEMY_GAUGE_WIDTH + 2 - dw, 1, dw,
    @sprite.bitmap.text_size(percent).height, percent)
  end # update_percentage

end # Enemy_HP_Gauge_Viewport

#------------------------------------------------------------------------------|

end # if $imported["YEA-BattleEngine"] && $imported["YEA-EnemyHPBars"]

#==============================================================================|
 
Last edited:

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
4,819
Reaction score
1,368
First Language
English
Primarily Uses
RMVXA
Try this edit I just did for Vlue Enemy HP.
I added showing mp numbers and added showing percents for the numbers.
Ruby:
#============================================================================
#VTS Enemy HP Bars
#By Ventwig
#Version 2.02 - Jul 15 2014
#For RPGMaker VX Ace
#=============================================================================
#=============================================================================
# Description:
# This script adds HP bars that display the name, mp, and states of
# enemies, with longer bars for up to two bosses.
# Many other features are also included!
#===============================================================================
# Compatability:
#  Works with Neo Gauge Ultimate Ace (Recommended)
#===============================================================================
# Instructions: Put in materials, above main.
# Put below Neo Gauge Ultimate Ace if used
#===============================================================================
# Please give credit to Ventwig if you would like to use one of my scripts!
# Use it commericial or non-commercial, and feel free to tell me if you're using
# it commercially!
# You may edit my scripts, just don't claim as your own!
#===============================================================================
#Notetags
#===============================================================================
#<hide_hp>
#<show_mp>/<hide_mp>
#<boss_bar>
#<personal_y x>
#===============================================================================
#Mix and match the three notetags! They're pretty much self-explanatory.
#<hide_hp> stops hp from being shown
#<show_mp> shows an mp bar, if REVERSE_MP below is set to false.
#<hide_mp> hides the mp bar, if REVERSE_MP is true.
#          If reverse_mp is false, enemies have hidden mp by default. If true,
#          then they normally have mp shown. Please use the right one.
#<boss_bar> sets the enemy to a boss, using the long bar (A BOSS MUST BE THE
#           FIRST ENEMY IN THE TROOP OR ELSE EVERYTHING GOES WHACK)
#<personal_y x> set x to any number (positive or negative)
#            determines how much to raise/lower the info for that enemy
#            + numbers raise, and - numbers lower
#===============================================================================

module EHUD
 
  #Determines how much to raise/lower the info
  #Same as <personal_y x>, except this affects all enemies
  Y_MOVE = 0
 
  #Are you using Neo Guage Ultimate Ace?
  #Set true if yes, false if no
  NEO_ULTIMATE_ACE = false
 
  #Want to show mp for most enemies but don't want to bother putting all the
  #noteatags? Turn this to true and show_mp turns into hide_mp and will actually
  #HIDE the mp. MP then shows by default
  REVERSE_MP = true
  DRAW_MP_NUMBERS = true
  DRAW_MP_PERCENT = true
 
  #Determines how to draw HP info
  #true shows the current HP amount, where as false only displays the bar
  DRAW_HP_NUMBERS = true
  DRAW_HP_PERCENT = true
 
  #true displays the abbreviation for HP set in the "Vocab" section
  #of the database, false does not
  DRAW_HP_VOCAB = true
  DRAW_MP_VOCAB = true
 
  #These settings make it compatible with my "Nova Battle Display" system!
  #Play around with the numbers, but I've provided recommended "Nova" settings
  #Change the X value of the bar. Def: 0  Nova:150
  BOSS_GAUGEX = 10
  #How long the boss gauge should be.  Def: 475  Nova:325
  BOSS_GAUGEW = 475
 
  #Determines whether or not the minions' HP will still be shown in a boss battle!
  #This is determined via a switch, so you can toggle per boss!
  #ON=HIDE OFF=SHOW
  #The thing about this switch, though, is that you have to toggle it MANUALLY
  #everytime you want to change it. So before a boss fight, turn it on.
  #After, turn it back off.
  #THIS DOES NOT HAVE TO BE USED WITH JUST BOSSES
  #Set to 0 if you don't want this.
  HIDE_MINIONS = 0
 
end
 

class RPG::BaseItem
  def show_mp
    if @show_mp.nil?
      if EHUD::REVERSE_MP == false
        if @note =~ /<show_mp>/i
          @show_mp = true
        else
          @show_mp = false
        end
      else
        if @note =~ /<hide_mp>/i
          @show_mp= false
        else
          @show_mp = true
        end
      end
    end
    @show_mp
  end
  def hide_hp
    if @hide_hp.nil?
      if @note =~ /<hide_hp>/i
        @hide_hp = true
      else
        @hide_hp = false
      end
    end
    @hide_hp
  end
  def boss_bar
    if @boss_bar.nil?
      if @note =~ /<boss_bar>/i
        @boss_bar= true
      else
        @boss_bar = false
      end
    end
    @boss_bar
  end
  def personal_y
    if @personal_y.nil?
      if @note =~ /<personal_y (.*)>/i
        @personal_y= $1.to_i
      else
        @personal_y = 0
      end
    end
    @personal_y
  end
end
 
class Game_Enemy < Game_Battler
 
  alias shaz_enemyhud_initialize initialize
 
  attr_accessor :old_hp
  attr_accessor :old_mp
 
  def initialize(index, enemy_id)
        shaz_enemyhud_initialize(index, enemy_id)
        @old_hp = mhp
        @old_mp = mmp
  end
  def boss_bar
     return enemy.boss_bar
  end
  def show_mp
     return enemy.show_mp
  end
  def hide_hp
     return enemy.hide_hp
  end
  def personal_y
     return enemy.personal_y
  end
end
 
class Window_Enemy_Hud < Window_Base
  def initialize
    super(0,0,545,400)
    self.opacity = 0
    self.arrows_visible = false
    self.z = 0
    @enemy = [] 
    @boss_enemy = []
    troop_fix
    boss_check
    enemy_hud
    refresh
  end
 
if EHUD::NEO_ULTIMATE_ACE == false
  def draw_actor_mp(actor, x, y, width = 124)
    draw_gauge(x, y+8, width, actor.mp_rate, mp_gauge_color1, mp_gauge_color2)
    change_color(system_color)
    draw_text(x, y+8, 30, line_height, Vocab::mp_a) if EHUD::DRAW_MP_VOCAB == true
    change_color(mp_color(actor))
    base = actor.mmp / 100.00
    mp = base == 0 ? 100 : (actor.mp / base).round.to_i
    if EHUD::DRAW_MP_PERCENT == true
      draw_text(x+width/4*3, y+8, 100, line_height, "#{mp}%") if EHUD::DRAW_MP_NUMBERS == true
    else
      draw_text(x+width/4*3, y+8, 100, line_height, actor.mp) if EHUD::DRAW_MP_NUMBERS == true
    end
    change_color(system_color)
  end
else
  def draw_actor_mp(actor, x, y, width = 124)
    gwidth = width * actor.mp / [actor.mmp, 1].max
    cg = neo_gauge_back_color
    c1, c2, c3 = cg[0], cg[1], cg[2]
    draw_neo_gauge(x + HPMP_GAUGE_X_PLUS, y + line_height - 8 +
      HPMP_GAUGE_Y_PLUS, width, HPMP_GAUGE_HEIGHT, c1, c2, c3)
    (1..3).each {|i| eval("c#{i} = MP_GCOLOR_#{i}")}
    draw_neo_gauge(x + HPMP_GAUGE_X_PLUS, y + line_height - 8 +
      HPMP_GAUGE_Y_PLUS, gwidth, HPMP_GAUGE_HEIGHT, c1, c2, c3, false, false,
      width, 40)
    draw_text(x, y+5, 30, line_height, Vocab::mp_a) if EHUD::DRAW_MP_VOCAB == true
    change_color(mp_color(actor))
    base = actor.mmp / 100.00
    mp = base == 0 ? 100 : (actor.mp / base).round.to_i
    if EHUD::DRAW_MP_PERCENT == true
      draw_text(x+width/4*3, y+5, 100, line_height, "#{mp}%") if EHUD::DRAW_MP_NUMBERS == true
    else
      draw_text(x+width/4*3, y+5, 100, line_height, actor.mp) if EHUD::DRAW_MP_NUMBERS == true
    end
    change_color(system_color)
  end
end

if EHUD::NEO_ULTIMATE_ACE == false
  def draw_actor_hp(actor, x, y, width = 124)
    draw_gauge(x, y, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2)
    change_color(system_color)
    draw_text(x, y, 30, line_height, Vocab::hp_a) if EHUD::DRAW_HP_VOCAB == true
    change_color(hp_color(actor))
    base = actor.mhp / 100.00
    hp = base == 0 ? 100 : (actor.hp / base).round.to_i
    if EHUD::DRAW_HP_PERCENT == true
      draw_text(x+width/4*3, y, 100, line_height, "#{hp}%") if EHUD::DRAW_HP_NUMBERS == true
    else
      draw_text(x+width/4*3, y, 100, line_height, actor.hp) if EHUD::DRAW_HP_NUMBERS == true
    end
    change_color(system_color)
  end
else
  def draw_actor_hp(actor, x, y, width = 124)
    gwidth = width * actor.hp / actor.mhp
    cg = neo_gauge_back_color
    c1, c2, c3 = cg[0], cg[1], cg[2]
    draw_neo_gauge(x + HPMP_GAUGE_X_PLUS, y + line_height - 8 +
    HPMP_GAUGE_Y_PLUS, width, HPMP_GAUGE_HEIGHT, c1, c2, c3)
    (1..3).each {|i| eval("c#{i} = HP_GCOLOR_#{i}")}
    draw_neo_gauge(x + HPMP_GAUGE_X_PLUS, y + line_height - 8 +
    HPMP_GAUGE_Y_PLUS, gwidth, HPMP_GAUGE_HEIGHT, c1, c2, c3, false, false,
    width, 30)
    change_color(system_color)
    draw_text(x, y, 30, line_height, Vocab::hp_a) if EHUD::DRAW_HP_VOCAB == true
    change_color(hp_color(actor))
    base = actor.mhp / 100.00
    hp = base == 0 ? 100 : (actor.hp / base).round.to_i
    if EHUD::DRAW_HP_PERCENT == true
      draw_text(x+width/4*3, y, 100, line_height, "#{hp}%") if EHUD::DRAW_HP_NUMBERS == true
    else
      draw_text(x+width/4*3, y, 100, line_height, actor.hp) if EHUD::DRAW_HP_NUMBERS == true
    end
    change_color(system_color)
  end
end
 
  def troop_fix
    @etroop = $game_troop
    return if @etroop.alive_members.size <= 0
    for i in 0..@etroop.alive_members.size-1
      @enemy[i] = @etroop.alive_members[i]
    end
  end
 
  def enemy_hud
    troop_fix   
    for i in 0..@etroop.alive_members.size-1
      e = @enemy[i]
      if i <= 1 and e.boss_bar == true and e == @boss_enemy[i]
        draw_actor_name(e,EHUD::BOSS_GAUGEX,5+50*i)
        draw_actor_hp(e,EHUD::BOSS_GAUGEX,20+50*i,width=EHUD::BOSS_GAUGEW) unless e.hide_hp == true
        draw_actor_mp(e,EHUD::BOSS_GAUGEX,30+50*i,width=EHUD::BOSS_GAUGEW) unless e.show_mp == false
        draw_actor_icons(e,EHUD::BOSS_GAUGEX+200,5+50*i, width = 96)
      elsif $game_switches[EHUD::HIDE_MINIONS] != true
        draw_actor_hp(e,e.screen_x-50,e.screen_y+EHUD::Y_MOVE-50+e.personal_y,width=96) unless e.hide_hp == true
        draw_actor_mp(e,e.screen_x-50,e.screen_y+EHUD::Y_MOVE-40+e.personal_y,width=96) unless e.show_mp == false
        draw_actor_icons(e,e.screen_x-50,e.screen_y+EHUD::Y_MOVE-70+e.personal_y,width=96)
      end
    end
  end
  
  def refresh
    contents.clear
    enemy_hud
    boss_check if @boss_enemy !=nil
  end
 
  def boss_check
    if @enemy[0].boss_bar == true
      @boss_enemy[0] = @enemy[0]
      if @enemy[1] != nil
        if @enemy[1].boss_bar == true
          @boss_enemy[1] = @enemy[1]
        else
          @boss_enemy[1] = nil
        end
      end
    else
      @boss_enemy[0] = nil
      @boss_enemy[1]= nil
    end
  end

 
  def update
    refresh_okay = false
    $game_troop.alive_members.each do |enemy|
      if enemy.hp != enemy.old_hp || enemy.mp != enemy.old_mp
        refresh_okay = true
        enemy.old_hp = enemy.hp
        enemy.old_mp = enemy.mp
      end
    end
  
    if $game_troop.alive_members.size != @old_size
      refresh_okay = true
    end
  
    if refresh_okay
      refresh
    end
  end
end
 
class Scene_Battle < Scene_Base
  alias hpbars_create_all_windows create_all_windows
  def create_all_windows
    hpbars_create_all_windows
    create_enemy_hud_window
  end
  def create_enemy_hud_window
    @enemy_hud_window = Window_Enemy_Hud.new
  end
end
  #########################################################################
  #End Of Script                                                          #
  #########################################################################
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
4,819
Reaction score
1,368
First Language
English
Primarily Uses
RMVXA
Or you may try something like this :)
Awesome, I missed that. Looked for it in my list but when he asked for percentages I only saw the other ones I had which didn't include mp+tp, But I do have that script. lol
 

Latest Threads

Latest Posts

Latest Profile Posts

Ooops ended up trying out making my own A2 tile page instead of testing doors everywhere. Went well so far I think.
I guess I'm done making a blue squirrel's life difficult for posting new threads on different forums.
That's just for today so don't get used to this, squirrel-ish friend! :p
Got new hard drive, now trying to install the softwares I lost to the dead drive, and more than half of them won't install because they're already installed on the dead drive, and uninstallers won't run because they can't find where their programs are installed. So I take it having a drive die on you screws you in more ways than just data loss. >:\
PC got fixed finally. Back online again. Turns out I have no business trying to self repair pcs because it was getting to like 176F / 80C. Shop installed a totally new cooling system and now it runs fine and is super quiet.
When you're making major progress, but have to stop to go to work.

Forum statistics

Threads
131,484
Messages
1,220,206
Members
173,225
Latest member
ZecaVn
Top