felix_the_cat
Member
so ive tried to put gradient hp and sp bars in battle but with the script i got this is what it looks like...
how can change the size help please i know its probably really simple but can some one please tell me how to change it or edit it themselves...script:
*** or if you have a better script for sharing that would be awesome :biggrin:
Code:
# Changes to the bitmap class to add a function which can draw gradient bars
class Bitmap
# Draw a rectangle with a gradient color shift from color1 to color2
# Goes from left to right, or top to bottom if vertical is set
def draw_gradient_rect(x, y, width, height, color1, color2, vertical=true)
# Determine what will limit the draw
limit = vertical ? height: width
for i in 0..limit
# Calculate the color1 multiplier for its color
mul = (limit - i).to_f / limit
# Calculate the new color for this part of the gradient
color = Color.new(
mul * (color1.red - color2.red) + color2.red,
mul * (color1.green - color2.green) + color2.green,
mul * (color1.blue - color2.blue) + color2.blue
)
# Draw the portion of the rectangle with the new color
if vertical
self.fill_rect(x, y+i, width,1, color)
else
self.fill_rect(x+i, y, 1, height, color)
end
end
end
end
#---------------------
# Changes to the Window_Base class where Draw_Actor_HP/SP reside
class Window_Base < Window
# --------
# Change the Draw_Actor_HP function so a gradient bar appears to show how
# much HP the actor has left
alias draw_actor_hp_healthgauges draw_actor_hp unless $@
def draw_actor_hp(actor, x, y, width = 144)
# First create the health gauge!
# Define colors for the gauges and the empty part of the gauge
# Color1 is the left of the gauge, Color2 is the right
health_gauge_color_1 = Color.new(128, 64, 32)
health_gauge_color_2 = Color.new(255, 128, 64)
black_color = Color.new(0, 0, 0)
# Define the dimensions of the gauge in pixels
height = 6
x_offset = 0
y_offset = 15
# If the actor has HP left...
if actor.hp > 0
# Draw the full gauge first
self.contents.draw_gradient_rect(
x + x_offset,
y + y_offset,
width,
height,
health_gauge_color_1,
health_gauge_color_2
)
# If HP isn't maxed out, we'll have to draw the empty part of the gauge
if actor.hp < actor.maxhp
# Calculate how long the empty part of thegauge is (it will be at least one pixel wide and it won't be as long as the health gauge)
empty_width = [[(width * (1 - actor.hp.to_f / actor.maxhp)).to_i, 1].max, width - 1].min
# Now draw the empty part of the bar using this width
self.contents.fill_rect(
width - empty_width + x + x_offset + 1,
y+y_offset,
empty_width,
height,
black_color
)
end
else
# The actor has no HP, just show a big black bar
self.contents.fill_rect(x+x_offset, y+y_offset, width, height, black_color)
end
# Now draw the HP value by calling the original method
draw_actor_hp_healthgauges(actor, x, y, width)
end
# ------------
# Change the Draw_Actor_SP function so it draws a gradient bar to show the
# amount of SP the actor has left
alias draw_actor_sp_healthgauges draw_actor_sp unless $@
def draw_actor_sp(actor, x, y, width = 144)
# First create the SP gauge!
# Define colors for the gauges and the empty part of the gauge
# Color1 is the left of the gauge, Color2 is the right
sp_gauge_color_1 = Color.new(32, 32, 128)
sp_gauge_color_2 = Color.new(64, 64, 255)
black_color = Color.new(0, 0, 0)
# Define the dimensions of the gauge in pixels
height = 6
x_offset =
y_offset = 15
# If the actor has SP left...
if actor.sp > 0
# Draw the full gauge first
self.contents.draw_gradient_rect(
x + x_offset,
y + y_offset,
width,
height,
sp_gauge_color_1,
sp_gauge_color_2
)
# If SP isn't maxed out, we'll have to draw the empty part of the gauge
if actor.sp < actor.maxsp
# Calculate how long the empty part of thegauge is (it will be at least one pixel wide and it won't be as long as the health gauge)
empty_width = [[(width * (1 - actor.sp.to_f / actor.maxsp)).to_i, 1].max, width - 1].min
# Now draw the empty part of the bar using this width
self.contents.fill_rect(
width - empty_width + x + x_offset + 1,
y+y_offset,
empty_width,
height,
black_color
)
end
else
# Just draw a big black empty bar
self.contents.fill_rect(x+x_offset, y+y_offset, width, height, black_color)
end
# Now draw the SP value by calling the original method
draw_actor_sp_healthgauges(actor, x, y, width)
end
end
#-------------------
# Change the RPG::Sprite class so it doesn't force it's viewport
# Overwrite required since you can't change the viewport of a created image
module RPG
class Sprite < ::Sprite
def damage(value, critical)
dispose_damage
if value.is_a?(Numeric)
damage_string = value.abs.to_s
else
damage_string = value.to_s
end
bitmap = Bitmap.new(160, 48)
bitmap.font.name = "Arial Black"
bitmap.font.size = 32
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
if value.is_a?(Numeric) and value < 0
bitmap.font.color.set(176, 255, 144)
else
bitmap.font.color.set(255, 255, 255)
end
bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
if critical
bitmap.font.size = 20
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1)
bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1)
bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1)
bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1)
bitmap.font.color.set(255, 255, 255)
bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1)
end
@_damage_sprite = ::Sprite.new#(self.viewport)
@_damage_sprite.bitmap = bitmap
@_damage_sprite.ox = 80
@_damage_sprite.oy = 20
@_damage_sprite.x = self.x
@_damage_sprite.y = self.y - self.oy / 2
@_damage_sprite.z = 3000
@_damage_duration = 40
end
end
end
*** or if you have a better script for sharing that would be awesome :biggrin: