Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Closed TopicStart new topic
> SAI Wander State, Make your events move more naturally!
Sailerius
post Jun 13 2011, 02:45 PM
Post #1


Blue Blue Glass Moon
Group Icon

Group: Revolutionary
Posts: 881
Type: Developer
RM Skill: Beginner





Version: 1.01
Author: Bishop Myers ("Sailerius")
Release Date: June 13, 2011


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.


Script
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



Compatibility
This script is designed to work with SDK 2.4, although it shouldn't have problems without it.


DEMO
See attachment.


Installation
Just paste the script somewhere below the SDK and let it work its magic.


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.


Terms and Conditions
This script is free for all use, including commercial.


Credits
Please give credit to Bishop Myers ("Sailerius") if you use this script.

This post has been edited by Sailerius: Jun 15 2011, 07:13 PM


__________________________
Go to the top of the page
 
+Quote Post
   
Xeyla
post Jun 14 2011, 07:27 PM
Post #2


Keeper of the RMVX FAQ
Group Icon

Group: Revolutionary
Posts: 706
Type: Mapper
RM Skill: Intermediate




Quick question: Since I cannot tell the difference between a rgss script and a rgss2 script, which maker is this for?
EDIT: I'm sorry, I did not realize this was in the RGSS section. Could you make this compatible for RMVX? I would like to use this, if its possible.


This post has been edited by Xeyla: Jun 14 2011, 07:30 PM


__________________________


QUOTE (Albino Parakeet @ Apr 1 2011, 05:46 PM) *
i need to know exactly how to put a penis inside someone's butt.
do you have the technical knowledge to tell me how?
QUOTE (Albino Parakeet @ Apr 2 2011, 01:20 PM) *
QUOTE (Shadyone @ Apr 2 2011, 06:29 AM) *
I see the keet likes anal.

im trying to get into it but people aren't answering my question
Go to the top of the page
 
+Quote Post
   
Sailerius
post Jun 14 2011, 08:05 PM
Post #3


Blue Blue Glass Moon
Group Icon

Group: Revolutionary
Posts: 881
Type: Developer
RM Skill: Beginner




QUOTE (Xeyla @ Jun 14 2011, 08:27 PM) *
Quick question: Since I cannot tell the difference between a rgss script and a rgss2 script, which maker is this for?
EDIT: I'm sorry, I did not realize this was in the RGSS section. Could you make this compatible for RMVX? I would like to use this, if its possible.

Unfortunately, my scripts rely on the SDK, for which there is no RGSS2 equivalent.


__________________________
Go to the top of the page
 
+Quote Post
   
Sailerius
post Jun 15 2011, 07:13 PM
Post #4


Blue Blue Glass Moon
Group Icon

Group: Revolutionary
Posts: 881
Type: Developer
RM Skill: Beginner




Updated to version 1.01, which has slightly cleaner code and a minor adjustment to destination selection.


__________________________
Go to the top of the page
 
+Quote Post
   
Redd
post Jun 16 2011, 10:46 AM
Post #5


:<
Group Icon

Group: Revolutionary
Posts: 2,312
Type: Developer
RM Skill: Advanced




Looks very nice, I like how you've done this. Gives a very professional feel to it wink.gif Great job!


__________________________
Go to the top of the page
 
+Quote Post
   

Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 23rd May 2013 - 04:45 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker