Enemy amount 'MiniMap add-on': This HUD will show the amount of enemies that are still on the map. Though it'll only work when Woratana's MiniMap script is used. The style of the HUD is the same as the one for the minimap, it uses the same configuration. To let it work, place the add-on script below the original MiniMap script.
CODE
################################################################################
# #
# ~~~~~ Copyright 2009 SojaBird ~~~~~ #
# #
################################################################################
#
# * Game_MiniMap: Gets amount of enemies on the map
#
class Game_MiniMap
attr_reader :enemies
alias hud_initialize initialize
alias draw_hud_object draw_object
def initialize(tilemap)
@enemies = 0
hud_initialize(tilemap)
end
def draw_object
@enemies = 0
draw_hud_object
@object_list.each do |key, events|
color = MiniMap::OBJECT_COLOR[key]
next if events.nil? or color.nil?
events.each do |obj|
if !obj.character_name.empty?
@enemies += 1 if color == MiniMap::OBJECT_COLOR
end
end
end
end
end
#
# * Woratana_MiniMap_Enemy_HUD: Creates the HUD
#
class Woratana_MiniMap_Enemy_HUD < Window_Base
include MiniMap
def initialize
@x = MAP_RECT[0]
@y = MAP_RECT[1] + MAP_RECT[3] - 16
@width = MAP_RECT[2]
@height = WLH + 32
super(@x, @y, @width, @height)
self.visible = $game_system.show_minimap
self.opacity = 0
self.z = MAP_Z + 1
@enemies_total = $scene.spriteset.minimap.enemies
@enemies = $scene.spriteset.minimap.enemies
refresh
end
def color
return knockout_color if @enemies >= (@enemies_total.to_f / 2)
return crisis_color if @enemies > 0
return power_up_color
end
def draw_border
@border = Sprite.new
@border.x = @x - MINIMAP_BORDER_SIZE
@border.y = @y + 16
b_width = @width + (MINIMAP_BORDER_SIZE * 2)
b_height = @height + (MINIMAP_BORDER_SIZE * 2) - 32
@border.bitmap = Bitmap.new(b_width, b_height)
@border.bitmap.fill_rect(@border.bitmap.rect, MINIMAP_BORDER_COLOR)
@border.bitmap.clear_rect(MINIMAP_BORDER_SIZE, MINIMAP_BORDER_SIZE,
@border.bitmap.width - (MINIMAP_BORDER_SIZE * 2),
@border.bitmap.height - (MINIMAP_BORDER_SIZE * 2))
@border.z = MAP_Z
end
def draw_background
@background = Sprite.new
@background.x = @x
@background.y = @y + MINIMAP_BORDER_SIZE + 16
b_width = @width
b_height = @height - 32
@background.bitmap = Bitmap.new(b_width, b_height)
@background.bitmap.fill_rect(@background.bitmap.rect, BACKGROUND_COLOR)
@background.z = MAP_Z
end
def refresh
contents.clear
draw_border if @border.nil?
draw_background if @background.nil?
@enemies = $scene.spriteset.minimap.enemies
self.contents.font.color = color
@string = "#{@enemies}/#{@enemies_total}"
self.contents.draw_text(0, 0, self.width - 32, WLH, @string, 1)
end
def dispose
@border.dispose if
[email protected]?
@background.dispose if
[email protected]?
end
def update
self.visible = $game_system.show_minimap
return if !self.visible
if $scene.is_a?(Scene_Map) and @enemies != $scene.spriteset.minimap.enemies
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
@woratana_minimap_enemy_hud = Woratana_MiniMap_Enemy_HUD.new
end
def terminate
@woratana_minimap_enemy_hud.dispose
terminate_hud
end
def update
update_hud
@woratana_minimap_enemy_hud.update
end
end