SAI Wander State Version: 1.01
By: Bishop Myers ("Sailerius")
Introduction
This script alters the behavior of the Random movement to appear more natural instead of the artificial-seeming default movement. It requires no special configuration to run.
Screenshots
It's random movement; screenshots won't really convey what it looks like.
Demo
http://www.megaupload.com/?d=C39Z9PVG
Script
Instructions
Just paste it in like you would any other script. This is designed to work with the SDK and should be pasted below it.
FAQ
Q: How does this differ from the default behavior?
A: All events using the Random movement will now select a random destination to seek out. Once they reach this destination, they will choose a new one, making it feel as if their movement is purposeful.
Compatibility
This script is SDK compliant and is designed for version 2.4.
Terms and Conditions
This script is free for all use, including commercial. Please give credit to Bishop Myers ("Sailerius") if you use this script.
By: Bishop Myers ("Sailerius")
Introduction
This script alters the behavior of the Random movement to appear more natural instead of the artificial-seeming default movement. It requires no special configuration to run.
Screenshots
It's random movement; screenshots won't really convey what it looks like.
Demo
http://www.megaupload.com/?d=C39Z9PVG
Script
Code:
#===============================================================================
# ** SAI Random Wander State
#-------------------------------------------------------------------------------
# Author: Bishop Myers ("Sailerius")
# Version: 1.01
# Date: 2011.06.15
# SDK Version: 2.4
#===============================================================================
# Instructions
# ------------------------------------------------------------------------------
# Just paste this script in below the SDK and all events using Random movement
# will automatically begin using the wander state.
# ------------------------------------------------------------------------------
# What It Does
# ------------------------------------------------------------------------------
# The default Random movement looks very artificial. Instead of choosing a
# random adjacent tile to move to, the events will not select a random
# destination and walk to it, making it appear as if they're moving with
# purpose. Once they reach their new destination, the events will select a new
# point to wander to.
#===============================================================================
#-------------------------------------------------------------------------------
# * SDK Log
#-------------------------------------------------------------------------------
SDK.log('SAI Wander State', 'Sailerius', 1.0, '2011.06.13')
SDK.log_overwrite(:Game_Character, :move_random)
#===============================================================================
# ** Game_Character
#===============================================================================
class Game_Character
#-----------------------------------------------------------------------------
# * Alias Listings
#-----------------------------------------------------------------------------
alias_method :sailerius_saiwander_gamecharacter_initialize, :initialize
alias_method :sailerius_saiwander_gamecharacter_movetyperandom, :move_type_random
#-----------------------------------------------------------------------------
# * Public Instance Variables
#-----------------------------------------------------------------------------
attr_reader :wander_x # map x-coordinate to pursue
attr_reader :wander_y # map y-coordinate to pursue
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
sailerius_saiwander_gamecharacter_initialize
set_wander_destination
end
#--------------------------------------------------------------------------
# * Move Type : Random
#--------------------------------------------------------------------------
def move_type_random
# Check if reached destination
if (@wander_x == @x and @wander_y == @y)
set_wander_destination
end
sailerius_saiwander_gamecharacter_movetyperandom
end
#--------------------------------------------------------------------------
# * Move at Random
#--------------------------------------------------------------------------
def move_random
# Get distance from destination
dx = @x - @wander_x
dy = @y - @wander_y
# Move horizontally
unless dx == 0
if dx < 0
# Go somewhere else if impassable
if not passable?(@x + 1, @y, 0)
set_wander_destination
return
end
move_right(false)
return
else
# Go somewhere else if impassable
if not passable?(@x - 1, @y, 0)
set_wander_destination
return
end
move_left(false)
return
end
end
# Move vertically
unless dy == 0
if dy < 0
# Go somewhere else if impassable
if not passable?(@x, @y + 1, 0)
set_wander_destination
return
end
move_down(false)
return
else
# Go somewhere else if impassable
if not passable?(@x, @y - 1, 0)
set_wander_destination
return
end
move_up(false)
return
end
end
end
#--------------------------------------------------------------------------
# * Determine New Wander Destination
#--------------------------------------------------------------------------
def set_wander_destination
@wander_x = @x + rand(40) - 20
@wander_y = @y + rand(40) - 20
end
end
Instructions
Just paste it in like you would any other script. This is designed to work with the SDK and should be pasted below it.
FAQ
Q: How does this differ from the default behavior?
A: All events using the Random movement will now select a random destination to seek out. Once they reach this destination, they will choose a new one, making it feel as if their movement is purposeful.
Compatibility
This script is SDK compliant and is designed for version 2.4.
Terms and Conditions
This script is free for all use, including commercial. Please give credit to Bishop Myers ("Sailerius") if you use this script.