The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Scripting => Topic started by: Tsunokiette on February 01, 2006, 09:17:37 PM

Title: HP/SP/EXP Bars by Tsunokiette
Post by: Tsunokiette on February 01, 2006, 09:17:37 PM
Just place this in a new script right bellow Window_Base.

Code: [Select]
  #------------------------------------------------------------------------------
   # 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(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
   #------------------------------------------------------------------------------
   # End Window_Base Edit
   #------------------------------------------------------------------------------


Now in the window you want to show the bars in, just do this -

For HP -
Code: [Select]
draw_hp_bar(actor,x position,y position,width)


For SP
Code: [Select]
draw_sp_bar(actor,x position,y position,width)


For EXP
Code: [Select]
draw_exp_bar(actor,x position,y position,width)
Title: HP/SP/EXP Bars by Tsunokiette
Post by: Neko on February 01, 2006, 09:44:19 PM
Where do I put the things?
Title: HP/SP/EXP Bars by Tsunokiette
Post by: Tsunokiette on February 01, 2006, 10:03:09 PM
Quote from: Neko
Where do I put the things?


in the refresh method of the chosen menu

EDIT: the bars should look something like this-

HP-
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi9.photobucket.com%2Falbums%2Fa57%2Ftsunokiette%2FHP.png&hash=1a85ff015e1e1ba925cc861af4b5fdc99571d61a)
SP-
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi9.photobucket.com%2Falbums%2Fa57%2Ftsunokiette%2FSP.png&hash=432badaae215a5506139cd2aa8b680472b8ecb5e)
EXP-
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi9.photobucket.com%2Falbums%2Fa57%2Ftsunokiette%2FEXP.png&hash=c2ea834130d3e39d6215843957b728aeb2fcd42e)

NOTE: you can change the colors if you want

everywhere you see

Code: [Select]
#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)


the first three numbers are the r,b,g values, just keep the fourth one 255, that's the opacity.

the lines are numbered 1-8 from top to bottem (the colored ones)
Title: HP/SP/EXP Bars by Tsunokiette
Post by: Neko on February 02, 2006, 12:51:25 AM
error =\ Im not sure how to edit this stuff so could you like make it so it has all the bars for me? Lol I dont mean to beg, but I dont understand what to do.
Title: HP/SP/EXP Bars by Tsunokiette
Post by: Tsunokiette on February 02, 2006, 01:23:07 AM
Quote from: Neko
error =\ Im not sure how to edit this stuff so could you like make it so it has all the bars for me? Lol I dont mean to beg, but I dont understand what to do.


kk, where do you want them, and are you using the default systems?
Title: HP/SP/EXP Bars by Tsunokiette
Post by: Neko on February 02, 2006, 02:38:37 AM
:O_o: ? Umm I want the at the top left corner and what do you mean by default?
Title: HP/SP/EXP Bars by Tsunokiette
Post by: Tsunokiette on February 02, 2006, 03:13:23 AM
Quote from: Neko
:O_o: ? Umm I want the at the top left corner and what do you mean by default?


I mean, if you want them in the menu/battle system, are you using the default systems.

So you want it on the map. right?

add this above main - (should work)

Code: [Select]
Window_Bars < Window_Base
   def initialize
      super(0,0,234,158)
      self.contents = Bitmap.new(width - 32, height - 32)
      self.contents.font.name = 'Times New Roman'
      self.contents.font.size = 22
      refresh_stats
   end
   def refresh_stats
      self.contents.clear
      actor = $game_party.actors[1]
      draw_actor_hp(actor,0,0,202)
      draw_hp_bar(actor,0,32)
      draw_actor_sp(actor,0,42,202)
      draw_sp_bar(actor,0,74)
      draw_actor_exp(actor,0,84)
      draw_exp_bar(actor,0,116)
   end
   def update
      refresh_stats
   end
