l0rdph0enix
Member
I need some help with someone putting HP and SP bars in this script for me. It really can't be that hard to do I'm just not sure how to.
Thanks in advance.
Code:
#=========================================
#Pathways Date/Time/Health/Mana/Gold Hub.
# Base coded by: Uknown
# Modified by: L0rdPh0enix
# Aided by: khmp
#=========================================
class Window_HUD < Window_Base
ICON_NAMES = {
'hp' => 'heart.png',
'sp' => 'mana.png',
'gold' => 'gold.png'}
def initialize
super(464,368,176,112)
self.z = 8000
self.contents = Bitmap.new(140,80)
self.contents.font.size = 12
self.back_opacity = 160
#Health Icon Start
@health_ico = RPG::Cache.icon(ICON_NAMES['hp'])
#Mana Icon Start
@mana_ico = RPG::Cache.icon(ICON_NAMES['sp'])
#Gold Icon Start
@gold_ico = RPG::Cache.icon(ICON_NAMES['gold'])
# Clear color.
@clear_color = Color.new(0, 0, 0, 0)
# Variables used to determine what needs to be redrawn.
@gold = @health = @mana = nil
refresh
end
def refresh
# Draw the time
self.contents.fill_rect(Rect.new(@health_ico.width, 1, 132, 20),
@clear_color)
self.contents.draw_text(4, 1, 132, 20, "#{$game_variables[142]}:0#{$game_variables[141]}", 1)
@actor = $game_party.actors[0]
if @health != @actor.hp
# Save the variable.
@health = @actor.hp
self.contents.fill_rect(Rect.new(@health_ico.width, 18, 132, 16),
@clear_color)
draw_actor_hp(@actor, 4, 16)
self.contents.blt(0, 12, @health_ico,
Rect.new(0, 0, @health_ico.width, @health_ico.height))
end
if @mana != @actor.sp
@mana = @actor.sp
self.contents.fill_rect(Rect.new(@health_ico.width, 41, 132, 16),
@clear_color)
draw_actor_sp(@actor, 4, 38)
self.contents.blt(0, 40, @mana_ico,
Rect.new(0, 0, @mana_ico.width, @mana_ico.height))
end
if @gold != $game_party.gold
@gold = $game_party.gold
self.contents.fill_rect(Rect.new(@health_ico.width, 64, 132, 16),
@clear_color)
self.contents.draw_text(4, 64, 132, 20, $game_party.gold.to_s, 2)
self.contents.blt(50, 58, @gold_ico,
Rect.new(0, 0, @gold_ico.width, @gold_ico.height))
end
end
end
class Scene_Map
#=========================================
# * Constant Variables
#=========================================
HUD_SWITCH = 2
alias hud_main main
alias hud_update update
def main
@timer = 0
@hud = Window_HUD.new
hud_main
@hud.dispose
end
#=========================================
# * Frame Update
#=========================================
def update
@timer += 1
@hud.visible = $game_switches[HUD_SWITCH]
if @timer >= 30 && @hud.visible
@timer = 0
@hud.refresh
end
hud_update
end
end
Thanks in advance.