=begin
Character as Static Graphic by Orochii
Version 1.0.0.0.0.0.0.0.0.0.0.1

"Lets you use the whole character graphic, instead of cutting it, and use it as if they were pictures". That describes it the better way I can get to.

INSTRUCTIONS:
Paste it above main. The script effect works the same way as putting ! or $ at the start of the graphic, but using "%". 
So, naming something %actor2525.png will make that graphic affected by the script. Easy right?

    --If you don't know about the ! and $ stuff, you better investigate a little by your own :P.--
  
Salut,
          Orochii Zouveleki
          
Credits:
Emmux for bugtesting.
And everyone that showed interest on it =D. 
Exellomas for example.
=======================
Overwritten methods:
class Sprite_Character
-initialize
-update_bitmap
-update_src_rect
=end

#==============================================================================
# ** Sprite_Character
#------------------------------------------------------------------------------
#  This sprite is used to display characters. It observes a instance of the
# Game_Character class and automatically changes sprite conditions.
#==============================================================================

class Sprite_Character < Sprite_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #    viewport  : viewport
  #    character : character (Game_Character)
  #--------------------------------------------------------------------------
  def initialize(viewport, character = nil)
    super(viewport)
    @like_picture = false
    @character = character
    @balloon_duration = 0
    update
  end
  
  #--------------------------------------------------------------------------
  # * Update Transfer Origin Bitmap
  #--------------------------------------------------------------------------
  def update_bitmap
    if @tile_id != @character.tile_id or
      @character_name != @character.character_name or
      @character_index != @character.character_index
      @tile_id = @character.tile_id
      @character_name = @character.character_name
      @character_index = @character.character_index
      if @tile_id > 0
        sx = (@tile_id / 128 % 2 * 8 + @tile_id % 8) * 32;
        sy = @tile_id % 256 / 8 % 16 * 32;
        self.bitmap = tileset_bitmap(@tile_id)
        self.src_rect.set(sx, sy, 32, 32)
        self.ox = 16
        self.oy = 32
      else
        self.bitmap = Cache.character(@character_name)
        sign = @character_name[/^[\!\$\%]./]
        if sign != nil and sign.include?('$')
          @like_picture = false
          @cw = bitmap.width / 3
          @ch = bitmap.height / 4
        elsif sign != nil and sign.include?('%')
          @like_picture = true
          @cw = bitmap.width
          @ch = bitmap.height
        else
          @like_picture = false
          @cw = bitmap.width / 12
          @ch = bitmap.height / 8
        end
        self.ox = @cw / 2
        self.oy = @ch
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Update Transfer Origin Rectangle
  #--------------------------------------------------------------------------
  def update_src_rect
    if @tile_id == 0
      index = @character.character_index
      pattern = @character.pattern < 3 ? @character.pattern : 1
      sx = (index % 4 * 3 + pattern) * @cw
      sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
      self.src_rect.set(sx, sy, @cw, @ch)
      self.src_rect.set(0, 0, @cw, @ch) if @like_picture == true
    end
  end
end