Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

2 Pages V   1 2 >  
Reply to this topicStart new topic
> HP & SP Bars on Map
Slipknot
post May 25 2006, 01:51 PM
Post #1


Level 2
Group Icon

Group: Member
Posts: 25
Type: Scripter
RM Skill: Masterful





HP & SP Bars on Map
Version: 1.0


Last Update
May 23, 2006.

Introduction

This is an updated and better version of my old HP bar script, this one will work faster and have some new features like the SP bar.

Features
  • Display nice bars for the HP and SP.
  • Allow the player change the current actor by pressing A (shift) and R or L (numpad).
  • Display the name and level of the current actor.
  • Changes the x position of the timer if the bars are showing.
Screenshots



Script

CODE
#==============================================================================
# ** HP & SP Bars on Map
#------------------------------------------------------------------------------
# Slipknot
# 1.0
# 05.23.06
#==============================================================================

#------------------------------------------------------------------------------
# SDK Log
#------------------------------------------------------------------------------
SDK.log('HP & SP Bars on Map', 'Slipknot', 1.0, '05.23.06')

#------------------------------------------------------------------------------
# Begin SDK Enabled Check
#------------------------------------------------------------------------------
if SDK.state('HP & SP Bars on Map') == true

module MapBars_Settings
 #--------------------------------------------------------------------------
 HPBar = true
 #--------------------------------------------------------------------------
 SPBar = true
 #--------------------------------------------------------------------------
 LevelText = 'Lv: '
 #--------------------------------------------------------------------------
 AllowChange = true
 #--------------------------------------------------------------------------
end

#------------------------------------------------------------------------------
# Begin Scene_Map Edit
#------------------------------------------------------------------------------
class Scene_Map
 #--------------------------------------------------------------------------
 # * Public Instance Variables
 #--------------------------------------------------------------------------
 attr_reader(:sprite_bars)
 #--------------------------------------------------------------------------
 # * Alias
 #--------------------------------------------------------------------------
 alias slipknot_mapbars_maindraw main_draw
 alias slipknot_mapbars_updgraphics update_graphics
 alias slipknot_mapbars_maindispose main_dispose
 #--------------------------------------------------------------------------
 # * Main Draw
 #--------------------------------------------------------------------------
 def main_draw
    slipknot_mapbars_maindraw
    @sprite_bars = Sprite_Bars.new
 end
 #--------------------------------------------------------------------------
 # * Main Dispose
 #--------------------------------------------------------------------------
 def main_dispose
    slipknot_mapbars_maindispose
    @sprite_bars.dispose
 end
 #--------------------------------------------------------------------------
 # * Update Graphics
 #--------------------------------------------------------------------------
 def update_graphics
    slipknot_mapbars_updgraphics
    @sprite_bars.update
 end
end
#------------------------------------------------------------------------------
# End Scene_Map Edit
#------------------------------------------------------------------------------

#------------------------------------------------------------------------------
# Begin Interpreter Edit
#------------------------------------------------------------------------------
class Interpreter
 #--------------------------------------------------------------------------
 # * Public Instance Variables
 #--------------------------------------------------------------------------
 attr_reader(:hp_bar, :sp_bar, :bars_index)
 attr_accessor(:bars_need_refresh)
 #--------------------------------------------------------------------------
 # * Alias
 #--------------------------------------------------------------------------
 alias slipknot_mapbars_initialize initialize
 #--------------------------------------------------------------------------
 # * Object Initialization
 #--------------------------------------------------------------------------
 def initialize(depth = 0, main = false)
    slipknot_mapbars_initialize(depth, main)
    if main
  @bars_need_refresh = true
  @hp_bar = MapBars_Settings::HPBar
  @sp_bar = MapBars_Settings::SPBar
  @bars_index = 0
    end
 end
 #--------------------------------------------------------------------------
 # * Bar's Actor Index
 #--------------------------------------------------------------------------
 def bars_index=(index)
    if @bars_index != index
  @bars_index = index
  @bars_need_refresh = true
    end
    return true
 end
 def set_bars_index(index = 0)
    self.bars_index = (index)
 end
 #--------------------------------------------------------------------------
 # * Show HP Bar
 #--------------------------------------------------------------------------
 def show_hp_bar(value = true)
    @hp_bar = value
    @bars_need_refresh = true
 end
 #--------------------------------------------------------------------------
 # * Show SP Bar
 #--------------------------------------------------------------------------
 def show_sp_bar(value = true)
    @sp_bar = value
    @bars_need_refresh = true
 end
end
#------------------------------------------------------------------------------
# End Interpreter Edit
#------------------------------------------------------------------------------

#------------------------------------------------------------------------------
# Begin Spriteset_Map Edit
#------------------------------------------------------------------------------
class Spriteset_Map
 #--------------------------------------------------------------------------
 # * Alias
 #--------------------------------------------------------------------------
 alias slipknot_mapbars_updpicturesprites update_picture_sprites
 #--------------------------------------------------------------------------
 # * Update Picture Sprites
 #--------------------------------------------------------------------------
 def update_picture_sprites
    @timer_sprite.x = ($game_system.map_interpreter.sp_bar ||
  $game_system.map_interpreter.sp_bar) ? 400 : 552
    slipknot_mapbars_updpicturesprites
 end
