# 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