end
class Scene_Map
   def main
      @spriteset = Spriteset_Map.new
      @message_window = Window_Message.new
      @bar_window = Window_Bars.new
      Graphics.transition
      loop do
         Graphics.update
         Input.update
         update
         if $scene != self
            break
         end
      end
      Graphics.freeze
      @spriteset.dispose
      @message_window.dispose
      @bar_window.dispose
      if $scene.is_a?(Scene_Title)
         Graphics.transition
         Graphics.freeze
      end
   end
   def update
      loop do
         $game_map.update
         $game_system.map_interpreter.update
         $game_player.update
         $game_system.update
         $game_screen.update
         unless $game_temp.player_transferring
            break
         end
         transfer_player
         if $game_temp.transition_processing
            break
         end
      end
      @spriteset.update
      @message_window.update
      @bar_window.update
      if $game_temp.gameover
         $scene = Scene_Gameover.new
         return
      end
      if $game_temp.to_title
         $scene = Scene_Title.new
         return
      end
      if $game_temp.transition_processing
         $game_temp.transition_processing = false
         if $game_temp.transition_name == ""
            Graphics.transition(20)
         else
            Graphics.transition(40, "Graphics/Transitions/" +
            $game_temp.transition_name)
         end
      end
      if $game_temp.message_window_showing
         return
      end
      if $game_player.encounter_count == 0 and $game_map.encounter_list != []
         unless $game_system.map_interpreter.running? or
            $game_system.encounter_disabled
            $game_temp.battle_calling = true
            $game_temp.battle_can_escape = true
            $game_temp.battle_can_lose = false
            $game_temp.battle_proc = nil
            n = rand($game_map.encounter_list.size)
            $game_temp.battle_troop_id = $game_map.encounter_list[n]
         end
      end
      if Input.trigger?(Input::B)
         unless $game_system.map_interpreter.running? or
            $game_system.menu_disabled
            $game_temp.menu_calling = true
            $game_temp.menu_beep = true
         end
      end
      if $DEBUG and Input.press?(Input::F9)
         $game_temp.debug_calling = true
      end
      unless $game_player.moving?
         if $game_temp.battle_calling
            call_battle
         elsif $game_temp.shop_calling
            call_shop
         elsif $game_temp.name_calling
            call_name
         elsif $game_temp.menu_calling
            call_menu
         elsif $game_temp.save_calling
            call_save
         elsif $game_temp.debug_calling
            call_debug
         end
    end
end
Title: HP/SP/EXP Bars by Tsunokiette
Post by: Neko on February 02, 2006, 04:00:47 AM
It says syntax error =\
Title: HP/SP/EXP Bars by Tsunokiette
Post by: Tsunokiette on February 02, 2006, 04:02:38 AM
Quote from: Neko
It says syntax error =\


it would help if you gave me the line... :|
Title: HP/SP/EXP Bars by Tsunokiette
Post by: Neko on February 02, 2006, 04:56:42 AM
Syntax error line 22 so far.. I would fix it, but I have no clue how to do ruby =\
Title: HP/SP/EXP Bars by Tsunokiette
Post by: Tsunokiette on February 02, 2006, 05:10:09 AM
Quote from: Neko
Syntax error line 22 so far.. I would fix it, but I have no clue how to do ruby =\


kk, I made just a little oopsie, Window_Bars was supposed to be class Window_Bars, but that's fixed now, here yoos go.

Code: [Select]
class Window_Bars < Window_Base
   def initialize
      super(0,0,234,158)
      self.contents = Bitmap.new(width - 32, height - 32)
      self.contents.font.name = 'Times New Roman'
      self.contents.font.size = 22
      refresh_stats
   end
   def refresh_stats
      self.contents.clear
      actor = $game_party.actors[1]
      draw_actor_hp(actor,0,0,202)
      draw_hp_bar(actor,0,32)
      draw_actor_sp(actor,0,42,202)
      draw_sp_bar(actor,0,74)
      draw_actor_exp(actor,0,84)
      draw_exp_bar(actor,0,116)
   end
   def update
      refresh_stats
   end
