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.

I cant find 8-way movement

I remember having this script a while ago but I dont know what I did with it. I am looking for an 8 directional movement script. One that doesnt make you have you use extra sprites in the sprite sheet. Just using a normal 4x4 spritesheet and say if you walked (down,left) it would still remain the down sprite, just moving diagonal. Anyway, anyone know what Im talking about and where I can find it?
 
You can use this:
Code:
#==============================================================================
# ** Hero and Event Frame Script 1.1         (25-03-2007)
#    by The Sleeping Leonhart
#------------------------------------------------------------------------------
# This script allow the user to choice the frame of the hero, the frame of 
# the event, add a standing pose and the 8 direction movement.
# This Script include the patch for the menu.
#==============================================================================

#=========================== CONFIGURATION =====================================
  HERO_FRAME   = 4         #frame for the hero
  EVENT_FRAME  = 4          #frame for the event
  HERO_STAND   = false       #enable/disable the hero standing pose
  EVENT_STAND  = false      #enable/disable the event standing pose
  EIGHT_DIRECTION = true    #enabledisable the 8 direction mode
#===============================================================================
  
class Sprite_Character < RPG::Sprite
  alias tsl_spritecharcter_update update
  def update
    super
    if @tile_id != @character.tile_id or
       @character_name != @character.character_name or
       @character_hue != @character.character_hue
      @tile_id = @character.tile_id
      @character_name = @character.character_name
      @character_hue = @character.character_hue
      if @tile_id >= 384
        self.bitmap = RPG::Cache.tile($game_map.tileset_name,
          @tile_id, @character.character_hue)
        self.src_rect.set(0, 0, 32, 32)
        self.ox = 16
        self.oy = 32
      else
        self.bitmap = RPG::Cache.character(@character.character_name,
          @character.character_hue)
        if @character.is_a?(Game_Event)
           if EVENT_STAND
             @cw = bitmap.width / (EVENT_FRAME + 1)
             @ch = bitmap.height / 4
           else
             @cw = bitmap.width / EVENT_FRAME
             @ch = bitmap.height / 4
           end
         elsif @character.is_a?(Game_Player)
           if HERO_STAND
             @cw = bitmap.width / (HERO_FRAME + 1)
             @ch = bitmap.height / 4
           else
             @cw = bitmap.width / HERO_FRAME
             @ch = bitmap.height / 4
           end
        end
        self.ox = @cw / 2
        self.oy = @ch
      end
    end
    tsl_spritecharcter_update
  end
end
  
class Game_Character  
  attr_reader   :step_anime
  attr_reader   :walk_anime
  attr_reader   :stop_count
  def update
    if jumping?
      update_jump
    elsif moving?
      update_move
    else
      update_stop
    end
    if not self.is_a?(Game_Player)
      if @anime_count > 16 - @move_speed * 2
        if not @step_anime and @stop_count > 0
          @pattern = @original_pattern
        else
          if EVENT_STAND == true
            @pattern = @pattern - 1
            @pattern = (@pattern + 1) % EVENT_FRAME + 1
          else
            @pattern = (@pattern + 1) % EVENT_FRAME
          end
        end
        @anime_count = 0
      end
    else
      if @anime_count > 16 - @move_speed * 2
        if not @step_anime and @stop_count > 0
          @pattern = @original_pattern
        else
          if HERO_STAND == true
            @pattern = @pattern - 1
            @pattern = (@pattern + 1) % HERO_FRAME + 1
          else
            @pattern = (@pattern + 1) % HERO_FRAME
          end
        end
        @anime_count = 0
      end
    end
    if @wait_count > 0
      @wait_count -= 1
      return
    end
    if @move_route_forcing
      move_type_custom
      return
    end
    if @starting or lock?
      return
    end
    if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency)
      case @move_type
      when 1
        move_type_random
      when 2
        move_type_toward_player
      when 3
        move_type_custom
      end     
    end
  end
  def move_lower_left
    unless @direction_fix
      if EIGHT_DIRECTION == true
        @direction = 3
      else
        @direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)        
      end
    end
    if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 4)) or
       (passable?(@x, @y, 4) and passable?(@x - 1, @y, 2))
      if EIGHT_DIRECTION == true
        turn_downleft
      end
      @x -= 1
      @y += 1
      increase_steps
    end
  end
  def move_lower_right
    unless @direction_fix
      if EIGHT_DIRECTION == true
        @direction = 3
      else
        @direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
      end
    end
    if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 6)) or
      (passable?(@x, @y, 6) and passable?(@x + 1, @y, 2))
      if EIGHT_DIRECTION == true      
        turn_downright
      end
      @x += 1
      @y += 1
      increase_steps
    end
  end
  def move_upper_left
    unless @direction_fix
      if EIGHT_DIRECTION == true
        @direction = 9
      else
        @direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
      end
    end
    if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 4)) or
      (passable?(@x, @y, 4) and passable?(@x - 1, @y, 8))
      if EIGHT_DIRECTION == true
        turn_upleft
      end
      @x -= 1
      @y -= 1
      increase_steps
    end
  end
  def move_upper_right
    unless @direction_fix
      if EIGHT_DIRECTION == true
        @direction = 9
      else
        @direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
      end
    end
    if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 6)) or
      (passable?(@x, @y, 6) and passable?(@x + 1, @y, 8))
      if EIGHT_DIRECTION == true
        turn_upright
      end
      @x += 1
      @y -= 1
      increase_steps
    end
  end
  def move_random
    if EIGHT_DIRECTION == true
      caserand=8
    else
      caserand=4
    end
    case rand(caserand)
    when 0
      move_down(false)
    when 1
      move_left(false)
    when 2
      move_right(false)
    when 3
      move_up(false)
    when 4
      move_lower_left
    when 5
      move_lower_right
    when 6
      move_upper_left
    when 7
      move_upper_right
    end
  end
  def move_toward_player
    sx = @x - $game_player.x
    sy = @y - $game_player.y
    if sx == 0 and sy == 0
      return
    end
    abs_sx = sx.abs
    abs_sy = sy.abs
    if EIGHT_DIRECTION == true
      if sx > 0
        if sy > 0
          move_upper_left
        elsif sy <0
          move_lower_left
        else
          move_left
        end
      elsif sx <0
        if sy > 0
          move_upper_right
        elsif sy <0
          move_lower_right
        else
          move_right
        end
      else
        if sy > 0
          move_up
        elsif sy <0
          move_down
        else
          
        end
      end
    else
      if abs_sx == abs_sy
        rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
      end
      if abs_sx > abs_sy
        sx > 0 ? move_left : move_right
        if not moving? and sy != 0
          sy > 0 ? move_up : move_down
        end
      else
        sy > 0 ? move_up : move_down
        if not moving? and sx != 0
          sx > 0 ? move_left : move_right
        end
      end    
    end  
  end
  def move_away_from_player
    sx = @x - $game_player.x
    sy = @y - $game_player.y
    if sx == 0 and sy == 0
      return
    end
    abs_sx = sx.abs
    abs_sy = sy.abs
    if EIGHT_DIRECTION == true
      if sx > 0
        if sy > 0
          move_lower_right
        elsif sy <0
          move_upper_right
        else
          move_right
        end
      elsif sx <0
        if sy > 0
          move_lower_left
        elsif sy <0
          move_upper_left
        else
          move_left
        end
      else
        if sy > 0
          move_down
        elsif sy <0
          move_up
        else
          
        end
      end
    else
      if abs_sx == abs_sy
        rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
      end
      if abs_sx > abs_sy
        sx > 0 ? move_right : move_left
        if not moving? and sy != 0
          sy > 0 ? move_down : move_up
        end
      else
        sy > 0 ? move_down : move_up
        if not moving? and sx != 0
          sx > 0 ? move_right : move_left
        end
      end
    end
  end
  def move_forward
    if EIGHT_DIRECTION == true
      case @direction
      when 2
        move_down(false)
      when 4
        move_left(false)
      when 6
        move_right(false)
      when 8
        move_up(false)
      end
    else  
      case @direction
      when 1
        move_lower_left
      when 2
        move_down(false)
      when 3
        move_lower_right
      when 4
        move_left(false)
      when 6
        move_right(false)
      when 7
        move_upper_left
      when 8
        move_up(false)
      when 9
        move_upper_right
      end
    end
  end
  def move_backward
    last_direction_fix = @direction_fix
    @direction_fix = true
    if EIGHT_DIRECTION == true
      case @direction
      when 1
        move_upper_right
      when 2
        move_up(false)
      when 3
        move_upper_left
      when 4
        move_right(false)
      when 6
        move_left(false)
      when 7
        move_lower_right
      when 8
        move_down(false)
      when 9
        move_lower_left
      end
    else
      case @direction
      when 2
        move_up(false)
      when 4
        move_right(false)
      when 6
        move_left(false)
      when 8
        move_down(false)
      end
    end
    @direction_fix = last_direction_fix
  end 
  def turn_upleft
    unless @direction_fix
      @direction = 9
      @stop_count = 0
    end
  end
  def turn_upright
    unless @direction_fix
      @direction = 9
      @stop_count = 0
    end
  end
  def turn_downleft
    unless @direction_fix
      @direction = 3
      @stop_count = 0
    end
  end
  def turn_downright
    unless @direction_fix
      @direction = 3
      @stop_count = 0
    end
  end
  def turn_right_90
    case @direction
    when 1
      turn_downright
    when 2
      turn_left
    when 3
      turn_upright
    when 4
      turn_up
    when 6
      turn_down
    when 7
      turn_downleft
    when 8
      turn_right
    when 9
      turn_upleft
    end
  end
  def turn_left_90
    case @direction
    when 1
      turn_upleft
    when 2
      turn_right
    when 3
      turn_downleft
    when 4
      turn_down
    when 6
      turn_up
    when 7
      turn_upright
    when 8
      turn_left
    when 9
      turn_downright
    end
  end
  def turn_180
    case @direction
    when 1
      turn_upright
    when 2
      turn_up
    when 3
      turn_upleft
    when 4
      turn_right
    when 6
      turn_left
    when 7
      turn_downright
    when 8
      turn_down
    when 9
      turn_downleft
    end
  end  
  def turn_random
    if EIGHT_DIRECTION == true 
      caserand = 8
    else
      caserand = 4
    end
    case rand(caserand)
    when 0
      turn_down     
    when 1
      turn_left
    when 2
      turn_right
    when 3
      turn_up
    when 4
      turn_downleft
    when 5
      turn_downright
    when 6
      turn_upleft
    when 7
      turn_upright
    end    
  end  
  def turn_toward_player
    sx = @x - $game_player.x
    sy = @y - $game_player.y
    if EIGHT_DIRECTION == true
      if sx > 0
        if sy > 0
          turn_upleft
        elsif sy <0
          turn_downleft
        else
          turn_left
        end
      elsif sx <0
        if sy > 0
          turn_upright
        elsif sy <0
          turn_downright
        else
          turn_right
        end
      else
        if sy > 0
          turn_up
        elsif sy <0
          turn_down
        else
          
        end
      end
    else
      if sx == 0 and sy == 0
        return
      end
      if sx.abs > sy.abs
        sx > 0 ? turn_left : turn_right
      else
        sy > 0 ? turn_up : turn_down
      end      
    end
  end
  def turn_away_from_player
    sx = @x - $game_player.x
    sy = @y - $game_player.y
    if EIGHT_DIRECTION == true
      if sx > 0
        if sy > 0
          turn_downright
        elsif sy <0
          turn_upright 
        else
          turn_right
        end
      elsif sx <0
        if sy > 0
          turn_downleft
        elsif sy <0
          turn_upleft
        else
          turn_left
        end
      else
        if sy > 0
          turn_down
        elsif sy <0
          turn_up
        else
        end
      end
    else
      if sx == 0 and sy == 0
        return
      endr
      if sx.abs > sy.abs
        sx > 0 ? turn_right : turn_left
      else
        sy > 0 ? turn_down : turn_up
      end      
    end
  end
  end
