[XP] Enemy HP Bars

MarioWidjaya123

Veteran
Veteran
Joined
May 16, 2020
Messages
187
Reaction score
6
First Language
English
Primarily Uses
RMXP
i found this script on the internet called: Enemy HP Bars
(i changed it a little to make it good in my game)
Ruby:
class Window_EnemyHP < Window_Base
 
  def initialize
    super(0, 0, 640, 480)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 0
    @old_hp = []
    refresh
  end
 
  def refresh
    self.contents.clear
    for i in 0...$game_troop.enemies.size
      @enemy = $game_troop.enemies[i]
      @old_hp[i] = @enemy.hp
      unless @enemy.hp == 0
        self.contents.font.name = "Times New Roman"
        self.contents.font.size = 18
        self.contents.font.color = Color.new(0,0,0)
        self.contents.font.color = normal_color
        self.contents.draw_text(0, i * 45 + 37, 100, 32, @enemy.name)
        draw_actor_hp(@enemy, 0, i*45 + 50)
      end
    end
  end
  def update
    for i in 0...$game_troop.enemies.size
      enemy = $game_troop.enemies[i]
      if enemy.hp != @old_hp[i]
        refresh
      end
    end
  end
end
 
class Scene_Battle
 
  alias raz_update_phase5 update_phase5
  alias raz_update_phase4_step1 update_phase4_step1
  alias raz_update_phase4_step5 update_phase4_step5
  alias raz_enemy_hp_main main
 
   def main
    @troop_id = $game_temp.battle_troop_id
    $game_troop.setup(@troop_id)
    @enemy_window = Window_EnemyHP.new
    @enemy_window.z = 95
    raz_enemy_hp_main
    @enemy_window.dispose
  end
 
  def update_phase5
    # If wait count is larger than 0
    if @phase5_wait_count > 0
      # Decrease wait count
      @phase5_wait_count -= 1
      # If wait count reaches 0
      if @phase5_wait_count == 0
        @enemy_window.visible = false
        # Show result window
        @result_window.visible = true
        # Clear main phase flag
        $game_temp.battle_main_phase = false
        # Refresh status window
        @status_window.refresh
        @enemy_window.refresh
      end
      return
    end
   raz_update_phase5
 end
 
def update_phase4_step1
  raz_update_phase4_step1
  @enemy_window.refresh
end
 
  def update_phase4_step5
    # Hide help window
    @help_window.visible = false
    # Refresh status window
    @status_window.refresh
    @enemy_window.refresh
    raz_update_phase4_step5
  end
end
while the bar appears the enemy's amount of HP shows too.
1599019872372.png
this will be way too easy for players to see that exact amount of HP that enemies have,
without having it to analyze them or something.
is there a way to hide the enemy's amount of HP and keep showing the HP bar?
 

KK20

Just some XP Scripter
Veteran
Joined
Oct 11, 2018
Messages
281
Reaction score
106
First Language
English
Primarily Uses
RMXP
You're using Tons of Add-ons bars, right?
You can try putting this script somewhere above it:
Ruby:
class Window_Base < Window
  alias only_draws_actor_hp draw_actor_hp
  def draw_actor_hp(*args)
    return if args.first.is_a?(Game_Enemy) && $scene.is_a?(Scene_Battle)
    only_draws_actor_hp(*args)
  end
end
 

MarioWidjaya123

Veteran
Veteran
Joined
May 16, 2020
Messages
187
Reaction score
6
First Language
English
Primarily Uses
RMXP
@KK20
ok i added it and tested...
1599031346985.png
1599031416436.png
bars are gone.
i want it to hide the enemy's HP value, but keep showing the bar.
 

KK20

Just some XP Scripter
Veteran
Joined
Oct 11, 2018
Messages
281
Reaction score
106
First Language
English
Primarily Uses
RMXP
I said to put the script ABOVE tons of addons
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

People3_5 and People3_8 added!

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.

Forum statistics

Threads
105,868
Messages
1,017,090
Members
137,586
Latest member
Usagiis
Top