end
class Scene_Map
   def main
      @spriteset = Spriteset_Map.new
      @message_window = Window_Message.new
      @bar_window = Window_Bars.new
      Graphics.transition
      loop do
         Graphics.update
         Input.update
         update
         if $scene != self
            break
         end
      end
      Graphics.freeze
      @spriteset.dispose
      @message_window.dispose
      @bar_window.dispose
      if $scene.is_a?(Scene_Title)
         Graphics.transition
         Graphics.freeze
      end
   end
   def update
      loop do
         $game_map.update
         $game_system.map_interpreter.update
         $game_player.update
         $game_system.update
         $game_screen.update
         unless $game_temp.player_transferring
            break
         end
         transfer_player
         if $game_temp.transition_processing
            break
         end
      end
      @spriteset.update
      @message_window.update
      @bar_window.update
      if $game_temp.gameover
         $scene = Scene_Gameover.new
         return
      end
      if $game_temp.to_title
         $scene = Scene_Title.new
         return
      end
      if $game_temp.transition_processing
         $game_temp.transition_processing = false
         if $game_temp.transition_name == ""
            Graphics.transition(20)
         else
            Graphics.transition(40, "Graphics/Transitions/" +
            $game_temp.transition_name)
         end
      end
      if $game_temp.message_window_showing
         return
      end
      if $game_player.encounter_count == 0 and $game_map.encounter_list != []
         unless $game_system.map_interpreter.running? or
            $game_system.encounter_disabled
            $game_temp.battle_calling = true
            $game_temp.battle_can_escape = true
            $game_temp.battle_can_lose = false
            $game_temp.battle_proc = nil
            n = rand($game_map.encounter_list.size)
            $game_temp.battle_troop_id = $game_map.encounter_list[n]
         end
      end
      if Input.trigger?(Input::B)
         unless $game_system.map_interpreter.running? or
            $game_system.menu_disabled
            $game_temp.menu_calling = true
            $game_temp.menu_beep = true
         end
      end
      if $DEBUG and Input.press?(Input::F9)
         $game_temp.debug_calling = true
      end
      unless $game_player.moving?
         if $game_temp.battle_calling
            call_battle
         elsif $game_temp.shop_calling
            call_shop
         elsif $game_temp.name_calling
            call_name
         elsif $game_temp.menu_calling
            call_menu
         elsif $game_temp.save_calling
            call_save
         elsif $game_temp.debug_calling
            call_debug
         end
    end
end
Title: HP/SP/EXP Bars by Tsunokiette
Post by: Neko on February 02, 2006, 05:19:06 AM
XD Error on lline 120 XD Sorry for being such a noob... This script is great for me though
Title: HP/SP/EXP Bars by Tsunokiette
Post by: Tsunokiette on February 02, 2006, 05:27:36 AM
do dis work?

Code: [Select]
class Window_Bars < Window_Base
def initialize
super(0,0,234,158)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = 'Times New Roman'
self.contents.font.size = 22
refresh_stats
end
def refresh_stats
self.contents.clear
actor = $game_party.actors[1]
draw_actor_hp(actor,0,0,202)
draw_hp_bar(actor,0,32)
draw_actor_sp(actor,0,42,202)
draw_sp_bar(actor,0,74)
draw_actor_exp(actor,0,84)
draw_exp_bar(actor,0,116)
end
def update
refresh_stats
end
end
class Scene_Map
def main
@spriteset = Spriteset_Map.new
@message_window = Window_Message.new
@bar_window = Window_Bars.new
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@spriteset.dispose
@message_window.dispose
@bar_window.dispose
if $scene.is_a?(Scene_Title)
Graphics.transition
Graphics.freeze
end
end
def update
loop do
$game_map.update
$game_system.map_interpreter.update
$game_player.update
$game_system.update
$game_screen.update
unless $game_temp.player_transferring
break
end
transfer_player
if $game_temp.transition_processing
break
end
end
@spriteset.update
@message_window.update
@bar_window.update
if $game_temp.gameover
$scene = Scene_Gameover.new
return
end
if $game_temp.to_title
$scene = Scene_Title.new
return
end
if $game_temp.transition_processing
$game_temp.transition_processing = false
if $game_temp.transition_name == ""
Graphics.transition(20)
else
Graphics.transition(40, "Graphics/Transitions/" +
$game_temp.transition_name)
end
end
if $game_temp.message_window_showing
return
end
if $game_player.encounter_count == 0 and $game_map.encounter_list != []
unless $game_system.map_interpreter.running? or
$game_system.encounter_disabled
$game_temp.battle_calling = true
$game_temp.battle_can_escape = true
$game_temp.battle_can_lose = false
$game_temp.battle_proc = nil
n = rand($game_map.encounter_list.size)
$game_temp.battle_troop_id = $game_map.encounter_list[n]
end
end
if Input.trigger?(Input::B)
unless $game_system.map_interpreter.running? or
$game_system.menu_disabled
$game_temp.menu_calling = true
$game_temp.menu_beep = true
end
end
if $DEBUG and Input.press?(Input::F9)
$game_temp.debug_calling = true
end
unless $game_player.moving?
if $game_temp.battle_calling
call_battle
elsif $game_temp.shop_calling
call_shop
elsif $game_temp.name_calling
call_name
elsif $game_temp.menu_calling
call_menu
elsif $game_temp.save_calling
call_save
elsif $game_temp.debug_calling
call_debug
end
end
end
end
Title: HP/SP/EXP Bars by Tsunokiette
Post by: Neko on February 02, 2006, 05:29:26 AM
No errors, but no bars either =\
Title: HP/SP/EXP Bars by Tsunokiette
Post by: Sacul on February 02, 2006, 06:14:28 PM
i got an error for the first script you posted up above. The error comes up as the very end where it says Editing Windows Base then has #----- you know
Title: HP/SP/EXP Bars by Tsunokiette
Post by: Sacul on February 02, 2006, 06:28:21 PM
here is the specific error, hopes this help I really want to use this...


