Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Fukuyama Caterpillar Edit

I'm pretty sure this is the last scripting help my game needs. (I plan to have the game completed in less than 2 weeks!)

So the problem is that the followers are not solid. What I mean is that events will go right through them! It is pretty crucial that they are solid since I have many puzzles set up to work that way. Here's the script I hope it's not a hard edit to make and it would be very much appreciated!!!

Code:
#
# Train_Actor
#
# fukuyama@alles.or.jp
# http://www4.big.or.jp/~fukuyama/
#

# ●透明状態用スイッチ設定
# true だとスイッチ制御を行う
# TRAIN_ACTOR_TRANSPARENT_SWITCH = true
TRAIN_ACTOR_TRANSPARENT_SWITCH = false
# ●透明状態用スイッチ番号
# この番号のスイッチがONだと透明になる
TRAIN_ACTOR_TRANSPARENT_SWITCHES_INDEX = 20

# 定数
#Input::DOWN  = 2
#Input::LEFT  = 4
#Input::RIGHT = 6
#Input::UP    = 8
DOWN_LEFT  = 1
DOWN_RIGHT = 3
UP_LEFT    = 7
UP_RIGHT   = 9
JUMP       = 5

class Game_Party_Actor < Game_Character
  def initialize
    super()
    @through = true
  end
  def setup(actor)
    # キャラクターのファイル名と色相を設定
    if actor != nil
      @character_name = actor.character_name
      @character_hue = actor.character_hue
    else
      @character_name = ""
      @character_hue = 0
    end
    # 不透明度と合成方法を初期化
    @opacity = 255
    @blend_type = 0
  end
  def screen_z(height = 0)
    if $game_player.x == @x and $game_player.y == @y
      return $game_player.screen_z(height) - 1
    end
    super(height)
  end
  #--------------------------------------------------------------------------
  # ● 下に移動
  #     turn_enabled : その場での向き変更を許可するフラグ
  #--------------------------------------------------------------------------
  def move_down(turn_enabled = true)
    # 下を向く
    if turn_enabled
      turn_down
    end
    # 通行可能な場合
    if passable?(@x, @y, Input::DOWN)
      # 下を向く
      turn_down
      # 座標を更新
      @y += 1
    end
  end
  #--------------------------------------------------------------------------
  # ● 左に移動
  #     turn_enabled : その場での向き変更を許可するフラグ
  #--------------------------------------------------------------------------
  def move_left(turn_enabled = true)
    # 左を向く
    if turn_enabled
      turn_left
    end
    # 通行可能な場合
    if passable?(@x, @y, Input::LEFT)
      # 左を向く
      turn_left
      # 座標を更新
      @x -= 1
    end
  end
  #--------------------------------------------------------------------------
  # ● 右に移動
  #     turn_enabled : その場での向き変更を許可するフラグ
  #--------------------------------------------------------------------------
  def move_right(turn_enabled = true)
    # 右を向く
    if turn_enabled
      turn_right
    end
    # 通行可能な場合
    if passable?(@x, @y, Input::RIGHT)
      # 右を向く
      turn_right
      # 座標を更新
      @x += 1
    end
  end
  #--------------------------------------------------------------------------
  # ● 上に移動
  #     turn_enabled : その場での向き変更を許可するフラグ
  #--------------------------------------------------------------------------
  def move_up(turn_enabled = true)
    # 上を向く
    if turn_enabled
      turn_up
    end
    # 通行可能な場合
    if passable?(@x, @y, Input::UP)
      # 上を向く
      turn_up
      # 座標を更新
      @y -= 1
    end
  end
  #--------------------------------------------------------------------------
  # ● 左下に移動
  #--------------------------------------------------------------------------
  def move_lower_left
    # 向き固定でない場合
    unless @direction_fix
      # 右向きだった場合は左を、上向きだった場合は下を向く
      @direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::UP ? Input::DOWN : @direction)
    end
    # 下→左、左→下 のどちらかのコースが通行可能な場合
    if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or
       (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN))
      # 座標を更新
      @x -= 1
      @y += 1
    end
  end
  #--------------------------------------------------------------------------
  # ● 右下に移動
  #--------------------------------------------------------------------------
  def move_lower_right
    # 向き固定でない場合
    unless @direction_fix
      # 左向きだった場合は右を、上向きだった場合は下を向く
      @direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::UP ? Input::DOWN : @direction)
    end
    # 下→右、右→下 のどちらかのコースが通行可能な場合
    if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or
       (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN))
      # 座標を更新
      @x += 1
      @y += 1
    end
  end
  #--------------------------------------------------------------------------
  # ● 左上に移動
  #--------------------------------------------------------------------------
  def move_upper_left
    # 向き固定でない場合
    unless @direction_fix
      # 右向きだった場合は左を、下向きだった場合は上を向く
      @direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::DOWN ? Input::UP : @direction)
    end
    # 上→左、左→上 のどちらかのコースが通行可能な場合
    if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or
       (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP))
      # 座標を更新
      @x -= 1
      @y -= 1
    end
  end
  #--------------------------------------------------------------------------
  # ● 右上に移動
  #--------------------------------------------------------------------------
  def move_upper_right
    # 向き固定でない場合
    unless @direction_fix
      # 左向きだった場合は右を、下向きだった場合は上を向く
      @direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::DOWN ? Input::UP : @direction)
    end
    # 上→右、右→上 のどちらかのコースが通行可能な場合
    if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or
       (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP))
      # 座標を更新
      @x += 1
      @y -= 1
    end
  end

  def set_move_speed(move_speed)
    @move_speed = move_speed
  end
