Code:
#==============================================================================
# ? Visual Equipment
#------------------------------------------------------------------------------
# Geso Chisku
# Version 2
# 14.02.06
#==============================================================================
# FEATURES
# - Shows the player equipment on the map
# - Shows NPC equipment on the map events
# - Compatible with Caterpillar and SBABS
# - Shows the equipment in windows
#------------------------------------------------------------------------------
# FUTURE WORK
# - Compatibility with Guillaume multi-equip
# - Compatibility with Netplay
# - Compatibility with different size graphics
# - Compatibility with shadows/reflection (that is gonna be hard)
#------------------------------------------------------------------------------
# BUGS
# - Don't work with shadow/reflection script
#------------------------------------------------------------------------------
# MAKING YOUR OWN GRAPHICS
# - All graphics must be in 128 x 192 size
# - For main character graphic, make only the hair and the eyes
# - Use the template to see if the equips fits well
#------------------------------------------------------------------------------
# SETTING UP YOUR GAME
# To set up the default body templates, search for "DEFAULT_ACTOR_BODY"
#
# To add a graphic to a equipment, search for "def equip_character"
#
# To add visual equipment to a event, add comments in this format:
# Comment: Visual Equipment
# Comment: Body [charset] [hue]
# Comment: Armor [charset] [hue]
# Comment: Helmet [charset] [hue]
# Comment: Weapon [charset] [hue]
# Comment: Accessory [charset] [hue]
# Comment: Shield [charset] [hue]
# Replace [charset] with the filename of the equipment or with none
# and [hue] with the graphic hue, the default hue is 0
#==============================================================================
#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('Visual Equipment', 'Geso Chisku', 2, '14.02.06')
#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.state('Visual Equipment') == true
#--------------------------------------------------------------------------
# This method returns the character name based on equipment type and id
# To add a item to the list, add the following line:
# return [char_name, hue] if id == item_id
# To add the charset 'equip-helmet', hue 0, for item 8 add the following
# return ['equip-helmet', 0] if id == 8
#--------------------------------------------------------------------------
def equip_character(type, id)
if type == 2
# WEAPONS GRAPHICS
# Add your weapon lines here
return ['equip\\weapon-sword01', 0] if id == 1
else
# ARMORS, HELMETS, SHIELDS, ACCESSORIES GRAPHICS
# Add your armor lines here
return ['equip\\Face Mask', 0] if id == 34
return ['equip\\head-helmet02', 0] if id == 2
return ['equip\\body-armor01', 0] if id == 3
return ['equip\\body-armor01', 170] if id == 4
return ['equip\\body-armor03', 0] if id == 5
return ['equip\\Amulet', 0] if id == 36
return ['equip\\body-clothes01', 0] if id == 7
return ['equip\\body-cape01', 0] if id == 8
return ['equip\\Ninja Suit', 0] if id == 35
return ['equip\\body-robe02', 0] if id == 10
return ['equip\\Shroud', 0] if id == 11
return ['equip\\head-bunny', 0] if id == 12
return ['equip\\body-bunny', 0] if id == 13
return ['equip\\head-hat01', 0] if id == 14
return ['equip\\head-hat02', 0] if id == 15
return ['equip\\head-hat03', 0] if id == 16
return ['equip\\head-sailor01', 0] if id == 17
return ['equip\\head-ninja', 0] if id == 18
return ['equip\\body-ninja', 0] if id == 19
return ['equip\\head-ninja', -100] if id == 28
return ['equip\\body-armor02', 0] if id == 20
return ['equip\\body-armor04', 0] if id == 21
return ['equip\\body-armor05', 0] if id == 22
return ['equip\\body-clothes02', 0] if id == 23
return ['equip\\body-clothes04', 0] if id == 24
return ['equip\\body-clothes03', 0] if id == 25
return ['equip\\body-clothes05', 0] if id == 26
return ['equip\\body-robe04', 0] if id == 27
return ['equip\\Elf Armor', 0] if id == 37
return ['equip\\Snake Armor', 128] if id == 38
return ['equip\\Holy Armor', 0] if id == 39
return ['equip\\', 0] if id == 40
end
return false
end
#----------------------------------------------------------------------------
# ** Game_Actor
#----------------------------------------------------------------------------
class Game_Actor < Game_Battler
attr_accessor :body
#--------------------------------------------------------------------------
DEFAULT_ACTOR_BODY = ['body-male', 'body-male', 'body-male', 'body-male']
#--------------------------------------------------------------------------
alias geso_visual_actor_init initialize
def initialize(actor_id)
geso_visual_actor_init(actor_id)
@body = DEFAULT_ACTOR_BODY[actor_id]
end
#--------------------------------------------------------------------------
def equip_char_array
equips = []
equips.push([@body, 0])
item = equip_character(0, actor_equip_id(0, self))
equips.push(item) unless item == false
equips.push([@character_name, @character_hue])
for i in 1..4
item = equip_character(i, actor_equip_id(i, self))
equips.push(item) unless item == false
end
return equips
end
end
#----------------------------------------------------------------------------
# ** Game_Event
#----------------------------------------------------------------------------
class Game_Event < Game_Character
attr_reader :page
end
#--------------------------------------------------------------------------
# Determines the order the equips are draw
#--------------------------------------------------------------------------
def actor_equip_id(i, actor)
case i
when 0 # Body
return actor.armor3_id
when 1 # Helmet
return actor.armor2_id
when 2 # Weapon
return actor.weapon_id
when 3 # Accessory
return actor.armor4_id
when 4 # Shield
return actor.armor1_id
end
end
#----------------------------------------------------------------------------
# ** Sprite_Character
#----------------------------------------------------------------------------
class Sprite_Character < RPG::Sprite
#--------------------------------------------------------------------------
alias geso_visual_equip_sprite_char_init initialize
def initialize(viewport, character = nil)
if character.is_a?(Game_Player)
@actor = $game_party.actors[0]
elsif SDK.state('SBABS') == true and character.is_a?(Game_Ally)
@actor = $game_party.actors[character.actor_id]
elsif SDK.state('Caterpillar') == true and character.is_a?(Game_Party_Actor)
@actor = character.actor
else
@actor = nil
end
@equips_id = [0, 0, 0, 0, 0]
geso_visual_equip_sprite_char_init(viewport, character)
end
#--------------------------------------------------------------------------
def equip_changed?
if SDK.state('Caterpillar') == true
if @character.is_a?(Game_Party_Actor)
if @character.actor != @actor
@actor = @character.actor
return true
end
end
end
if SDK.state('SBABS') == true
if @character.is_a?(Game_Ally)
if $game_party.actors[@character.actor_id] != @actor
return true
end
end
end
if @character.is_a?(Game_Player)
if $game_party.actors[0] != @actor
@actor = $game_party.actors[0]
return true
end
elsif @character.is_a?(Game_Event)
if @page != @character.page
@page = @character.page
return true
end
return false
end
if @actor == nil
return false
end
for i in 0..4
return true if @equips_id[i] != actor_equip_id(i, @actor)
end
return false
end
#--------------------------------------------------------------------------
def adv_update
@character_name = ''
update
end
#--------------------------------------------------------------------------
def update
# If character is a event
super
# If tile ID, file name, hue or equipment are different from current ones
if @tile_id != @character.tile_id or
@character_name != @character.character_name or
@character_hue != @character.character_hue or
equip_changed?
# Remember tile ID, file name and hue
@tile_id = @character.tile_id
@character_name = @character.character_name
@character_hue = @character.character_hue
# If tile ID value is valid
if @tile_id >= 384
self.bitmap = RPG::Cache.tile($game_map.tileset_name,
@tile_id, @character.character_hue)
self.src_rect.set(0, 0, 32, 32)
self.ox = 16
self.oy = 32
# If tile ID value is invalid
else
equips = []
# If handling a event
if @character.is_a?(Game_Event) == true
# Check for comment input
parameters = SDK.event_comment_input(@character, 6, 'Visual Equipment')
if parameters.nil?
equips.push([@character_name, @character_hue])
else
for i in 0..5
item = parameters[i].split
hue = item.size > 2 ? item[2] : 0
equips.push([item[1], hue]) if item[1] != 'none'
if i == 1
equips.push([@character_name, @character_hue])
end
end
end
# If handling the player
elsif @actor != nil
equips = @actor.equip_char_array
end
# Dispose old bitmap
self.bitmap.dispose unless self.bitmap == nil
# Draws the character bitmap
bmp = RPG::Cache.character(@character_name, @character_hue)
self.bitmap = Bitmap.new(bmp.width, bmp.height)
src_rect = Rect.new(0, 0, bmp.width, bmp.height)
# If character fits the size
if equips.size > 0 and bmp.width == 128 and bmp.height == 192
size = equips.size -1
for i in 0..size
next if equips[i] == false or equips[i][0] == false or equips[i][0] == nil
bmp2 = RPG::Cache.character(equips[i][0], equips[i][1].to_i)
self.bitmap.blt(0, 0, bmp2, src_rect, 255)
end
else
src_rect = Rect.new(0, 0, bmp.width, bmp.height)
self.bitmap.blt(0, 0, bmp, src_rect, 255)
end
@cw = bitmap.width / 4
@ch = bitmap.height / 4
self.ox = @cw / 2
self.oy = @ch
end
end
# Set visible situation
self.visible = (not @character.transparent)
# If graphic is character
if @tile_id == 0
# Set rectangular transfer
sx = @character.pattern * @cw
sy = (@character.direction - 2) / 2 * @ch
self.src_rect.set(sx, sy, @cw, @ch)
end
# Set sprite coordinates
self.x = @character.screen_x
self.y = @character.screen_y
self.z = @character.screen_z(@ch)
# Set opacity level, blend method, and bush depth
self.opacity = @character.opacity
self.blend_type = @character.blend_type
self.bush_depth = @character.bush_depth
# Animation
if @character.animation_id != 0
animation = $data_animations[@character.animation_id]
animation(animation, true)
@character.animation_id = 0
end
end
#--------------------------------------------------------------------------
end
#----------------------------------------------------------------------------
# ** Window_Base
#----------------------------------------------------------------------------
class Window_Base < Window
#--------------------------------------------------------------------------
def draw_actor_graphic(actor, x, y)
bmp = RPG::Cache.character(actor.character_name, actor.character_hue)
bitmap = Bitmap.new(bmp.width, bmp.height)
src_rect = Rect.new(0, 0, bmp.width, bmp.height)
# Setup actor equipment
equips = actor.equip_char_array
# If character fits the size
if equips.size > 0 and bmp.width == 128 and bmp.height == 192
size = equips.size -1
for i in 0..size
next if equips[i] == false or equips[i][0] == false or equips[i][0] == nil
bmp2 = RPG::Cache.character(equips[i][0], equips[i][1].to_i)
bitmap.blt(0, 0, bmp2, src_rect, 255)
end
else
bitmap.blt(0, 0, bmp, src_rect, 255)
end
cw = bitmap.width / 4
ch = bitmap.height / 4
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
end
end
end
#------------------------------------------------------------------------------
# * End SDK Enable Test
#------------------------------------------------------------------------------