RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[request] the simplest-HP bar...

0 Members and 1 Guest are viewing this topic.

**
Rep: +0/-0Level 82
well i am new on rpg maker.. and defenantly not a coder..
so i want to request a simple hp bar script.. and can you please explain me where exactly to put it on the script page?
thank you very much... kliko

copy the code in the spoiler bellow.
Spoiler for:
Code: [Select]
# HP/SP Bars - By HamsterMan
# Credit to Tsunokiette of Creationasylum - as I used his original
# Tsunobars script for reference when creating this one.
# Credit to HamsterMan is NOT neccessary if used.

# Edit of Game_Actor
class Game_Actor < Game_Battler
 
  def needed_exp(current_level)
    return @exp_list[current_level + 1]
  end
 
  def gained_exp(current_level, current_exp)
    return (current_exp - @exp_list[current_level])
  end
 
  def lvl
    return @level
  end
 
end # End of class

# Add draw_hp_bar and draw_sp_bar methods to Window_Base
class Window_Base < Window
 
  def draw_hp_bar(actor,x,y,w = 100)
    hp = actor.hp # Gets actor's current HP
    max_hp = actor.maxhp # Gets actor's max HP
    border_color = Color.new(0,0,0,255) # Define border colour (R,G,B,O)
    line1_color = Color.new(0,250,0,255)
    line2_color = Color.new(0,230,0,255)
    line3_color = Color.new(0,210,0,255)     # These lines define the colors
    line4_color = Color.new(0,190,0,255)     # Used to make up the HP bars
    line5_color = Color.new(0,170,0,255)
    line6_color = Color.new(0,150,0,255)
    line7_color = Color.new(0,130,0,255)
    line8_color = Color.new(0,110,0,255)
    empty_color = Color.new(75,75,75,255)
   
    line_width = ((hp * 1.0 / max_hp) * (w - 2))
    empty_width = ((w -2) - line_width)
    empty_x = ((x + 1) + line_width)
   
    border1 = Rect.new(x, y, w, 1)
    border2 = Rect.new(x, y + 9, w, 1)
    border3 = Rect.new(x, y + 1, 1, 8)
    border4 = Rect.new(x + (w -1), y + 1, 1, 8)
   
    line1 = Rect.new(x + 1, y + 1, line_width, 1)
    line2 = Rect.new(x + 1, y + 2, line_width, 1)
    line3 = Rect.new(x + 1, y + 3, line_width, 1)
    line4 = Rect.new(x + 1, y + 4, line_width, 1)
    line5 = Rect.new(x + 1, y + 5, line_width, 1)
    line6 = Rect.new(x + 1, y + 6, line_width, 1)
    line7 = Rect.new(x + 1, y + 7, line_width, 1)
    line8 = Rect.new(x + 1, y + 8, line_width, 1)
    empty = Rect.new(empty_x, y + 1, empty_width, 8)
   
    self.contents.fill_rect(border1, border_color)
    self.contents.fill_rect(border2, border_color)
    self.contents.fill_rect(border3, border_color)
    self.contents.fill_rect(border4, border_color)
   
    self.contents.fill_rect(line1, line1_color)
    self.contents.fill_rect(line2, line2_color)
    self.contents.fill_rect(line3, line3_color)
    self.contents.fill_rect(line4, line4_color)
    self.contents.fill_rect(line5, line5_color)
    self.contents.fill_rect(line6, line6_color)
    self.contents.fill_rect(line7, line7_color)
    self.contents.fill_rect(line8, line8_color)
   
    self.contents.fill_rect(empty, empty_color)
   
  end # End of def draw_hp_bar

  def draw_sp_bar(actor,x,y,w = 100)
    sp = actor.sp # Gets actor's current SP
    max_sp = actor.maxsp # Gets actor's max SP
    border_color = Color.new(0,0,0,255) # Define border colour (R,G,B,O)
    line1_color = Color.new(0,0,250,255)
    line2_color = Color.new(0,0,230,255)
    line3_color = Color.new(0,0,210,255)     # These lines define the colors
    line4_color = Color.new(0,0,190,255)     # Used to make up the HP bars
    line5_color = Color.new(0,0,170,255)
    line6_color = Color.new(0,0,150,255)
    line7_color = Color.new(0,0,130,255)
    line8_color = Color.new(0,0,110,255)
    empty_color = Color.new(75,75,75,255)
   
    line_width = ((sp * 1.0 / max_sp) * (w - 2))
    empty_width = ((w -2) - line_width)
    empty_x = ((x + 1) + line_width)
   
    border1 = Rect.new(x, y, w, 1)
    border2 = Rect.new(x, y + 9, w, 1)
    border3 = Rect.new(x, y + 1, 1, 8)
    border4 = Rect.new(x + (w -1), y + 1, 1, 8)
   
    line1 = Rect.new(x + 1, y + 1, line_width, 1)
    line2 = Rect.new(x + 1, y + 2, line_width, 1)
    line3 = Rect.new(x + 1, y + 3, line_width, 1)
    line4 = Rect.new(x + 1, y + 4, line_width, 1)
    line5 = Rect.new(x + 1, y + 5, line_width, 1)
    line6 = Rect.new(x + 1, y + 6, line_width, 1)
    line7 = Rect.new(x + 1, y + 7, line_width, 1)
    line8 = Rect.new(x + 1, y + 8, line_width, 1)
    empty = Rect.new(empty_x, y + 1, empty_width, 8)
   
    self.contents.fill_rect(border1, border_color)
    self.contents.fill_rect(border2, border_color)
    self.contents.fill_rect(border3, border_color)
    self.contents.fill_rect(border4, border_color)
   
    self.contents.fill_rect(line1, line1_color)
    self.contents.fill_rect(line2, line2_color)
    self.contents.fill_rect(line3, line3_color)
    self.contents.fill_rect(line4, line4_color)
    self.contents.fill_rect(line5, line5_color)
    self.contents.fill_rect(line6, line6_color)
    self.contents.fill_rect(line7, line7_color)
    self.contents.fill_rect(line8, line8_color)
   
    self.contents.fill_rect(empty, empty_color)
  end # End of def draw_sp_bar

  def draw_exp_bar(actor, x, y, w = 200)
    exp = actor.exp
    gained_exp = actor.gained_exp(actor.level, exp)
    needed_exp = actor.needed_exp(actor.level)
    border_color = Color.new(0,0,0,255)
    line1_color = Color.new(140,140,0,255)
    line2_color = Color.new(157,157,0,255)
    line3_color = Color.new(170,170,0,255)
    line4_color = Color.new(196,196,0,255)
    line5_color = Color.new(170,170,0,255)
    line6_color = Color.new(157,157,0,255)
    line7_color = Color.new(140,140,0,255)
    line8_color = Color.new(128,128,0,255)
    empty_color = Color.new(75,75,75,255)
    #get widths and x's
    line_width = (((gained_exp * 1.0) / needed_exp) * (w - 2))
    empty_width = ((w - 2) - line_width)
    empty_x = ((x + 1) + line_width)
    #make border Rects
    border1 = Rect.new(x, y, w, 1)
    border2 = Rect.new(x, y + 9, w, 1)
    border3 = Rect.new(x, y + 1, 1, 8)
    border4 = Rect.new(x + (w - 1), y + 1, 1, 8)
    #make line Rects
    line1 = Rect.new(x + 1, y + 1, line_width, 1)
    line2 = Rect.new(x + 1, y + 2, line_width, 1)
    line3 = Rect.new(x + 1, y + 3, line_width, 1)
    line4 = Rect.new(x + 1, y + 4, line_width, 1)
    line5 = Rect.new(x + 1, y + 5, line_width, 1)
    line6 = Rect.new(x + 1, y + 6, line_width, 1)
    line7 = Rect.new(x + 1, y + 7, line_width, 1)
    line8 = Rect.new(x + 1, y + 8, line_width, 1)
    #make empty Rect
    empty = Rect.new(empty_x, y + 1, empty_width, 8)
    #fill border Rects
    self.contents.fill_rect(border1,border_color)
    self.contents.fill_rect(border2,border_color)
    self.contents.fill_rect(border3,border_color)
    self.contents.fill_rect(border4,border_color)
    #fill line Rects
    self.contents.fill_rect(line1,line1_color)
    self.contents.fill_rect(line2,line2_color)
    self.contents.fill_rect(line3,line3_color)
    self.contents.fill_rect(line4,line4_color)
    self.contents.fill_rect(line5,line5_color)
    self.contents.fill_rect(line6,line6_color)
    self.contents.fill_rect(line7,line7_color)
    self.contents.fill_rect(line8,line8_color)
    #fill empty Rect
    self.contents.fill_rect(empty,empty_color)
  end