end
#------------------------------------------------------------------------------
# End Spriteset_Map Edit
#------------------------------------------------------------------------------

class Sprite_Bars < Window_Base
 #--------------------------------------------------------------------------
 # * Object Initialization
 #--------------------------------------------------------------------------
 def initialize
    @sprite = Sprite.new()
    @sprite.bitmap = Bitmap.new(144, 82)
    @sprite.x = 488
    @sprite.y = 8
    @old_hp = @old_sp = false
    interpreter.bars_need_refresh = true
    update
 end
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
    if ! hp? && ! sp?
  bitmap.clear
  return
    end
    if MapBars_Settings::AllowChange && Input.press?(11)
  if Input.repeat?(Input::L)
 interpreter.bars_index = (interpreter.bars_index - 1) % $game_party.actors.size
  end
  if Input.repeat?(Input::R)
 interpreter.bars_index = (interpreter.bars_index + 1) % $game_party.actors.size
  end
    end
    actor = $game_party.actors[interpreter.bars_index]
    if need_refresh?
  bitmap.clear
  lvt = MapBars_Settings::LevelText + actor.level.to_s
  width = bitmap.text_size(lvt).width
  draw_text(1, 0, 143 - width, 22, actor.name)
  draw_text(143 - width, 0, width, 22, lvt)
    end  
    if hp? && (need_refresh? || @old_hp != actor.hp)
  draw_hp_bar(actor, 0, 22)
  @old_hp = actor.hp
  hp = true
    end
    if sp? && (need_refresh? || @old_sp != actor.sp)
  y = hp != nil ? 30 : 0
  draw_sp_bar(actor, 0, y + 22)
  @old_sp = actor.sp
    end
    interpreter.bars_need_refresh = false
 end
 #--------------------------------------------------------------------------
 # * @sprite.bitmap & $game_system.map_interpreter
 #--------------------------------------------------------------------------
 def bitmap
    @sprite.bitmap
 end
 def interpreter
    $game_system.map_interpreter
 end
 #--------------------------------------------------------------------------
 # * Return Interpreter Variables
 #--------------------------------------------------------------------------
 def need_refresh?
    interpreter.bars_need_refresh
 end
 def hp?
    interpreter.hp_bar
 end
 def sp?
    interpreter.sp_bar
 end
 #--------------------------------------------------------------------------
 # * Dispose
 #--------------------------------------------------------------------------
 def dispose
    @sprite.dispose
    bitmap.dispose
 end
 #--------------------------------------------------------------------------
 # * Draw HP Bar
 #--------------------------------------------------------------------------
 def draw_hp_bar(actor, x, y)
    bitmap.fill_rect(x, y, 144, 30, Color.new(0, 0, 0, 0))
    bitmap.font.color = system_color
    draw_text(x, y, 32, 30, $data_system.words.hp)
    hp_x = x + 36
    x += 32
    bitmap.fill_rect(x, y + 14, 112, 10, Color.new(0, 0, 0))
    width = 112.0 * actor.hp / actor.maxhp
    red = 144.0
    step = 80.0 / (width - 2).to_f
    for p in 0...(width - 2)
  bitmap.fill_rect(x + p + 1, y + 15, 1, 8, Color.new(red, 64, 32))
  red += step
    end
    bitmap.font.size -= 2
    bitmap.font.color = actor.hp == 0 ? knockout_color :
  actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
    draw_text(hp_x, y, 48, 26, actor.hp.to_s, 2)
    bitmap.font.color = normal_color
    draw_text(hp_x + 48, y, 12, 26, '/', 1)
    draw_text(hp_x + 60, y, 48, 26, actor.maxhp.to_s)
    bitmap.font.size += 2
 end
 #--------------------------------------------------------------------------
 # * Draw SP Bar
 #--------------------------------------------------------------------------
 def draw_sp_bar(actor, x, y)
    bitmap.fill_rect(x, y, 144, 30, Color.new(0, 0, 0, 0))
    self.bitmap.font.color = system_color
    draw_text(x, y, 32, 30, $data_system.words.sp)
    sp_x = x + 36
    x += 32
    bitmap.fill_rect(x, y + 14, 112, 10, Color.new(0, 0, 0))
    width = 112.0 * actor.sp / actor.maxsp
    blue = 144.0
    step = 80.0 / (width - 2).to_f
    for p in 0...(width - 2)
  bitmap.fill_rect(x + p + 1, y + 15, 1, 8, Color.new(32, 64, blue))
  blue += step
    end
    bitmap.font.size -= 2
    bitmap.font.color = actor.sp == 0 ? knockout_color :
  actor.sp <= actor.maxhp / 4 ? crisis_color : normal_color
    draw_text(sp_x, y, 46, 26, actor.sp.to_s, 2)
    bitmap.font.color = normal_color
    draw_text(sp_x + 46, y, 10, 26, '/', 1)
    draw_text(sp_x + 58, y, 46, 26, actor.maxsp.to_s)
    bitmap.font.size += 2
 end
 #--------------------------------------------------------------------------
 # * Draw Outline Text
 #--------------------------------------------------------------------------
 def draw_text(x, y, width, height, string, align = 0)
    col = bitmap.font.color.dup
    bitmap.font.color = Color.new(32, 32, 32, col.alpha)
    bitmap.draw_text(x - 1, y, width, height, string, align)
    bitmap.draw_text(x, y - 1, width, height, string, align)
    bitmap.draw_text(x + 1, y, width, height, string, align)
    bitmap.draw_text(x, y + 1, width, height, string, align)
    bitmap.font.color = col
    bitmap.draw_text(x, y, width, height, string, align)
 end
