Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
  • 0
Heretic86

[Resolved] Need Support for a Script

Question

DISREGARD - PROBLEM RESOLVED

 

So what I have is Zeriab's Caterpillar Script, and Im trying to modify it so that I can delete the last registerd move event or two from the Caterpillar Actors Move Array. I'll post the code I have because I made some other edits to it as well, such as a Caterpillar Pause, so I can run a cutscene and not kick members from my party. Seems to be easier to do it this way, at least for me, I dont know if that feature would be useful to anyone else. But my big problem right now is trying to delete one or two of the Main Actors (Player) move events so that the Caterpillar wont walk over an event that, after triggering a touch event, will be unmoveable.

 

Something quick, look at about line 160

 

 

 

#==============================================================================
# ** Zeriab's Caterpillar Script
#------------------------------------------------------------------------------
# Zeriab
# 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]"
#
# 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. Then 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.
#==============================================================================
class Game_Caterpillar
 CATERPILLAR_PAUSE_SWITCH = 22  #NEW
 CATERPILLAR_ACTIVE_SWITCH = 23
 REMOVE_VISIBLE_ACTORS = false
 MAX_ACTORS = 4
 ##
 # 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
 ##
 # Clear the Move data
 #
 def clear_moves
@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.actors
  if actor.id == actor_id
	@actors << event
	if !$game_switches[CATERPILLAR_PAUSE_SWITCH]
	  event.moveto($game_player.x, $game_player.y)
	  added = true
	end
  end
end
if remove_visible_actors? && !added && $game_switches[CATERPILLAR_ACTIVE_SWITCH]
  event.erase
end
 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] && !$game_switches[CATERPILLAR_PAUSE_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
# Check if the caterpillar is active
return unless $game_switches[CATERPILLAR_ACTIVE_SWITCH] && !$game_switches[CATERPILLAR_PAUSE_SWITCH]
# 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] && !$game_switches[CATERPILLAR_PAUSE_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
if !$game_switches[CATERPILLAR_PAUSE_SWITCH]
  #While Paused, prevents new events from being added to move_list
  #This prevents the need of clearing moves during cutscenes without
  #disabling the CATERPILLAR_ACTIVE_SWITCH

  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
 end
 ##
 # Delete Last Move Event of Actor
 #
 # NOT WORKING
 #
 # call by Script: $game_system.caterpillar.del_last_move
 def del_last_move
for i in 0...@actors.size
  if i + 1 < @move_list.size
	  #command = @move_list[i + 1]
	  actor = @actors[i]
	  actor.move_list.delete_at(i)
	  #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.actors.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?
	event.character_name = actor.character_name
  end
end
if remove_visible_actors?
  # Go through the old actors to see if any should be erased
  for actor in old_actors
	unless @actors.include?(actor)
	  actor.erase
	end
  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)
 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
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_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?
if Module.constants.include?('SDK')
  alias zeriab_caterpillar_game_event_update_movement  :update_movement
else
  alias zeriab_caterpillar_game_event_update  :update
end
 end
 ##
 # Object Initialization
 #
 def initialize(map_id, event, *args)
# Default update
zeriab_caterpillar_game_event_initialize(map_id, event, *args)
# Check if the caterpillar is active
return unless $game_switches[Game_Caterpillar::CATERPILLAR_ACTIVE_SWITCH]
# Check for caterpillar actor denomination
check_caterpillar
 end
 ##
 # Check for caterpillar actor denomination
 #
 def check_caterpillar
# 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
 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
 ##
 # SDK and Non-SDK stuff
 #
 if Module.constants.include?('SDK')
##
# Update Movement
#
def update_movement
  if @caterpillar_actor.nil? || move_list.empty? ||
	 !$game_switches[Game_Caterpillar::CATERPILLAR_ACTIVE_SWITCH]
	return zeriab_caterpillar_game_event_update_movement
  end
  # Interrupt if not stopping
  if jumping? or moving?
	return
  end
  # 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
 else # Non-SDK version
##
# Update Movement
#
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
 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 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

 

Edited by Heretic86

