#==============================================================================
# ** Prexus ABS HUD
#------------------------------------------------------------------------------
# MeisMe
# Version 1.0
# September 2006
#==============================================================================
#--------------------------------------------------------------------------
# * SDK Log Script
#--------------------------------------------------------------------------
SDK.log('Prexus ABS HUD', 'MeisMe', 1, 'September 2006')
#--------------------------------------------------------------------------
# * Begin SDK Enable Test
#--------------------------------------------------------------------------
if (SDK.state('Prexus ABS') == true && SDK.state('Prexus ABS HUD') == true)
class ABS
class Window_Hud < Window_Base
attr_accessor :action_text
def initialize
super(-16, -16, 672, 512)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = "Georgia"
self.contents.font.bold = true
self.contents.font.size = 14
self.opacity = 0
self.contents_opacity = $game_player.screen_y < 128 ? 90 : 255
@hp = 0
@maxhp = 0
@sp = 0
@maxsp = 0
@action_text = ''
refresh
end
def refresh
self.contents.clear
@hp = $game_party.actors[0].hp
@maxhp = $game_party.actors[0].maxhp
@sp = $game_party.actors[0].sp
@maxsp = $game_party.actors[0].maxsp
@weapon = $game_party.actors[0].weapon_id
@text = @action_text
@x = 32
#---------------------------------------------------------------------
# * Draw HUD Icons
#---------------------------------------------------------------------
bitmap = RPG::Cache.icon('Attack Icon')
opacity = $ABS.player.weapon_id == 0 ? 160 : 255
self.contents.blt(383, 15, bitmap, Rect.new(0, 0, 34, 34), opacity)
if $ABS.player.weapon_id != 0
bitmap = RPG::Cache.icon($data_weapons[$ABS.player.weapon_id].icon_name)
self.contents.blt(383 + 5, 20, bitmap, Rect.new(0, 0, 24, 24))
end
bitmap = RPG::Cache.icon('Action Icon')
self.contents.blt(438, 15, bitmap, Rect.new(0, 0, 34, 34))
self.contents.font.color = Color.new(0,0,0)
self.contents.draw_text(422, 24, 68, 12, @text, 1)
self.contents.font.color = normal_color
self.contents.draw_text(421, 25, 68, 12, @text, 1)
bitmap = RPG::Cache.icon('Skill Icon')
opacity = $ABS.player.abs.hot_key[0] ? 255 : 160
self.contents.blt(493, 15, bitmap, Rect.new(0, 0, 34, 34), opacity)
if $ABS.player.abs.hot_key[0]
skill = $data_skills[$ABS.player.abs.hot_key[0]]
bitmap = RPG::Cache.icon(skill.icon_name)
self.contents.blt(493 + 5, 20, bitmap, Rect.new(0, 0, 24, 24))
self.contents.font.color = Color.new(0,0,0)
self.contents.draw_text(494, 44, 16, 12, "x")
self.contents.draw_text(502, 44, 24, 12, skill.sp_cost.to_s, 2)
self.contents.font.color = $ABS.player.sp >= skill.sp_cost ?
normal_color : Color.new(255,0,0)
self.contents.draw_text(493, 45, 16, 12, "x")
self.contents.draw_text(501, 45, 24, 12, skill.sp_cost.to_s, 2)
end
bitmap = RPG::Cache.icon('Skill Icon')
opacity = $ABS.player.abs.hot_key[1] ? 255 : 160
self.contents.blt(527, 30, bitmap, Rect.new(0, 0, 34, 34), opacity)
if $ABS.player.abs.hot_key[1]
skill = $data_skills[$ABS.player.abs.hot_key[1]]
bitmap = RPG::Cache.icon(skill.icon_name)
self.contents.blt(527 + 5, 35, bitmap, Rect.new(0, 0, 24, 24))
self.contents.font.color = Color.new(0,0,0)
self.contents.draw_text(528, 59, 16, 12, "y")
self.contents.draw_text(536, 59, 24, 12, skill.sp_cost.to_s, 2)
self.contents.font.color = $ABS.player.sp >= skill.sp_cost ?
normal_color : Color.new(255,0,0)
self.contents.draw_text(527, 60, 16, 12, "y")
self.contents.draw_text(535, 60, 24, 12, skill.sp_cost.to_s, 2)
end
bitmap = RPG::Cache.icon('Skill Icon')
opacity = $ABS.player.abs.hot_key[2] ? 255 : 160
self.contents.blt(561, 15, bitmap, Rect.new(0, 0, 34, 34), opacity)
if $ABS.player.abs.hot_key[2]
skill = $data_skills[$ABS.player.abs.hot_key[2]]
bitmap = RPG::Cache.icon(skill.icon_name)
self.contents.blt(561 + 5, 20, bitmap, Rect.new(0, 0, 24, 24))
self.contents.font.color = Color.new(0,0,0)
self.contents.draw_text(562, 44, 16, 12, "z")
self.contents.draw_text(570, 44, 24, 12, skill.sp_cost.to_s, 2)
self.contents.font.color = $ABS.player.sp >= skill.sp_cost ?
normal_color : Color.new(255,0,0)
self.contents.draw_text(561, 45, 16, 12, "z")
self.contents.draw_text(569, 45, 24, 12, skill.sp_cost.to_s, 2)
end
#---------------------------------------------------------------------
# * Draw HP and SP Bars and Text
#---------------------------------------------------------------------
#hpp = (@hp.to_f / @maxhp) * 100
@y = 16
hearts = @maxhp / 250
for i in 1..hearts
x = ((i - 1) % 20) * 16 + @x
y = ((i - 1) / 20) * 16 + 4
if @hp >= i * 250
bitmap = RPG::Cache.icon('HeartF')
elsif (@hp < i * 250) && (@hp > (i - 1) * 250)
bitmap = RPG::Cache.icon('HeartH')
else
bitmap = RPG::Cache.icon('HeartE')
end
self.contents.blt(x, y + 8, bitmap, Rect.new(0, 0, 16, 16))
end
if @maxsp != 0
length = @maxsp / 25
spp = (@sp.to_f / @maxsp) * length
self.contents.fill_rect(@x + 2, @y + 34, length + 2, 16, Color.new(255, 255, 255))
self.contents.fill_rect(@x + 1, @y + 35, length + 4, 14, Color.new(255, 255, 255))
self.contents.fill_rect(@x, @y + 36, length + 6, 12, Color.new(255, 255, 255))
self.contents.fill_rect(@x + 3, @y + 36, length, 12, Color.new(0, 0, 0))
self.contents.fill_rect(@x + 3, @y + 36, spp, 12, Color.new(0, 155, 0))
self.contents.fill_rect(@x + 3, @y + 38, spp, 8, Color.new(0, 200, 0))
self.contents.fill_rect(@x + 3, @y + 39, spp, 6, Color.new(0, 225, 0))
self.contents.fill_rect(@x + 3, @y + 40, spp, 4, Color.new(0, 255, 0))
end
end
#-----------------------------------------------------------------------
def update
refresh unless (@hp == $game_party.actors[0].hp and
@maxhp == $game_party.actors[0].maxhp and
@sp == $game_party.actors[0].sp and
@maxsp == $game_party.actors[0].maxsp and
@weapon == $game_party.actors[0].weapon_id and
@text == @action_text)
if $game_player.screen_y < 128
self.contents_opacity -= 15 if self.contents_opacity > 90
else
self.contents_opacity += 15 if self.contents_opacity < 255
end
end
end
attr_accessor :action_triggers
alias hud_initialize initialize
alias hud_setup_enemies setup_enemies
def initialize
hud_initialize
@action_triggers = {}
end
def setup_enemies(events)
@action_triggers = {}
for event in events.values
parameter = SDK.event_comment_input(event, 1, 'Action Trigger')
next if !parameter
text = parameter[0].split
@action_triggers[event.id] = text.to_s
end
hud_setup_enemies(events)
end
def check_straight_facing(element, object)
element = $game_map.events[element.event_id] if element.is_a?(ABS::Enemy)
object = $game_map.events[object.event_id] if object.is_a?(ABS::Enemy)
if element.direction == 2
return true if object.y > element.y
end
if element.direction == 4
return true if object.x < element.x
end
if element.direction == 6
return true if object.x > element.x
end
if element.direction == 8
return true if object.y < element.y
end
return false
end
end
class Scene_Map
alias hud_update update
def update
for event in $game_map.events.values
if ($ABS.check_range($game_player, event, 1) and
$ABS.check_straight_facing($game_player, event))
if $ABS.action_triggers[event.id]
@hud_window.action_text = $ABS.action_triggers[event.id]
end
break
else
@hud_window.action_text = ''
end
end
hud_update
end
end
#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end