Posts: 50
Threads: 4
Joined: Nov 2011
Hi everyone !
I need to change meter style but I don't find a solution !
I want to make the meter graphic scrolling up and down. **By default it's right to left**
I try to change the direction in this part of script
Code: #--------------------------------------------------------------------------
# * Draw HP
# actor : actor
# x : draw spot x-coordinate
# y : draw spot y-coordinate
# width : draw spot width
#--------------------------------------------------------------------------
alias draw_actor_hp_bar draw_actor_hp
def draw_actor_hp(actor, x, y, width = 144)
bar_x = HP_Pos_Adjust[0] + x
bar_y = HP_Pos_Adjust[1] + y + (Font.default_size * 2 /3)
@skin = RPG::Cache.windowskin(HP_Meter)
@width = @skin.width
@height = @skin.height / 3
src_rect = Rect.new(0, 0, @width, @height)
self.contents.blt(bar_x, bar_y, @skin, src_rect)
@line = (actor.hp == actor.maxhp ? 2 : 1)
@amount = actor.hp.to_f / actor.maxhp.to_f
src_rect2 = Rect.new(0, @line * @height, @width * @amount, @height)
self.contents.blt(bar_x, bar_y, @skin, src_rect2)
draw_actor_hp_bar(actor, x, y, width)
end
Posts: 867
Threads: 15
Joined: Nov 2009
Could you post the whole script? I'll take a look at it.
Posts: 50
Threads: 4
Joined: Nov 2011
Code: #==============================================================================
# Add-On: HP/SP/EXP Meter
# by Atoa
#==============================================================================
# Adds HP/SP/EXP Meters
# Remove this Add-On if you wish to use custom HP/SP/EXP bars
# This Add-On must be always bellow 'ACBS | Battle Windows'
# if you are using it
#==============================================================================module Atoa
HP_Meter = 'HPMeter' # Name of the HP meter graphic file
SP_Meter = 'SPMeter' # Name of the SP meter graphic file
EXP_Meter = 'EXPMeter' # Name of the EXP meter graphic file
# Bars position adjust
# [x, y]
HP_Pos_Adjust = [-28, -45]
SP_Pos_Adjust = [0, -3]
EXP_Pos_Adjust = [0, 0]
end#==============================================================================
# ** Atoa Module
#==============================================================================
$atoa_script = {} if $atoa_script.nil?
$atoa_script['HP-SP-EXP Bars'] = true#==============================================================================
# ** 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
#--------------------------------------------------------------------------
# * Set Current EXP
#--------------------------------------------------------------------------
def now_exp
return @exp - @exp_list[@level]
end
#--------------------------------------------------------------------------
# * Set next level EXP
#--------------------------------------------------------------------------
def next_exp
return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
end
end#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
# This class is for all in-game windows.
#==============================================================================class Window_Base < Window
#--------------------------------------------------------------------------
# * Include Settings Module
#--------------------------------------------------------------------------
include Atoa
#--------------------------------------------------------------------------
# * Draw HP
# actor : actor
# x : draw spot x-coordinate
# y : draw spot y-coordinate
# width : draw spot width
#--------------------------------------------------------------------------
alias draw_actor_hp_bar draw_actor_hp
def draw_actor_hp(actor, x, y, width = 144)
bar_x = HP_Pos_Adjust[0] + x
bar_y = HP_Pos_Adjust[1] + y + (Font.default_size * 2 /3)
@skin = RPG::Cache.windowskin(HP_Meter)
@width = @skin.width
@height = @skin.height / 3
src_rect = Rect.new(0, 0, @width, @height)
self.contents.blt(bar_x, bar_y, @skin, src_rect)
@line = (actor.hp == actor.maxhp ? 2 : 1)
@amount = actor.hp.to_f / actor.maxhp.to_f
src_rect2 = Rect.new(0, @line * @height, @width * @amount, @height)
self.contents.blt(bar_x, bar_y, @skin, src_rect2)
draw_actor_hp_bar(actor, x, y, width)
end
#--------------------------------------------------------------------------
# * Draw SP
# actor : actor
# x : draw spot x-coordinate
# y : draw spot y-coordinate
# width : draw spot width
#--------------------------------------------------------------------------
alias draw_actor_sp_bar draw_actor_sp
def draw_actor_sp(actor, x, y, width = 144)
bar_x = SP_Pos_Adjust[0] + x
bar_y = SP_Pos_Adjust[1] + y + (Font.default_size * 2 /3)
@skin = RPG::Cache.windowskin(SP_Meter)
@width = @skin.width
@height = @skin.height / 3
src_rect = Rect.new(0, 0, @width, @height)
self.contents.blt(bar_x, bar_y, @skin, src_rect)
@line = (actor.sp == actor.maxsp ? 2 : 1)
@amount = (actor.maxsp == 0 ? 0 : actor.sp.to_f / actor.maxsp.to_f)
src_rect2 = Rect.new(0, @line * @height, @width * @amount, @height)
self.contents.blt(bar_x, bar_y, @skin, src_rect2)
draw_actor_sp_bar(actor, x, y, width)
end
#--------------------------------------------------------------------------
# * Draw EXP
# actor : actor
# x : draw spot x-coordinate
# y : draw spot y-coordinate
#--------------------------------------------------------------------------
alias draw_actor_exp_bar draw_actor_exp
def draw_actor_exp(actor, x, y)
bar_x = EXP_Pos_Adjust[0] + x
bar_y = EXP_Pos_Adjust[1] + y + (Font.default_size * 2 /3)
@skin = RPG::Cache.windowskin(EXP_Meter)
@width = @skin.width
@height = @skin.height / 3
src_rect = Rect.new(0, 0, @width, @height)
self.contents.blt(bar_x, bar_y, @skin, src_rect)
@line = (actor.now_exp == actor.next_exp ? 2 : 1)
@amount = (actor.next_exp == 0 ? 1 : actor.now_exp.to_f / actor.next_exp.to_f)
src_rect2 = Rect.new(0, @line * @height, @width * @amount, @height)
self.contents.blt(bar_x, bar_y, @skin, src_rect2)
draw_actor_exp_bar(actor, x, y)
end
end
Thank you to take a look ^^ !
Posts: 867
Threads: 15
Joined: Nov 2009
Did I get it right?
You want it like the custom one?
Posts: 50
Threads: 4
Joined: Nov 2011
Yes this is exactly what I want :D !
Posts: 867
Threads: 15
Joined: Nov 2009
I don't know for sure how to change it. First I would turn the graphic file vertical. Otherwise I don't really have a clue, it has been a long time since I used RMXP.
Maybe someone else can help you more.
Posts: 11,230
Threads: 649
Joined: May 2009
As he said, change the windowskin graphic you are using for your HP_BAR vertical... a simple rotate 90* in any paint program should work.... BUT... an edit to the HP script was needed.
Code: #--------------------------------------------------------------------------
# * Draw HP
# actor : actor
# x : draw spot x-coordinate
# y : draw spot y-coordinate
# width : draw spot width
#--------------------------------------------------------------------------
alias draw_actor_hp_bar draw_actor_hp
def draw_actor_hp(actor, x, y, width = 144)
# Set Bar Position
bar_x = HP_Pos_Adjust[0] + x
bar_y = HP_Pos_Adjust[1] + y + (Font.default_size * 2 /3)
# Acquire bar image and dimensions
bar_img = RPG::Cache.windowskin(HP_Meter)
bar_width = bar_img.width
bar_height = bar_img.height / 3
# Define source rectangle for bar
src_rect = Rect.new(0, 0, bar_width, bar_height)
self.contents.blt(bar_x, bar_y, bar_img, src_rect)
# Determine which line used in bar image
bar_line = (actor.hp == actor.maxhp ? 2 : 1)
# Calculate value to adjust drawn line
bar_amount = actor.hp.to_f / actor.maxhp.to_f
# Adjust dimensions of destination rectangle
src_rect2 = Rect.new(bar_line * bar_width, 0, bar_width, bar_height * bar_amount)
# Draw the bar with the new rectangle area
self.contents.blt(bar_x, bar_y, bar_img, src_rect2)
# Perform the original call
draw_actor_hp_bar(actor, x, y, width)
end
I just edited the original code you provided from Atoa's script, inverted 'both' the width/height and the x/y positions in the destination rectangle system, and added a bunch of comments to describe.
Still... he didn't need to make the values anything but instant values (the '@' weren't necessary if they were for use in just that method). The mem resources are saved just a little and are cleared once they leave the method.
This is untested as I just cobbled this bit together while at work. I have no RMXP editor in front of me.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
Above are clickable links
Posts: 50
Threads: 4
Joined: Nov 2011
Thank you for your held !
I don't know why DerVV but the background of the bar meter appear but not the gauge bar :S !
The HP bar graphic is divise by 3 ( background bar meter, load bar meter color, bar meter color when hp is low)
Posts: 11,230
Threads: 649
Joined: May 2009
Just for giggles, see what happens if you use this:
Code: src_rect2 = Rect.new(0, 0, bar_width, bar_height * bar_amount)
... Still at work.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
Above are clickable links
Posts: 50
Threads: 4
Joined: Nov 2011
Same problem :S The bar don't appear only the background !
|