#==============================================================================
#AnotherMove Fog - Move variation for fogs.
#A random idea I thought about and made ahahaha.
#==============================================================================

#The script adds a waving movement to fogs. What it does is just to adjust the x/y 
#speed on the fog each certain time.
#It's flexible enough, letting you to define the lapse between speed changes, the 
#change amount, and minimum/maximum values.

#INSTRUCCIONES: Paste above Main. The system is controlled by event commands (script calls).
#(Autostart, script call, and lastly "erase event temporally").
#==============================================================================
#                            SCRIPT COMMANDS

#These are the script calls
#------------------------------------------------------------------------------
#$game_map.x_speeds = [min,max,variation]
#$game_map.y_speeds = [min,max,variation]
#                                        Minimum, maximum values of speeds, and the variation for each "step".
# 
#------------------------------------------------------------------------------
#$game_map.animation_frame_num
#                                      Adjusts the lapse between variation (time between "steps")
#------------------------------------------------------------------------------
#$fog_wave = true; $fog_wave = false
#                                      Activates/deactivates the effect. 
# The x/y speeds will remain as they were when you deactivated it.
# By default, the fog_wave is off (false).
#------------------------------------------------------------------------------
#$game_map.fog_sx=num; #$game_map.fog_sy=num
#                                              This is part of default RMXP scripts, but is useful
# for manually adjusting the x/y speeds at any time.
#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
#  Aliased methods:
#      initialize, setup, update
#  New methods: None
#  Overwritten: None
#==============================================================================

class Game_Map
  
  #--------------------------------------------------------------------------
  # * Access definitions (?)
  #--------------------------------------------------------------------------
  attr_accessor :x_speeds
  attr_accessor :y_speeds
  attr_accessor :animation_frame_num

  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias ozmhfh_initialize initialize unless $@
  alias ozmhfh_setup setup unless $@
  alias ozmhfh_update update unless $@
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    $fog_wave=false
    @animation_frame = 0
    @fr_count_tmp = 0
    ozmhfh_initialize
  end

  def setup(map_id)
    @animation_frame = 0
    @animation_frame_num = 10
    @x_speeds = [0,8,1]
    @y_speeds = [0,8,1]
    $fog_wave=false
    ozmhfh_setup(map_id)
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    ozmhfh_update
    
    #OROCHII: Make fog animation
    if $fog_wave
      if @animation_frame<=0
          if @fxup_var
            @fog_sx += @x_speeds[2]
            @fxup_var = false if @fog_sx >= @x_speeds[1]
          else
            @fog_sx -= @x_speeds[2]
            @fxup_var = true if @fog_sx <= @x_speeds[0]
          end
          if @fyup_var
            @fog_sy += @y_speeds[2]
            @fyup_var = false if @fog_sy >= @y_speeds[1]
          else
            @fog_sy -= @y_speeds[2]
            @fyup_var = true if @fog_sy <= @y_speeds[0]
          end
        @animation_frame = @animation_frame_num
      end
      
      if @fr_count_tmp != Graphics.frame_count
        @animation_frame -= 1
        @fr_count_tmp = Graphics.frame_count
      end
    end
    
  end
end