?????? ' ' ? 65 ??? name error ????????
undefined local variable or method 'border_1' for #<Windows_Bars:0x457a1a0>


there might be one to many or too few ?, but thats pretty much what it said. If its something im doing very sorry, scriptings not one of my things, but if this helps you good good good because im interested in using this script in my new game, thanks man.
Title: HP/SP/EXP Bars by Tsunokiette
Post by: Tsunokiette on February 02, 2006, 10:41:36 PM
I apologize, that was a lazy error, you see, when I started making the bars, I named them border1, border2, etc.

But for some reason when I tried to fill them with color, I typed border_1, etc.

Here's a completely tested, bug-proof system. It's completed, I've tested it and it works.

Code: [Select]
  #------------------------------------------------------------------------------
   # 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(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
   #------------------------------------------------------------------------------
   # End Window_Base Edit
   #------------------------------------------------------------------------------
Title: HP/SP/EXP Bars by Tsunokiette
Post by: Sacul on February 02, 2006, 11:14:25 PM
Very good, is there any way to call it by a certain key?
Title: HP/SP/EXP Bars by Tsunokiette
Post by: Tsunokiette on February 03, 2006, 12:11:24 AM
Quote from: Sacul
Very good, is there any way to call it by a certain key?


Say what?
Title: HP/SP/EXP Bars by Tsunokiette
Post by: Sacul on February 03, 2006, 06:33:10 AM
haha,

i mean like... I dont want it to always be on the map, i want it to pop and go away when you click the "S" key. So like you press "S" and you can see the status, you press "S" again and it hides...get it? thanks if you can do it
Title: HP/SP/EXP Bars by Tsunokiette
Post by: Tsunokiette on February 03, 2006, 09:12:39 PM
Quote from: Sacul
haha,

i mean like... I dont want it to always be on the map, i want it to pop and go away when you click the "S" key. So like you press "S" and you can see the status, you press "S" again and it hides...get it? thanks if you can do it


The window on the map was a separate project which I finished at my grandparents house. I'll edit it to support what you want and upload it here.

What key do you want to be pressed? I was thinking maybe the shift key? If not, I'll use the keyboard input script to do what you want.
Title: HP/SP/EXP Bars by Tsunokiette
Post by: Sacul on February 03, 2006, 10:57:33 PM
Shift key works. If you want to do the KB input script then S, but right shift works just as well. Thanks

-sacul
Title: HP/SP/EXP Bars by Tsunokiette
Post by: Dalton on February 06, 2006, 12:16:52 AM
Hey Tsuno, the map version doesn't have any defined colors, you might want to fix that.
Title: HP/SP/EXP Bars by Tsunokiette
Post by: Tsunokiette on February 06, 2006, 09:05:37 PM
Quote from: DeathTrooper
Hey Tsuno, the map version doesn't have any defined colors, you might want to fix that.


here's the map version completed. (the other was premature -_- lol)

Make sure you use the most recently posted bar script, and just paste this above main, call it something like Map Addition. Press 'shift' to make it visible/invisible, and use the q/w keys to rotate the actors' stats

Code: [Select]
class Window_Bars < Window_Base
   attr_accessor  :actor_id
   def initialize
      super(0,0,234,190)
      self.contents = Bitmap.new(width - 32, height - 32)
      self.contents.font.name = 'Times New Roman'
      self.contents.font.size = 22
      self.opacity = 100
      self.back_opacity = 100
      self.visible = false
      self.active = false
      @actor_id = 0
      refresh_stats
   end
   def refresh_stats
      self.contents.clear
      actor = $game_party.actors[@actor_id]
      draw_actor_name(actor,0,0)
      draw_actor_hp(actor,0,32,202)
      draw_hp_bar(actor,0,64)
      draw_actor_sp(actor,0,74,202)
      draw_sp_bar(actor,0,106)
      draw_actor_exp(actor,0,116)
      draw_exp_bar(actor,0,148)
    end
    def id(id,type)
      if type == 0
        @actor_id = id
      elsif type == 1
        @actor_id += id
      elsif type == 2
        @actor_id -= id
      end
    end
    def current_id(id)
      if @actor_id == id
        return true
      end
      return false
    end
   def update
      refresh_stats
   end
