Twin Matrix
Member
When I open the Menu (basically switching scenes, then?) the caterpillar resets when I go back to the game and all actors are on the main actor (like what happens when transporting to a new map, etc.). Could you help me pleassee? ^_^ I have no clue where to start.~
The script is divided into some parts.
Spriteset_Map (handles the sprites):
Game_Map (updates):
Game_MoveCommand:
And the Class Game_TrainActor, where the actors are initialized:
And intializing the actual train in class Game_Train:
And the last bit of script that seems to have something to do with the issue:
Thanks! ^_^
The script is divided into some parts.
Spriteset_Map (handles the sprites):
Code:
#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
# Â This class brings together map screen sprites, tilemaps, etc.
# Â It's used within the Scene_Map class.
#==============================================================================
Â
class Spriteset_Map
 #--------------------------------------------------------------------------
 # * Object Initialization
 #--------------------------------------------------------------------------
 def initialize
  # Make viewports
  @viewport1 = Viewport.new(0, 0, 640, 480)
  @viewport2 = Viewport.new(0, 0, 640, 480)
  @viewport3 = Viewport.new(0, 0, 640, 480)
  @viewport2.z = 200
  @viewport3.z = 5000
  # Make tilemap
  @tilemap = Tilemap.new(@viewport1)
  @tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
  for i in 0..6
   autotile_name = $game_map.autotile_names[i]
   @tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name)
  end
  @tilemap.map_data = $game_map.data
  @tilemap.priorities = $game_map.priorities
 Â
 Â
 Â
  # Make panorama plane
  @panorama = Plane.new(@viewport1)
  @panorama.z = -1000
  # Make fog plane
  @fog = Plane.new(@viewport1)
  @fog.z = 3000
 Â
 Â
 Â
 Â
  #DOUBLE FOG
    # Make fog2 plane
  @fog2 = Plane.new(@viewport1)
  @fog2.z = 3050
 Â
 Â
 Â
 Â
  #WoaR map name dream world mapname dreamworld
  #if $data_mapinfos[$game_map.id].name.include?("Dream")
  if $currentmapname.include?("Dreamworld")
   @fog.z = -50
  end
 Â
Â
 Â
  # Make character sprites
  @character_sprites = []
  for i in $game_map.events.keys.sort
   sprite = Sprite_Character.new(@viewport1, $game_map.events[i])
   @character_sprites.push(sprite)
  end
  @character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
  $game_train.refresh
  for actor in $game_train.actors
   @character_sprites.push(Sprite_Character.new(@viewport1, actor))
   actor.moveto($game_player.x, $game_player.y)
  end
  $game_train.clear_movelist
  # Make weather
  @weather = RPG::Weather.new(@viewport1)
  # Make picture sprites
  @picture_sprites = []
  for i in 1..50
   @picture_sprites.push(Sprite_Picture.new(@viewport2,
    $game_screen.pictures[i]))
  end
  # Make timer sprite
  @timer_sprite = Sprite_Timer.new
  # Frame update
 Â
  update
 end