end

class Game_Player < Game_Character
  alias tsl_gameplayer_update update
  def update
    last_moving = moving?
    unless moving? or $game_system.map_interpreter.running? or
           @move_route_forcing or $game_temp.message_window_showing
      if EIGHT_DIRECTION == true      
        case Input.dir8
        when 1
          move_lower_left
        when 2
          move_down        
        when 3
          move_lower_right
        when 4
          move_left
        when 6
          move_right        
        when 7
          move_upper_left
        when 8
          move_up
        when 9
          move_upper_right
        end
      else
        case Input.dir4
        when 2
          move_down
        when 4
          move_left
        when 6
          move_right
        when 8
          move_up
        end
      end
    end
    tsl_gameplayer_update
  end
end

class Window_Base < Window
  def draw_actor_graphic(actor, x, y)
    bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
    if HERO_STAND
      cw = bitmap.width / (HERO_FRAME + 1)
    else
      cw = bitmap.width / HERO_FRAME
    end
    ch = bitmap.height / 4
    src_rect = Rect.new(0, 0, cw, ch)
    self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
  end
end
 
Thats awesome Leonhart :) Sorry to trouble you but there's 2 things though.
I forgot to mention, is it possible to make this compatiable with this caterpillar script im using? Because I keep getting an error while trying to use it at the same time. Its basically just a script that allows party members to trail behind you rather then not be visible at all.
Code:
# Train_Actor 
	
# Config.rb 
#==============================================================================
# ?? Train_Actor::Config
#------------------------------------------------------------------------------
# ?}?b?v????A?N?^?[???????????????
#==============================================================================

module Train_Actor

# ??????????p?X?C?b?`???
# true ????X?C?b?`???????s??
# TRANSPARENT_SWITCH = true
TRANSPARENT_SWITCH = false

# ??????????p?X?C?b?`???
# TRANSPARENT_SWITCH ?? true ??A????????X?C?b?`??ON???????????
TRANSPARENT_SWITCHES_INDEX = 20

# ???A?N?^?[????
# ?????I????l???p?[?e?B???o???????????????c
TRAIN_ACTOR_SIZE_MAX = 4

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

end
 
# rgss 
	
# Spriteset_Map_Module.rb 
#==============================================================================
# ?? Spriteset_Map_Module
#------------------------------------------------------------------------------
# ?}?b?v????A?N?^?[???????????????
#==============================================================================

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
#------------------------------------------------------------------------------
# ?}?b?v????A?N?^?[???????????????
#==============================================================================

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
#------------------------------------------------------------------------------
# ?}?b?v????A?N?^?[???????????????
#==============================================================================

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
  if TRANSPARENT_SWITCH
    def transparent_switch
      transparent = $game_player.transparent
      if transparent == false
        transparent = $game_switches[TRANSPARENT_SWITCHES_INDEX]
      end
      return transparent
    end
  else
    def transparent_switch
      return $game_player.transparent
    end
  end
  def update_party_actors
    update_party_order
    setup_actor_character_sprites
    transparent = transparent_switch
    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
# ?????
if Train_Actor::TRAIN_ACTOR_SIZE_MAX != 4
  #--------------------------------------------------------------------------
  # ?? ?A?N?^?[????????
  #     actor_id : ?A?N?^?[ ID
  #--------------------------------------------------------------------------
  def add_actor(actor_id)
    # ?A?N?^?[????
    actor = $game_actors[actor_id]
    # ?p?[?e?B?l???? 4 ?l??????A????A?N?^?[???p?[?e?B????????
    if @actors.size < Train_Actor::TRAIN_ACTOR_SIZE_MAX and not @actors.include?(actor)
      # ?A?N?^?[?????
      @actors.push(actor)
      # ?v???C???[?????t???b?V??
      $game_player.refresh
    end
  end
end

end
 
# Game_Player_Module.rb 
#==============================================================================
# ?? Game_Player_Module
#------------------------------------------------------------------------------
# ?}?b?v????A?N?^?[???????????????
#==============================================================================

module Train_Actor

module Game_Player_Module
  attr_reader :move_speed
  attr_reader :step_anime

  def update_party_actors
    if $game_party.actors.empty?
      return
    end
    $game_party.update_party_actors
    actor = $game_party.actors[0]
    if not actor.dead?
      if not @prev_dead.nil?
        @character_name = actor.character_name
        @character_hue = actor.character_hue
        @prev_dead = nil
      end
      return
    end
    @prev_dead = true
    $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
    # ???????A?????? ????????R?[?X????s??\???
    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
    # ?????E?A?E???? ????????R?[?X????s??\???
    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
    # ?????A?????? ????????R?[?X????s??\???
    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
    # ???E?A?E???? ????????R?[?X????s??\???
    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)
    # ?V???????W???v?Z
    new_x = @x + x_plus
    new_y = @y + y_plus
    # ???Z?l?? (0,0) ??????A?W?????v????s??\???
    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
#------------------------------------------------------------------------------
# ?}?b?v????A?N?^?[???????????????
#==============================================================================

module Train_Actor

module Game_Event_Module
  #--------------------------------------------------------------------------
  # ?? ??s??\????
  #     x  : X ???W
  #     y  : Y ???W
  #     d  : ???? (0,2,4,6,8)  ?? 0 = ?S??????s?s?????????? (?W?????v?p)
  # return : ??s?s?? false ??\ true
  #--------------------------------------------------------------------------
  def passable?(x, y, d)
    result = super(x, y, d)
    if result
      # ?V???????W???????
      new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
      new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
      # ?g???C???A?N?^?[????[?v
      for actor in $game_party.characters
        # ?\?????????????
        if not actor.character_name.empty?
          # ?A?N?^?[????W???????????v??????
          if actor.x == new_x and actor.y == new_y
            # ???????C?x???g???
            if self != $game_player
              # ??s?s??
              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