end

class Spriteset_Map
  def setup_actor_character_sprites?
    return @setup_actor_character_sprites_flag != nil
  end
  def setup_actor_character_sprites(characters)
    if !setup_actor_character_sprites?
      index_game_player = 0
      @character_sprites.each_index do |i|
        if @character_sprites[i].character.instance_of?(Game_Player)
          index_game_player = i
          break
        end
      end
      for character in characters.reverse
        @character_sprites.unshift(
          Sprite_Character.new(@viewport1, character)
        )
      end
      @setup_actor_character_sprites_flag = true
    end
  end
end

class Scene_Map
  def setup_actor_character_sprites(characters)
    @spriteset.setup_actor_character_sprites(characters)
  end
end

class Game_Party
  def set_transparent_actors(transparent)
    @transparent = transparent
  end
  def setup_actor_character_sprites
    if @characters == nil
      @characters = []
      for i in 1 .. 4
        @characters.push(Game_Party_Actor.new)
      end
    end
    if @actors_chach == nil
      @actors_chach = []
    end
    if @actors_chach != @actors
      @actors_chach = @actors.clone
      for i in 1 .. 4
        @characters[i - 1].setup(actors[i])
      end
    end
    if $scene.instance_of?(Scene_Map)
      $scene.setup_actor_character_sprites(@characters)
    end
  end
  def update_party_actors
    setup_actor_character_sprites
    transparent = $game_player.transparent
    if transparent == false
      if TRAIN_ACTOR_TRANSPARENT_SWITCH
        transparent = $game_switches[TRAIN_ACTOR_TRANSPARENT_SWITCHES_INDEX]
      else
        transparent = $game_player.transparent
      end
    end
    for character in @characters
      character.transparent = transparent
      character.set_move_speed($game_player.get_move_speed)
      character.update
    end
  end
  def moveto_party_actors( x, y )
    setup_actor_character_sprites
    for character in @characters
      character.moveto( x, y )
    end
    if @move_list == nil
      @move_list = []
    end
    for i in 0 .. 10
      @move_list[i] = nil
    end
  end
  def move_party_actors
    if @move_list == nil
      @move_list = []
      for i in 0 .. 10
        @move_list[i] = nil
      end
    end
    @move_list.each_index do |i|
      if @characters[i] != nil
        case @move_list[i].type
          when Input::DOWN
            @characters[i].move_down(@move_list[i].args[0])
          when Input::LEFT
            @characters[i].move_left(@move_list[i].args[0])
          when Input::RIGHT
            @characters[i].move_right(@move_list[i].args[0])
          when Input::UP
            @characters[i].move_up(@move_list[i].args[0])
          when DOWN_LEFT
            @characters[i].move_lower_left
          when DOWN_RIGHT
            @characters[i].move_lower_right
          when UP_LEFT
            @characters[i].move_upper_left
          when UP_RIGHT
            @characters[i].move_upper_right
          when JUMP
            @characters[i].jump(@move_list[i].args[0],@move_list[i].args[1])
        end
      end
    end
  end
  class Move_List_Element
    def initialize(type,args)
      @type = type
      @args = args
    end
    def type() return @type end
    def args() return @args end
  end
  def add_move_list(type,*args)
    @move_list.unshift(Move_List_Element.new(type,args)).pop
  end
  def move_down_party_actors(turn_enabled = true)
    move_party_actors
    add_move_list(Input::DOWN,turn_enabled)
  end
  def move_left_party_actors(turn_enabled = true)
    move_party_actors
    add_move_list(Input::LEFT,turn_enabled)
  end
  def move_right_party_actors(turn_enabled = true)
    move_party_actors
    add_move_list(Input::RIGHT,turn_enabled)
  end
  def move_up_party_actors(turn_enabled = true)
    move_party_actors
    add_move_list(Input::UP,turn_enabled)
  end
  def move_lower_left_party_actors
    move_party_actors
    add_move_list(DOWN_LEFT)
  end
  def move_lower_right_party_actors
    move_party_actors
    add_move_list(DOWN_RIGHT)
  end
  def move_upper_left_party_actors
    move_party_actors
    add_move_list(UP_LEFT)
  end
  def move_upper_right_party_actors
    move_party_actors
    add_move_list(UP_RIGHT)
  end
  def jump_party_actors(x_plus, y_plus)
    move_party_actors
    add_move_list(JUMP,x_plus, y_plus)
  end