end

#------------------------------------------------------------------------------
# End SDK Enabled Test
#------------------------------------------------------------------------------
end


Instructions

You need paste the code before Main, but below SDK.

To turn on the HP bar use in the call script command:
CODE
show_hp_bar

To turn it off use:
CODE
show_hp_bar(false)

To turn on the SP bar use:
CODE
show_sp_bar

And to turn it off use:
CODE
show_sp_bar(false)

To change the current actor use this:
CODE
set_bars_index(id)


You can also customize some aspects more, like start the game with or without any of the bars, change the text for the level and allow or disallow the player ability to change the actor just by changing the constants in the begin of the script.

FAQ

empty!

Compatibility

SDK compatible scripts.

Author's Notes

This script requires SDK to work, I tested it with the version 1.5.
Enjoy it, and report any bug! cool.gif


__________________________
Go to the top of the page
 
+Quote Post
   
jens009
post May 25 2006, 03:24 PM
Post #2


L Did you know? Death gods... only eat apples
Group Icon

Group: +Gold Member
Posts: 2,976
Type: Scripter
RM Skill: Skilled




OOhhhhh It's actually Slipknot!!!

SCRIPTER!!!! WOW,

Yeah this is kinda cool for Nearfantastica's Squad Action Battle System (Kingdom Hearts battle system)


__________________________

My RMXP Project:


Farewell RRR. =]
Go to the top of the page
 
+Quote Post
   
Slipknot
post May 28 2006, 09:05 AM
Post #3


Level 2
Group Icon

Group: Member
Posts: 25
Type: Scripter
RM Skill: Masterful




Thanks!


__________________________
Go to the top of the page
 
+Quote Post
   
rpgmakerxpuser
post Jul 22 2006, 04:07 PM
Post #4


Level 1
Group Icon

Group: Member
Posts: 12
Type: None
RM Skill: Beginner




it won't work
Go to the top of the page
 
+Quote Post
   
jens009
post Jul 22 2006, 04:38 PM
Post #5


L Did you know? Death gods... only eat apples
Group Icon

Group: +Gold Member
Posts: 2,976
Type: Scripter
RM Skill: Skilled




Umm we need more information that "It wont work" that doesnt actually help the author

Anyway I think you dont have the SDK script that can be found in www.dubealex.com

EDited: YOu should try reading the whole post because he literaly said

QUOTE
This script requires SDK to work, I tested it with the version 1.5.
Enjoy it, and report any bug!


This post has been edited by jens009: Jul 22 2006, 04:40 PM


__________________________

My RMXP Project:


Farewell RRR. =]
Go to the top of the page
 
+Quote Post
   
Ember
post Jul 23 2006, 01:18 AM
Post #6


Level 68
Group Icon

Group: Revolutionary
Posts: 2,799
Type: Artist
RM Skill: Advanced




Maybe you should make a Non-SDK for those who don't use it?

I use it, but hey..not thinking of my self for once.


__________________________
Go to the top of the page
 
+Quote Post
   
jens009
post Jul 23 2006, 07:23 AM
Post #7


L Did you know? Death gods... only eat apples
Group Icon

Group: +Gold Member
Posts: 2,976
Type: Scripter
RM Skill: Skilled




QUOTE (ember2inferno @ Jul 23 2006, 01:18 AM)
Maybe you should make a Non-SDK for those who don't use it?

I use it, but hey..not thinking of my self for once.
*


SDK Makes things compatible, I rather have scripts SDK compatible because they are sure compatible that no errors would occur in your script


__________________________

My RMXP Project:


Farewell RRR. =]
Go to the top of the page
 
+Quote Post
   
Sniper Wolf
post Jul 26 2006, 09:42 PM
Post #8


Level 1
Group Icon

Group: Member
Posts: 9
Type: Event Designer
RM Skill: Skilled




Where do you get the sdk? I cant find it anywhere, googled and found all sdk's except this one, looked on that website that started with a D (sorry), I think jens009 mentioned it in another topic, couldnt find it. Any help would be appreciated, even if it is right in front of my face.


__________________________
Go to the top of the page
 
+Quote Post
   
italianstal1ion
post Jul 27 2006, 01:24 AM
Post #9


Level 5
Group Icon

Group: Member
Posts: 67
Type: None
RM Skill: Skilled




http://www.dubealex.com/asylum/index.php?showtopic=7481

^^^^^^^^^^^^^^^^ SDK 1.5 ^^^^^^^^^^^^^^^^^


__________________________
Go to the top of the page
 
+Quote Post
   
Sniper Wolf
post Jul 27 2006, 11:20 AM
Post #10


Level 1
Group Icon

Group: Member
Posts: 9
Type: Event Designer
RM Skill: Skilled




Thanks, much appreciated.


__________________________
Go to the top of the page
 
+Quote Post
   
UltimaDude
post Aug 16 2006, 06:08 AM
Post #11


Level 2
Group Icon

Group: Member
Posts: 27
Type: None
RM Skill: Undisclosed




