#==============================================================================
# ** Character Auras
#------------------------------------------------------------------------------
# SephirothSpawn
# Version 1.0
# 2008-09-20
#==============================================================================
#==============================================================================
# ** Game_Character
#==============================================================================
class Game_Character
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :aura_on
attr_accessor :aura_color
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias_method :seph_sprchraura_gmchr_init, :initialize
def initialize
seph_sprchraura_gmchr_init
@aura_on = self.is_a?(Game_Player) ? true : false
@aura_color = Color.new(255, 0, 0)
end
end
#==============================================================================
# ** Sprite_Character
#==============================================================================
class Sprite_Character < RPG::Sprite
#--------------------------------------------------------------------------
# * Clear color
#--------------------------------------------------------------------------
Clear_Color = Color.new(255, 255, 255, 0)
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias_method :seph_sprchraura_sprchr_update, :update
def update
# Check to see if aura needs update
need_aura_updated = @character != nil &&
(@aura_on != @character.aura_on ||
@tile_id != @character.tile_id ||
@character_name != @character.character_name ||
@character_hue != @character.character_hue)
# Original update
seph_sprchraura_sprchr_update
# Update aura if needs it
update_aura if need_aura_updated
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update_aura
# If nil and not on
if @aura_on == nil && @character.aura_on != true
@aura_on == @character.aura_on
return
end
# If now off
if @aura_on && @character.aura_on != true
@aura_on == @character.aura_on
self.bitmap = RPG::Cache.character(@character.character_name,
@character.character_hue)
# Set rectangular transfer
sx = @character.pattern * @cw
sy = (@character.direction - 2) / 2 * @ch
self.src_rect.set(sx, sy, @cw, @ch)
return
end
# Turn on
@aura_on = true
# Dup bitmap
self.bitmap = self.bitmap.dup
# Pass through bitmap
for x in 0...bitmap.width
for y in 0...bitmap.height
# Get pixel
pixel = bitmap.get_pixel(x, y)
# Skip if not clear pixel
next unless pixel == Clear_Color
# Collect surrounding pixels
pixels = {}
pixels[[x - 1, y]] = bitmap.get_pixel(x - 1, y)
pixels[[x + 1, y]] = bitmap.get_pixel(x + 1, y)
pixels[[x, y - 1]] = bitmap.get_pixel(x, y - 1)
pixels[[x, y + 1]] = bitmap.get_pixel(x, y + 1)
# Pass through each surrounding pixel
pixels.each do |loc, p|
# If not clear color or aura color
if p != Clear_Color && p != @character.aura_color
# Draw aura pixel
bitmap.set_pixel(loc[0], loc[1], @character.aura_color)
end
end
end
end
end
end