end
class Scene_Map
   def main
      @spriteset = Spriteset_Map.new
      @message_window = Window_Message.new
      @bar_window = Window_Bars.new
      @wait_count = 15
      Graphics.transition
      loop do
         Graphics.update
         Input.update
         update
         if $scene != self
            break
         end
      end
      Graphics.freeze
      @spriteset.dispose
      @message_window.dispose
      @bar_window.dispose
      if $scene.is_a?(Scene_Title)
         Graphics.transition
         Graphics.freeze
      end
   end
   def update
      loop do
         $game_map.update
         $game_system.map_interpreter.update
         $game_player.update
         $game_system.update
         $game_screen.update
         unless $game_temp.player_transferring
            break
         end
         transfer_player
         if $game_temp.transition_processing
            break
         end
       end
       if @bar_window.active
         if Input.repeat?(Input::L)
           if @bar_window.current_id(0)
             @bar_window.id(3,0)
           else
             @bar_window.id(1,2)
           end
         elsif Input.repeat?(Input::R)
           if @bar_window.current_id(3)
             @bar_window.id(0,0)
           else
             @bar_window.id(1,1)
           end
         end
       end
      if Input.press?(Input::A) and @wait_count >= 15
         if @bar_window.active
           @bar_window.active = false
           @bar_window.visible = false
           @wait_count = 0
         else
           @bar_window.active = true
           @bar_window.visible = true
           @wait_count = 0
         end
       end
       @wait_count += 1
      @spriteset.update
      @message_window.update
      @bar_window.update
      if $game_temp.gameover
         $scene = Scene_Gameover.new
         return
      end
      if $game_temp.to_title
         $scene = Scene_Title.new
         return
      end
      if $game_temp.transition_processing
         $game_temp.transition_processing = false
         if $game_temp.transition_name == ""
            Graphics.transition(20)
         else
            Graphics.transition(40, "Graphics/Transitions/" +
            $game_temp.transition_name)
         end
      end
      if $game_temp.message_window_showing
         return
      end
      if $game_player.encounter_count == 0 and $game_map.encounter_list != []
         unless $game_system.map_interpreter.running? or
            $game_system.encounter_disabled
            $game_temp.battle_calling = true
            $game_temp.battle_can_escape = true
            $game_temp.battle_can_lose = false
            $game_temp.battle_proc = nil
            n = rand($game_map.encounter_list.size)
            $game_temp.battle_troop_id = $game_map.encounter_list[n]
         end
      end
      if Input.trigger?(Input::B)
         unless $game_system.map_interpreter.running? or
            $game_system.menu_disabled
            $game_temp.menu_calling = true
            $game_temp.menu_beep = true
         end
      end
      if $DEBUG and Input.press?(Input::F9)
         $game_temp.debug_calling = true
      end
      unless $game_player.moving?
         if $game_temp.battle_calling
            call_battle
         elsif $game_temp.shop_calling
            call_shop
         elsif $game_temp.name_calling
            call_name
         elsif $game_temp.menu_calling
            call_menu
         elsif $game_temp.save_calling
            call_save
         elsif $game_temp.debug_calling
            call_debug
         end
      end
   end
end  
Title: HP/SP/EXP Bars by Tsunokiette
Post by: Sacul on February 07, 2006, 04:34:15 AM
I love you man, defintely going to be credited in my newest game... Also, you can be first to get a demo to! Add me to MSN if you want my email is littleoppelt@hotmail.com, I can fill you in on my game.
Title: HP/SP/EXP Bars by Tsunokiette
Post by: sub7 on March 04, 2006, 03:57:54 AM
ok i've put the tested script in the list but no bars show up.

When my little dude is walking around the map are they supposed to appear at the top-left?
Title: HP/SP/EXP Bars by Tsunokiette
Post by: Tsunokiette on March 05, 2006, 03:01:01 AM
Quote from: sub7
ok i've put the tested script in the list but no bars show up.

When my little dude is walking around the map are they supposed to appear at the top-left?


If you just put the bar script in, you wont see any bars, because that's just the code to make the bars.