end
Â
Game_Map (updates):
Code:
#------------------------------------------------------------------------------
# This class handles the map. It includes scrolling and passable determining
# functions. Refer to "$game_map" for the instance of this class.
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Refresh map if necessary
if $game_map.need_refresh
refresh
end
# If scrolling
if @scroll_rest > 0
# Change from scroll speed to distance in map coordinates
distance = 2 ** @scroll_speed
# Execute scrolling
case @scroll_direction
when 2 # Down
scroll_down(distance)
when 4 # Left
scroll_left(distance)
when 6 # Right
scroll_right(distance)
when 8 # Up
scroll_up(distance)
end
# Subtract distance scrolled
@scroll_rest -= distance
end
# Update map event
for event in @events.values
event.update
end
# update train actors
for actor in $game_train.actors
actor.update
end
# Update common event
for common_event in @common_events.values
common_event.update
end
# Manage fog scrolling
@fog_ox -= @fog_sx / 8.0
@fog_oy -= @fog_sy / 8.0
# Manage change in fog color tone
if @fog_tone_duration >= 1
d = @fog_tone_duration
target = @fog_tone_target
@fog_tone.red = (@fog_tone.red * (d - 1) + target.red) / d
@fog_tone.green = (@fog_tone.green * (d - 1) + target.green) / d
@fog_tone.blue = (@fog_tone.blue * (d - 1) + target.blue) / d
@fog_tone.gray = (@fog_tone.gray * (d - 1) + target.gray) / d
@fog_tone_duration -= 1
end
# Manage change in fog opacity level
if @fog_opacity_duration >= 1
d = @fog_opacity_duration
@fog_opacity = (@fog_opacity * (d - 1) + @fog_opacity_target) / d
@fog_opacity_duration -= 1
end
end
end
Game_MoveCommand:
Code:
class Game_MoveCommand
attr_accessor :code
attr_accessor :args
def initialize(code, args)
@code = code
@args = args
end
end
And the Class Game_TrainActor, where the actors are initialized:
Code:
class Game_TrainActor < Game_Character
attr_accessor :move_speed
attr_accessor :return_to_player
attr_accessor :move_route_forcing
def initialize(actor_index)
super()
# they should be able to be walked through
@through = true
@actor_index = actor_index
@return_to_player = false
$directionfixcaterpillar = false # WoaR
$nayco_current_charset = "0014-Butterfly3_Flying"
refresh
end
# refresh the character sprite
def refresh
actor = $game_party.actors[@actor_index]
if actor == nil and @actor_index != 4
@character_name = ""
#WoaR begin
#=begin
#else
elsif @actor_index == 4
if $nayco_in_party == true # Turn != for testing
#if $game_party.actors[0].name == "Hellena" or $game_party.actors[1].name == "Hellena" or $game_party.actors[2].name == "Hellena" or $game_party.actors[3].name == "Hellena"
@character_name = $nayco_current_charset
@character_hue = 0
@direction = $game_player.direction
##### Checks for turning train off for worldmap ####### vv WoaR
if $currentmapname != nil
if $currentmapname.include?("Worldmap")
@transparent = true
else
if $game_switches[TRANSPARENT_SWITCH]
@transparent = true
else
@transparent = $game_player.transparent if $game_switches[170] != true #woar opacity fix
end
end
################ ^^ WoaR
else
if $game_switches[TRANSPARENT_SWITCH]
@transparent = true
else
@transparent = $game_player.transparent if $game_switches[170] != true #woar opacity fix
end
end
end
#=end
else
#WoaR end
@character_name = actor.character_name
@character_hue = actor.character_hue
@direction = $game_player.direction
##### Checks for turning train off for worldmap ####### vv WoaR
if $currentmapname != nil
if $currentmapname.include?("Worldmap")
@transparent = true
else
if $game_switches[TRANSPARENT_SWITCH]
@transparent = true
else
@transparent = $game_player.transparent if $game_switches[170] != true #woar opacity fix
end
end
################ ^^ WoaR
else
if $game_switches[TRANSPARENT_SWITCH]
@transparent = true
else
@transparent = $game_player.transparent if $game_switches[170] != true #woar opacity fix
end
end
end
@opacity = 255
@blend_type = 0
@through = true
@curr_terrain = terrain_tag
##### WoaR start
$movingcountx = 0
$movingcount0 = 0
$movingcount1 = 0
$movingcount2 = 0
$movingcount3 = 0
$move = 0 #Mouse fix
$mouse_moving_down = false
$mouse_moving_left = false
$mouse_moving_right = false
$mouse_moving_up = false
@opacity = $game_player.opacity if $game_switches[170] != true #woar opacity fix
@blend_type = $game_player.blend_type
@move_speed = $game_player.move_speed
#@direction_fix = $game_player.direction_fix
@direction_fix = false if $game_player.direction_fix == false
@always_on_top = $game_player.always_on_top
@walk_anime = $game_player.walk_anime
@step_anime = $game_player.step_anime
@step_anime = true if @actor_index == 4
##### WoaR end
end
# frame update
def update
if @return_to_player
if self.x == $game_player.x and self.y == $game_player.y
@return_to_player = false
@move_route_forcing = false
else
move_toward_player
end
end
##### Checks for turning train off for worldmap ####### vv WoaR
if $currentmapname != nil
if $currentmapname.include?("Worldmap")
@transparent = true
else
if $game_switches[TRANSPARENT_SWITCH]
@transparent = true
else
@transparent = $game_player.transparent if $game_switches[170] != true #woar opacity fix
end
end
################ ^^ WoaR
else
if $game_switches[TRANSPARENT_SWITCH]
@transparent = true
else
@transparent = $game_player.transparent if $game_switches[170] != true #woar opacity fix
end
end
if $directionfixcaterpillar == true
$df_temp_x = $game_player.x
$df_temp_y = $game_player.y
$directionfix1 = true
$directionfix2 = true
$directionfix3 = true
$directionfix4 = true
$directionfixcaterpillar = false
end
if $directionfix1 == true and @actor_index == 1
if @x == $df_temp_x and @y == $df_temp_y
@direction = $game_player.direction
@direction_fix = $game_player.direction_fix
$directionfix1 = false
end
elsif $directionfix2 == true and @actor_index == 2
if @x == $df_temp_x and @y == $df_temp_y
@direction = $game_player.direction
@direction_fix = $game_player.direction_fix
$directionfix2 = false
end
elsif $directionfix3 == true and @actor_index == 3
if @x == $df_temp_x and @y == $df_temp_y
@direction = $game_player.direction
@direction_fix = $game_player.direction_fix
$directionfix3 = false
end
elsif $directionfix4 == true and @actor_index == 4
if @x == $df_temp_x and @y == $df_temp_y
@direction = $game_player.direction
@direction_fix = $game_player.direction_fix
$directionfix4 = false
end
end
#p @character_name if @actor_index == 4
#p @opacity if @actor_index == 4
######################################################## WoaR start
######################################################## WoaR start
#if !moving? and $game_player.character_name.include?("-Running")
#$movingcount += 1 if $movingcount < 10
#end
if $game_switches[157] != true
actor = $game_party.actors[@actor_index]
if actor == nil and @actor_index != 4
@character_name = ""
#WoaR begin
=begin
#else
elsif @actor_index == 4
if !$nayco_in_party
#if $game_party.actors[0].name == "Hellena" or $game_party.actors[1].name == "Hellena" or $game_party.actors[2].name == "Hellena" or $game_party.actors[3].name == "Hellena"
@character_name = "3305-Cliche"
@character_hue = 0
@direction = $game_player.direction
if $game_switches[TRANSPARENT_SWITCH]
@transparent = false
else
@transparent = $game_player.transparent
end
end
=end
elsif @actor_index == 1 #@actor_index is 1, 2 or 3 w/o party members
$movingcount1 = 0 if moving? and $movingcount1 != 0
$movingcount1_2 = 0 if !moving? and $movingcount1_2 != 0
if moving? and !@character_name.include?("-Running")
limit2 = 2
$movingcount1_2 += 1 if $movingcount1_2 < limit2
if $movingcount1_2 == limit2
@character_name = @character_name + "-Running"
$movingcount1 = 0
@pattern = rand(4) # Returns 0, 1, 2 or 3
end
elsif !moving? and @character_name.include?("-Running")
$movingcount1 += 1 if $movingcount1 < 6
if $movingcount1 == 6
@character_name = @character_name.split('-Running').last
$movingcount1 = 0
end
end
elsif @actor_index == 2 #@actor_index is 1, 2 or 3 w/o party members
$movingcount2 = 0 if moving? and $movingcount2 != 0
$movingcount2_2 = 0 if !moving? and $movingcount2_2 != 0
if moving? and !@character_name.include?("-Running")
limit2 = 4
$movingcount2_2 += 1 if $movingcount2_2 < limit2
if $movingcount2_2 == limit2
@character_name = @character_name + "-Running"
$movingcount2 = 0
@pattern = rand(4) # Returns 0, 1, 2 or 3
end
elsif !moving? and @character_name.include?("-Running")
$movingcount2 += 1 if $movingcount2 < 4
if $movingcount2 == 4
@character_name = @character_name.split('-Running').last
$movingcount2 = 0
end
end
elsif @actor_index == 3 #@actor_index is 1, 2 or 3 w/o party members
$movingcount3 = 0 if moving? and $movingcount3 != 0
$movingcount3_2 = 0 if !moving? and $movingcount3_2 != 0
if moving? and !@character_name.include?("-Running")
limit2 = 6
$movingcount3_2 += 1 if $movingcount3_2 < limit2
if $movingcount3_2 == limit2
@character_name = @character_name + "-Running"
$movingcount3 = 0
@pattern = rand(4) # Returns 0, 1, 2 or 3
end
elsif !moving? and @character_name.include?("-Running")
$movingcount3 += 1 if $movingcount3 < 7
if $movingcount3 == 7
@character_name = @character_name.split('-Running').last
$movingcount3 = 0
end
end
end
$movingcount0 = 0 if moving?
if moving? and !$game_player.character_name.include?("-Running")
$game_player.character_name = $game_player.character_name + "-Running"
@pattern = rand(4) # Returns 0, 1, 2 or 3
#$movingcount0 = 0
elsif !moving? and $game_player.character_name.include?("-Running")
$movingcount0 += 1 if $movingcount0 < 5
if $movingcount0 == 5
$game_player.character_name = $game_player.character_name.split('-Running').last
$movingcount0 = 0
end
end
elsif $game_switches[157] == true and @character_name.include?("-Running")
@character_name = @character_name.split('-Running').last
elsif $game_switches[157] == true and $game_player.character_name.include?("-Running")
$game_player.character_name = $game_player.character_name.split('-Running').last
end
# Movement fix
$movingcountx = 0 if moving?
if moving?
#$mouse_moving_down = true if $mouse_moving_down == false and $game_player.direction == 2
#$mouse_moving_left = true if $mouse_moving_left == false and $game_player.direction == 4
#$mouse_moving_right = true if $mouse_moving_right == false and $game_player.direction == 6
#$mouse_moving_up = true if $mouse_moving_up == false and $game_player.direction == 8
elsif !moving?
$movingcountx += 1 if $movingcountx < 5
#if $movingcountx == 5
$mouse_moving_down = false if $mouse_moving_down == true
$mouse_moving_left = false if $mouse_moving_left == true
$mouse_moving_right = false if $mouse_moving_right == true
$mouse_moving_up = false if $mouse_moving_up == true
$movingcountx = 0
#end
end
@opacity = $game_player.opacity if $game_switches[170] != true #woar opacity fix
@blend_type = $game_player.blend_type
@move_speed = $game_player.move_speed
#@direction_fix = $game_player.direction_fix
@direction_fix = false if $game_player.direction_fix == false
@always_on_top = $game_player.always_on_top
@walk_anime = $game_player.walk_anime
@step_anime = $game_player.step_anime
@step_anime = true if @actor_index == 4
######################################################## WoaR end
######################################################## WoaR end
super
end
# z coord of train actor
def screen_z(height = 0)
# place the train actor under the player if on the same square
if $game_player.x == @x and $game_player.y == @y
return $game_player.screen_z(height) - 1
end
# nope, use normal z
super(height)
end
end
And intializing the actual train in class Game_Train:
Code:
class Game_Train
attr_reader :actors
attr_accessor :returning_to_player
def initialize
@returning_to_player = false
@move_list = []
@actors = []
@actors.push(Game_TrainActor.new(1))
@actors.push(Game_TrainActor.new(2))
@actors.push(Game_TrainActor.new(3))
@actors.push(Game_TrainActor.new(4))
end
def add_move(command)
unless @move_list.empty?
move_actors
end
@move_list.unshift(command)
if @move_list.size > @actors.size
@move_list.pop
end
# WOAR BEGIN
if $game_player.character_name.include?("Hellen")
case @move_list[0].code
when DOWN
@actors[3].move_down
when LEFT
@actors[3].move_left #if $game_player.character_name.include?("Hellen")#(@move_list[1].args[0])
when RIGHT
@actors[3].move_right
when UP
@actors[3].move_up
when DOWN_LEFT
@actors[3].move_lower_left
when DOWN_RIGHT
@actors[3].move_lower_right
when UP_LEFT
@actors[3].move_upper_left
when UP_RIGHT
@actors[3].move_upper_right
when JUMP
@actors[3].jump(@move_list[0].args[0], @move_list[0].args[1])
end
end
# WOAR END
end
def refresh
for actor in @actors
actor.refresh
end
end
def move_actors
@move_list.each_index do |i|
if @actors[i] != nil and !@actors[i].move_route_forcing
case @move_list[i].code
when DOWN
@actors[i].move_down(@move_list[i].args[0]) unless i == 3 # WoaR: unless i == 3
if @actors[i].character_name.include?("Hellen") #WOAR
@actors[3].move_down(@move_list[i].args[0])
end
when LEFT
@actors[i].move_left(@move_list[i].args[0]) unless i == 3 # WoaR: unless i == 3
if @actors[i].character_name.include?("Hellen") #WOAR
@actors[3].move_left(@move_list[i].args[0])
end
when RIGHT
@actors[i].move_right(@move_list[i].args[0]) unless i == 3 # WoaR: unless i == 3
if @actors[i].character_name.include?("Hellen") #WOAR
@actors[3].move_right(@move_list[i].args[0])
end
when UP
@actors[i].move_up(@move_list[i].args[0]) unless i == 3 # WoaR: unless i == 3
if @actors[i].character_name.include?("Hellen") #WOAR
@actors[3].move_up(@move_list[i].args[0])
end
when DOWN_LEFT
@actors[i].move_lower_left unless i == 3 # WoaR: unless i == 3
if @actors[i].character_name.include?("Hellen") #WOAR
@actors[3].move_lower_left
end
when DOWN_RIGHT
@actors[i].move_lower_right unless i == 3 # WoaR: unless i == 3
if @actors[i].character_name.include?("Hellen") #WOAR
@actors[3].move_lower_right
end
when UP_LEFT
@actors[i].move_upper_left unless i == 3 # WoaR: unless i == 3
if @actors[i].character_name.include?("Hellen") #WOAR
@actors[3].move_upper_left
end
when UP_RIGHT
@actors[i].move_upper_right unless i == 3 # WoaR: unless i == 3
if @actors[i].character_name.include?("Hellen") #WOAR
@actors[3].move_upper_right
end
when JUMP
@actors[i].jump(@move_list[i].args[0], @move_list[i].args[1]) unless i == 3 # WoaR: unless i == 3
if @actors[i].character_name.include?("Hellen") #WOAR
@actors[3].jump(@move_list[i].args[0], @move_list[i].args[1])
end
end
end
end
end
def move_nayco(x_dest,y_dest)
@actors[3].jump(x_dest,y_dest)
end
def clear_movelist
@move_list = []
end
def return_to_player
clear_movelist
@returning_to_player = true
end
end
And the last bit of script that seems to have something to do with the issue:
Code:
class Game_Temp
attr_accessor :transfer_move_route # what train actor to transfer move route to
alias train_init initialize
def initialize
train_init
@transfer_move_route = 0
end
end
Thanks! ^_^