#------------------------------------------------------------------------------
# ?}?b?v????A?N?^?[???????????????
#==============================================================================

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)
    # ?L?????N?^?[??t?@?C??????F???????
    if actor != nil and (not actor.dead?) # ????????????? ?????A????????c
      @character_name = actor.character_name
      @character_hue = actor.character_hue
    else
      @character_name = ""
      @character_hue = 0
    end
    # ?s?????x????????@????????
    @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 : ?????????????X??????????t???O
  #--------------------------------------------------------------------------
  def move_down(turn_enabled = true)
    # ???????*
    if turn_enabled
      turn_down
    end
    # ??s??\???
    if passable?(@x, @y, Input::DOWN)
      # ???????*
      turn_down
      # ???W???X?V
      @y += 1
    end
  end
  #--------------------------------------------------------------------------
  # ?? ??????
  #     turn_enabled : ?????????????X??????????t???O
  #--------------------------------------------------------------------------
  def move_left(turn_enabled = true)
    # ???????*
    if turn_enabled
      turn_left
    end
    # ??s??\???
    if passable?(@x, @y, Input::LEFT)
      # ???????*
      turn_left
      # ???W???X?V
      @x -= 1
    end
  end
  #--------------------------------------------------------------------------
  # ?? ?E????
  #     turn_enabled : ?????????????X??????????t???O
  #--------------------------------------------------------------------------
  def move_right(turn_enabled = true)
    # ?E?????*
    if turn_enabled
      turn_right
    end
    # ??s??\???
    if passable?(@x, @y, Input::RIGHT)
      # ?E?????*
      turn_right
      # ???W???X?V
      @x += 1
    end
  end
  #--------------------------------------------------------------------------
  # ?? ??????
  #     turn_enabled : ?????????????X??????????t???O
  #--------------------------------------------------------------------------
  def move_up(turn_enabled = true)
    # ???????*
    if turn_enabled
      turn_up
    end
    # ??s??\???
    if passable?(@x, @y, Input::UP)
      # ???????*
      turn_up
      # ???W???X?V
      @y -= 1
    end
  end
  #--------------------------------------------------------------------------
  # ?? ????????
  #--------------------------------------------------------------------------
  def move_lower_left
    # ??????’???????
    unless @direction_fix
      # ?E??????????????????A??????????????????????*
      @direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::UP ? Input::DOWN : @direction)
    end
    # ???????A?????? ????????R?[?X????s??\???
    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))
      # ???W???X?V
      @x -= 1
      @y += 1
    end
  end
  #--------------------------------------------------------------------------
  # ?? ?E??????
  #--------------------------------------------------------------------------
  def move_lower_right
    # ??????’???????
    unless @direction_fix
      # ????????????????E???A??????????????????????*
      @direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::UP ? Input::DOWN : @direction)
    end
    # ?????E?A?E???? ????????R?[?X????s??\???
    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))
      # ???W???X?V
      @x += 1
      @y += 1
    end
  end
  #--------------------------------------------------------------------------
  # ?? ????????
  #--------------------------------------------------------------------------
  def move_upper_left
    # ??????’???????
    unless @direction_fix
      # ?E??????????????????A??????????????????????*
      @direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::DOWN ? Input::UP : @direction)
    end
    # ?????A?????? ????????R?[?X????s??\???
    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))
      # ???W???X?V
      @x -= 1
      @y -= 1
    end
  end
  #--------------------------------------------------------------------------
  # ?? ?E??????
  #--------------------------------------------------------------------------
  def move_upper_right
    # ??????’???????
    unless @direction_fix
      # ????????????????E???A??????????????????????*
      @direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::DOWN ? Input::UP : @direction)
    end
    # ???E?A?E???? ????????R?[?X????s??\???
    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))
      # ???W???X?V
      @x += 1
      @y -= 1
    end
  end
end

end
Also I realized that when im going down a stairs to my left in the game as shown here
http://img160.imageshack.us/img160/9604 ... ingjc1.png[/IMG]
that character still faces down. Is there a way to make it so that if your holding left first then you hold down, he would walk (left,down) still maintaining the left walking sprite. but if you hold down first then left he would maintain the down walking sprite. Cause It doesnt look right walking down a stairs sideways. :/
 
The fixed code for the caterpillar:
Code:
#==============================================================================
# ** Hero and Event Frame Script 1.2         (24-04-2007)
#    by The Sleeping Leonhart
#------------------------------------------------------------------------------
# This script allow the user to choice the frame of the hero, the frame of 
# the event, add a standing pose and the 8 direction movement.
# This Script include the patch for the menu.
#==============================================================================

#=========================== CONFIGURATION =====================================
  HERO_FRAME   = 8          #frame for the hero
  EVENT_FRAME  = 4          #frame for the event
  HERO_STAND   = true       #enable/disable the hero standing pose
  EVENT_STAND  = false      #enable/disable the event standing pose
  EIGHT_DIRECTION = true    #enabledisable the 8 direction mode
#===============================================================================
  
class Sprite_Character < RPG::Sprite
  alias tsl_spritecharcter_update update
  def update
    super
    if @tile_id != @character.tile_id or
       @character_name != @character.character_name or
       @character_hue != @character.character_hue
      @tile_id = @character.tile_id
      @character_name = @character.character_name
      @character_hue = @character.character_hue
      if @tile_id >= 384
        self.bitmap = RPG::Cache.tile($game_map.tileset_name,
          @tile_id, @character.character_hue)
        self.src_rect.set(0, 0, 32, 32)
        self.ox = 16
        self.oy = 32
      else
        self.bitmap = RPG::Cache.character(@character.character_name,
          @character.character_hue)
        if @character.is_a?(Game_Event)
           if EVENT_STAND
             @cw = bitmap.width / (EVENT_FRAME + 1)
             @ch = bitmap.height / 4
           else
             @cw = bitmap.width / EVENT_FRAME
             @ch = bitmap.height / 4
           end
         elsif @character.is_a?(Game_Player)
           if HERO_STAND
             @cw = bitmap.width / (HERO_FRAME + 1)
             @ch = bitmap.height / 4
           else
             @cw = bitmap.width / HERO_FRAME
             @ch = bitmap.height / 4
           end
         else
           @cw = bitmap.width / 4
           @ch = bitmap.height / 4
        end
        self.ox = @cw / 2
        self.oy = @ch
      end
    end
    tsl_spritecharcter_update
  end