If your talking about the script I posted for sacul, you press shift to show it.
Title: HP/SP/EXP Bars by Tsunokiette
Post by: Aus Ace Leader on March 05, 2006, 02:26:49 PM
K', I just got here and am intrested in this, yet I am lost, can you tell me what goes where?(I read over the topic and It still gets me lost)
Title: HP/SP/EXP Bars by Tsunokiette
Post by: Tsunokiette on March 06, 2006, 12:17:54 AM
Quote from: Aus Ace Leader
K', I just got here and am intrested in this, yet I am lost, can you tell me what goes where?(I read over the topic and It still gets me lost)


just put it above main, but showing the actual bars requires a little bit of very simple scripting.
Title: HP/SP/EXP Bars by Tsunokiette
Post by: Aus Ace Leader on March 06, 2006, 12:34:51 AM
Start anew, or the one already there?
Title: HP/SP/EXP Bars by Tsunokiette
Post by: vinco on March 28, 2006, 06:24:18 AM
Hey, the code worked for me but it lags alot!
Title: HP/SP/EXP Bars by Tsunokiette
Post by: Blizzard on March 28, 2006, 10:32:33 AM
OMG, you
Title: HP/SP/EXP Bars by Tsunokiette
Post by: Tsunokiette on March 29, 2006, 03:51:02 AM
Quote from: vinco
Hey, the code worked for me but it lags alot!


I figured I might as well log in for this one, seeing as it pertains to code which I provided.

Let me put it simply -

The code shouldn't lag, it hasn't on anything I've tested it on. It's either the computer's processing power (bps) or something's just seriously wrong with your copy of RMXP. (Which I hope BTW: Is LEGAL)

PS: To those who read my goodbye post: what I said in it still remains true, however the reasons I posted in topic are obvious, and therefore reasonable causes for breach of trust so-to-speak. (Is-done-trying-to-sound-smart)

PSS: DOH!
Title: Re: HP/SP/EXP Bars by Tsunokiette
Post by: Snailer on January 02, 2007, 02:24:49 PM
I am replying because i used it but It  doesn't work for me at a level 99 Char.
Title: Re: HP/SP/EXP Bars by Tsunokiette
Post by: gotix on January 02, 2007, 07:00:53 PM
well, this might be sorta late (XD) but, the code dosn't work for me. And also, where do I put the little codes under the big one? I keep getting error messages for some reaon =C
Title: Re: HP/SP/EXP Bars by Tsunokiette
Post by: &&&&&&&&&&&&& on January 02, 2007, 07:17:46 PM
you dont put them anywhere.  ;8
He was just showing you where in the code you can change to get diffrent color bars.
Title: Re: HP/SP/EXP Bars by Tsunokiette
Post by: Blizzard on January 03, 2007, 04:14:20 PM
Hey, Tsuno, are you going to decrease the lag? If yes, check my ABS, there is a HUD code in it which is highly optimized. Just use the same "Refresh it only if it changes" algorythm.:)
Title: Re: HP/SP/EXP Bars by Tsunokiette
Post by: Tsunokiette on January 04, 2007, 12:33:38 AM
Well, that's part is completely out of my control Bliz. *points at script* lolz.

I just posted the script for the bars. Of course I could post the script for those other bars I made, but yours are very similar *cough*andBETTER*cough* so I see no point in doing so lol.

:D
Title: Re: HP/SP/EXP Bars by Tsunokiette
Post by: Blizzard on January 04, 2007, 12:55:16 PM
Lol! I guess there is no point in making a script if there already is a better one. The only 3 points in making one are:

1. Don't want to credit somebody else to have done something, what you can do yourself.

2. Want to make a better one, even if it's only a little bit more efficient code.

3. To make a script to help somebody, because the script from the other guy is ruggish~

At least these are my three reasons, lol!
Title: Re: HP/SP/EXP Bars by Tsunokiette
Post by: Fallen Angel on December 05, 2007, 06:48:11 AM
Ok I just tried to use your script and it looks good from pics but it wont work im a little confused  I whant to have the bars in battle only to replace the numbers for hp sp ect. Can someone help me plz?  :)
Title: Re: HP/SP/EXP Bars by Tsunokiette
Post by: Shinami on December 05, 2007, 08:18:16 AM
....okies. You just resurrected a very, very old thread. In the words of the great Milk-chan I shall scold you! You dumbass! Now...