end

module Game_Player_Module
  def update
    $game_party.update_party_actors
    super
  end
  def moveto( x, y )
    super
    $game_party.moveto_party_actors( x, y )
  end
  def move_down(turn_enabled = true)
    if passable?(@x, @y, Input::DOWN)
      $game_party.move_down_party_actors(turn_enabled)
    end
    super(turn_enabled)
  end
  def move_left(turn_enabled = true)
    if passable?(@x, @y, Input::LEFT)
      $game_party.move_left_party_actors(turn_enabled)
    end
    super(turn_enabled)
  end
  def move_right(turn_enabled = true)
    if passable?(@x, @y, Input::RIGHT)
      $game_party.move_right_party_actors(turn_enabled)
    end
    super(turn_enabled)
  end
  def move_up(turn_enabled = true)
    if passable?(@x, @y, Input::UP)
      $game_party.move_up_party_actors(turn_enabled)
    end
    super(turn_enabled)
  end
  def move_lower_left
    # 下→左、左→下 のどちらかのコースが通行可能な場合
    if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or
       (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN))
      $game_party.move_lower_left_party_actors
    end
    super
  end
  def move_lower_right
    # 下→右、右→下 のどちらかのコースが通行可能な場合
    if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or
       (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN))
      $game_party.move_lower_right_party_actors
    end
    super
  end
  def move_upper_left
    # 上→左、左→上 のどちらかのコースが通行可能な場合
    if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or
       (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP))
      $game_party.move_upper_left_party_actors
    end
    super
  end
  def move_upper_right
    # 上→右、右→上 のどちらかのコースが通行可能な場合
    if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or
       (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP))
      $game_party.move_upper_right_party_actors
    end
    super
  end
  def jump(x_plus, y_plus)
    # 新しい座標を計算
    new_x = @x + x_plus
    new_y = @y + y_plus
    # 加算値が (0,0) の場合か、ジャンプ先が通行可能な場合
    if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y, 0)
      $game_party.jump_party_actors(x_plus, y_plus)
    end
    super(x_plus, y_plus)
  end
 
  # -----------------------------------------------
  # move_speed を外から見れるように
  # -----------------------------------------------
  def get_move_speed
    return @move_speed
  end
end

class Game_Player
  include Game_Player_Module
end

Please help me someone this is very important for my game and my game is nearly done!
 
Okay, a bit experimental here (I don't really understand that script and especially not the comments) but try adding this to Game_Character's def_passable function.
Code:
    for i in 0..$game_party.size - 1
      return false if $game_party[i].x == x or $game_party[i].y == y
    end
EDIT: Just realised even if it does work, the player should also be blocked.
 
Ya, I couldn't get that to work. I actually was using an old version of this script which had the followers solid. However, that script had a terrible bug so I used this new version. But I set up so many puzzles with the old script before I discovered the bug. Man, I guess worst case scenario I might be able to convert back to the old script and just make some programming changes in order to avoid the bug. That'd probably be better than changing all the puzzles. Either way is going to be a hassle though. I'll post the old script just in case it might help:

Code:
# train_actor
=begin

Caterpillar walking script

Copyright (C) 2005 fukuyama

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

http://www.gnu.org/licenses/lgpl.html
http://www.opensource.gr.jp/lesser/lgpl.ja.html

=end

# Config.rb
#==============================================================================
# â–  Train_Actor::Config
#------------------------------------------------------------------------------
# Caterpillar movement of actor is carried out on map
#==============================================================================

module Train_Actor

# ●Switch setup for transparent status
# When true, switch control is used
# TRANSPARENT_SWITCH = true
TRANSPARENT_SWITCH = false

# ●Switch number for transparent status
# When TRANSPARENT_SWITCH is true, transparency will be activated when the switch of this number is on
TRANSPARENT_SWITCHES_INDEX = 20

# ●Maximum number of actors
# There will be support for a large number of people in a party in the future...
TRAIN_ACTOR_SIZE_MAX = 4

# Constants
DOWN_LEFT  = 1
DOWN_RIGHT = 3
UP_LEFT    = 7
UP_RIGHT   = 9
JUMP       = 5

end

# rgss

# Spriteset_Map_Module.rb
#==============================================================================
# â–  Spriteset_Map_Module
#------------------------------------------------------------------------------
# Caterpillar movement of actor is carried out on map
#==============================================================================

module Train_Actor

module Spriteset_Map_Module
 def setup_actor_character_sprites?
   return @setup_actor_character_sprites_flag != nil
 end
 def setup_actor_character_sprites(characters)
   if !setup_actor_character_sprites?
     for character in characters.reverse
       @character_sprites.unshift(
         Sprite_Character.new(@viewport1, character)
       )
     end
     @setup_actor_character_sprites_flag = true
   end
 end
end

end

class Spriteset_Map
 include Train_Actor::Spriteset_Map_Module
end

# Scene_Map_Module.rb
#==============================================================================
# â–  Scene_Map_Module
#------------------------------------------------------------------------------
# Caterpillar movement of actor is carried out on map
#==============================================================================

module Train_Actor

module Scene_Map_Module
 def setup_actor_character_sprites(characters)
   @spriteset.setup_actor_character_sprites(characters)
 end
end

end

class Scene_Map
 include Train_Actor::Scene_Map_Module
end

# Game_Party_Module.rb
#==============================================================================
# â–  Game_Party_Module
#------------------------------------------------------------------------------
# Caterpillar movement of actor is carried out on map
#==============================================================================

module Train_Actor

module Game_Party_Module
 attr_reader :characters
 def actors_dead?
   for actor in actors
     if actor.dead?
       return true
     end
   end
   return false
 end
 def update_party_order
   if not actors_dead?
     return actors
   end
   alive_actors = []
   dead_actors = []
   for actor in actors
     if actor.dead?
       dead_actors.push actor
     else
       alive_actors.push actor
     end
   end
   return alive_actors + dead_actors
 end
 def setup_actor_character_sprites
   if @characters.nil?
     @characters = []
     for i in 1 ... TRAIN_ACTOR_SIZE_MAX
       @characters.push(Game_Party_Actor.new)
     end
   end
   setup_actors = update_party_order
   for i in 1 ... TRAIN_ACTOR_SIZE_MAX
     @characters[i - 1].setup(setup_actors[i])
   end
   if $scene.class.method_defined?('setup_actor_character_sprites')
     $scene.setup_actor_character_sprites(@characters)
   end
 end
 def update_party_actors
   update_party_order
   setup_actor_character_sprites
   transparent = $game_player.transparent
   if transparent == false
     if TRANSPARENT_SWITCH
       transparent = $game_switches[TRANSPARENT_SWITCHES_INDEX]
     end
   end
   for character in @characters
     character.transparent = transparent
     character.move_speed = $game_player.move_speed
     character.step_anime = $game_player.step_anime
     character.update
   end
 end
 def moveto_party_actors( x, y )
   setup_actor_character_sprites
   for character in @characters
     character.moveto( x, y )
   end
   if @move_list == nil
     @move_list = []
   end
   move_list_setup
 end
 def move_party_actors
   if @move_list == nil
     @move_list = []
     move_list_setup
   end
   @move_list.each_index do |i|
     if @characters[i] != nil
       case @move_list[i].type
         when Input::DOWN
           @characters[i].move_down(@move_list[i].args[0])
         when Input::LEFT
           @characters[i].move_left(@move_list[i].args[0])
         when Input::RIGHT
           @characters[i].move_right(@move_list[i].args[0])
         when Input::UP
           @characters[i].move_up(@move_list[i].args[0])
         when DOWN_LEFT
           @characters[i].move_lower_left
         when DOWN_RIGHT
           @characters[i].move_lower_right
         when UP_LEFT
           @characters[i].move_upper_left
         when UP_RIGHT
           @characters[i].move_upper_right
         when JUMP
           @characters[i].jump(@move_list[i].args[0],@move_list[i].args[1])
       end
     end
   end
 end
 class Move_List_Element
   def initialize(type,args)
     @type = type
     @args = args
   end
   def type() return @type end
   def args() return @args end
 end
 def move_list_setup
   for i in 0 .. TRAIN_ACTOR_SIZE_MAX
     @move_list[i] = nil
   end
 end
 def add_move_list(type,*args)
   @move_list.unshift(Move_List_Element.new(type,args)).pop
 end
 def move_down_party_actors(turn_enabled = true)
   move_party_actors
   add_move_list(Input::DOWN,turn_enabled)
 end
 def move_left_party_actors(turn_enabled = true)
   move_party_actors
   add_move_list(Input::LEFT,turn_enabled)
 end
 def move_right_party_actors(turn_enabled = true)
   move_party_actors
   add_move_list(Input::RIGHT,turn_enabled)
 end
 def move_up_party_actors(turn_enabled = true)
   move_party_actors
   add_move_list(Input::UP,turn_enabled)
 end
 def move_lower_left_party_actors
   move_party_actors
   add_move_list(DOWN_LEFT)
 end
 def move_lower_right_party_actors
   move_party_actors
   add_move_list(DOWN_RIGHT)
 end
 def move_upper_left_party_actors
   move_party_actors
   add_move_list(UP_LEFT)
 end
 def move_upper_right_party_actors
   move_party_actors
   add_move_list(UP_RIGHT)
 end
 def jump_party_actors(x_plus, y_plus)
   move_party_actors
   add_move_list(JUMP,x_plus, y_plus)
 end
end

end

class Game_Party
 include Train_Actor::Game_Party_Module
end

# Game_Player_Module.rb
#==============================================================================
# â–  Game_Player_Module
#------------------------------------------------------------------------------
# Caterpillar movement of actor is carried out on map
#==============================================================================

module Train_Actor

module Game_Player_Module
 attr_reader :move_speed
 attr_reader :step_anime

 def update_party_actors
   $game_party.update_party_actors
   $game_party.actors.each do |actor|
     if actor.dead?
       next
     end
     @character_name = actor.character_name
     @character_hue = actor.character_hue
     break
   end
 end
 def update
   update_party_actors
   super
 end
 def moveto( x, y )
   $game_party.moveto_party_actors( x, y )
   super( x, y )
 end
 def move_down(turn_enabled = true)
   if passable?(@x, @y, Input::DOWN)
     $game_party.move_down_party_actors(turn_enabled)
   end
   super(turn_enabled)
 end
 def move_left(turn_enabled = true)
   if passable?(@x, @y, Input::LEFT)
     $game_party.move_left_party_actors(turn_enabled)
   end
   super(turn_enabled)
 end
 def move_right(turn_enabled = true)
   if passable?(@x, @y, Input::RIGHT)
     $game_party.move_right_party_actors(turn_enabled)
   end
   super(turn_enabled)
 end
 def move_up(turn_enabled = true)
   if passable?(@x, @y, Input::UP)
     $game_party.move_up_party_actors(turn_enabled)
   end
   super(turn_enabled)
 end
 def move_lower_left
   # When possible to move from down→left or from left→down
   if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or
      (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN))
     $game_party.move_lower_left_party_actors
   end
   super
 end
 def move_lower_right
   # When possible to move from down→right or from right→down
   if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or
      (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN))
     $game_party.move_lower_right_party_actors
   end
   super
 end
 def move_upper_left
   # When possible to move from up→left or from left→up
   if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or
      (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP))
     $game_party.move_upper_left_party_actors
   end
   super
 end
 def move_upper_right
   # When possible to move from up→right or from right→up
   if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or
      (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP))
     $game_party.move_upper_right_party_actors
   end
   super
 end
 def jump(x_plus, y_plus)
   # New coordinates are calculated
   new_x = @x + x_plus
   new_y = @y + y_plus
   # When addition values are (0,0), it is possible to jump to the destination
   if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y, 0)
     $game_party.jump_party_actors(x_plus, y_plus)
   end
   super(x_plus, y_plus)
 end
