#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
# Weapon Equip HUD for Z-HUD
# By RPGManiac3030
# Version 1.6
# www.chaos-project.com
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
# Version History:
# v.1.0
# -Original Release
# v.1.1
# -Removed direct hotkey code
# v.1.2
# -Added compatibility for no weapon equipped
# v.1.3
# -Added weapon background that displays when no weapon is equipped
# v.1.4
# -Added option to change order of the icons via config.
# v.1.5
# -Removed edits in v.1.4, and added a background to the weapon icon if desired
# v.1.5.5
# -Added option to change location of hotkeys/weapon HUD.
# v.1.6
# -Background images for weapon graphic can now be larger than 24x24.
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
# Features:
# -Adds the player's equipped weapon to the HUD.
# -Displays a graphic for when no weapon is equipped.
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
# Instructions:
# -Instructions for editing the config are located in that section.
# -Place this script right under Z-HUD and above main.
# -Place all graphics in your game's pictures folder.
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
# Improvements/ Things to change for next version:
# -Spread out icons to it doesn't look cluttered.
# -Improve efficiency of the code.
# -Return layout options?
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
if !$BlizzABS || BlizzABS::VERSION < 2.7
raise 'Error: Weapon Equip Hud needs Blizz-ABS of version 2.7 or higher.'
end
#BEGIN CONFIGURATION
#==============================================================================
# module BlizzCFG
#==============================================================================
module BlizzCFG
#Set to false to show a picture behind the equipped weapon, and true for none
DISABLE_WEAPON_BACK = false
Z_WEAPON_BACK = '' #image to be displayed behind the weapon
WEAPON_EMPTY = 'Weapon' #image file for when no weapon is equipped
HUD_X = 632 #Horizontal location of HUD.
#This is where the right side of the hud will be!
#Take into effect the width of your 3 pictures
#in order to set this properly.
#The formula is: HUD's left side = HUD_X - width of 3 graphics
HUD_Y = 4 #Vertical location of HUD.
#END CONFIGURATION
end
#==============================================================================
# DO NOT EDIT ANYTHING BELOW UNLESS YOU KNOW WHAT YOU'RE DOING!!!
#==============================================================================
#==============================================================================
# Hud
#------------------------------------------------------------------------------
# This class was modified to support SR display and modify the number of
# skills left to use.
#==============================================================================
class Hud
#----------------------------------------------------------------------------
# update
# Checks if HUD needs refreshing.
#----------------------------------------------------------------------------
def update
# if actor doesn't exist
if actor == nil
# unless already drawn empty HUD
unless @empty_hud_drawn
# draw HUD template
draw_basic
# draw empty HP, SP and EXP bars
draw_empty
# empty HUD was drawn
@empty_hud_drawn = true
end
else
# if HUD needs refresh
if $game_temp.hud_refresh
# draw all data about actor
draw_name
draw_level
draw_hp
draw_sp
draw_equip
draw_hitem
draw_litem
unless BlizzABS::Config::DIRECT_HOTKEYS
draw_hskill
draw_lskill
end
# remove flag
$game_temp.hud_refresh = nil
else
# draw data that needs to ve updated
test_name
test_level
test_hp
test_sp
test_equip
test_hitem
test_litem
unless BlizzABS::Config::DIRECT_HOTKEYS
test_hskill
test_lskill
end
end
# empty HUD wasn't drawn
@empty_hud_drawn = false
end
end
#-------------------------------------------------------------------
# draw_equip
# Draws the equipped weapon on the screen.
#----------------------------------------------------------------------------
def draw_equip
b0 = RPG::Cache.picture(BlizzCFG::Z_WEAPON_BACK)
if BlizzCFG::DISABLE_WEAPON_BACK == true
@hotkey_sprite.bitmap.fill_rect(0, 0, 24, 24, Color.new(0, 0, 0, 0))
else
@hotkey_sprite.bitmap.fill_rect(0, 0, b0.width, b0.height, Color.new(0, 0, 0, 0))
@hotkey_sprite.bitmap.blt(0, 0, b0, Rect.new(0, 0, b0.width, b0.height))
end
wpn = $data_weapons[$game_party.actors[0].weapon_id]
if wpn != nil
b1 = RPG::Cache.icon(wpn.icon_name)
x, y = (b0.width - 24) / 2, (b0.height - 24) / 2
@hotkey_sprite.bitmap.blt(x, y, b1, Rect.new(0, 0, 24, 24))
else
b1 = RPG::Cache.picture(BlizzCFG::WEAPON_EMPTY)
x, y = (b0.width - 24) / 2, (b0.height - 24) / 2
@hotkey_sprite.bitmap.blt(x, y, b1, Rect.new(0, 0, 24, 24))
end
end
#----------------------------------------------------------------------------
# draw_hskill
# Draws the skill hotkey on the screen.
#----------------------------------------------------------------------------
def draw_hskill
@skill = actor.skill
b1 = RPG::Cache.picture(BlizzCFG::Z_WEAPON_BACK)
b2 = RPG::Cache.picture(BlizzCFG::Z_SKILL_BACK)
x = b1.width + 4
@hotkey_sprite.bitmap.fill_rect(x, 0, b2.width, b2.height, Color.new(0, 0, 0, 0))
@hotkey_sprite.bitmap.blt(x, 0, b2, Rect.new(0, 0, b2.width, b2.height))
if @skill != 0
bitmap = RPG::Cache.icon($data_skills[@skill].icon_name)
x, y = b1.width + 4 + (b2.width - 24) / 2, (b2.height - 24) / 2
@hotkey_sprite.bitmap.blt(x, y, bitmap, Rect.new(0, 0, 24, 24))
end
draw_lskill
end
#----------------------------------------------------------------------------
# draw_lskill
# Draws the number of skills left to use.
#----------------------------------------------------------------------------
def draw_lskill
b1 = RPG::Cache.picture(BlizzCFG::Z_WEAPON_BACK)
x = b1.width + 4
@hotkey_sprite.bitmap.fill_rect(x, @left_y, @left_x, 16, Color.new(0, 0, 0, 0))
@skills_left = get_skills_left
if @skill != nil && @skill > 0
if @skills_left >= 0
if @skills_left == 0
@hotkey_sprite.bitmap.font.color = Color.new(255, 0, 0)
elsif @skills_left <= 5
@hotkey_sprite.bitmap.font.color = Color.new(255, 255, 0)
else
@hotkey_sprite.bitmap.font.color = normal_color
end
@hotkey_sprite.bitmap.font.size -= 2
@hotkey_sprite.bitmap.draw_text_full(x, @left_y - 4, @left_x, 20, @skills_left.to_s, 1)
@hotkey_sprite.bitmap.font.size += 2
elsif @skills_left == -1
@hotkey_sprite.bitmap.font.color = Color.new(0, 255, 0)
@hotkey_sprite.bitmap.font.size += 4
@hotkey_sprite.bitmap.draw_text_full(x, @left_y - 4, @left_x, 20, '∞', 1)
@hotkey_sprite.bitmap.font.size -= 4
end
end
end
#----------------------------------------------------------------------------
# draw_hitem
# Draws the item hotkey on the screen.
#----------------------------------------------------------------------------
def draw_hitem
@item = actor.item
b1 = RPG::Cache.picture(BlizzCFG::Z_WEAPON_BACK)
b2 = RPG::Cache.picture(BlizzCFG::Z_SKILL_BACK)
b3 = RPG::Cache.picture(BlizzCFG::Z_ITEM_BACK)
x = b1.width + b2.width + 4
@hotkey_sprite.bitmap.fill_rect(x, 0, b3.width, b3.height, Color.new(0, 0, 0, 0))
@hotkey_sprite.bitmap.blt(x, 0, b3, Rect.new(0, 0, b3.width, b3.height))
if @item != 0
bitmap = RPG::Cache.icon($data_items[@item].icon_name)
x, y = b1.width + b2.width + 4 + (b3.width - 24) / 2, (b3.height - 24) / 2
@hotkey_sprite.bitmap.blt(x, y, bitmap, Rect.new(0, 0, 24, 24))
end
draw_litem
end
#----------------------------------------------------------------------------
# draw_litem
# Draws the number of items left to use.
#----------------------------------------------------------------------------
def draw_litem
@items_left = $game_party.item_number(@item)
b1 = RPG::Cache.picture(BlizzCFG::Z_WEAPON_BACK)
b2 = RPG::Cache.picture(BlizzCFG::Z_SKILL_BACK)
x = b1.width + b2.width + 4
@hotkey_sprite.bitmap.fill_rect(x, @left_y, @left_x, 16, Color.new(0, 0, 0, 0))
if @item != nil && @item > 0
if $data_items[@item] != nil && !$data_items[@item].consumable
@hotkey_sprite.bitmap.font.color = Color.new(0, 255, 0)
@hotkey_sprite.bitmap.font.size += 4
@hotkey_sprite.bitmap.draw_text_full(x, @left_y - 4, @left_x, 20, '∞', 1)
@hotkey_sprite.bitmap.font.size -= 4
else
if @items_left == 0
@hotkey_sprite.bitmap.font.color = Color.new(255, 0, 0)
elsif @items_left <= 10
@hotkey_sprite.bitmap.font.color = Color.new(255, 255, 0)
else
@hotkey_sprite.bitmap.font.color = normal_color
end
@hotkey_sprite.bitmap.font.size -= 2
@hotkey_sprite.bitmap.draw_text_full(x, @left_y - 4, @left_x, 20, @items_left.to_s, 1)
@hotkey_sprite.bitmap.font.size += 2
end
end
end
#----------------------------------------------------------------------------
# test_equip
# Tests and draws the equipment.
#----------------------------------------------------------------------------
def test_equip
# tests if the weapon was changed
draw_equip if actor.weapon_id != nil
end
#----------------------------------------------------------------------------
# init_hotkey_sprite(viewport)
# Sets up the area where the hotkey icons and equipped weapon will be drawn.
#----------------------------------------------------------------------------
def init_hotkey_sprite(viewport)
b1 = RPG::Cache.picture(BlizzCFG::Z_WEAPON_BACK)
b2 = RPG::Cache.picture(BlizzCFG::Z_ITEM_BACK)
b3 = RPG::Cache.picture(BlizzCFG::Z_SKILL_BACK)
width = b1.width + b2.width + b3.width
@hotkey_sprite = Sprite.new(viewport)
@hotkey_sprite.x = BlizzCFG::HUD_X - width
@hotkey_sprite.y = BlizzCFG::HUD_Y
@hotkey_sprite.bitmap = Bitmap.new(width + 4, b1.height + 24)
@hotkey_sprite.bitmap.font.name = 'Times New Roman'
@hotkey_sprite.bitmap.font.size = 16
@hotkey_sprite.bitmap.font.bold = true
end
end
$BlizzABS = BlizzABS::Processor.new