#1:If you find an old thread like this with a script that you need help with, post a thread in the Script Request section detailing what you want and link to the old thread for reference.

#2:Necro posting is bad! It may bring about the wrath of Falcon and nobody wants the wrath of Falcon to be brought.

#3:If you want to add bars to the battle system, then look at Scene_Battle's "main" method to find out which windows are created for the battles. Then, you look through each window until you find the one that displays the actor hp/sp etc. That will be the window you want to use.

#4:To use a bar script, you have to have some sort of knowledge on how windows and scenes work.
Title: Re: HP/SP/EXP Bars by Tsunokiette
Post by: Fallen Angel on December 05, 2007, 08:28:06 AM
srry bringing this old thread up but i was desprete and didn't thinkof making a new one  my bad anyways im fairly good at working rmxp and a little about scrpts just not how to write them I was just confused wether to put the thing the Bar script or somthing els for where the bars will be just scripts. The directions were vaige to me i got confused.  but thnx for replying anyway. And thnx for the help srry if i pissed any 1 off.
Title: Re: HP/SP/EXP Bars by Tsunokiette
Post by: :) on December 06, 2007, 12:04:06 AM
....okies. You just resurrected a very, very old thread. In the words of the great Milk-chan I shall scold you! You dumbass! Now...

#1:If you find an old thread like this with a script that you need help with, post a thread in the Script Request section detailing what you want and link to the old thread for reference.

#2:Necro posting is bad! It may bring about the wrath of Falcon and nobody wants the wrath of Falcon to be brought.

#3:If you want to add bars to the battle system, then look at Scene_Battle's "main" method to find out which windows are created for the battles. Then, you look through each window until you find the one that displays the actor hp/sp etc. That will be the window you want to use.

#4:To use a bar script, you have to have some sort of knowledge on how windows and scenes work.

People who say bumping old topics is bad are idiots.
It's relevant to him, he has all rights to post in it. It's not like he's bumping a topic in spam, no need to call him a dumbass.
Title: Re: HP/SP/EXP Bars by Tsunokiette
Post by: Tsunokiette on December 06, 2007, 12:28:10 AM
srry bringing this old thread up but i was desprete and didn't thinkof making a new one  my bad anyways im fairly good at working rmxp and a little about scrpts just not how to write them I was just confused wether to put the thing the Bar script or somthing els for where the bars will be just scripts. The directions were vaige to me i got confused.  but thnx for replying anyway. And thnx for the help srry if i pissed any 1 off.

No problem. *smiles as if he actually did something*
Title: Re: HP/SP/EXP Bars by Tsunokiette
Post by: Fallen Angel on December 06, 2007, 12:48:07 AM
thnx im still new to the site idk wats good or bad on this site intirly btw I like the script alot but if you dont mind um Im having some trouble getting it to work idk were to put  the other 3 strips( hp sp ect.) for it to replac the numbers for battle ive been searching for a good Bar script and this is the best one i found  :)
Title: Re: HP/SP/EXP Bars by Tsunokiette
Post by: TheWorld on January 08, 2008, 01:39:43 AM
 Tsunokiette could you do me a favor & combine these two scripts?
Code: [Select]
#------------------------------------------------------------------------------
   # 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(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
   #------------------------------------------------------------------------------
   # End Window_Base Edit
   #------------------------------------------------------------------------------
Code: [Select]
class Window_Bars < Window_Base
   attr_accessor  :actor_id
   def initialize
      super(0,0,234,190)
      self.contents = Bitmap.new(width - 32, height - 32)
      self.contents.font.name = 'Times New Roman'
      self.contents.font.size = 22
      self.opacity = 100
      self.back_opacity = 100
      self.visible = false
      self.active = false
      @actor_id = 0
      refresh_stats
   end
   def refresh_stats
      self.contents.clear
      actor = $game_party.actors[@actor_id]
      draw_actor_name(actor,0,0)
      draw_actor_hp(actor,0,32,202)
      draw_hp_bar(actor,0,64)
      draw_actor_sp(actor,0,74,202)
      draw_sp_bar(actor,0,106)
      draw_actor_exp(actor,0,116)
      draw_exp_bar(actor,0,148)
    end
    def id(id,type)
      if type == 0
        @actor_id = id
      elsif type == 1
        @actor_id += id
      elsif type == 2
        @actor_id -= id
      end
    end
    def current_id(id)
      if @actor_id == id
        return true
      end
      return false
    end
   def update
      refresh_stats
   end
