# Move route animation by Coelocanth
#
# Instructions:
#
# Place the script in the "Materials" section
# In a move route, use these script call commands:
# set_frame(frame) - change the character frame to that frame number (0-11)
# unset_frame - reset the character frame to normal
#
# Frames:
# 00 01 02 (Facing down)
# 03 04 05 (Facing left)
# 06 07 08 (Facing right)
# 09 10 11 (Facing up)

class Game_CharacterBase
  # prevent resetting of frame when a frame is forced
  alias ccmr_update_anime_pattern update_anime_pattern
  def update_anime_pattern
    return unless @ccmr_frame.nil?
    ccmr_update_anime_pattern
  end
  
  alias ccmr_straighten straighten
  def straighten
    return unless @ccmr_frame.nil?
    ccmr_straighten
  end
  
  def set_frame(frame)
    @ccmr_frame = frame
    # direction is 2,4,6,8
    @direction = ((frame / 3) + 1) * 2;
    @pattern = (frame % 3);
  end
  
  def unset_frame
    @ccmr_frame = nil
    @pattern = @original_pattern
    @direction = @original_direction
  end
end