I?m not sure if this is necro posting but when teleported the bar doesn?t show up.
You have to enable it which is a bit annoying sometimes isn't it?
Go to the top of the page
 
+Quote Post
   
Heavyblues
post Jun 28 2007, 04:01 PM
Post #12


Level 11
Group Icon

Group: Revolutionary
Posts: 188
Type: Artist
RM Skill: Beginner




is there any way to add this in with a graphic? I have this awesome HP/MP bar graphic I really wanted to use... but I dunno >.>

could it work?

here's the graphic...



Go to the top of the page
 
+Quote Post
   
jens009
post Jun 28 2007, 06:22 PM
Post #13


L Did you know? Death gods... only eat apples
Group Icon

Group: +Gold Member
Posts: 2,976
Type: Scripter
RM Skill: Skilled




Yes, It is possible to use those graphics instead of the regular Hp and Sp bars. But here's the catch. You need to do some slight script tweaking to make it possible.

First of all, the bars that were drawn an the map were generated by the rpg maker. What does that mean? It simply means that it didn't use any graphics(like the one you posted) to show the actor's hp and sp bars but rather used regular draw functions.

If you want to show pictures as Hp and Sp bars, you have to find the def draw_actor_hp and def draw_actor_sp or whatever the name that slipknot used to create those bars. After locating it, you have to change the lines below the def function so that pictures would indicate the actor's hp and sp.

I would gladly help you out but we have a problem you see. I can't even see the script! =P


__________________________

My RMXP Project:


Farewell RRR. =]
Go to the top of the page
 
+Quote Post
   
Heavyblues
post Jun 29 2007, 10:18 AM
Post #14


Level 11
Group Icon

Group: Revolutionary
Posts: 188
Type: Artist
RM Skill: Beginner




here's teh code >.> um... did I link to the images? I'll do it again anyway >.>

perhaps you could explain it to me :3?

<-- this be the image :3

also >.> is there a way to make this work for monsters in battle... too?

CODE
#==============================================================================
# ** COGWHEEL Plug 'n' Play Menu Bars (based on Syvkal's revisions)
#-------------------------------------------------------------------------------
# by DerVVulfman
# Version 1.1
# 06-28-06
#------------------------------------------------------------------------------
# This is a revision of Cogwheel's famous bargraph system, now set as an inser-
# table script to display bargraphs behind values in the menus.
#
# To prevent conflict with Cogwheel's RTAB system, two key definitions have been
# renamed: "gauge_rect" to "cw_gauge" & "gradation_rect" to "cw_grad_rect."
#
#
# Affected Systems:  Main Menu
#                    Skill Menu
#                    Status Menu
#                    Hero Select Menu (for Items & Skills)
#                    Equipment Menu
#                    BattleStatus Menu
#                    
# The system uses a series of CONSTANTS that can be edited here.  They control
# the basic gauge colors and the manner the gauge is filled:

  # Gauge Border Colors
    COG_COLOR1 = Color.new(0, 0, 0, 192)         # Outer Border
    COG_COLOR2 = Color.new(255, 255, 192, 192)   # Inner Border
  # Gauge Empty filler
    COG_COLOR3 = Color.new(0, 0, 0, 192)         # Half of Inner Shading
    COG_COLOR4 = Color.new(64, 0, 0, 192)        # Half of Inner Shading
  # Alignment
    COG_ALIGN1 = 1    # Type 1: (0: Left / 1: Center / 2: Right Justify)
    COG_ALIGN2 = 2    # Type 2: (0: Upper / 1: Central / 2: Lower)
    COG_ALIGN3 = 0    # FILL ALIGNMENT (0: Left Justify / 1: Right Justify)
  # Gauge Settings
    COG_GRADE1 = 1    # EMPTY  gauge (0: Side / 1: Vertical / 2: Slanted)
    COG_GRADE2 = 0    # FILLER gauge (0: Side / 1: Vertical / 2: Slanted)


#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#  This class handles the actor. It's used within the Game_Actors class
#  ($game_actors) and refers to the Game_Party class ($game_party).
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Get EXP - numeric for calculations
  #--------------------------------------------------------------------------  
  def now_exp
   return @exp - @exp_list[@level]
  end
  #--------------------------------------------------------------------------
  # * Get Next Level EXP - numeric for calculations
  #--------------------------------------------------------------------------
  def next_exp
   return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
  end
  #--------------------------------------------------------------------------
  # * End of Class
  #--------------------------------------------------------------------------
end


#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
#  This class is for all in-game windows.
#==============================================================================

