#==============================================================================
# ** TDS Confusion Reverse Walk
#    Ver: 1.0
#------------------------------------------------------------------------------
#  * Description:
#  This script reverses the walking direction of the player when any of the
#  party members are afflicted with a confuse state.
#------------------------------------------------------------------------------
#  * Features: 
#  Reversing walking direction of the player when confused.
#------------------------------------------------------------------------------
#  * Instructions:
#  Just put it in your game under the "Materials" area of the script list and
#  enjoy.
#------------------------------------------------------------------------------
#  * Notes:
#  Confusion states should have a "Remove by Walking" amount of steps in order
#  for the script to be effective.
#------------------------------------------------------------------------------
# WARNING:
#
# Do not release, distribute or change my work without my expressed written 
# consent, doing so violates the terms of use of this work.
#
# If you really want to share my work please just post a link to the original
# site.
#
# * Not Knowing English or understanding these terms will not excuse you in any
#   way from the consequenses.
#==============================================================================
# * Import to Global Hash *
#==============================================================================
($imported ||= {})[:TDS_Confusion_Reverse_Walk] = true

#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
#  This class handles the player. It includes event starting determinants and
# map scrolling functions. The instance of this class is referenced by
# $game_player.
#==============================================================================

class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------  
  alias tds_confusion_reverse_walk_game_player_move_by_input    move_by_input
  #--------------------------------------------------------------------------
  # * Processing of Movement via Input from Directional Buttons
  #--------------------------------------------------------------------------
  def move_by_input(*args, &block)
    # If Movable and Game Interpreter is not running
    if movable? and !$game_map.interpreter.running?
      # If any Party Member is confused
      if $game_party.members.any? {|m| m.confusion?}
        # Move in Reverse Direction
        move_straight(reverse_dir(Input.dir4)) if Input.dir4 > 0
        return
      end
    end
    # Run Original Method
    tds_confusion_reverse_walk_game_player_move_by_input(*args, &block)
  end
end