################################################################################ # # # ~~~~~ Copyright 2009 SojaBird ~~~~~ # # # ################################################################################ module HUD_ITEM_HP_MP HUD_SWITCH = 1 # Turn this ON to show HUD #~ ITEM_ID = 28 # Id of item to show ACTOR_ID = 0 # Id of actor to show hp/mp (actor1=0, actor2=1...actorN=N-1) HIDE = true # Hide if player is beneath the hud (true/false) OPACITY = 100 # Opacity when hidden end ################################################################################ class Window_HUD_Item_HP_MP < Window_Base include HUD_ITEM_HP_MP def initialize super(0, 0, 90, 85) self.opacity = OPACITY self.visible = $game_switches[HUD_SWITCH] hide_status refresh end def refresh contents.clear @actor = $game_party.members[ACTOR_ID] @hp = @actor.hp @mp = @actor.mp #~ @item = $game_party.item_number($data_items[ITEM_ID]) #~ item_icon = $data_items[ITEM_ID].icon_index #~ draw_icon(item_icon, 0, 0) #~ contents.draw_text(1, 0, contents.width - 24, WLH, @item, 2) draw_actor_hp(@actor, 0, 0, self.width - 32) draw_actor_mp(@actor, 0, 24, self.width - 32) end def hide_status if HIDE == true if $game_player.screen_x + 16 > self.x and $game_player.screen_y + 4 > self.y and $game_player.screen_x - 16 < self.x + self.width and $game_player.screen_y - 28 < self.y + self.height self.opacity = OPACITY self.contents_opacity = OPACITY else self.opacity = 255 self.contents_opacity = 255 end end end def update self.visible = $game_switches[HUD_SWITCH] return if !self.visible #~ if @icon != $game_party.item_number($data_items[ITEM_ID]) or @hp != @actor.hp or @mp != @actor.mp refresh end end #~ end #------------------------------------------------------------ # * Scene_Map: Attach HUD to map #------------------------------------------------------------ class Scene_Map < Scene_Base alias start_hud start alias terminate_hud terminate alias update_hud update def start start_hud @item_hp_mp_hud = Window_HUD_Item_HP_MP.new end def terminate @item_hp_mp_hud.dispose terminate_hud end def update update_hud @item_hp_mp_hud.update end end