Autonomous Movement Extension

#==============================================================================
# Autonomous Movement Extension
# Version 1.01
# By Napoleon
#
# About:
# Allows you to set the range for the autonomous movement events. Supports both
# a default range (so it can be configured per map) as well as an event-specific
# range.
#
# Instructions:
# - Place below "▼ Materials" but above "▼ Main Process".
# - You may adjust the range for specific events by adding a comment to it.
# - Comment sample: assign 25 to x and 35 to y (without the quotes):
#   "<auto_mov = 25 35>"
# - You may change "auto_mov" to something else by modifiying the value
#   of COMMENT_TAG
#
# Requires:
# - RPG Maker VX Ace
#
# Terms of Use:
# - Attribution 3.0 Unported (CC BY 3.0)
#   http://creativecommons.org/licenses/by/3.0/
# - Attribution is not required. This overrules what's stated in the above
#   license.
#
# Version History:
# 1.01 (21-05-2013)
#   - Improved the $imported
# 1.00 (4-2-2013)
#   - First Release
#==============================================================================
# Configurable section
#==============================================================================
COMMENT_TAG = "auto_mov" # The first value of the comment tags
GAME_VAR_IDX_X = 3 # The index for the game_variable that sets the default update range for delta x. Assign a 0 value to disable this.
GAME_VAR_IDX_Y = 4 # The index for the game_variable that sets the default update range for delta y. Assign a 0 value to disable this.
#==============================================================================
# Don't edit below this line
#==============================================================================
$imported ||= {}
$imported[:nap_autonomous_mov_ext] = 1.01

class Game_Event < Game_Character
 
  def update_self_movement
    # Set default values
    if GAME_VAR_IDX_X > 0 then range_x = $game_variables[GAME_VAR_IDX_X] else range_x = 12 end
    if GAME_VAR_IDX_Y > 0 then range_y = $game_variables[GAME_VAR_IDX_Y] else range_y = 8 end
   
    # Search for a comment for a specific range for this event.
    if @list != nil
      @list.each {|i|
        if [108, 408].include?(i.code) && i.parameters[0] =~ /<#{Regexp.escape(COMMENT_TAG)} = ([^>]*)>/
            range_x = Integer($1.split[0])
            range_y = Integer($1.split[1])
          break
      end}
    end
   
    if near_the_screen?(range_x, range_y) && @stop_count > stop_count_threshold
      case @move_type
      when 1;  move_type_random
      when 2;  move_type_toward_player
      when 3;  move_type_custom
      end
    end
  end # update_self_movement
 
end # Game_Character
#==============================================================================
# 
# ■ End of File
# 
#==============================================================================
This entry was posted in RMVXA. Bookmark the permalink.