end

Open your project and follow the tutorial in the spoiler bellow.  (WARNING: lots of big pictures in the spoiler
Spoiler for:

**
Rep: +0/-0Level 82
well than i did exactly what you said on a new project and then i did a playtest and i didnt show anything new... ??? :-\

i have no idea, you'll have to find another HUD script and do the same.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Well, the script posted has methods for drawing the bars, but it doesn't actually call those methods in the areas required.

Try adding this in its own slot directly below the script valdred provided:
Code: [Select]
class Window_Base
  alias ma_tsuno_hms_bars_drwhp_8jg3 draw_actor_hp
  def draw_actor_hp(actor, x, y, width = 144, *args)
    draw_hp_bar (actor, x, y + 24, width)
    ma_tsuno_hms_bars_drwhp_8jg3(actor, x, y, width, *args)
  end
  alias mtshmst_bar_drwsp_1gr2 draw_actor_sp
  def draw_actor_sp(actor, x, y, width = 144, *args)
    draw_sp_bar (actor, x, y + 24, width)
    mtshmst_bar_drwsp_1gr2(actor, x, y, width, *args)
  end
end

If you don't want the SP bar, just delete:

Code: [Select]

  alias mtshmst_bar_drwsp_1gr2 draw_actor_sp
  def draw_actor_sp(actor, x, y, width = 144, *args)
    draw_sp_bar (actor, x, y + 24, width)
    mtshmst_bar_drwsp_1gr2(actor, x, y, width, *args)
  end



My personal favourite bar script is Blizzard's though. This one is pretty too though.
« Last Edit: January 12, 2010, 07:00:50 PM by modern algebra »

**
Rep: +0/-0Level 82
well thanks.. but it still doesnt work..:S
i can see it on the menu bt not on the game screen..

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
umm, huh?

HP normally doesn't show up on the map.

Are you actually asking for an HUD script (which consists of an HP bar) here? And not the HP Bar script you explicitly requested?
HUD meaning heads up display, as in any information that is visible while moving around on the map. 

**
Rep: +0/-0Level 82
oh well i didnt know there is a differance thanks anyway!

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Well, there's this script, but you probably want something less Zelda-ey: http://rmrk.net/index.php/topic,34731.0.html

This one's pretty, but you sound like you want something simpler: http://punkid89.b1.jcink.com/index.php?showtopic=182

In any case, there are a lot of HUDs out there - just search around the forums (not just this one, but other RMXP forums too) using the keyword HUD  and I'm sure you'll find one that you'll like.