end

end

class Game_Player
 include Train_Actor::Game_Player_Module
end

# Game_Event_Module.rb
#==============================================================================
# â–  Game_Event_Module
#------------------------------------------------------------------------------
# Caterpillar movement of actor is carried out on map
#==============================================================================

module Train_Actor

module Game_Event_Module
 #--------------------------------------------------------------------------
 # ● Judgement determined
 #     x  : X coordinates
 #     y  : Y coordinates
 #     d  : Direction (0,2,4,6,8)  ※ 0 = Checks if all directions are not able to be passed (for a jump)
 # return : Passing is impossible (false), possible (true)
 #--------------------------------------------------------------------------
 def passable?(x, y, d)
   result = super(x, y, d)
   if result
     # New coordinates are searched for
     new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
     new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
     # Loops for actor in train
     for actor in $game_party.characters
       # When displayed
       if not actor.character_name.empty?
         # When actor's coordinates correspond to the destination
         if actor.x == new_x and actor.y == new_y
           # When event
           if self != $game_player
             # Passing is impossible
             return false
           end
         end
       end
     end
   end
   return result
 end
end

end

class Game_Event
 include Train_Actor::Game_Event_Module
end
 
# Game_Party_Actor.rb
#==============================================================================
# â–  Game_Party_Actor
#------------------------------------------------------------------------------
# Caterpillar movement of actor is carried out on map
#==============================================================================

