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]# 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[/spoiler]
Open your project and follow the tutorial in the spoiler bellow. (WARNING: lots of big pictures in the spoiler
[spoiler](https://rmrk.net/proxy.php?request=http%3A%2F%2Fimg189.imageshack.us%2Fimg189%2F9837%2Ftut1a.png&hash=d3e89c7417b4a9fed07486e26ee30ec4ef0b25d0)(https://rmrk.net/proxy.php?request=http%3A%2F%2Fimg697.imageshack.us%2Fimg697%2F6682%2Ftut2q.png&hash=5c6fe6e12eae1f84f1fb44ee58802814c4afc6b9)(https://rmrk.net/proxy.php?request=http%3A%2F%2Fimg192.imageshack.us%2Fimg192%2F5185%2Ftut3g.png&hash=b4419a891abf82c1e1595aab87873c1e8b1793a7)(https://rmrk.net/proxy.php?request=http%3A%2F%2Fimg189.imageshack.us%2Fimg189%2F439%2Ftut4.png&hash=e75e0ee6b38131c1ae1541b12aa722468b825356)(https://rmrk.net/proxy.php?request=http%3A%2F%2Fimg62.imageshack.us%2Fimg62%2F2572%2Ftut5.png&hash=c7560745de58324a7fd74e282b534a5f77eca720)(https://rmrk.net/proxy.php?request=http%3A%2F%2Fimg62.imageshack.us%2Fimg62%2F9609%2Ftut6.png&hash=f7d7dc0cbc2207b7299ba8361a492430ed84a15e)[/spoiler]
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.
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:
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:
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.
well thanks.. but it still doesnt work..:S
i can see it on the menu bt not on the game screen..
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.
oh well i didnt know there is a differance thanks anyway!
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.