Share this post


Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Okay, no reples. I'll try to simplify.

 

  def del_last_move
   for i in 0...@actors.size
     if i + 1 < @move_list.size
         #command = @move_list[i + 1]  (disregard commented lines, they dont add to the script)
         actor = @actors[i]
         actor.move_list.delete_at(i)
         #actor.move_speed = command[0]
     end
   end
 end

 

Is this how to delete a specific element of an array in RGSS? I just cant seem to delete move events from the caterpillar!

Share this post


Link to post
Share on other sites
  • 0

Ok, figured it out. I was overthinking it. I thought there was one array per character, there is just ONE array.

 

  def del_last_move
   @move_list.delete_at(0)
 end

 

Updated RMXP Version of script with my additional commands of CATERPILLAR_PAUSE, Command: del_last_move and Command: clear_moves

 

 

#==============================================================================
# ** Zeriab's Caterpillar Script
#------------------------------------------------------------------------------
# Zeriab
# 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]"
#
# 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. Then the switch is off they are just like any other event.
#
# Heretic:  I added a CATERPILLAR_PAUSE_SWITCH (default is 22) to be a Temporary
# way to stop the Characters Movements during Cutscenes.  While this switch is
# set to ON, Characters in the Caterpillar will not move, unless specified by
# another Event, such as a Cutscene Event.  Any of the Main Actors Movements
# will NOT be Recorded, so when the Pause Switch is turned off, the other
# Caterpillar Actors will resume any new Movements of the Main Actor (including
# those in Events.  The reason that this was added is that while the Active
# switch is ON, the other Characters continue to follow the Main Actor, however
# turning the Active Switch OFF, then ON again causes everyone in the 
# Caterpillar Train to stack on top of the Main Character.

# 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.
#
# Heretic:  I also added two additional Commands that need to be called
# by running a SCRIPT in an EVENT.  The two Commands are:
#
# clear_moves
# del_last_move
#
# Call these Commands by running:
# $game_system.caterpillar.clear_moves
# $game_system.caterpillar.del_last_move
#
# clear_moves erases all of the characters movements.  I found this to be
# semi useful at the end of cutscenes while trying to get any following
# characters back into a Caterpillar position when returning control of
# the Players Character to the Player.  This usually is needed when
# Caterpillar Pause is turned ON and OFF in different locations, as 
# the Actors will try to walk to that previous location.
#
# del_last_move is useful for allowing the Player to move the Main Character
# on to a Tile that the rest of the Caterpillar Characters should NOT go
# for example, a bridge that falls away just as the Player steps on it, then
# steps back off of it.  In this situation, it would appear pretty strange
# to allow the rest of the Caterpillar to walk over a place where the 
# Bridge had just fallen away and preventing future Player Movement
# across that Tile.
#
# ---  NOTES ---
#
#  I've found it to be useful when creating new maps to create ONE Placeholder
#  Event, followed by ALL of your games characters, whether they are going
#  to be in your party on the new mapscreen or not.  This has less to do with
#  the way Zeriab's script works, and more to do with the way that the 
#  Multiple Message Windows script works.  Zeriab's script works by getting
#  the Events by Event Name, hence the requirement for "Name\cat_actor[3]" of
#  each event expected for the Caterpillar.  Unfortunately, the MMW Script
#  does NOT do quite as excellent of a job of identifying events by Name, but
#  instead, by Event ID.  Event ID's are created in ORDER.  Thus, the first event
#  that you creat will be EV001, and the next will be EV002, followed by EV003, so
#  on and so forth.  However, if you delete EV002 and have FIVE events, the NEXT
#  Event to be created will be the LOWEST POSSIBLE EVENT ID NUMBER.  Thus, if you
#  deleted EV002, then create a New Event, that New Event will take that lowest
#  number, making the New Event EV0002.  This is important because the MMW Script
#  calls by Event ID.  So during a Cutscene with your Characters, you have to
#  refer to them by \P[0] for the Main Character, and it skips EV0001 for some
#  reason, then goes to EV002 as the 2nd Character.  Again, this is NOT for
#  move events, only Dialogue Events (MMW).  I've found it much easier once
#  I have set up all the Characters to have the Same Event ID on EVERY MAP.  Also
#  since the Character Events will be the most frequently moved events, it is
#  easier to do without having to hunt through the entire list, when they are 
#  all organized nicely at the top of your list.  Otherwise, you'll end up trying
#  to remember that on This Map, your 2nd Character is EV043 and on That Map, your
#  2nd Character is EV036.
#
#  Additional Note for Multiple Message Windows is that when making specific
#  characters talk by using the \P[0] or \P[2] switch,
#  DO NOT USE PRECEEDING ZEROS.
#  I.E. \P[002] is NOT the same as \P[2].  Only use \P[2] or \P[5]
#