end
  
class Game_Character  
  attr_reader   :step_anime
  attr_reader   :walk_anime
  attr_reader   :stop_count
  def update
    if jumping?
      update_jump
    elsif moving?
      update_move
    else
      update_stop
    end
    if not self.is_a?(Game_Player)
      if @anime_count > 16 - @move_speed * 2
        if not @step_anime and @stop_count > 0
          @pattern = @original_pattern
        else
          if EVENT_STAND == true
            @pattern = @pattern - 1
            @pattern = (@pattern + 1) % EVENT_FRAME + 1
          else
            @pattern = (@pattern + 1) % EVENT_FRAME
          end
        end
        @anime_count = 0
      end
    else
      if @anime_count > 16 - @move_speed * 2
        if not @step_anime and @stop_count > 0
          @pattern = @original_pattern
        else
          if HERO_STAND == true
            @pattern = @pattern - 1
            @pattern = (@pattern + 1) % HERO_FRAME + 1
          else
            @pattern = (@pattern + 1) % HERO_FRAME
          end
        end
        @anime_count = 0
      end
    end
    if @wait_count > 0
      @wait_count -= 1
      return
    end
    if @move_route_forcing
      move_type_custom
      return
    end
    if @starting or lock?
      return
    end
    if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency)
      case @move_type
      when 1
        move_type_random
      when 2
        move_type_toward_player
      when 3
        move_type_custom
      end     
    end
  end
  def move_lower_left
    unless @direction_fix
      if EIGHT_DIRECTION == true
        @direction = 3
      else
        @direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)        
      end
    end
    if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 4)) or
       (passable?(@x, @y, 4) and passable?(@x - 1, @y, 2))
      if EIGHT_DIRECTION == true
        turn_downleft
      end
      @x -= 1
      @y += 1
      increase_steps
    end
  end
  def move_lower_right
    unless @direction_fix
      if EIGHT_DIRECTION == true
        @direction = 3
      else
        @direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
      end
    end
    if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 6)) or
      (passable?(@x, @y, 6) and passable?(@x + 1, @y, 2))
      if EIGHT_DIRECTION == true      
        turn_downright
      end
      @x += 1
      @y += 1
      increase_steps
    end
  end
  def move_upper_left
    unless @direction_fix
      if EIGHT_DIRECTION == true
        @direction = 9
      else
        @direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
      end
    end
    if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 4)) or
      (passable?(@x, @y, 4) and passable?(@x - 1, @y, 8))
      if EIGHT_DIRECTION == true
        turn_upleft
      end
      @x -= 1
      @y -= 1
      increase_steps
    end
  end
  def move_upper_right
    unless @direction_fix
      if EIGHT_DIRECTION == true
        @direction = 9
      else
        @direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
      end
    end
    if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 6)) or
      (passable?(@x, @y, 6) and passable?(@x + 1, @y, 8))
      if EIGHT_DIRECTION == true
        turn_upright
      end
      @x += 1
      @y -= 1
      increase_steps
    end
  end
  def move_random
    if EIGHT_DIRECTION == true
      caserand=8
    else
      caserand=4
    end
    case rand(caserand)
    when 0
      move_down(false)
    when 1
      move_left(false)
    when 2
      move_right(false)
    when 3
      move_up(false)
    when 4
      move_lower_left
    when 5
      move_lower_right
    when 6
      move_upper_left
    when 7
      move_upper_right
    end
  end
  def move_toward_player
    sx = @x - $game_player.x
    sy = @y - $game_player.y
    if sx == 0 and sy == 0
      return
    end
    abs_sx = sx.abs
    abs_sy = sy.abs
    if EIGHT_DIRECTION == true
      if sx > 0
        if sy > 0
          move_upper_left
        elsif sy <0
          move_lower_left
        else
          move_left
        end
      elsif sx <0
        if sy > 0
          move_upper_right
        elsif sy <0
          move_lower_right
        else
          move_right
        end
      else
        if sy > 0
          move_up
        elsif sy <0
          move_down
        else
          
        end
      end
    else
      if abs_sx == abs_sy
        rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
      end
      if abs_sx > abs_sy
        sx > 0 ? move_left : move_right
        if not moving? and sy != 0
          sy > 0 ? move_up : move_down
        end
      else
        sy > 0 ? move_up : move_down
        if not moving? and sx != 0
          sx > 0 ? move_left : move_right
        end
      end    
    end  
  end
  def move_away_from_player
    sx = @x - $game_player.x
    sy = @y - $game_player.y
    if sx == 0 and sy == 0
      return
    end
    abs_sx = sx.abs
    abs_sy = sy.abs
    if EIGHT_DIRECTION == true
      if sx > 0
        if sy > 0
          move_lower_right
        elsif sy <0
          move_upper_right
        else
          move_right
        end
      elsif sx <0
        if sy > 0
          move_lower_left
        elsif sy <0
          move_upper_left
        else
          move_left
        end
      else
        if sy > 0
          move_down
        elsif sy <0
          move_up
        else
          
        end
      end
    else
      if abs_sx == abs_sy
        rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
      end
      if abs_sx > abs_sy
        sx > 0 ? move_right : move_left
        if not moving? and sy != 0
          sy > 0 ? move_down : move_up
        end
      else
        sy > 0 ? move_down : move_up
        if not moving? and sx != 0
          sx > 0 ? move_right : move_left
        end
      end
    end
  end
  def move_forward
    if EIGHT_DIRECTION == true
      case @direction
      when 2
        move_down(false)
      when 4
        move_left(false)
      when 6
        move_right(false)
      when 8
        move_up(false)
      end
    else  
      case @direction
      when 1
        move_lower_left
      when 2
        move_down(false)
      when 3
        move_lower_right
      when 4
        move_left(false)
      when 6
        move_right(false)
      when 7
        move_upper_left
      when 8
        move_up(false)
      when 9
        move_upper_right
      end
    end
  end
  def move_backward
    last_direction_fix = @direction_fix
    @direction_fix = true
    if EIGHT_DIRECTION == true
      case @direction
      when 1
        move_upper_right
      when 2
        move_up(false)
      when 3
        move_upper_left
      when 4
        move_right(false)
      when 6
        move_left(false)
      when 7
        move_lower_right
      when 8
        move_down(false)
      when 9
        move_lower_left
      end
    else
      case @direction
      when 2
        move_up(false)
      when 4
        move_right(false)
      when 6
        move_left(false)
      when 8
        move_down(false)
      end
    end
    @direction_fix = last_direction_fix
  end 
  def turn_upleft
    unless @direction_fix
      @direction = 9
      @stop_count = 0
    end
  end
  def turn_upright
    unless @direction_fix
      @direction = 9
      @stop_count = 0
    end
  end
  def turn_downleft
    unless @direction_fix
      @direction = 3
      @stop_count = 0
    end
  end
  def turn_downright
    unless @direction_fix
      @direction = 3
      @stop_count = 0
    end
  end
  def turn_right_90
    case @direction
    when 1
      turn_downright
    when 2
      turn_left
    when 3
      turn_upright
    when 4
      turn_up
    when 6
      turn_down
    when 7
      turn_downleft
    when 8
      turn_right
    when 9
      turn_upleft
    end
  end
  def turn_left_90
    case @direction
    when 1
      turn_upleft
    when 2
      turn_right
    when 3
      turn_downleft
    when 4
      turn_down
    when 6
      turn_up
    when 7
      turn_upright
    when 8
      turn_left
    when 9
      turn_downright
    end
  end
  def turn_180
    case @direction
    when 1
      turn_upright
    when 2
      turn_up
    when 3
      turn_upleft
    when 4
      turn_right
    when 6
      turn_left
    when 7
      turn_downright
    when 8
      turn_down
    when 9
      turn_downleft
    end
  end  
  def turn_random
    if EIGHT_DIRECTION == true 
      caserand = 8
    else
      caserand = 4
    end
    case rand(caserand)
    when 0
      turn_down     
    when 1
      turn_left
    when 2
      turn_right
    when 3
      turn_up
    when 4
      turn_downleft
    when 5
      turn_downright
    when 6
      turn_upleft
    when 7
      turn_upright
    end    
  end  
  def turn_toward_player
    sx = @x - $game_player.x
    sy = @y - $game_player.y
    if EIGHT_DIRECTION == true
      if sx > 0
        if sy > 0
          turn_upleft
        elsif sy <0
          turn_downleft
        else
          turn_left
        end
      elsif sx <0
        if sy > 0
          turn_upright
        elsif sy <0
          turn_downright
        else
          turn_right
        end
      else
        if sy > 0
          turn_up
        elsif sy <0
          turn_down
        else
          
        end
      end
    else
      if sx == 0 and sy == 0
        return
      end
      if sx.abs > sy.abs
        sx > 0 ? turn_left : turn_right
      else
        sy > 0 ? turn_up : turn_down
      end      
    end
  end
  def turn_away_from_player
    sx = @x - $game_player.x
    sy = @y - $game_player.y
    if EIGHT_DIRECTION == true
      if sx > 0
        if sy > 0
          turn_downright
        elsif sy <0
          turn_upright 
        else
          turn_right
        end
      elsif sx <0
        if sy > 0
          turn_downleft
        elsif sy <0
          turn_upleft
        else
          turn_left
        end
      else
        if sy > 0
          turn_down
        elsif sy <0
          turn_up
        else
        end
      end
    else
      if sx == 0 and sy == 0
        return
      endr
      if sx.abs > sy.abs
        sx > 0 ? turn_right : turn_left
      else
        sy > 0 ? turn_down : turn_up
      end      
    end
  end
  end
