Kingdom Hearts HUD + Addon
Introduction This is a very basic script, all it does is make the health and magic bar rounded.
Plus the addon adds a window for more information/stats.
Features Round Health and Magic Display
Editable placement for HUD
Screenshots since I know people will ask...
And for the addon..
Demo Not needed
Script Spoiler for "script" :
#============================================================================== # ? Kingdom Hearts HUD #------------------------------------------------------------------------------ # by Skive # skivedaft@yahoo.com # # -- # # released on 5th March 2006 #============================================================================== #============================================================================== # ? Sprite_HP #------------------------------------------------------------------------------ # ?the HUD's hp bar #============================================================================== class Sprite_HP < Sprite #-------------------------------------------------------------------------- # ? instances #-------------------------------------------------------------------------- attr_writer :actor #-------------------------------------------------------------------------- # ? initialize #-------------------------------------------------------------------------- def initialize(actor = nil) super(nil) self.z = 202 self.bitmap = Bitmap.new(60, 26) @actor = actor if !@actor.nil? @hp = @actor.hp @maxhp = @actor.maxhp end refresh end #-------------------------------------------------------------------------- # ? refresh #-------------------------------------------------------------------------- def refresh self.bitmap.clear return if @actor.nil? @hp = @actor.hp @maxhp = @actor.maxhp draw_bar(20, 6) self.angle = 270 end #-------------------------------------------------------------------------- # ? update #-------------------------------------------------------------------------- def update super if @actor.nil? self.bitmap.clear return end if @hp != @actor.hp or @maxhp != @actor.maxhp refresh end end #-------------------------------------------------------------------------- # ? draw_bar #-------------------------------------------------------------------------- def draw_bar(radius, width) max = (@actor.hp * 360) / @actor.maxhp for j in 1..width for i in 0..max bx = Math.cos( (i * Math::PI) / 360) * (radius + j) by = Math.sin( (i * Math::PI) / 360) * (radius + j) case j when 1 color = Color.new(74, 112, 29) when 2 color = Color.new(77, 120, 29) when 3 color = Color.new(80, 131, 28) when 4 color = Color.new(85, 144, 27) when 5 color = Color.new(89, 156, 26) when 6 color = Color.new(93, 167, 26) end self.bitmap.set_pixel(30 + bx, by, color) end end end end #============================================================================== # ? Sprite_SP #------------------------------------------------------------------------------ # ?the HUD's sp bar #============================================================================== class Sprite_SP < Sprite #-------------------------------------------------------------------------- # ? instances #-------------------------------------------------------------------------- attr_writer :actor #-------------------------------------------------------------------------- # ? initialize #-------------------------------------------------------------------------- def initialize(actor = nil) super(nil) self.z = 202 self.bitmap = Bitmap.new(60, 26) @actor = actor if !@actor.nil? @sp = @actor.sp @maxsp = @actor.maxsp end refresh end #-------------------------------------------------------------------------- # ? refresh #-------------------------------------------------------------------------- def refresh self.bitmap.clear return if @actor.nil? @sp = @actor.sp @maxsp = @actor.maxsp draw_bar(20, 6) self.angle = 90 self.mirror = true end #-------------------------------------------------------------------------- # ? update #-------------------------------------------------------------------------- def update super if @actor.nil? self.bitmap.clear return end if @sp != @actor.sp or @maxsp != @actor.maxsp refresh end end #-------------------------------------------------------------------------- # ? draw_bar #-------------------------------------------------------------------------- def draw_bar(radius, width) max = (@actor.sp * 360) / @actor.maxsp for j in 1..width for i in 0..max bx = Math.cos( (i * Math::PI) / 360) * (radius + j) by = Math.sin( (i * Math::PI) / 360) * (radius + j) case j when 1 color = Color.new(29, 82, 112) when 2 color = Color.new(29, 86, 120) when 3 color = Color.new(28, 90, 131) when 4 color = Color.new(27, 96, 144) when 5 color = Color.new(26, 102, 156) when 6 color = Color.new(26, 106, 167) end self.bitmap.set_pixel(30 + bx, by, color) end end end end #============================================================================== # ? Sprite_HUD #------------------------------------------------------------------------------ # ?draws the HUD on the map #============================================================================== class Sprite_HUD < Sprite #-------------------------------------------------------------------------- # ? initialize #-------------------------------------------------------------------------- def initialize(corner = 4) super(nil) self.z = 200 for actor in $game_party.actors next if actor.dead? @actor = actor @actor_index = $game_party.actors.index(@actor) break end @hp_sprite = Sprite_HP.new(@actor) @sp_sprite = Sprite_SP.new(@actor) self.bitmap = Bitmap.new(60, 60) case corner when 1 x = 16 y = 16 when 2 x = 640 - 52 - 16 y = 16 when 3 x = 16 y = 480 - 52 - 16 when 4 x = 640 - 52 - 16 y = 480 - 52 - 16 end self.x = x self.y = y @hp_sprite.x = x + 27 @hp_sprite.y = y - 3 @sp_sprite.x = x + 27 - 1 @sp_sprite.y = y - 3 - 1 + 60 refresh end #-------------------------------------------------------------------------- # ? refresh #-------------------------------------------------------------------------- def refresh self.bitmap.clear return if @actor.nil? bmp = RPG::Cache.character(@actor.character_name, @actor.character_hue) rect = Rect.new(0, 0, bmp.width / 4, (bmp.height / 4)) self.bitmap.blt(27 - bmp.width / 8, 5, bmp, rect) self.bitmap.blt(0, 0, RPG::Cache.picture("hud"), Rect.new(0, 0, 60, 60)) end #-------------------------------------------------------------------------- # ? update #-------------------------------------------------------------------------- def update super @hp_sprite.update @sp_sprite.update if @actor != $game_party.actors[@actor_index] @actor = $game_party.actors[@actor_index] @hp_sprite.actor = @actor @sp_sprite.actor = @actor @hp_sprite.refresh @sp_sprite.refresh refresh end end end #============================================================================== # ? Scene_Map #------------------------------------------------------------------------------ # ?draws the hud on the map screen # @khhud_corner is the corner you want the hud to be displayed in. # 1 is upper left, 2 is upper right, 3 is bottom left and 4 is bottom right #============================================================================== class Scene_Map alias main_khhud main alias update_khhud update alias transfer_khhud transfer_player #-------------------------------------------------------------------------- # ? initialize #-------------------------------------------------------------------------- def initialize @khhud_corner = 4 # 1 or 2 or 3 or 4 end #-------------------------------------------------------------------------- # ? main #-------------------------------------------------------------------------- def main @hud = Sprite_HUD.new(@khhud_corner) main_khhud @hud.dispose end #-------------------------------------------------------------------------- # ? update #-------------------------------------------------------------------------- def update @hud.update update_khhud end end
Spoiler for "My Addon" :
#============================================================================== # Basic HUD Window #------------------------------------------------------------------------------ # By Italianstal1ion, based around Skive's HUD # # Just wanted to make a basic HUD for people that wanted to use the round health bars # Skive made but didnt like how bland it was. # Note: I did not edit Skive's part of the script at all, just added the window around it. # If you do use the picture, it needs to be about 180x120 and in your pictures folder #============================================================================== class Window_KHUD < Window_Base def initialize super(440, 350, 200, 130) self.contents = Bitmap.new(width - 32, height - 32) self.back_opacity = 145 #Change to 0 if you use a picture refresh end def refresh self.contents.clear #Remove these lines if you dont want a picture bitmap = RPG::Cache.picture("khud") self.contents.blt(0, 0, bitmap, Rect.new(0, 10, 175, 175)) # Displays Gold, Map, and unchanged words self.contents.font.size = 14 self.contents.font.color = normal_color self.contents.draw_text(-32, 54, 120, 32, $game_party.gold.to_s, 2) #Show Map Name map_infos = load_data("Data/MapInfos.rxdata") name = map_infos[$game_map.map_id].name.to_s self.contents.draw_text(28, 22, 400, 32, name.to_s) self.contents.font.color = system_color self.contents.draw_text(-96, 54, 120, 32, $data_system.words.gold, 2) self.contents.draw_text(0, 22, 120, 32, "Map") self.contents.draw_text(0, 38, 120, 32, "Status") reset_variables return if !@actor # Displays actors state, level, EXP and name draw_actor_level(@actor, 0, 6) draw_actor_state(@actor, 44, 38, width = 120) self.contents.font.size = 18 draw_actor_name(@actor, 0, -10) self.contents.font.size = 14 self.contents.font.color = system_color self.contents.draw_text(72, 6, 48, 32, "EXP") self.contents.font.color = normal_color self.contents.draw_text(76, 6, 84, 32, @actor.exp_s, 2) end def reset_variables @actor = $game_party.actors[0] @old_level = @actor ? @actor.level : 0 @old_exp = @actor ? @actor.exp : 0 end def update super refresh end end class Scene_Map alias khud_main main alias khud_update update def main @khud = Window_KHUD.new khud_main @khud.dispose end def update @khud.update khud_update end end
Note: Both scripts are independent. I did not make any changes to Skive's script for the addon. Either one can work without the other.
Instructions Place above main, below all other scripts. Addon can go above or below Skive's script.
To change the corner its displayed find
@khhud_corner
and change the number it equals to whatever corner you want.
(1 is upper left, 2 is upper right, 3 is bottom left and 4 is bottom right, if you move the bars, you'll have to edit the addon window's x and y coordinates).
Don't forget to put this in your Pictures folder:
Also, for the picture, it needs to be a pic about 180x120 and in your pictures folder. Yes I realize the picture cuts off, its because I drew it in the window. Just use this for now, Ill figure out how to draw the picture outside the window, shouldnt be too hard.
OR, you could make an event having it Show Picture, and set it x and y coordinates to the map, I know its not scripting, but its faster and easier :p
FAQ Nothing yet
Compatibility Works with SDK, untested with anything else.
This script is made for an ABS ONLY. If you try using it for a normal battle, the health/magic bars will show through. Also note this is for any window, so it will show in menu also.
Credits and Thanks Skive made the script, I only made the addon. Many thanks to Yeyinde for the HUD tutorial!