class Window_Base < Window
  
  
  #--------------------------------------------------------------------------
  # * Draw EXP w/ Bars
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  alias draw_actor_exp_original draw_actor_exp
  def draw_actor_exp(actor, x, y, width = 204)
    if actor.next_exp != 0
      rate = actor.now_exp.to_f / actor.next_exp
    else
      rate = 1
    end
    # Calculate Bar Gradiation
    if actor.next_exp != 0
      rate = actor.now_exp.to_f / actor.next_exp
    else
      rate = 1
    end
    # Adjust Bar Color based on Gradiation
    color1 = Color.new(80 * rate, 80 - 80 * rate ** 2, 80 - 80 * rate, 192)
    color2 = Color.new(240 * rate, 240 - 240 * rate ** 2, 240 - 240 * rate, 192)
    # Calculate Bar Width
    if actor.next_exp != 0
      exp = width * actor.now_exp / actor.next_exp
    else
      exp = width
    end
    # Draw Bar Graph
    cw_gauge(x, y + 25, width, 10, exp, color1, color2)
    # Call original EXP                
    draw_actor_exp_original(actor, x, y)
  end  
  
  #--------------------------------------------------------------------------
  # * Draw HP w/ Bars
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     width : draw spot width
  #--------------------------------------------------------------------------
  alias draw_actor_hp_original draw_actor_hp
  def draw_actor_hp(actor, x, y, width = 144)
    # Calculate Bar Gradiation
    if actor.maxhp != 0
      rate = actor.hp.to_f / actor.maxhp
    else
      rate = 0
    end
    # Adjust Bar Color based on Gradiation
    color1 = Color.new(80 - 24 * rate, 80 * rate, 14 * rate, 192)
    color2 = Color.new(240 - 72 * rate, 240 * rate, 62 * rate, 192)
    # Calculate Bar Width
    if actor.maxhp != 0
      hp = width * actor.hp / actor.maxhp
    else
      hp = 0
    end
    # Draw Bar Graph
    cw_gauge(x, y + 25, width, 10, hp, color1, color2)
    # Call original HP
    draw_actor_hp_original(actor, x, y, width)
  end

  #--------------------------------------------------------------------------
  # * Draw SP w/ Bars
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     width : draw spot width
  #--------------------------------------------------------------------------
  alias draw_actor_sp_original draw_actor_sp
  def draw_actor_sp(actor, x, y, width = 144)
    # Calculate Bar Gradiation
    if actor.maxsp != 0
      rate = actor.sp.to_f / actor.maxsp
    else
      rate = 1
    end  
    # Adjust Bar Color based on Gradiation
    color1 = Color.new(14 * rate, 80 - 24 * rate, 80 * rate, 192)
    color2 = Color.new(62 * rate, 240 - 72 * rate, 240 * rate, 192)
    # Calculate Bar Width
    if actor.maxsp != 0
      sp = width * actor.sp / actor.maxsp
    else
      sp = width  
    end
    # Draw Bar Graph
    cw_gauge(x + width * 0 / 100, y + 25, width, 10, sp, color1, color2)
    # Call original SP                
    draw_actor_sp_original(actor, x, y, width)
  end

  #--------------------------------------------------------------------------
  # * Draw Parameter w/ Bars
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     type  : parameter type (0-6)
  #--------------------------------------------------------------------------
  alias draw_actor_parameter_original draw_actor_parameter
  def draw_actor_parameter(actor, x, y, type)
    # Choose Color & Parameter Type
    case type
    when 0
      e1 = actor.atk
      c6 = Color.new(253, 53, 56, 192)
      c5 = Color.new(242, 2, 6, 192)
    when 1
      e1 = actor.pdef
      c6 = Color.new(238, 254, 124, 192)
      c5 = Color.new(228, 253, 48, 192)
    when 2
      e1 = actor.mdef
      c6 = Color.new(150, 37, 184, 192)
      c5 = Color.new(170, 57, 204, 192)
    when 3
      e1 = actor.str
      c6 = Color.new(253, 163, 33, 192)
      c5 = Color.new(254, 209, 154, 192)
    when 4
      e1 = actor.dex
      c6 = Color.new(255, 255, 255, 192)
      c5 = Color.new(222, 222, 222, 192)
    when 5
      e1 = actor.agi
      c6 = Color.new(124, 254, 155, 192)
      c5 = Color.new(33, 253, 86, 192)
    when 6
      e1 = actor.int
      c6 = Color.new(119, 203, 254, 192)
      c5 = Color.new(8, 160, 253, 192)
    end
    # Calculate Bar Gradiation
    e2 = 999
    if e1.to_f != 0
      rate = e1.to_f / e2.to_f
    else
      rate = 1
    end
    # Adjust Bar Color based on Gradiation & Parameter Type
    for i in 0..7
      r = c6.red * rate
      g = (c6.green - 10) * rate
      b = c6.blue  * rate
      a = c6.alpha
    end
    # Calculate Bar Width
    width = 168
    if e1.to_f != 0
      par = width * e1.to_f / e2.to_f
    else
      par = width
    end
    # Equipment Calc Fix    
    case type
    when 0
      if e1 == 0
        par = 0
      end
    when 1
      if e1 == 0
        par = 0
      end
    when 2
      if e1 == 0
        par = 0
      end
    end
    # Draw Bar Graph
    cw_gauge(x , y + 25, width, 7, par, c5, Color.new(r, g, b, a))
    # Call Original Parameter            
    draw_actor_parameter_original(actor, x, y, type)
  end

  #--------------------------------------------------------------------------
  # * Gauge Rectangle (New to Class)
  #--------------------------------------------------------------------------
  def cw_gauge(x, y, width, height, gauge, color1, color2)

    # Use Cogwheel PRESETS
    color3 = COG_COLOR1
    color4 = COG_COLOR2
    color5 = COG_COLOR3
    color6 = COG_COLOR4
    align1 = COG_ALIGN1
    align2 = COG_ALIGN2
    align3 = COG_ALIGN3
    grade1 = COG_GRADE1
    grade2 = COG_GRADE2
    
    # Create Rectangle Width based on gauge max.
    rect_width = width
    
    case align1
    when 1
      x += (rect_width - width) / 2
    when 2
      x += rect_width - width
    end
    case align2
    when 1
      y -= height / 2
    when 2
      y -= height
    end
    self.contents.fill_rect(x, y, width, height, color3)
    self.contents.fill_rect(x + 1, y + 1, width - 2, height - 2, color4)
    if align3 == 0
      if grade1 == 2
        grade1 = 3
      end
      if grade2 == 2
        grade2 = 3
      end
    end
    if (align3 == 1 and grade1 == 0) or grade1 > 0
      color = color5
      color5 = color6
      color6 = color
    end
    if (align3 == 1 and grade2 == 0) or grade2 > 0
      color = color1
      color1 = color2
      color2 = color
    end
    self.contents.cw_grad_rect(x + 2, y + 2, width - 4, height - 4, color5, color6, grade1)
    if align3 == 1
      x += width - gauge
    end
    self.contents.cw_grad_rect(x + 2, y + 2, gauge - 4, height - 4, color1, color2, grade2)
  end
  
  #--------------------------------------------------------------------------
  # * End of Class
  #--------------------------------------------------------------------------
end


#==============================================================================
# ** Bitmap
#==============================================================================
class Bitmap

  #--------------------------------------------------------------------------
  # * Gradation Rectangle
  #--------------------------------------------------------------------------
  def cw_grad_rect(x, y, width, height, color3, color4, align = 0)
   if align == 0
     for i in x...x + width
       red   = color3.red + (color4.red - color3.red) * (i - x) / (width - 1)
       green = color3.green +
               (color4.green - color3.green) * (i - x) / (width - 1)
       blue  = color3.blue +
               (color4.blue - color3.blue) * (i - x) / (width - 1)
       alpha = color3.alpha +
               (color4.alpha - color3.alpha) * (i - x) / (width - 1)
       color = Color.new(red, green, blue, alpha)
       fill_rect(i, y, 1, height, color)
     end
   elsif align == 1
     for i in y...y + height
       red   = color3.red +
               (color4.red - color3.red) * (i - y) / (height - 1)
       green = color3.green +
               (color4.green - color3.green) * (i - y) / (height - 1)
       blue  = color3.blue +
               (color4.blue - color3.blue) * (i - y) / (height - 1)
       alpha = color3.alpha +
               (color4.alpha - color3.alpha) * (i - y) / (height - 1)
       color = Color.new(red, green, blue, alpha)
       fill_rect(x, i, width, 1, color)
     end
   elsif align == 2
     for i in x...x + width
       for j in y...y + height
         red   = color3.red + (color4.red - color3.red) *
                 ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
         green = color3.green + (color4.green - color3.green) *
                 ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
         blue  = color3.blue + (color4.blue - color3.blue) *
                 ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
         alpha = color3.alpha + (color4.alpha - color3.alpha) *
                 ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
         color = Color.new(red, green, blue, alpha)
         set_pixel(i, j, color)
       end
     end
   elsif align == 3
     for i in x...x + width
       for j in y...y + height
         red   = color3.red + (color4.red - color3.red) *
               ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
         green = color3.green + (color4.green - color3.green) *
               ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
         blue  = color3.blue + (color4.blue - color3.blue) *
               ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
         alpha = color3.alpha + (color4.alpha - color3.alpha) *
               ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
         color = Color.new(red, green, blue, alpha)
         set_pixel(i, j, color)
       end
     end
   end
end

  #--------------------------------------------------------------------------
  # * End of Class
  #--------------------------------------------------------------------------
end
Go to the top of the page
 
+Quote Post
   
jens009
post Jun 29 2007, 02:00 PM
Post #15


L Did you know? Death gods... only eat apples
Group Icon

Group: +Gold Member
Posts: 2,976
Type: Scripter
RM Skill: Skilled




Ah excellent! I can fix it to you right now but I won't be able to give it to you 'til tomorow because I'm at a friend's house.. won't be home 'til tomorow. lol. I want to test it first so that I can just give it to you and you can just plug it in.

QUOTE
perhaps you could explain it to me :3?


I don't know if you have scripting experience so I'll try to explain it to you. Better yet, I'll add the explanation in the beginining of the script. Okay?

QUOTE
also >.> is there a way to make this work for monsters in battle... too?


It is possible but you have to have another script for that and you have to change the bars that were used for the monsters.


__________________________

My RMXP Project:


Farewell RRR. =]
Go to the top of the page
 
+Quote Post
   
Heavyblues
post Jun 30 2007, 12:44 PM
Post #16


Level 11
Group Icon

Group: Revolutionary
Posts: 188
Type: Artist
RM Skill: Beginner




actually, i just finished the one I wanted for monsters x3
here it be >.>





I made them longer ^-^
Go to the top of the page
 
+Quote Post
   
jens009
post Jul 2 2007, 12:15 PM
Post #17


L Did you know? Death gods... only eat apples
Group Icon

Group: +Gold Member
Posts: 2,976
Type: Scripter
RM Skill: Skilled




Okay, I installed rpgxp on this computer(different from the one I ussually use) and also started working on your request. However, the script you provided me only modified the HP and Sp of the characters this means that it didn't show the bars on the map.