module Train_Actor

class Game_Party_Actor < Game_Character
 attr_writer :move_speed
 attr_writer :step_anime

 def initialize
   super()
   @through = true
 end
 def setup(actor)
   # The file name and hue of the character are set
   if actor != nil and (not actor.dead?) # When dead, it is erased for the time being...
     @character_name = actor.character_name
     @character_hue = actor.character_hue
   else
     @character_name = ""
     @character_hue = 0
   end
   # Opacity and blending method are initialized
   @opacity = 255
   @blend_type = 0
 end
 def screen_z(height = 0)
   if $game_player.x == @x and $game_player.y == @y
     return $game_player.screen_z(height) - 1
   end
   super(height)
 end
 #--------------------------------------------------------------------------
 # ● Move down
 #     turn_enabled : Flag that permits direction change on the spot
 #--------------------------------------------------------------------------
 def move_down(turn_enabled = true)
   # Face down
   if turn_enabled
     turn_down
   end
   # When possible to pass
   if passable?(@x, @y, Input::DOWN)
     # Face down
     turn_down
     # Update coordinates
     @y += 1
   end
 end
 #--------------------------------------------------------------------------
 # ● Move left
 #     turn_enabled : Flag that permits direction change on the spot
 #--------------------------------------------------------------------------
 def move_left(turn_enabled = true)
   # Face left
   if turn_enabled
     turn_left
   end
   # When possible to pass
   if passable?(@x, @y, Input::LEFT)
     # Face left
     turn_left
     # Update coordinates
     @x -= 1
   end
 end
 #--------------------------------------------------------------------------
 # ● Move right
 #     turn_enabled : Flag that permits direction change on the spot
 #--------------------------------------------------------------------------
 def move_right(turn_enabled = true)
   # Face right
   if turn_enabled
     turn_right
   end
   # When possible to pass
   if passable?(@x, @y, Input::RIGHT)
     # Face right
     turn_right
     # Update coordinates
     @x += 1
   end
 end
 #--------------------------------------------------------------------------
 # ● Move up
 #     turn_enabled : Flag that permits direction change on the spot
 #--------------------------------------------------------------------------
 def move_up(turn_enabled = true)
   # Face up
   if turn_enabled
     turn_up
   end
   # When possible to pass
   if passable?(@x, @y, Input::UP)
     # Face up
     turn_up
     # Update coordinates
     @y -= 1
   end
 end
 #--------------------------------------------------------------------------
 # ● Move lower left
 #--------------------------------------------------------------------------
 def move_lower_left
   # When no direction fixation
   unless @direction_fix
     # Turn left when facing right, turn down when facing up
     @direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::UP ? Input::DOWN : @direction)
   end
   # When possible to move from down→left or from left→down
   if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or
      (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN))
     # Update coordinates
     @x -= 1
     @y += 1
   end
 end
 #--------------------------------------------------------------------------
 # ● Move lower right
 #--------------------------------------------------------------------------
 def move_lower_right
   # When no direction fixation
   unless @direction_fix
     # Turn right when facing left, turn down when facing up
     @direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::UP ? Input::DOWN : @direction)
   end
   # When possible to move from down→right or from right→down
   if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or
      (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN))
     # Update coordinates
     @x += 1
     @y += 1
   end
 end
 #--------------------------------------------------------------------------
 # ● move upper left
 #--------------------------------------------------------------------------
 def move_upper_left
   # When no direction fixation
   unless @direction_fix
     # Turn left when facing right, turn up when facing down
     @direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::DOWN ? Input::UP : @direction)
   end
   # When possible to move from up→left or from left→up
   if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or
      (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP))
     # Update coordinates
     @x -= 1
     @y -= 1
   end
 end
 #--------------------------------------------------------------------------
 # ● move upper right
 #--------------------------------------------------------------------------
 def move_upper_right
   # When no direction fixation
   unless @direction_fix
     # Turn right when facing left, turn up when facing down
     @direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::DOWN ? Input::UP : @direction)
   end
   # When possible to move from up→right or from right→up
   if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or
      (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP))
     # Update coordinates
     @x += 1
     @y -= 1
   end
 end