#==============================================================================
class Game_Caterpillar
 CATERPILLAR_PAUSE_SWITCH = 22
 CATERPILLAR_ACTIVE_SWITCH = 23
 REMOVE_VISIBLE_ACTORS = false
 MAX_ACTORS = 4
 ##
 # 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
 ##
 # Clear the Move data
 #
 def clear_moves
   @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.actors
     if actor.id == actor_id
       @actors << event
       if !$game_switches[CATERPILLAR_PAUSE_SWITCH]
         event.moveto($game_player.x, $game_player.y)
         added = true
       end
     end
   end
   if remove_visible_actors? && !added && $game_switches[CATERPILLAR_ACTIVE_SWITCH]
     event.erase
   end
 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
   # Check if the caterpillar is active
   return unless $game_switches[CATERPILLAR_ACTIVE_SWITCH] && !$game_switches[CATERPILLAR_PAUSE_SWITCH]
   # 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] && !$game_switches[CATERPILLAR_PAUSE_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.actors.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?
       event.character_name = actor.character_name
     end
   end
   if remove_visible_actors?
     # Go through the old actors to see if any should be erased
     for actor in old_actors
       unless @actors.include?(actor)
         actor.erase
       end
     end
   end
 end
 ##
 # Delete Last Characters Movement
 # (Call with $game_system.caterpillar.del_last_move)
 #
 def del_last_move
   @move_list.delete_at(0)
 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)
 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
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_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?
   if Module.constants.include?('SDK')
     alias zeriab_caterpillar_game_event_update_movement  :update_movement
   else
     alias zeriab_caterpillar_game_event_update  :update
   end
 end
 ##
 # Object Initialization
 #
 def initialize(map_id, event, *args)
   # Default update
   zeriab_caterpillar_game_event_initialize(map_id, event, *args)
   # Check if the caterpillar is active
   return unless $game_switches[Game_Caterpillar::CATERPILLAR_ACTIVE_SWITCH]
   # Check for caterpillar actor denomination
   check_caterpillar
 end
 ##
 # Check for caterpillar actor denomination
 #
 def check_caterpillar
   # 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
 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
 ##
 # SDK and Non-SDK stuff
 #
 if Module.constants.include?('SDK')
   ##
   # Update Movement
   #
   def update_movement
     if @caterpillar_actor.nil? || move_list.empty? ||
        !$game_switches[Game_Caterpillar::CATERPILLAR_ACTIVE_SWITCH]
       return zeriab_caterpillar_game_event_update_movement
     end
     # Interrupt if not stopping
     if jumping? or moving?
       return
     end
     # 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
 else # Non-SDK version
   ##
   # Update Movement
   #
   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
 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 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

 

Share this post


Link to post
Share on other sites
  • 0

I think...

 

 

def del_last_move

@move_list.delete_at(i)

end

 

I think this would work on non-updated RMXPs...

(WoRKS on ME!)

Share this post


Link to post
Share on other sites
  • 0

Wouldnt it work the same on updated RMXPs too?

 

Figured that out a while ago, notice the date... And learned a few new tricks since then.

Share this post


Link to post
Share on other sites
  • 0

100% YES!!! Its not about the version of your RMXP, its about the scriptings...

 

PS:(YOU WANT TO EXTRACT RGSS FROM RMXP GAMES? PM ME at quest.major@yahoo.com)

 

I've Extracted RGSS from many games and used their scripts...

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...