I would still do your request but I would only modify the Hp and Sp of the actors.

as for your other request of displaying the bars for the monsters. err.. I'll try to do that.


__________________________

My RMXP Project:


Farewell RRR. =]
Go to the top of the page
 
+Quote Post
   
jens009
post Jul 2 2007, 03:38 PM
Post #18


L Did you know? Death gods... only eat apples
Group Icon

Group: +Gold Member
Posts: 2,976
Type: Scripter
RM Skill: Skilled




BUMPING TOPIC:

Hehe.. Well looks like I pulled it off hehe..

Okay some battle screenie for you:


Now the scripts:
Place this script above main and below that Cogwheel's Hp and Sp bars script.
First, the actor's hp and sp bars
CODE
#==============================================================================
# ** HP and SP Images
#-------------------------------------------------------------------------------
# by Jens009
# Well looks like I pulled it off. Lol. To use the script just replace
# draw_actor_hp and draw_actor_sp with draw_actorhp2
#------------------------------------------------------------------------------
class Window_Base < Window

def draw_actor_hp2(actor,x,y)
  
hpspbackground = RPG::Cache.picture("HPSP_Background")    
cw = hpspbackground.width  
ch = hpspbackground.height
src_rect = Rect.new(0, 0, cw, ch)    
self.contents.blt(x + 43, y - ch + 40, hpspbackground, src_rect)    

hpback = RPG::Cache.picture("Hp_Back")    
cw = hpback.width  
ch = hpback.height
src_rect = Rect.new(0, 0, cw, ch)    
self.contents.blt(x + 65, y - ch + 29, hpback, src_rect)
hpmeter = RPG::Cache.picture("HP_Bar")    
cw = hpmeter.width  * actor.hp / actor.maxhp
ch = hpmeter.height
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x + 65, y - ch + 29, hpmeter, src_rect)
#
spback = RPG::Cache.picture("SP_Back")    
cw = spback.width  
ch = spback.height
src_rect = Rect.new(0, 0, cw, ch)    
self.contents.blt(x + 58, y - ch + 35, spback, src_rect)
spmeter = RPG::Cache.picture("SP_Bar")    
cw = spmeter.width  * actor.sp / actor.maxsp
ch = spmeter.height
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x + 58, y - ch + 35, spmeter, src_rect)
end  
end



Now, the enemy's Hp and Sp bars script

Paste this code above the previous one Name it EnemyHPSp or whatever. It doesn't really matter
CODE
#===============================================================================
# Enemy Hp Bars
# Originally by: Raziel and SephirothSpawn
# Modified by: Jens009
#==============================================================================
class Window_Base < Window  
  #--------------------------------------------------------------------------
  # * Draw Slant Bar(by SephirothSpawn)
  #--------------------------------------------------------------------------
  def draw_slant_bar(x, y, min, max, width = 152, height = 6,
      bar_color = Color.new(150, 0, 0, 255), end_color = Color.new(255, 255, 60, 255))
    # Draw Border
    for i in 0..height
      self.contents.fill_rect(x + i, y + height - i, width + 1, 1, Color.new(50, 50, 50, 255))
    end
    # Draw Background
    for i in 1..(height - 1)
      r = 100 * (height - i) / height + 0 * i / height
      g = 100 * (height - i) / height + 0 * i / height
      b = 100 * (height - i) / height + 0 * i / height
      a = 255 * (height - i) / height + 255 * i / height
      self.contents.fill_rect(x + i, y + height - i, width, 1, Color.new(r, b, g, a))
    end
    # Draws Bar
    for i in 1..( (min / max.to_f) * width - 1)
      for j in 1..(height - 1)
        r = bar_color.red * (width - i) / width + end_color.red * i / width
        g = bar_color.green * (width - i) / width + end_color.green * i / width
        b = bar_color.blue * (width - i) / width + end_color.blue * i / width
        a = bar_color.alpha * (width - i) / width + end_color.alpha * i / width
        self.contents.fill_rect(x + i + j, y + height - j, 1, 1, Color.new(r, g, b, a))
      end
    end
  end
end
#============================================================================
# Window_EnemyHP
# Draws the window for the enemy's hp and sp
#============================================================================
class Window_EnemyHP < Window_Base
  
  def initialize
    super(0, 0, 640, 480)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 0
    refresh
  end
  def draw_enemybar(enemy, x,y)
    ehpspbackground = RPG::Cache.picture("EHPSP_Background")    
cw = ehpspbackground.width  
ch = ehpspbackground.height
src_rect = Rect.new(0, 0, cw, ch)    
self.contents.blt(x + 36, y - ch + 42, ehpspbackground, src_rect)    
  ehpback = RPG::Cache.picture("EHP_Back")    
    cw = ehpback.width  
    ch = ehpback.height
    src_rect = Rect.new(0, 0, cw, ch)    
    self.contents.blt(x + 66, y - ch + 29, ehpback, src_rect)
    ehpmeter = RPG::Cache.picture("EHP_Bar")    
    cw = ehpmeter.width * @enemy.hp / @enemy.maxhp
    ch = ehpmeter.height
    src_rect = Rect.new(0, 0, cw, ch)
   self.contents.blt(x + 66, y - ch + 29, ehpmeter, src_rect)
  espback = RPG::Cache.picture("ESP_Back")    
  cw = espback.width  
  ch = espback.height
  src_rect = Rect.new(0, 0, cw, ch)    
  self.contents.blt(x + 60, y - ch + 35, espback, src_rect)
  espmeter = RPG::Cache.picture("ESP_Bar")    
  cw = espmeter.width  * @enemy.sp / @enemy.maxsp
  ch = espmeter.height
  src_rect = Rect.new(0, 0, cw, ch)
  self.contents.blt(x + 60, y - ch + 35, espmeter, src_rect)