end
class Scene_Map
   def main
      @spriteset = Spriteset_Map.new
      @message_window = Window_Message.new
      @bar_window = Window_Bars.new
      @wait_count = 15
      Graphics.transition
      loop do
         Graphics.update
         Input.update
         update
         if $scene != self
            break
         end
      end
      Graphics.freeze
      @spriteset.dispose
      @message_window.dispose
      @bar_window.dispose
      if $scene.is_a?(Scene_Title)
         Graphics.transition
         Graphics.freeze
      end
   end
   def update
      loop do
         $game_map.update
         $game_system.map_interpreter.update
         $game_player.update
         $game_system.update
         $game_screen.update
         unless $game_temp.player_transferring
            break
         end
         transfer_player
         if $game_temp.transition_processing
            break
         end
       end
       if @bar_window.active
         if Input.repeat?(Input::L)
           if @bar_window.current_id(0)
             @bar_window.id(3,0)
           else
             @bar_window.id(1,2)
           end
         elsif Input.repeat?(Input::R)
           if @bar_window.current_id(3)
             @bar_window.id(0,0)
           else
             @bar_window.id(1,1)
           end
         end
       end
      if Input.press?(Input::A) and @wait_count >= 15
         if @bar_window.active
           @bar_window.active = false
           @bar_window.visible = false
           @wait_count = 0
         else
           @bar_window.active = true
           @bar_window.visible = true
           @wait_count = 0
         end
       end
       @wait_count += 1
      @spriteset.update
      @message_window.update
      @bar_window.update
      if $game_temp.gameover
         $scene = Scene_Gameover.new
         return
      end
      if $game_temp.to_title
         $scene = Scene_Title.new
         return
      end
      if $game_temp.transition_processing
         $game_temp.transition_processing = false
         if $game_temp.transition_name == ""
            Graphics.transition(20)
         else
            Graphics.transition(40, "Graphics/Transitions/" +
            $game_temp.transition_name)
         end
      end
      if $game_temp.message_window_showing
         return
      end
      if $game_player.encounter_count == 0 and $game_map.encounter_list != []
         unless $game_system.map_interpreter.running? or
            $game_system.encounter_disabled
            $game_temp.battle_calling = true
            $game_temp.battle_can_escape = true
            $game_temp.battle_can_lose = false
            $game_temp.battle_proc = nil
            n = rand($game_map.encounter_list.size)
            $game_temp.battle_troop_id = $game_map.encounter_list[n]
         end
      end
      if Input.trigger?(Input::B)
         unless $game_system.map_interpreter.running? or
            $game_system.menu_disabled
            $game_temp.menu_calling = true
            $game_temp.menu_beep = true
         end
      end
      if $DEBUG and Input.press?(Input::F9)
         $game_temp.debug_calling = true
      end
      unless $game_player.moving?
         if $game_temp.battle_calling
            call_battle
         elsif $game_temp.shop_calling
            call_shop
         elsif $game_temp.name_calling
            call_name
         elsif $game_temp.menu_calling
            call_menu
         elsif $game_temp.save_calling
            call_save
         elsif $game_temp.debug_calling
            call_debug
         end
      end
   end
end   
Title: Re: HP/SP/EXP Bars by Tsunokiette
Post by: Guardian on January 11, 2008, 09:29:14 PM
Looks very good, maybe I'll use it in my game...
Title: Re: HP/SP/EXP Bars by Tsunokiette
Post by: zen03y on February 03, 2008, 04:33:53 AM
Alright, I've been putting scripts into classes and groups, but nothing happens.....how do I get them working? I think I've been putting them in the right place but nothing happens...
Title: Re: HP/SP/EXP Bars by Tsunokiette
Post by: Tsunokiette on February 03, 2008, 03:37:38 PM
Tsunokiette could you do me a favor & combine these two scripts?

Could you provide me with a link to a topic with the second script? Just so I can get an idea as to what it's supposed to do.

Alright, I've been putting scripts into classes and groups, but nothing happens.....how do I get them working? I think I've been putting them in the right place but nothing happens...

If you read the first post you'll notice that I say the bars don't show up by themselves. :)
This is just the code that draws the bars, but you have to tell the system to draw them, otherwise it's like giving a builder the blueprints to a house without telling him to build the house.

I don't remember what the code is exactly (it should be in the first post) but you put it in the refresh method of most windows where it draws everything that is supposed to be in the window.

If this doesn't work post the code you have and I'll fix it for you. ^_^