Perecent HP HUD Request

Stormowl

"They played us like a damn fiddle!"
Veteran
Joined
Dec 21, 2012
Messages
82
Reaction score
10
First Language
English
Hi, I would like to request a simple script where the first party members HP is displayed in percents at all times.

Please Note:

-First Party Member Only

-Percent only

-Do not make the HUD disappear when speaking to objects

I hope this is easy for you guys to do!

Thank you.
 

Stormowl

"They played us like a damn fiddle!"
Veteran
Joined
Dec 21, 2012
Messages
82
Reaction score
10
First Language
English
I made a sketch of what I want it to look like if this helps at all:

 

Evgenij

Veteran
Veteran
Joined
Aug 28, 2013
Messages
349
Reaction score
100
First Language
German
Primarily Uses
N/A
Code:
module EVG  module PercentHudConfig    LABEL = "HP:"    FONT = {} # do not edit    FONT[:size]   = 24    FONT[:bold]   = false    FONT[:italic] = false    FONT[:color]  = Color.new(240, 0, 0, 255)  end  class PercentHud < Sprite    include PercentHudConfig    def initialize(*args)      super(*args)      self.x = 0      self.y = 0      create_bitmap      @temp_hp = nil      refresh    end    def actor      $game_party.leader    end    def percent_hp      "#{(actor.hp.to_f / actor.mhp * 100).to_i}%"    end    def create_bitmap      self.bitmap = Bitmap.new(Graphics.width, Graphics.height)      FONT.each {|m, v| self.bitmap.font.send("#{m}=", v)}    end    def refresh      self.bitmap.clear      @temp_hp = actor.hp      draw_label      draw_percent_hp    end    def draw_label      self.bitmap.draw_text(4, 0, Graphics.width, FONT[:size], LABEL)    end    def draw_percent_hp      self.bitmap.draw_text(4, FONT[:size], Graphics.width, FONT[:size], percent_hp)    end    def update      super      refresh if need_refresh?    end    def need_refresh?      @temp_hp != actor.hp    end  endendclass Spriteset_Map  alias :evg_sm_cp_ph11     :create_pictures  def create_pictures    evg_sm_cp_ph11    @percent_hud = EVG::PercentHud.new(@viewport2)  end  alias :evg_sm_up_ph11     :update_pictures  def update_pictures    evg_sm_up_ph11    @percent_hud.update  end  alias :evg_sm_dp_ph11     :dispose_pictures  def dispose_pictures    evg_sm_dp_ph11    @percent_hud.bitmap.dispose    @percent_hud.dispose  endend
 

Stormowl

"They played us like a damn fiddle!"
Veteran
Joined
Dec 21, 2012
Messages
82
Reaction score
10
First Language
English
module EVG module PercentHudConfig LABEL = "HP:" FONT = {} # do not edit FONT[:size] = 24 FONT[:bold] = false FONT[:italic] = false FONT[:color] = Color.new(240, 0, 0, 255) end class PercentHud < Sprite include PercentHudConfig def initialize(*args) super(*args) self.x = 0 self.y = 0 create_bitmap @temp_hp = nil refresh end def actor $game_party.leader end def percent_hp "#{(actor.hp.to_f / actor.mhp * 100).to_i}%" end def create_bitmap self.bitmap = Bitmap.new(Graphics.width, Graphics.height) FONT.each {|m, v| self.bitmap.font.send("#{m}=", v)} end def refresh self.bitmap.clear @temp_hp = actor.hp draw_label draw_percent_hp end def draw_label self.bitmap.draw_text(4, 0, Graphics.width, FONT[:size], LABEL) end def draw_percent_hp self.bitmap.draw_text(4, FONT[:size], Graphics.width, FONT[:size], percent_hp) end def update super refresh if need_refresh? end def need_refresh? @temp_hp != actor.hp end endendclass Spriteset_Map alias :evg_sm_cp_ph11 :create_pictures def create_pictures evg_sm_cp_ph11 @percent_hud = EVG::percentHud.new(@viewport2) end alias :evg_sm_up_ph11 :update_pictures def update_pictures evg_sm_up_ph11 @percent_hud.update end alias :evg_sm_dp_ph11 :dispose_pictures def dispose_pictures evg_sm_dp_ph11 @percent_hud.bitmap.dispose @percent_hud.dispose endend
Thank you so much! I absolutely love it!
 

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

Latest Threads

Latest Posts

Latest Profile Posts

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.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,863
Messages
1,017,053
Members
137,571
Latest member
grr
Top