end
   def refresh
    self.contents.clear
    for i in 0...$game_troop.enemies.size
      @enemy = $game_troop.enemies[i]
      @percent = (@enemy.hp * 100) / @enemy.maxhp
      draw_enemybar(i, @enemy.screen_x - 105, @enemy.screen_y-10)
      self.contents.draw_text(@enemy.screen_x - 39, @enemy.screen_y - 22, 100, 32, "#{@percent}" + "%")
  end
end
end

class Scene_Battle
  
  alias raz_update update
  alias raz_update_phase5 update_phase5
  alias raz_update_phase4_step1 update_phase4_step1
  alias raz_update_phase4_step5 update_phase4_step5
  alias raz_enemy_hp_main main
  
   def main
    @troop_id = $game_temp.battle_troop_id
    $game_troop.setup(@troop_id)
    @enemy_window = Window_EnemyHP.new
    @enemy_window.z = 95
    raz_enemy_hp_main
    @enemy_window.dispose
  end
  
  def update
    @enemy_window.update
    raz_update
  end

  def update_phase5
    # If wait count is larger than 0
    if @phase5_wait_count > 0
      # Decrease wait count
      @phase5_wait_count -= 1
      # If wait count reaches 0
      if @phase5_wait_count == 0
        @enemy_window.visible = false
        # Show result window
        @result_window.visible = true
        # Clear main phase flag
        $game_temp.battle_main_phase = false
        # Refresh status window
        @status_window.refresh
        @enemy_window.refresh
      end
      return
    end
   raz_update_phase5
end

def update_phase4_step1
  raz_update_phase4_step1
  @enemy_window.refresh
end

  def update_phase4_step5
    # Hide help window
    @help_window.visible = false
    # Refresh status window
    @status_window.refresh
    @enemy_window.refresh
    raz_update_phase4_step5
  end
end


ok, now put the following images in the pictures folder of your rmxp game:











And you're all set...

You're probably wondering:

How did I replace the actor's hp and sp bars?
How can I put this in my main menu?
How can I adjust them?

Ehh.. I'll answer them if you're interested.


__________________________

My RMXP Project:


Farewell RRR. =]
Go to the top of the page
 
+Quote Post
   
Heavyblues
post Jul 2 2007, 04:34 PM
Post #19


Level 11
Group Icon

Group: Revolutionary
Posts: 188
Type: Artist
RM Skill: Beginner




OMG thanks <3

I REALLY appreciate this

and I'd like an explanation :3 but I'm sure I could figure it out on my own :3

and the HP bars on the map are no big deal, I just figured it'd be cool x3 I REALLY wanted them in battle tho, s thanks much ^-^

uh >.>;; the HP/MPbars for the heroes don't work >.>

I put them all in like you said ^-^ but I dont' get what you meanw ehn you say that I should replace draw_actor_hp and draw_actor_sp with draw_actor_hp2

it gives me an error ;.;

This post has been edited by Heavyblues: Jul 3 2007, 09:27 AM
Go to the top of the page
 
+Quote Post
   
jens009
post Jul 6 2007, 04:00 PM
Post #20


L Did you know? Death gods... only eat apples
Group Icon

Group: +Gold Member
Posts: 2,976
Type: Scripter
RM Skill: Skilled




QUOTE (Heavyblues @ Jul 2 2007, 05:34 PM) *
uh >.>;; the HP/MPbars for the heroes don't work >.>

I put them all in like you said ^-^ but I dont' get what you meanw ehn you say that I should replace draw_actor_hp and draw_actor_sp with draw_actor_hp2

it gives me an error ;.;


To activate the code so that it replaces draw_actor_hp

Find my script, and find the line where it says
CODE
def draw_actor_hp2

replace that line with:
CODE
draw_actor_hp


Now I made the script so that it would be mixed. This means that the sp bar also comes with the hp bar whenever the scene is trying to draw the hp bar... so you have to find certain lines in your script where it says draw_actor_sp and delete that line. Those lines would be most likely in the windows section.

I'll give you some important locations where you should delete the draw_actor_sp lines.

To delete the sp bar in battle:

Find Window_BattleStatus in your script editor

find line 41 where it says
CODE
draw_actor_sp

delete that whole line.

To delete the sp bar in the main menu

Find Window_MenusStatus in your script editor

find line 35 and delete:
CODE
draw_actor_sp



Remember, that I made the script so that the drawing the hp and sp bars only takes one line instead of 2. So whenever the script draws the hp bar, the sp bar also pops out. This is why we are deleting the extra sp bar that has been drawn.

This post has been edited by jens009: Jul 6 2007, 04:46 PM


__________________________

My RMXP Project:


Farewell RRR. =]
Go to the top of the page
 
+Quote Post
   

2 Pages V   1 2 >
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 22nd May 2013 - 10:08 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker