Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Kingdom Hearts HP & MP Gauges
#1
Kingdom Hearts HP & MP Gauges
V1.2
By Ánemus
Aug 26, 2008

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


HP and MP Gauges just like those of the Kingdom Hearts



Description

V 1.0 Shows the MP and HP Gagues like those in the screen above. It has a little animation when you get harmed (the face turns red) and the portion of health taken turns red and fades away. Also, when you use magic, the piece of MP you waste turns white and fades away.

V 1.1 The system to show and hide is on. Works with Switches.

V 1.2 You can change the player and it will still work. The animation of the HP gague when health is restored is being improved (before it turned blue and faded in, now it just grows). If you wish you can keep the older system. The magic animation is being improved also, now it fades and moves away.


NOTE: Script requires graphics not supplied. The initial post suggested using graphics from a demo that no longer exists.


Code
Code:
#===============================================================#
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>SCRIPT<<<<<<<<<<<<<<<<<<<<<<<<<<<<<#
#===============================================================#
# #
# Kingdom Hearts HP Bar for Action Batle System #
# by Ánemus (www.arcadiumrpg.net #
# #
# This script shows a HP bar similar to that in the GBA game #
# Kingdom Hearts, Chain of Memories, but placed at the top- #
# rigt edge of the screen (the map in this version). #
# #
# For any comments: anemus@arcadiumrpg.net #
# #
#===============================================================#
#>>>>>>>>>>>>>>>>>>>>>>>>>>>SETTINGS<<<<<<<<<<<<<<<<<<<<<<<<<<<<#
#===============================================================#
# #
# Maximum size of HP gauge: #
# That's the size when the palayer is in level 99 (or max). #
MAXHP = 400 #px
# #
# Minimum size of HP gauge: #
# That's the size of the HP bar when the player is in initial #
# level. #
MINHP = 100 #px
# #
# Frames of hurt or heal animation: #
# The system shows the lost or healed hp in a diferent color #
# during the next number of frames.
FRAMES = 10 #frames
# #
# Show de Magic Power Gauge: #
MPGAUGE = true #true or false
# #
# Activation Switch ID: #
# The ID of the switch that activates or disactivates the #
# system. Leave as 0 to disable it (always show the gauges) #
SWID = 1 #px
# #
# Growning HP when heal: #
# If this is true, then the hp will grow till the amount that #
# is going to be reestored is filled. If not, it will turn the #
# healed hp in another color (blue). #
HPCREC = true #true or false
# #
# Static MP bar: #
# If it's true the magic bar will be always the same size, no #
# matter the level you are in. #
MPSTATIC = true #true or false
# #
# Size of the Magic Power gauge: #
# It's the size it will always have if MPSTATIC = true, and the #
# smallest size of the Magic Power gauge (initial level) if it #
# is false.
MPSIZE = 120 #px
# #
# Maximum size of MP gauge: #
# That's the size when the palayer is in level 99 (or max). #
MPMAX = 250 #px
# #
#===============================================================#
#>>>>>>>>>>>>>>>>>>>>>>>>>INSTRUCTIONS<<<<<<<<<<<<<<<<<<<<<<<<<<#
#===============================================================#
# #
# Set the values on top as you wish. You have to copy the #
# picture in the Pictures folder to your proyect. After this, #
# one more thing. Make a new folder inside Charcaters folder. #
# There you need to make a Face for the system. With the #
# Facemaker they work just perfect. Now you´ve got to cut the #
# border of the face (for the circular display). For that you #
# can use the PSD file. Once in Photoshop, glue the Face (96x96)#
# on a new lawyer, placing the top border, one pixel higher than#
# the margin of the drawing, and place the right border, one #
# pixel to the left of the drawing. There is a model to check. #
# #
# Finally, we need two faces. One normal, and the other one in #
# pain, for when the hero is hurt. The name of both is the name #
# of the player (Joshua in the example), and ended in -NORM if #
# is the normal face, and ended in -HIT if is the pain face. #
# #
# If you ever want to use the MP Gauge, you also need to take #
# the other image in pictures (MPGauge) to your project Pictures#
# folder. #
# #
#===============================================================#
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>END<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<#
#===============================================================#

#===============================================================#
#>>>>>>>>>>>>>>>>Scene Map Edit to show gauge<<<<<<<<<<<<<<<<<<<#
#===============================================================#
class Scene_Map
alias :back_main :main
def main
@khhpback = KHHP_Back.new
@khhpbar = KHHP_Contents.new
@khhpbar.z = 500
@khhpshd = KHHP_Shade.new
@khhpshd.z = 800
@khface = Sprite.new
@name = $game_party.actors[0].name
@khface.bitmap = RPG::Cache.character("Faces/"+$game_party.actors[0].name+"-NORM", $game_party.actors[0].character_hue)
@khface.x = 640-@khface.bitmap.width-1
@khface.y = 0
@khface.z = 1000
if MPGAUGE
@khmpbar = KHMP_Gauge.new
@khmpbar.z = 1100
end
if SWID != 0 && !$game_switches[SWID]
@khhpbar.visible = false
@khhpback.visible = false
@khhpshd.visible = false
@khface.visible = false
if MPGAUGE
@khmpbar.visible = false
end
end
@lasthp = $game_party.actors[0].hp
back_main
if MPGAUGE
@khmpbar.dispose
end
@khhpshd.dispose
@khhpbar.dispose
@khface.dispose
@khhpback.dispose

end
alias :back_update :update
def update
if (SWID == 0 || $game_switches[SWID]) && @khhpback.visible == false
@khhpbar.visible = true
@khhpback.visible = true
@khhpshd.visible = true
@khface.visible = true
if MPGAUGE
@khmpbar.visible = true
end
elsif SWID != 0 && !$game_switches[SWID] && @khhpback.visible
@khhpbar.visible = false
@khhpback.visible = false
@khhpshd.visible = false
@khface.visible = false
if MPGAUGE
@khmpbar.visible = false
end
end
if SWID == 0 || $game_switches[SWID]
if $game_party.actors[0].name != @name
@name = $game_party.actors[0].name
@khface.bitmap = RPG::Cache.character("Faces/"+$game_party.actors[0].name+"-NORM", $game_party.actors[0].character_hue)
@khhpback.dispose
@khhpback = KHHP_Back.new
@khhpbar.dispose
@khhpbar = KHHP_Contents.new
@khhpshd.dispose
@khhpshd = KHHP_Shade.new
if MPGAUGE
@khmpbar.dispose
@khmpbar = KHMP_Gauge.new
@khmpbar.z = 1100
end
@lasthp = $game_party.actors[0].hp
end
@khhpbar.reset
@khhpback.re_do
@khhpshd.reset
if MPGAUGE
@khmpbar.reset
end
if @lasthp > $game_party.actors[0].hp
@frames = FRAMES*2
@lasthp = $game_party.actors[0].hp
end
if @frames == 0
@khface.bitmap = RPG::Cache.character("Faces/"+$game_party.actors[0].name+"-NORM", $game_party.actors[0].character_hue)
@frames = nil
@khface.tone = Tone.new(0,0,0)
elsif @frames == FRAMES*2
@khface.bitmap = RPG::Cache.character("Faces/"+$game_party.actors[0].name+"-HIT", $game_party.actors[0].character_hue)
@khface.tone = Tone.new(255,-255,-255)
@frames -= 1
elsif @frames != nil
@frames -= 1
@khface.tone = Tone.new(255/(FRAMES*2-@frames),-255/(FRAMES*2-@frames),-255/(FRAMES*2-@frames))
end
@lasthp = $game_party.actors[0].hp
end
back_update
end
end
#===============================================================#
#>>>>>>>>>>>>>>>>>>>>>>>>>>Background<<<<<<<<<<<<<<<<<<<<<<<<<<<#
#===============================================================#
class KHHP_Back < Window_Base
def initialize
super(640-116-MAXHP-5, -16, 100+MAXHP+32+5, 99+32)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
self.opacity = 0
set_level
set_colors
refresh
end
def set_level
@actor = $game_party.actors[0]
@check != @actor.maxhp
max = $data_actors[@actor.id].parameters[0, $data_actors[@actor.id].final_level]
min = $data_actors[@actor.id].parameters[0,$data_actors[@actor.id].initial_level]
dist = MAXHP - MINHP
@act_dist = ((@actor.maxhp - min)*1.000000000000 / (max - min)*1.000000000000) * dist + MINHP
end
def set_colors
#===============================================================#
#>>>>>>>>>>>>>>>>>>>>>>>>>>Color Set<<<<<<<<<<<<<<<<<<<<<<<<<<<<#
#===============================================================#
# This colors are a bit messy, and unless you change the bar #
# back picture, you shouldn't change them. #
@ext_line = Color.new(160,160,176,230)
@mid_line = Color.new(211,211,218)
@int_line = Color.new(255,255,255)
@inside = Color.new(0,0,0)
#===============================================================#
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>end<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<#
#===============================================================#
end
def refresh
self.contents.clear
self.contents.blt(MAXHP+5, 0, RPG::Cache.picture("BackofSystem"), Rect.new(0, 0, 100, 99), 255)
self.contents.fill_rect (MAXHP-@act_dist-1+5, 1, @act_dist+3, 24, @ext_line)
self.contents.fill_rect (MAXHP-@act_dist-1+5, 2, @act_dist+3, 22, @mid_line)
self.contents.fill_rect (MAXHP-@act_dist-1+5, 3, @act_dist+3, 20, @int_line)
self.contents.fill_rect (MAXHP-@act_dist-1+5, 4, @act_dist+3, 18, @inside)
self.contents.fill_rect (MAXHP-@act_dist-2+5, 2, 1, 22, @ext_line)
self.contents.fill_rect (MAXHP-@act_dist-3+5, 3, 1, 20, @ext_line)
self.contents.fill_rect (MAXHP-@act_dist-4+5, 4, 1, 18, @ext_line)
self.contents.fill_rect (MAXHP-@act_dist-2+5, 3, 1, 20, @mid_line)
self.contents.fill_rect (MAXHP-@act_dist-3+5, 4, 1, 18, @mid_line)
self.contents.fill_rect (MAXHP-@act_dist-2+5, 4, 1, 18, @int_line)
self.contents.fill_rect (MAXHP-@act_dist-1+5, 4, 1, 1, Color.new(255,255,255,100))
self.contents.fill_rect (MAXHP-@act_dist-1+5, 21, 1, 1, Color.new(255,255,255,100))
end
def re_do
if @check != @actor.maxhp
set_level
refresh
end
end
end
#===============================================================#
#>>>>>>>>>>>>>>>>>>>>>>>>>>Green Gauge<<<<<<<<<<<<<<<<<<<<<<<<<<#
#===============================================================#
class KHHP_Contents < Window_Base
def initialize
set_level
super(640-115-@act_dist, -16+6, @act_dist+32+1, 16+32)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
self.opacity = 0
set_colors
refresh
@lasthp = @actor.hp
end
def set_level
@actor = $game_party.actors[0]
@check = @actor.maxhp
max = $data_actors[@actor.id].parameters[0, $data_actors[@actor.id].final_level]
min = $data_actors[@actor.id].parameters[0,$data_actors[@actor.id].initial_level]
dist = MAXHP - MINHP
@act_dist = ((@actor.maxhp - min)*1.000000000000 / (max - min)*1.000000000000 ) * dist + MINHP
@eachhp = (@act_dist / (@actor.maxhp*1.00000000000000000000000))
end
def set_colors
#===============================================================#
#>>>>>>>>>>>>>>>>>>>>>>>>>>Color Set<<<<<<<<<<<<<<<<<<<<<<<<<<<<#
#===============================================================#
@green = Color.new(72,216,0)# Color of the HP bar (green default)
@hurt = Color.new(187,0,0)# Color of the HP bar whith damage.
@heal = Color.new(1,216,210)# Color of the healed HP (HPCREC = false)
#===============================================================#
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>end<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<#
#===============================================================#
end
def refresh
self.contents.clear
self.contents.fill_rect (@act_dist-@eachhp*@actor.hp, 0, @eachhp*@actor.hp, 14, @green)
if @difference != nil && @difference < 0
self.contents.fill_rect (@act_dist-@eachhp*(@actor.hp-@difference), 0, @eachhp*@difference.abs+1, 14, @color)
elsif @difference != nil && @difference > 0
if HPCREC
self.contents.fill_rect (@act_dist-@eachhp*(@actor.hp), 0, @eachhp*@difference.abs+1, 14, @green)
else
self.contents.fill_rect (@act_dist-@eachhp*(@actor.hp), 0, @eachhp*@difference.abs+1, 14, @color)
end
end
end
def reset
if @check != @actor.maxhp
self.contents.dispose
initialize
end
if @lasthp != @actor.hp
if @difference == nil
@frames = FRAMES
end
if @frames == FRAMES
@difference = nil
@difference = @actor.hp - @lasthp
if @difference > 0
@color = @heal
end
if @difference < 0
@color = @hurt
end
end
if @frames == 0
@difference = nil
@color = nil
@frames = nil
@lasthp = @actor.hp
else
@frames -= 1
end
refresh
end
end
end
#===============================================================#
#>>>>>>>>>>>>>>>>>>>>>>>>>Shade Effect<<<<<<<<<<<<<<<<<<<<<<<<<<#
#===============================================================#
class KHHP_Shade < Window_Base
def initialize
set_level
super(640-115-@act_dist, -16+6, @act_dist+32+1, 16+32)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
self.opacity = 0
refresh
end
def set_level
@actor = $game_party.actors[0]
@lasthp = @actor.hp
@check = @actor.maxhp
max = $data_actors[@actor.id].parameters[0, $data_actors[@actor.id].final_level]
min = $data_actors[@actor.id].parameters[0,$data_actors[@actor.id].initial_level]
dist = MAXHP - MINHP
@act_dist = ((@actor.maxhp - min)*1.000000000000 / (max - min)*1.000000000000 ) * dist + MINHP
@eachhp = (@act_dist / (@actor.maxhp*1.00000000000000000000000))
end
def refresh
self.contents.clear
for i in 0..5
self.contents.fill_rect (@act_dist-@eachhp*@lasthp, i, @eachhp*@lasthp, 1, Color.new(255,255,255,170/(i+1)))
end
for i in 0..8
self.contents.fill_rect (0, i+6, @act_dist, 1, Color.new(0,0,0,245/(9-i)))
end
if @difference != nil && @difference > 0 && HPCREC
if FRAMES==@frames
width = 0
else
width = (@difference.abs+1)/(FRAMES-@frames)
end
self.contents.fill_rect (@act_dist-@eachhp*(@actor.hp), 0, @eachhp*width, 14, Color.new(0,0,0,255))
end
end
def reset
if @check != @actor.maxhp
self.contents.dispose
initialize
end
if @lasthp != @actor.hp
if @difference == nil
@frames = FRAMES
@difference = @actor.hp - @lasthp
if @difference > 0
@lasthp = @actor.hp - 1
end
end
if @frames == 0
@difference = nil
@frames = nil
@lasthp = @actor.hp
refresh
else
@frames -= 1
refresh
end
end
end
end
#===============================================================#
#>>>>>>>>>>>>>>>>>>>>>>>>>>MP Gauge<<<<<<<<<<<<<<<<<<<<<<<<<<<<<#
#===============================================================#
class KHMP_Gauge < Window_Base
def initialize
set_level
super(640-94-@act_dist-16-19, 30-16, @act_dist + 32+19, 10+32)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
self.opacity = 0
set_colors
refresh
@lastsp = @actor.sp
end
def set_level
@actor = $game_party.actors[0]
@check = @actor.maxsp
if MPSTATIC
@act_dist = MPSIZE
else
max = $data_actors[@actor.id].parameters[1, $data_actors[@actor.id].final_level]
min = $data_actors[@actor.id].parameters[1,$data_actors[@actor.id].initial_level]
dist = MPMAX - MPSIZE
@act_dist = ((@actor.maxsp - min)*1.000000000000 / (max - min)*1.000000000000 ) * dist + MPSIZE
end
@eachsp = (@act_dist / (@actor.maxsp*1.00000000000000000000000))
end
def set_colors
#===============================================================#
#>>>>>>>>>>>>>>>>>>>>>>>>>>Color Set<<<<<<<<<<<<<<<<<<<<<<<<<<<<#
#===============================================================#
# If yo aren't planing in changing the MP back picture, don't #
# touch this ones. #
@grey = Color.new(51,51,51)
@black = Color.new(0,13,30)
# This is the base color of the MP bar (an electric blue) #
@blue_r = 0
@blue_g = 100
@blue_b = 214
# This is the base color of the MP bar when using some magic #
@use_r = 255
@use_g = 255
@use_b = 255
#===============================================================#
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>end<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<#
#===============================================================#
end
def refresh
self.contents.clear
self.contents.blt(@act_dist+2, 0, RPG::Cache.picture("MPGauge"), Rect.new(0, 0, 17, 10), 255)
self.contents.fill_rect (1, 0, @act_dist+1, 10, @grey)
self.contents.fill_rect (1, 1, @act_dist+1, 8, @black)
self.contents.fill_rect (0, 1, 1, 8, @grey)
for i in 0...6
self.contents.fill_rect (@act_dist-@eachsp*@actor.sp+2, 2+i, @eachsp*@actor.sp, 1, Color.new(@blue_r,@blue_g,@blue_b,200/(((i+1)/2.00)**1.5)+55))
end
if @difference != nil && @difference < 0
for i in 0...6
each = @difference / FRAMES * 1.000
self.contents.fill_rect (@act_dist-@eachsp*(@actor.sp-@difference-each*(FRAMES-@frames))+2, 2+i, @eachsp*(@difference.abs+1+each*(FRAMES-@frames)), 1, Color.new(@use_r,@use_g,@use_b,(200/(((i+1)/2.00)**1.5)+55)/(FRAMES - @frames)))#/(FRAMES/2 - @frames)))
end
end
end
def reset
if @check != @actor.maxsp
self.contents.dispose
initialize
self.z = 1100
end
if @lastsp != @actor.sp
if @difference == nil
@frames = FRAMES
end
if @frames == FRAMES
@difference = nil
@difference = @actor.sp - @lastsp
end
if @frames == 0
@difference = nil
@color = nil
@frames = nil
@lastsp = @actor.sp
else
@frames -= 1
end
refresh
end
end
end
}




Users browsing this thread: