Tsuno Bars
#1
Tsuno Bars
Tsunokiette
Version: 1
Feb 6 2006

This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.


Introduction

Allows you to draw Hp/Sp/Exp bars; some work is required though, you can't just copy/paste to see it where ever the hp/sp/exp are shown.


Features
  • Solid colored lines, so it wont get distorted with different widths.


Script
Code:
#------------------------------------------------------------------------------
   # Begin Game_Actor Edit
   #------------------------------------------------------------------------------
   class Game_Actor < Game_Battler
      #--------------------------------------------------------------------------
      # * Return the exp needed to reach the next level
      #--------------------------------------------------------------------------
      def needed_exp(current_lvl)
         return @exp_list[current_lvl + 1]
      end
      #--------------------------------------------------------------------------
      # * Return the currently gained exp
      #--------------------------------------------------------------------------
      def gained_exp(current_lvl,current_exp)
         return (current_exp - @exp_list[current_lvl])
       end
      #--------------------------------------------------------------------------
      # * Return the current level
      #--------------------------------------------------------------------------
      def lvl
         return @level
      end
   end
   #------------------------------------------------------------------------------
   # End Game_Actor Edit
   #------------------------------------------------------------------------------

   #------------------------------------------------------------------------------
   # Begin Window_Base Edit
   #------------------------------------------------------------------------------
   class Window_Base < Window
      #--------------------------------------------------------------------------
      # * Draw HP Bar
      #--------------------------------------------------------------------------
      def draw_hp_bar(actor,x,y,w = 202)
         #get hp and max hp
         hp = actor.hp
         max_hp = actor.maxhp
         #define colors to be used
         border_color = Color.new(0,0,0,255)
         line1_color = Color.new(0,145,0,255)
         line2_color = Color.new(0,176,0,255)
         line3_color = Color.new(0,215,0,255)
         line4_color = Color.new(0,253,0,255)
         line5_color = Color.new(0,215,0,255)
         line6_color = Color.new(0,176,0,255)
         line7_color = Color.new(0,145,0,255)
         line8_color = Color.new(0,120,0,255)
         empty_color = Color.new(75,75,75,255)
         #get widths and x's
         line_width = (((hp * 1.0) / max_hp) * (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
      #--------------------------------------------------------------------------
      # * Draw SP Bar
      #--------------------------------------------------------------------------
      def draw_sp_bar(actor,x,y,w = 202)
         #get sp and max sp
         sp = actor.sp
         max_sp = actor.maxsp
         #get percentage width
         percentage_width = ((w - 2) / 100)
         #define colors to be used
         border_color = Color.new(0,0,0,255)
         line1_color = Color.new(112,0,223,255)
         line2_color = Color.new(130,4,255,255)
         line3_color = Color.new(155,55,255,255)
         line4_color = Color.new(170,85,255,255)
         line5_color = Color.new(155,55,255,255)
         line6_color = Color.new(130,4,255,255)
         line7_color = Color.new(112,0,223,255)
         line8_color = Color.new(88,0,176,255)
         empty_color = Color.new(75,75,75,255)
         #get widths and x's
         line_width = (((sp * 1.0) / max_sp) * (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
      #--------------------------------------------------------------------------
      # * Draw EXP Bar
      #--------------------------------------------------------------------------
      def draw_exp_bar(actor,x,y,w = 202)
         #get exp and needed exp
         exp = actor.exp
         gained_exp = actor.gained_exp(actor.lvl,exp)
         needed_exp = actor.needed_exp(actor.lvl)
         #define colors to be used
         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(xA, 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
   #------------------------------------------------------------------------------
   # End Window_Base Edit
   #------------------------------------------------------------------------------


Instructions

Place this just bellow Window_Base and above all the other window scripts.

CALLS:

the widths are automaticly 202

HP
Code:
draw_hp_bar(actor,x,y,w)

SP
Code:
draw_sp_bar(actor,x,y,w)

EXP
Code:
draw_exp_bar(actor,x,y,w)


Compatibility

Should be compatible with anything, as long as no other script uses the following methods.

IN GAME_ACTOR
  • needed_exp
  • gained_exp
  • lvl
IN WINDOW_BASE
  • draw_hp_bar
  • draw_sp_bar
  • draw_exp_bar
Even if they did, these methods are straight forward, and probably do the same things.

Credits and Thanks
  • God (for giving me the ability to do this)
  • Enterbrain (for providing RMXP)
  • SephirothSpawn (for helping me with finding certain exp values)
}


Possibly Related Threads…
Thread Author Replies Views Last Post
  HP & SP Bars on Map Sheol 0 2,651 05-23-2006, 01:00 PM
Last Post: Sheol



Users browsing this thread: 2 Guest(s)