end

end
 
The Bug I hate most is the fact that you can't change graphics with a caterpiller script. Say you wanted everyone to fall over. You cant.. Even if you put a Change hero graphics to: Dead. ETC. Thats the only reason keeping me from having one of these.
 
You should be able to change them, just add 'attr_accessor :character_name' under 'class Game_Party_Actor < Game_Character' (no apostrophes).

EDIT: And when you want to change them just put Game_Party.characters.character_name = "Dead_Jimbo" again, not sure if it will work, I'm in class ;)
 
Brimstone-x said:
The Bug I hate most is the fact that you can't change graphics with a caterpiller script. Say you wanted everyone to fall over. You cant.. Even if you put a Change hero graphics to: Dead. ETC. Thats the only reason keeping me from having one of these.

Ugh you're right!! I mean, I thought you were wrong. I was just about to make a gif for you showing you that you can because I would change character graphics frequently! I went to go do it right now and it didn't work though! It's because of the new version of this script. On the old version you can though! that's it, I'm definetely converting back to the old version and I will simply program some work around so that I can avoid the bug.

Well that solves that problem. So no one needs to script this for me now.

And ya Brimstone-x, that second script I posted, it will allow you to change the followers graphics. The bug is this though. If a character gets knocked out, their graphic disappears. This didn't matter to my game since I have it where they come back with 1Hp after every battle. But the bug that did matter was if you get knocked out, outside of battle then it gets very glitchy! And I spent a long time editing different things to try to fix this but nothing worked. So now I'm just going to edit some things to avoid the possibility of getting knocked out outside of battle.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top