I found today the VX version of the caterpillar script and I receive this error randomly whenever I move if I have a party member. The direction whenever I get the error is random, but it might have to do with when I walk into my party. I started out with the party member who's actually not in my party, sort of just a pet. Any ideas? Thanks for the help
I also forgot to mention I have "Silver Wind's AutoParty Addon to Zeriab's Caterpillar Script" It's posted underneath the main one.
"Line 273: NoMethosError Occured.
undefined method 'caterpillar_actor' for
#<game_player:0x2c04670>"
Line 273 ===> unless event.caterpillar_actor.nil?
#==============================================================================
# ** Zeriab's Caterpillar Script (RMVX)
#------------------------------------------------------------------------------
# Zeriab
# 1.1c
# RMVX Version 1.1c: 2010-02-21
# RMVX Version 1.1b: 2010-01-15
# RMVX Version 1.1 : 2009-12-08
# RMVX Version 1.0 : 2009-10-13
# RMXP Version 1.0 : 2008-08-16
#------------------------------------------------------------------------------
# This script creates a caterpillar of the party members by using events.
#------------------------------------------------------------------------------
# Paste this script just above main.
#
# Put \cat_actor[3] in the name of an event and it will be considered the event
# for the actor with id 3. The name could for example be "Cyrus\cat_actor[3]".
# For actors, you don't have to set a graphic to their events, as it will be
# switched to their graphic automatically.
#
# The switch number specified with CATERPILLAR_ACTIVE_SWITCH (default is 23) is
# used to determine whether the events should be positioned in the caterpillar
# or not. When the switch is off they are just like any other event.
#
# The REMOVE_VISIBLE_ACTORS (default is true) is used to determine whether
# actor event not in the party should be erased or not.
# If it is set to an integer rather than true or false the switch with the
# corresponding id is used. For example REMOVE_VISIBLE_ACTORS = 21 will allow
# you to determine whether the events should be erased or not depending whether
# switch 21 is OFF or ON.
#
# The MAX_ACTORS (default is 4) is used to determine how many player moves
# should be remembered. Only change this if you can have a party with more than
# 4 actors.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Features added for RMVX version by modern algebra:
#
# ~Non-Party Followers
#
# This addon allows you to set events to follow the player in the
# caterpillar without having to be an actor in the party. It is set by page,
# rather than name, as that allows a number of conditions to be placed on
# being able to follow. In order to set an event to be a follower, you MUST
# place a comment as the FIRST line of a page and in the first line of the
# comment there must be the code: \cat_event
#
# ~Pass Through Solid Followers
#
# This addon to Zeriab's Caterpillar Script allows the player to walk
# through a Caterpillar event that is not set to through - this will make it
# so that the events are treated as non-through in all cases except the
# player walking through them. To enable this, you must set
# PASS_SOLID_FOLLOWERS below to true. You can also set the MUST_FACE_FIRST
# constant, which forces the player to face the event before being allowed to
# pass through the follower event. It's useful if you want to allow the
# player the opportunity to interact with the 1st follower event for whatever
# reason.
#
# ~Auto Change Graphic
#
# This is a simple feature. If AUTO_CHANGE_GRAPHIC at line 73 is true, then
# the graphic of the caterpillar actors will automatically change to the
# current graphic of the actor it represents, regardless of what you have the
# graphic in the event set as. If you use silver wind's addon, then it MUST be
# set to true. This feature is also recommended if you use Composite
# Characters, in order to have them show up with all their added equipment.
#==============================================================================
class Game_Caterpillar
CATERPILLAR_ACTIVE_SWITCH = 11 # See line 16 for details
REMOVE_VISIBLE_ACTORS = true # See line 20 for details
MAX_ACTORS = 4 # See line 27 for details
PASS_SOLID_ACTORS = true # See line 45 for details
MUST_FACE_FIRST = false # See line 49 for details
AUTO_CHANGE_GRAPHIC = true # See line 57 for details
##
# Initialize the caterpillar
#
def initialize
@actors = []
@actor_id_to_event = {}
@move_list = []
end
##
# Clear the caterpillar data
#
def clear
@actors.clear
@actor_id_to_event.clear
@move_list.clear
end
##
# Add an actor event to the caterpillar
#
def add_actor(event, actor_id)
@actor_id_to_event[actor_id] = event
event.move_list.clear
added = false
for actor in $game_party.members
if actor.id == actor_id
@actors << event
event.moveto($game_player.x, $game_player.y)
added = true
end
end
if !$game_switches[Game_Caterpillar::CATERPILLAR_ACTIVE_SWITCH]
event.erase
elsif !added && remove_visible_actors?
event.erase
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Add Event
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def add_event (event, event_id)
@actor_id_to_event[event_id] = event
event.move_list.clear
@actors << event unless @actors.include? (event)
event.moveto($game_player.x, $game_player.y)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Remove Event
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def remove_event (event)
event_id = event.id + $data_actors.size
return unless @actor_id_to_event.keys.include? (event_id)
@actor_id_to_event.delete (event_id)
event.move_list.clear
@actors.delete (event)
end
##
# Check if visible actors should be removed
#
def remove_visible_actors?
if REMOVE_VISIBLE_ACTORS.is_a?(Integer)
return $game_switches[REMOVE_VISIBLE_ACTORS]
else
return REMOVE_VISIBLE_ACTORS
end
end
##
# If the game player has been center. I.e. teleported somewhere.
#
def center
# Check if the caterpillar is active
return unless $game_switches[CATERPILLAR_ACTIVE_SWITCH]
# Clear the move_llist
@move_list.clear
# Refresh the caterpillar
update
# Move the actors to the new place
for event in @actors
event.moveto($game_player.x, $game_player.y)
event.move_list.clear
end
end
##
# Refresh the caterpillar. (Use sparingly)
#
def refresh
# Clear the data
clear
# Check each event
for event in $game_map.events.values
if event.is_a?(Game_Event)
event.check_caterpillar
end
end
# Center the events around the player
center
# Update the caterpillar
update
end
##
# Register a player move
#
def register_player_move(move_speed, *args)
# Check if the caterpillar is active
return unless $game_switches[CATERPILLAR_ACTIVE_SWITCH]
# Add the new command
@move_list.unshift([move_speed, args])
# Append the new moves to the caterpillar events
update_actor_movement
# Check if the last command should be removed
if @move_list.size > MAX_ACTORS + 1
# Remove the last move command
@move_list.pop
end
end
##
# Updates the actors movement.
#
def update_actor_movement
for i in 0...@actors.size
if i + 1 < @move_list.size
command = @move_list[i + 1]
actor = @actors[i]
actor.move_list.unshift(command[1])
actor.move_speed = command[0]
end
end
end
##
# Update the caterpillar.
#
def update
# Check if the caterpillar is active
return unless $game_switches[CATERPILLAR_ACTIVE_SWITCH]
old_actors = @actors
@actors = []
# Create a copy of the party actors
caterpillar = $game_party.members.dup
# Remove the first element
caterpillar.shift
# Go through each actor that's possible present in the caterpillar
for actor in caterpillar
event = @actor_id_to_event[actor.id]
unless event.nil?
@actors << event
event.unerase if remove_visible_actors?
# Set graphic of event to actor
if Game_Caterpillar::AUTO_CHANGE_GRAPHIC
begin # If using composite characters
event.composite_character.clear
event.composite_character.push (*$game_actors[actor.id].composite_character)
rescue
event.set_graphic ($game_actors[actor.id].character_name, $game_actors[actor.id].character_index)
end
end
end
end
for member in old_actors
next if @actors.include? (member)
if member.caterpillar_actor < $data_actors.size
member.erase if remove_visible_actors?
else
@actors << member
end
end
end
##
# Unerase all erased actor events
#
def unerase_all
for event in @actor_id_to_event.values
event.unerase
end
end
##
# Erase actor events not in the party
#
def erase_non_party_events
for event in @actor_id_to_event.values
event.erase unless @actors.include?(event)
end
end
end
class Game_Player < Game_Character
unless self.method_defined?('zeriab_caterpillar_game_player_center')
alias_method(:zeriab_caterpillar_game_player_center, :center)
alias malg_pass_cat_check_8jh2 passable?
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Passability Check
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def passable? (x, y, *args)
# Get real passability
result = malg_pass_cat_check_8jh2 (x, y, *args)
if Game_Caterpillar::PASS_SOLID_ACTORS && !result # If not passable
for event in $game_map.events_xy (x, y)
# If a caterpillar event
unless event.caterpillar_actor.nil?
dx, dy = event.distance_x_from_player, event.distance_y_from_player
# Skip if not already facing this event and adjacent to it
next if @direction < 4 && dy != 1
next if @direction > 6 && dy != -1
next if dx != -1 && [1, 4, 7].include? (@direction)
next if dx != 1 && [3, 6, 9].include? (@direction)
# Return true if player has repressed the key
if Game_Caterpillar::MUST_FACE_FIRST
return true if Input.trigger? (Input.dir8)
else
return true
end
end
end
end
# Return real passability
return result
end
##
# When the player is centered (i.e. teleported somewhere)
#
def center(*args)
zeriab_caterpillar_game_player_center(*args)
$game_system.caterpillar.center
end
##
# Generate registration of player moves to the caterpillar code
#
MOVE_METHODS = ['move_down', 'move_left', 'move_right', 'move_up',
'move_lower_left', 'move_lower_right', 'move_upper_left',
'move_upper_right', 'jump']
# Go through each method
for method in MOVE_METHODS
# Create the script for the specific method
PROG = <<_END_
def #{method}(*args)
x,y = self.x, self.y
super(*args)
unless self.x == x && self.y == y
$game_system.caterpillar.register_player_move(@move_speed, '#{method}', args, [self.x, self.y])
end
end
_END_
# Run the script
eval(PROG)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Refresh
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias ma_rfrsh_zrctpl_ccve_6gc1 refresh
def refresh (*args)
ma_rfrsh_zrctpl_ccve_6gc1 (*args) # Run Original Method
# Refresh caterpillar also if Autogenerating graphics
if $game_party.members.size > 1 && Game_Caterpillar::AUTO_CHANGE_GRAPHIC
$game_system.caterpillar.refresh
end
end
end
class Module
# Prevent adding the method again should it already be present.
unless self.method_defined?('attr_sec_accessor')
def attr_sec_accessor(sym, default = 0)
attr_writer sym
attr_sec_reader sym, default
end
def attr_sec_reader(sym, default = 0)
sym = sym.id2name
string = "def #{sym};" +
" @#{sym} = #{default} if @#{sym}.nil?;" +
" @#{sym};" +
"end;"
module_eval(string)
end
end
end
class Game_System
attr_sec_accessor :caterpillar, 'Game_Caterpillar.new'
end
class Game_Event < Game_Character
##
# Attributes
#
attr_reader :caterpillar_actor # variable holding actor ID
attr_reader :page
attr_sec_accessor :move_list, '[]'
attr_accessor :move_speed
attr_writer :character_name
##
# Aliases
#
unless self.method_defined?('zeriab_caterpillar_game_event_passable?')
alias zeriab_caterpillar_game_event_initialize :initialize
alias zeriab_caterpillar_game_event_passable? :passable?
alias zeriab_caterpillar_game_event_update :update
alias modal_zriab_cater_setup_5ch2 :setup
end
##
# Object Initialization
#
def initialize(map_id, event, *args)
# Default update
zeriab_caterpillar_game_event_initialize(map_id, event, *args)
# Check for caterpillar actor denomination
check_caterpillar
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Setup Page
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def setup (new_page, *args)
modal_zriab_cater_setup_5ch2 (new_page, *args)
check_event_caterpillar
# Set graphic of event to actor
if Game_Caterpillar::AUTO_CHANGE_GRAPHIC && @caterpillar_actor != nil &&
@caterpillar_actor < $data_actors.size
actor = $game_actors[@caterpillar_actor]
unless @erased
begin # If using composite characters
@composite_character = actor.composite_character
rescue
set_graphic (actor.character_name, actor.character_index)
end
end
end
end
##
# Check for caterpillar actor denomination
#
def check_caterpillar
@caterpillar_actor = nil
# Check for caterpillar actor denomination (Last is used if more present)
@event.name.gsub (/\\cat_actor\[([0-9]+)\]/i) {@caterpillar_actor = $1 }
# Check if an valid denomination is found.
if @caterpillar_actor.is_a?(String)
@caterpillar_actor = @caterpillar_actor.to_i
if $data_actors[@caterpillar_actor].nil?
@caterpillar_actor = nil
else
$game_system.caterpillar.add_actor(self, @caterpillar_actor)
end
end
check_event_caterpillar if @caterpillar_actor == nil
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Check Event Caterpillar
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def check_event_caterpillar
return unless $game_switches[Game_Caterpillar::CATERPILLAR_ACTIVE_SWITCH]
return if @event.name[/\\cat_actor\[([0-9]+)\]/i] != nil
if @page != nil
first_command = @page.list[0]
# If a Comment and includes caterpillar code
if first_command.code == 108 && first_command.parameters[0][/\\CAT_EVENT/i] != nil
@caterpillar_actor = $data_actors.size + @event.id
$game_system.caterpillar.add_event (self, @caterpillar_actor)
else
$game_system.caterpillar.remove_event (self)
@caterpillar_actor = nil
end
else
$game_system.caterpillar.remove_event (self)
@caterpillar_actor = nil
end
end
##
# Check passability
#
def passable?(*args)
if @caterpillar_actor.nil? || move_list.empty? ||
!$game_switches[Game_Caterpillar::CATERPILLAR_ACTIVE_SWITCH]
return zeriab_caterpillar_game_event_passable?(*args)
else
return true
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Dash?
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias malg_zrb_catrplr_dsh_4rq1 dash?
def dash? (*args)
return @caterpillar_actor != nil ? $game_player.dash? : malg_zrb_catrplr_dsh_4rq1 (*args)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Frame Update
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def update
# Interrupt if not stopping
no_move = jumping? or moving?
# Update
zeriab_caterpillar_game_event_update
# Check if it should return
if $game_switches[Game_Caterpillar::CATERPILLAR_ACTIVE_SWITCH] &&
@caterpillar_actor != nil && !move_list.empty? && !no_move
# Retrive the command
command = move_list[0]
# Call the command
method(command[0]).call(*command[1])
# Make sure the x and y are right in the end
@x, @y = *command[2]
# Remove the command
move_list.pop
end
end
##
# Bring back an erased event
#
def unerase
@erased = false
refresh
end
end
class Game_Map
##
# Aliases
#
unless self.method_defined?('zeriab_caterpillar_game_map_setup')
alias zeriab_caterpillar_game_map_setup :setup
end
##
# Transfer Player
#
def setup(*args)
$game_system.caterpillar.clear
zeriab_caterpillar_game_map_setup(*args)
end
end
class Game_Switches
##
# Aliases
#
unless self.method_defined?('zeriab_caterpillar_game_switches_setter')
alias zeriab_caterpillar_game_switches_setter :[]=
end
##
# Setter
#
def []=(switch_id, value, *args)
zeriab_caterpillar_game_switches_setter(switch_id, value, *args)
if switch_id == Game_Caterpillar::CATERPILLAR_ACTIVE_SWITCH
$game_system.caterpillar.refresh
elsif switch_id == Game_Caterpillar::REMOVE_VISIBLE_ACTORS
if value
$game_system.caterpillar.erase_non_party_events
else
$game_system.caterpillar.unerase_all
end
end
end
end
class Game_Interpreter
##
# Aliases
#
unless self.method_defined?('zeriab_caterpillar_interpreter_command_129')
alias zeriab_caterpillar_interpreter_command_129 :command_129
alias zeriab_caterpillar_interpreter_command_322 :command_322
end
##
# Change Party Member
#
def command_129
result = zeriab_caterpillar_interpreter_command_129
$game_system.caterpillar.refresh
return result
end
##
# Change Actor Graphic
#
def command_322
result = zeriab_caterpillar_interpreter_command_322
$game_system.caterpillar.update
return result
end
end
#==============================================================================
# Silver Wind's AutoParty
# Addon to Zeriab's Caterpillar Script
# Version: 1.1
# Author: silver wind (converted to RMVX by modern algebra)
# Date: December 6, 2009
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Description:
# * Now you don't have to create events for each party member, in every map.
# This script will create them automatically. You may create events for some
# of the actors, and let this system add the missing events.
# * If you ever need to know the id of the event used for a certain actor,
# use:
# event_id = $game_map.cat_event_id(actor_id)
#==============================================================================
#==============================================================================
# ** Game_Map
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased method - setup
# new methods - make_cat_events; new_cat_event; cat_event_id
#==============================================================================
class Game_Map
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Setup
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias silwer_wind_cat_game_map_setup setup
def setup(*args)
silwer_wind_cat_game_map_setup(*args)
make_cat_events
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Make Caterpillar Events
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def make_cat_events
# if the caterpillar event doesn't exist, create it
all_actors = []
for i in 1...$data_actors.size
all_actors.push ($game_actors[i].id)
end
actor_events = []
for event in @events.values
actor_events.push (event.caterpillar_actor)if event.caterpillar_actor != nil
end
for actor_id in all_actors
# add a new event for this actor
new_cat_event(actor_id) if !actor_events.include? (actor_id)
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Create new Caterpillar Event
# actor_id : the ID of the actor to create event for
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def new_cat_event(actor_id)
# create unique ID for the event
ids = @map.events.keys
event_id = (ids.size==0) ? 1 : ((ids.max) +1)
# Set the event on the upper-left corner
new_event = RPG::Event.new(0,0)
new_event.name = "EV#{event_id} \\cat_actor[#{actor_id}]"
new_event.pages[0].priority_type = 1
new_event.pages[0].graphic.pattern = 1
l = @map.events.keys.length
@map.events.keys[l]=event_id
@map.events[event_id]=new_event
game_event = Game_Event.new(@map_id, new_event)
@events[event_id] = game_event
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Retrieve Caterpillar Event ID
# actor_id : the ID of the actor you want event ID for
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def cat_event_id(actor_id)
for i in @events.keys
return i if @events[i].caterpillar_actor == actor_id
end
return false
end
end
class Game_Caterpillar
AUTO_CHANGE_GRAPHIC = true # DO NOT CHANGE
end