end

class Game_Player < Game_Character
  alias tsl_gameplayer_update update
  def update
    last_moving = moving?
    unless moving? or $game_system.map_interpreter.running? or
           @move_route_forcing or $game_temp.message_window_showing
      if EIGHT_DIRECTION == true      
        case Input.dir8
        when 1
          move_lower_left
        when 2
          move_down        
        when 3
          move_lower_right
        when 4
          move_left
        when 6
          move_right        
        when 7
          move_upper_left
        when 8
          move_up
        when 9
          move_upper_right
        end
      else
        case Input.dir4
        when 2
          move_down
        when 4
          move_left
        when 6
          move_right
        when 8
          move_up
        end
      end
    end
    tsl_gameplayer_update
  end
end

class Window_Base < Window
  def draw_actor_graphic(actor, x, y)
    bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
    if HERO_STAND
      cw = bitmap.width / (HERO_FRAME + 1)
    else
      cw = bitmap.width / HERO_FRAME
    end
    ch = bitmap.height / 4
    src_rect = Rect.new(0, 0, cw, ch)
    self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
  end
end
Also I realized that when im going down a stairs to my left in the game as shown here
that character still faces down. Is there a way to make it so that if your holding left first then you hold down, he would walk (left,down) still maintaining the left walking sprite. but if you hold down first then left he would maintain the down walking sprite. Cause It doesnt look right walking down a stairs sideways. :/
I think is impossible because to make this i used a standard Methods in the RGSS but i can try to do.
 
Well at least you got the caterpillar to work :) Sorry to post another problem with it though >.<
http://img391.imageshack.us/img391/1701 ... ng2sc7.png[/IMG]
My main character now is sliced in half and such when ever I walk with him. Also sometimes my second character remains in a fixed position while walking up and down stairs. Although the second problem in my last post seems to work fine with my second character while walking normally, as in not on a stairs.
I appreciate your efforts :)
 
You must change this:
#=========================== CONFIGURATION =====================================
HERO_FRAME = 8 #frame for the hero
EVENT_FRAME = 4 #frame for the event
HERO_STAND = true #enable/disable the hero standing pose
EVENT_STAND = false #enable/disable the event standing pose
EIGHT_DIRECTION = true #enabledisable the 8 direction mode

with this:
#=========================== CONFIGURATION =====================================
HERO_FRAME = 4 #frame for the hero
EVENT_FRAME = 4 #frame for the event
HERO_STAND = false #enable/disable the hero standing pose
EVENT_STAND = false #enable/disable the event standing pose
EIGHT_DIRECTION = true #enabledisable the 8 direction mode
 
TADA!!!
The script for your request:
Also I realized that when im going down a stairs to my left in the game as shown here
that character still faces down. Is there a way to make it so that if your holding left first then you hold down, he would walk (left,down) still maintaining the left walking sprite. but if you hold down first then left he would maintain the down walking sprite. Cause It doesnt look right walking down a stairs sideways. :/
I have made it!!!!
#==============================================================================
# ** Hero and Event Frame Script 1.3 (25-04-2007)
# by The Sleeping Leonhart
#------------------------------------------------------------------------------
# This script allow the user to choice the frame of the hero, the frame of
# the event, add a standing pose and the 8 direction movement.
# This Script include the patch for the menu.
#==============================================================================

#=========================== CONFIGURATION =====================================
HERO_FRAME = 4 #frame for the hero
EVENT_FRAME = 4 #frame for the event
HERO_STAND = false #enable/disable the hero standing pose
EVENT_STAND = false #enable/disable the event standing pose
EIGHT_DIRECTION = true #enabledisable the 8 direction mode
#===============================================================================

class Sprite_Character < RPG::Sprite
alias tsl_spritecharcter_update update
def update
super
if @tile_id != @character.tile_id or
@character_name != @character.character_name or
@character_hue != @character.character_hue
@tile_id = @character.tile_id
@character_name = @character.character_name
@character_hue = @character.character_hue
if @tile_id >= 384
self.bitmap = RPG::Cache.tile($game_map.tileset_name,
@tile_id, @character.character_hue)
self.src_rect.set(0, 0, 32, 32)
self.ox = 16
self.oy = 32
else
self.bitmap = RPG::Cache.character(@character.character_name,
@character.character_hue)
if @character.is_a?(Game_Event)
if EVENT_STAND
@cw = bitmap.width / (EVENT_FRAME + 1)
@ch = bitmap.height / 4
else
@cw = bitmap.width / EVENT_FRAME
@ch = bitmap.height / 4
end
elsif @character.is_a?(Game_Player)
if HERO_STAND
@cw = bitmap.width / (HERO_FRAME + 1)
@ch = bitmap.height / 4
else
@cw = bitmap.width / HERO_FRAME
@ch = bitmap.height / 4
end
else
@cw = bitmap.width / 4
@ch = bitmap.height / 4
end
self.ox = @cw / 2
self.oy = @ch
end
end
tsl_spritecharcter_update
end
end

class Game_Character
attr_reader :step_anime
attr_reader :walk_anime
attr_reader :stop_count
def update
if jumping?
update_jump
elsif moving?
update_move
else
update_stop
end
if not self.is_a?(Game_Player)
if @anime_count > 16 - @move_speed * 2
if not @step_anime and @stop_count > 0
@pattern = @original_pattern
else
if EVENT_STAND == true
@pattern = @pattern - 1
@pattern = (@pattern + 1) % EVENT_FRAME + 1
else
@pattern = (@pattern + 1) % EVENT_FRAME
end
end
@anime_count = 0
end
else
if @anime_count > 16 - @move_speed * 2
if not @step_anime and @stop_count > 0
@pattern = @original_pattern
else
if HERO_STAND == true
@pattern = @pattern - 1
@pattern = (@pattern + 1) % HERO_FRAME + 1
else
@pattern = (@pattern + 1) % HERO_FRAME
end
end
@anime_count = 0
end
end
if @wait_count > 0
@wait_count -= 1
return
end
if @move_route_forcing
move_type_custom
return
end
if @starting or lock?
return
end
if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency)
case @move_type
when 1
move_type_random
when 2
move_type_toward_player
when 3
move_type_custom
end
end
end
def move_lower_left
unless @direction_fix
@direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
end
if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 4)) or
(passable?(@x, @y, 4) and passable?(@x - 1, @y, 2))
@x -= 1
@y += 1
increase_steps
end
end
def move_lower_right
unless @direction_fix
@direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
end
if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 6)) or
(passable?(@x, @y, 6) and passable?(@x + 1, @y, 2))
@x += 1
@y += 1
increase_steps
end
end
def move_upper_left
unless @direction_fix
@direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
end
if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 4)) or
(passable?(@x, @y, 4) and passable?(@x - 1, @y, 8))
@x -= 1
@y -= 1
increase_steps
end
end
def move_upper_right
unless @direction_fix
@direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
end
if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 6)) or
(passable?(@x, @y, 6) and passable?(@x + 1, @y, 8))
@x += 1
@y -= 1
increase_steps
end
end
def move_random
if EIGHT_DIRECTION == true
caserand=8
else
caserand=4
end
case rand(caserand)
when 0
move_down(false)
when 1
move_left(false)
when 2
move_right(false)
when 3
move_up(false)
when 4
move_lower_left
when 5
move_lower_right
when 6
move_upper_left
when 7
move_upper_right
end
end
def move_toward_player
sx = @x - $game_player.x
sy = @y - $game_player.y
if sx == 0 and sy == 0
return
end
abs_sx = sx.abs
abs_sy = sy.abs
if EIGHT_DIRECTION == true
if sx > 0
if sy > 0
move_upper_left
elsif sy <0
move_lower_left
else
move_left
end
elsif sx <0
if sy > 0
move_upper_right
elsif sy <0
move_lower_right
else
move_right
end
else
if sy > 0
move_up
elsif sy <0
move_down
else

end
end
else
if abs_sx == abs_sy
rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
end
if abs_sx > abs_sy
sx > 0 ? move_left : move_right
if not moving? and sy != 0
sy > 0 ? move_up : move_down
end
else
sy > 0 ? move_up : move_down
if not moving? and sx != 0
sx > 0 ? move_left : move_right
end
end
end
end
def move_away_from_player
sx = @x - $game_player.x
sy = @y - $game_player.y
if sx == 0 and sy == 0
return
end
abs_sx = sx.abs
abs_sy = sy.abs
if EIGHT_DIRECTION == true
if sx > 0
if sy > 0
move_lower_right
elsif sy <0
move_upper_right
else
move_right
end
elsif sx <0
if sy > 0
move_lower_left
elsif sy <0
move_upper_left
else
move_left
end
else
if sy > 0
move_down
elsif sy <0
move_up
else

end
end
else
if abs_sx == abs_sy
rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
end
if abs_sx > abs_sy
sx > 0 ? move_right : move_left
if not moving? and sy != 0
sy > 0 ? move_down : move_up
end
else
sy > 0 ? move_down : move_up
if not moving? and sx != 0
sx > 0 ? move_right : move_left
end
end
end
end
def move_forward
if EIGHT_DIRECTION == true
case @direction
when 2
move_down(false)
when 4
move_left(false)
when 6
move_right(false)
when 8
move_up(false)
end
else
case @direction
when 1
move_lower_left
when 2
move_down(false)
when 3
move_lower_right
when 4
move_left(false)
when 6
move_right(false)
when 7
move_upper_left
when 8
move_up(false)
when 9
move_upper_right
end
end
end
def move_backward
last_direction_fix = @direction_fix
@direction_fix = true
if EIGHT_DIRECTION == true
case @direction
when 1
move_upper_right
when 2
move_up(false)
when 3
move_upper_left
when 4
move_right(false)
when 6
move_left(false)
when 7
move_lower_right
when 8
move_down(false)
when 9
move_lower_left
end
else
case @direction
when 2
move_up(false)
when 4
move_right(false)
when 6
move_left(false)
when 8
move_down(false)
end
end
@direction_fix = last_direction_fix
end
def turn_upleft
unless @direction_fix
@direction = 9
@stop_count = 0
end
end
def turn_upright
unless @direction_fix
@direction = 9
@stop_count = 0
end
end
def turn_downleft
unless @direction_fix
@direction = 3
@stop_count = 0
end
end
def turn_downright
unless @direction_fix
@direction = 3
@stop_count = 0
end
end
def turn_right_90
case @direction
when 1
turn_downright
when 2
turn_left
when 3
turn_upright
when 4
turn_up
when 6
turn_down
when 7
turn_downleft
when 8
turn_right
when 9
turn_upleft
end
end
def turn_left_90
case @direction
when 1
turn_upleft
when 2
turn_right
when 3
turn_downleft
when 4
turn_down
when 6
turn_up
when 7
turn_upright
when 8
turn_left
when 9
turn_downright
end
end
def turn_180
case @direction
when 1
turn_upright
when 2
turn_up
when 3
turn_upleft
when 4
turn_right
when 6
turn_left
when 7
turn_downright
when 8
turn_down
when 9
turn_downleft
end
end
def turn_random
if EIGHT_DIRECTION == true
caserand = 8
else
caserand = 4
end
case rand(caserand)
when 0
turn_down
when 1
turn_left
when 2
turn_right
when 3
turn_up
when 4
turn_downleft
when 5
turn_downright
when 6
turn_upleft
when 7
turn_upright
end
end
def turn_toward_player
sx = @x - $game_player.x
sy = @y - $game_player.y
if EIGHT_DIRECTION == true
if sx > 0
if sy > 0
turn_upleft
elsif sy <0
turn_downleft
else
turn_left
end
elsif sx <0
if sy > 0
turn_upright
elsif sy <0
turn_downright
else
turn_right
end
else
if sy > 0
turn_up
elsif sy <0
turn_down
else

end
end
else
if sx == 0 and sy == 0
return
end
if sx.abs > sy.abs
sx > 0 ? turn_left : turn_right
else
sy > 0 ? turn_up : turn_down
end
end
end
def turn_away_from_player
sx = @x - $game_player.x
sy = @y - $game_player.y
if EIGHT_DIRECTION == true
if sx > 0
if sy > 0
turn_downright
elsif sy <0
turn_upright
else
turn_right
end
elsif sx <0
if sy > 0
turn_downleft
elsif sy <0
turn_upleft
else
turn_left
end
else
if sy > 0
turn_down
elsif sy <0
turn_up
else
end
end
else
if sx == 0 and sy == 0
return
endr
if sx.abs > sy.abs
sx > 0 ? turn_right : turn_left
else
sy > 0 ? turn_down : turn_up
end
end
end
end
end

class Game_Player < Game_Character
alias tsl_gameplayer_update update
def update
last_moving = moving?
unless moving? or $game_system.map_interpreter.running? or
@move_route_forcing or $game_temp.message_window_showing
if EIGHT_DIRECTION == true
case Input.dir8
when 1
move_lower_left
when 2
move_down
when 3
move_lower_right
when 4
move_left
when 6
move_right
when 7
move_upper_left
when 8
move_up
when 9
move_upper_right
end
else
case Input.dir4
when 2
move_down
when 4
move_left
when 6
move_right
when 8
move_up
end
end
end
tsl_gameplayer_update
end
end

class Window_Base < Window
def draw_actor_graphic(actor, x, y)
bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
if HERO_STAND
cw = bitmap.width / (HERO_FRAME + 1)
else
cw = bitmap.width / HERO_FRAME
end
ch = bitmap.height / 4
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
end
end
 

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