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.

[Resolved] Face Direction then move ?

Status
Not open for further replies.

Jason

Awesome Bro

Hello, I am in need of a script, which MAY be used in my game (If it works as I wish)

What I need is something LIKE the resident evil movement, but it isnt...

For example, when you press down, you will face down, but not move, if you press down again, you will move.
when you press left, you will face left, but not move, if you press left again, you will move.

Thats basically all I need, however, I would like it if I could activate it using a switch.

Thankyou.
 
Try this out:
Code:
class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Remember whether or not moving in local variables
    last_moving = moving?
    # Check if still pressing button after turning
    if $game_switches[1] and @turning
      if Input.dir4 == 0
        @turning = false
      else
        return
      end
    end
    # If moving, event running, move route forcing, and message window
    # display are all not occurring
    unless moving? or $game_system.map_interpreter.running? or
           @move_route_forcing or $game_temp.message_window_showing
      # Move player in the direction the directional button is being pressed
      if !$game_switches[1] or Input.dir4 == @direction
        case Input.dir4
        when 2
          move_down
        when 4
          move_left
        when 6
          move_right
        when 8
          move_up
        end
      else
        case Input.dir4
        when 2
          turn_down
          straighten
          @turning = true
        when 4
          turn_left
          straighten
          @turning = true
        when 6
          turn_right
          straighten
          @turning = true
        when 8
          turn_up
          straighten
          @turning = true
        end
      end
    end
    # Remember coordinates in local variables
    last_real_x = @real_x
    last_real_y = @real_y
    super
    # If character moves down and is positioned lower than the center
    # of the screen
    if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
      # Scroll map down
      $game_map.scroll_down(@real_y - last_real_y)
    end
    # If character moves left and is positioned more let on-screen than
    # center
    if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
      # Scroll map left
      $game_map.scroll_left(last_real_x - @real_x)
    end
    # If character moves right and is positioned more right on-screen than
    # center
    if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
      # Scroll map right
      $game_map.scroll_right(@real_x - last_real_x)
    end
    # If character moves up and is positioned higher than the center
    # of the screen
    if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
      # Scroll map up
      $game_map.scroll_up(last_real_y - @real_y)
    end
    # If not moving
    unless moving?
      # If player was moving last time
      if last_moving
        # Event determinant is via touch of same position event
        result = check_event_trigger_here([1,2])
        # If event which started does not exist
        if result == false
          # Disregard if debug mode is ON and ctrl key was pressed
          unless $DEBUG and Input.press?(Input::CTRL)
            # Encounter countdown
            if @encounter_count > 0
              @encounter_count -= 1
            end
          end
        end
      end
      # If C button was pressed
      if Input.trigger?(Input::C)
        # Same position and front event determinant
        check_event_trigger_here([0])
        check_event_trigger_there([0,1,2])
      end
    end
  end
end

To change which switch is controlling the script, change the number of the "$game_switches[1]" on lines 9 and 21.
 

boon

Sponsor

Hey there jbrist. There's a brilliant script for this that I asked about a while back; heres a link.
http://www.rmxp.org/forums/index.php?topic=39690.0

I've tried it, it does work.

The script found thanks to Gando:
Code:
=begin
Face the direction you press - Matte/Homer
http://www.rmxp.net/forums/index.php?showtopic=28183


Homer
Nov 14 2005, 04:58 PM
Hi there!
This is a script I made from a request really. It's not a big script or anything, but it's quite powerful.

What it does:
QUOTE(TehSpritah)

s it possible for anybody to create a script whereby tapping a direction button quickly will make a character merely face the direction pressed, as well as walking when it is held down? I noticed this in Poké­¯n, and it's a nice little feature that you can turn yourself without actually moving in that direction.


There are two ways to implement it;
Either place this in a new script above main:
CODE
=end

WAIT = 2



#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
# This class handles the player. Its functions include event starting
# determinants and map scrolling. Refer to "$game_player" for the one
# instance of this class.
#==============================================================================

class Game_Player < Game_Character
#--------------------------------------------------------------------------
# * Invariables
#--------------------------------------------------------------------------
CENTER_X = (320 - 16) * 4 # Center screen x-coordinate * 4
CENTER_Y = (240 - 16) * 4 # Center screen y-coordinate * 4
#--------------------------------------------------------------------------
# * Passable Determinants
# x : x-coordinate
# y : y-coordinate
# d : direction (0,2,4,6,8)
# * 0 = Determines if all directions are impassable (for jumping)
#--------------------------------------------------------------------------
def passable?(x, y, d)
# Get new coordinates
new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
# If coordinates are outside of map
unless $game_map.valid?(new_x, new_y)
# Impassable
return false
end
# If debug mode is ON and ctrl key was pressed
if $DEBUG and Input.press?(Input::CTRL)
# Passable
return true
end
super
end
#--------------------------------------------------------------------------
# * Set Map Display Position to Center of Screen
#--------------------------------------------------------------------------
def center(x, y)
max_x = ($game_map.width - 20) * 128
max_y = ($game_map.height - 15) * 128
$game_map.display_x = [0, [x * 128 - CENTER_X, max_x].min].max
$game_map.display_y = [0, [y * 128 - CENTER_Y, max_y].min].max
end
#--------------------------------------------------------------------------
# * Move to Designated Position
# x : x-coordinate
# y : y-coordinate
#--------------------------------------------------------------------------
def moveto(x, y)
super
# Centering
center(x, y)
# Make encounter count
make_encounter_count
end
#--------------------------------------------------------------------------
# * Increaase Steps
#--------------------------------------------------------------------------
def increase_steps
super
# If move route is not forcing
unless @move_route_forcing
# Increase steps
$game_party.increase_steps
# Number of steps are an even number
if $game_party.steps % 2 == 0
# Slip damage check
$game_party.check_map_slip_damage
end
end
end
#--------------------------------------------------------------------------
# * Get Encounter Count
#--------------------------------------------------------------------------
def encounter_count
return @encounter_count
end
#--------------------------------------------------------------------------
# * Make Encounter Count
#--------------------------------------------------------------------------
def make_encounter_count
# Image of two dice rolling
if $game_map.map_id != 0
n = $game_map.encounter_step
@encounter_count = rand(n) + rand(n) + 1
end
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
# If party members = 0
if $game_party.actors.size == 0
# Clear character file name and hue
@character_name = ""
@character_hue = 0
# End method
return
end
# Get lead actor
actor = $game_party.actors[0]
# Set character file name and hue
@character_name = actor.character_name
@character_hue = actor.character_hue
# Initialize opacity level and blending method
@opacity = 255
@blend_type = 0
end
#--------------------------------------------------------------------------
# * Same Position Starting Determinant
#--------------------------------------------------------------------------
def check_event_trigger_here(triggers)
result = false
# If event is running
if $game_system.map_interpreter.running?
return result
end
# All event loops
for event in $game_map.events.values
# If event coordinates and triggers are consistent
if event.x == @x and event.y == @y and triggers.include?(event.trigger)
# If starting determinant is same position event (other than jumping)
if not event.jumping? and event.over_trigger?
event.start
result = true
end
end
end
return result
end
#--------------------------------------------------------------------------
# * Front Envent Starting Determinant
#--------------------------------------------------------------------------
def check_event_trigger_there(triggers)
result = false
# If event is running
if $game_system.map_interpreter.running?
return result
end
# Calculate front event coordinates
new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
# All event loops
for event in $game_map.events.values
# If event coordinates and triggers are consistent
if event.x == new_x and event.y == new_y and
triggers.include?(event.trigger)
# If starting determinant is front event (other than jumping)
if not event.jumping? and not event.over_trigger?
event.start
result = true
end
end
end
# If fitting event is not found
if result == false
# If front tile is a counter
if $game_map.counter?(new_x, new_y)
# Calculate 1 tile inside coordinates
new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
# All event loops
for event in $game_map.events.values
# If event coordinates and triggers are consistent
if event.x == new_x and event.y == new_y and
triggers.include?(event.trigger)
# If starting determinant is front event (other than jumping)
if not event.jumping? and not event.over_trigger?
event.start
result = true
end
end
end
end
end
return result
end
#--------------------------------------------------------------------------
# * Touch Event Starting Determinant
#--------------------------------------------------------------------------
def check_event_trigger_touch(x, y)
result = false
# If event is running
if $game_system.map_interpreter.running?
return result
end
# All event loops
for event in $game_map.events.values
# If event coordinates and triggers are consistent
if event.x == x and event.y == y and [1,2].include?(event.trigger)
# If starting determinant is front event (other than jumping)
if not event.jumping? and not event.over_trigger?
event.start
result = true
end
end
end
return result
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Remember whether or not moving in local variables
last_moving = moving?
# If moving, event running, move route forcing, and message window
# display are all not occurring
unless moving? or $game_system.map_interpreter.running? or
@move_route_forcing or $game_temp.message_window_showing
# Move player in the direction the directional button is being pressed
if Input.press?(Input::DOWN)
turn_down
if @cur_dir == Input::DOWN and @w >= WAIT
move_down
end
if @w == nil or @cur_dir != Input::DOWN then @w = 0 end
@cur_dir = Input::DOWN
elsif Input.press?(Input::LEFT)
turn_left
if @cur_dir == Input::LEFT and @w >= WAIT
move_left
end
if @w == nil or @cur_dir != Input::LEFT then @w = 0 end
@cur_dir = Input::LEFT
elsif Input.press?(Input::RIGHT)
turn_right
if @cur_dir == Input::RIGHT and @w >= WAIT
move_right
end
if @w == nil or @cur_dir != Input::RIGHT then @w = 0 end
@cur_dir = Input::RIGHT
elsif Input.press?(Input::UP)
turn_up
if @cur_dir == Input::UP and @w >= WAIT
move_up
end
if @w == nil or @cur_dir != Input::UP then @w = 0 end
@cur_dir = Input::UP
end
if @w != nil
@w += 1
end
end
# Remember coordinates in local variables
last_real_x = @real_x
last_real_y = @real_y
super
# If character moves down and is positioned lower than the center
# of the screen
if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
# Scroll map down
$game_map.scroll_down(@real_y - last_real_y)
end
# If character moves left and is positioned more let on-screen than
# center
if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
# Scroll map left
$game_map.scroll_left(last_real_x - @real_x)
end
# If character moves right and is positioned more right on-screen than
# center
if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
# Scroll map right
$game_map.scroll_right(@real_x - last_real_x)
end
# If character moves up and is positioned higher than the center
# of the screen
if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
# Scroll map up
$game_map.scroll_up(last_real_y - @real_y)
end
# If not moving
unless moving?
# If player was moving last time
if last_moving
# Event determinant is via touch of same position event
result = check_event_trigger_here([1,2])
# If event which started does not exist
if result == false
# Disregard if debug mode is ON and ctrl key was pressed
unless $DEBUG and Input.press?(Input::CTRL)
# Encounter countdown
if @encounter_count > 0
@encounter_count -= 1
end
end
end
end
# If C button was pressed
if Input.trigger?(Input::C)
# Same position and front event determinant
check_event_trigger_here([0])
check_event_trigger_there([0,1,2])
end
end
end
end

=begin
COMMENTS BEGIN HERE

Or go to your Game_Player script and replace
CODE

case Input.dir4
when 2
move_down
when 4
move_left
when 6
move_right
when 8
move_up
end

With
CODE

if Input.press?(Input::DOWN)
turn_down
if @cur_dir == Input::DOWN and @w >= WAIT
move_down
end
if @w == nil or @cur_dir != Input::DOWN then @w = 0 end
@cur_dir = Input::DOWN
elsif Input.press?(Input::LEFT)
turn_left
if @cur_dir == Input::LEFT and @w >= WAIT
move_left
end
if @w == nil or @cur_dir != Input::LEFT then @w = 0 end
@cur_dir = Input::LEFT
elsif Input.press?(Input::RIGHT)
turn_right
if @cur_dir == Input::RIGHT and @w >= WAIT
move_right
end
if @w == nil or @cur_dir != Input::RIGHT then @w = 0 end
@cur_dir = Input::RIGHT
elsif Input.press?(Input::UP)
turn_up
if @cur_dir == Input::UP and @w >= WAIT
move_up
end
if @w == nil or @cur_dir != Input::UP then @w = 0 end
@cur_dir = Input::UP
end
if @w != nil
@w += 1
end


And then write, at top of the script (look on the first option to see where you should put it)
CODE

WAIT = 10


You can freely change the WAIT variable to whatever you like.
COMMENTS END HERE
=end
 
I don't know if you're talking to me or Boonzeet, but for mine, you just need to copy and paste it above main and below Game_Player, and make sure switch 1 is on. (You can edit which switch needs to be on like I described in my initial post)
 
I edited the Aleworks Push Events to include my little sciptlet, see if this works for you: (insert under your current APE, or overwrite it after you've checked that it works for you.) I assumed you were using the non SDK version, but if you're using the SDK version, let me know and I'll edit that one.
Code:
=begin =======================================================================
 â–“ Aleworks Push Events (APE)
==============================================================================
 Created by Aleworks
 Version: 1.01
 Last Update: 22/02/2008 (dd/mm/yyyy)
==============================================================================
                             *** Instructions ***
 For setup an event for being pushable, you need to add a comment with one or
 more of the commands in the comment commands list. The PUSH SPEED #, 
 PUSH DISTANCE #, PUSH SOUND # and PUSH TRIGGER commands, need that the
 PUSHABLE command be added.
==============================================================================
                         *** Comment Commands List *** 
 PUSHABLE
   If the player move in the direction of the event, it will move in the same
   direction the player moves, if the event can't move in that direction, it
   will try to move in other directions.
 PUSHABLE IN DIRECTION
   If the player move in the direction of the event, it will move in the same
   direction the player moves.
 PUSHABLE #
 PUSHABLE IN DIRECTION #
   Change the # with the posible directions that the event can be pushed.
 PUSH SPEED #
   Change the # with the speed that the event will move when pushed.
 PUSH DISTANCE #
   Change the # with the tiles that the event will be pushed.
 PUSH SOUND #
   Change the # with the file name of the sound effect that will be played when
   the event is pushed.
 PUSH TRIGGER
   The event will be pushed, only if the button C is pressed.
 TRASPASABLE
   Make that the player can pass through the event.
==============================================================================
                       *** APE RGSS Classes edits ***
 *** Game_Character ***
alias: update; alias name: aleworks_pushevents_gamecharacter_update
replace: passable?(x, y, d)
replace: screen_z
 *** Game_Event ***
alias: refresh; alias name: aleworks_pushevents_gameevent_refresh
 *** Game_Player ***
replace: update
==============================================================================
=end

#=============================================================================
# â–’ Game_Character
#=============================================================================
class Game_Character
  attr_accessor :move_speed
  alias aleworks_pushevents_gamecharacter_update update
  #===========================================================================
  # â–‘ update
  #===========================================================================
  def update
    if moving? == false and self.is_a?(Game_Event)
      if @left_push == 0
        @pushing = false
        @pushing_direction = 0
      else
        case @pushing_direction
        when 2
          move_down
          Audio.se_play("Audio/SE/" + @push_sound) if @push_sound != nil
        when 4
          move_left
          Audio.se_play("Audio/SE/" + @push_sound) if @push_sound != nil
        when 6
          move_right
          Audio.se_play("Audio/SE/" + @push_sound) if @push_sound != nil
        when 8
          move_up
          Audio.se_play("Audio/SE/" + @push_sound) if @push_sound != nil
        end
        @left_push -= 1
      end
    end
    if @old_speed != nil and @pushing == false
      @move_speed = @old_speed if @move_speed == @push_speed
      @old_speed = nil
    end
    aleworks_pushevents_gamecharacter_update
  end
  #===========================================================================
  # â–‘ passable?
  #===========================================================================
  def passable?(x, y, d)
    new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
    new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
    return false unless $game_map.valid?(new_x, new_y)
    return true if @through
    return false unless $game_map.passable?(x, y, d, self)
    return false unless $game_map.passable?(new_x, new_y, 10 - d)
    for event in $game_map.events.values
      if event.x == new_x and event.y == new_y
        next if self == $game_player and event.traspasable
        unless event.through
          return false if event.character_name != ""
        end
      end
    end
    if $game_player.x == new_x and $game_player.y == new_y
      unless $game_player.through
        return false if @character_name != ""
      end
    end
    return true
  end
  #===========================================================================
  # â–‘ screen_z
  #===========================================================================
  def screen_z(height = 0)
    return 999 if @always_on_top
    z = (@real_y - $game_map.display_y + 3) / 4 + 32
    if @tile_id > 0
      return z + $game_map.priorities[@tile_id] * 32
    else
      if self.is_a?(Game_Event)
        if @traspasable == true
          return z + ((height > 32) ? 31 : 0) + 16
        else
          return z + ((height > 32) ? 31 : 0)
        end
      else
        return z + ((height > 32) ? 31 : 0)
      end
    end
  end
end

#=============================================================================
# â–’ Game_Event
#=============================================================================
class Game_Event
  attr_reader :pushable
  attr_reader :push_speed
  attr_reader :push_distance
  attr_reader :traspasable
  attr_reader :push_in_diretion
  attr_reader :push_direction
  attr_reader :push_sound
  attr_reader :push_trigger
  attr_accessor :pushing
  attr_accessor :old_speed
  attr_accessor :left_push
  attr_accessor :pushing_direction
  alias aleworks_pushevents_gameevent_refresh refresh
  #===========================================================================
  # â–‘ refresh
  #===========================================================================
  def refresh
    @pushable = false
    @push_speed = nil
    @push_distance = 1
    @pushing = false
    @old_speed = nil
    @left_push = 0
    @push_direction = []
    @pushing_direction = 0
    @traspasable = false
    @push_in_diretion = false
    @push_sound = nil
    @push_trigger = false
    aleworks_pushevents_gameevent_refresh
    for i in @page.list
      if i.code == 108 or i.code == 408
        if i.parameters[0].upcase[/PUSHABLE/] != nil
          @pushable = true
          @push_in_diretion = true if i.parameters[0].upcase[/IN DIRECTION/] != nil
          @push_direction.push(2) if i.parameters[0][/2/] != nil
          @push_direction.push(4) if i.parameters[0][/4/] != nil
          @push_direction.push(6) if i.parameters[0][/6/] != nil
          @push_direction.push(8) if i.parameters[0][/8/] != nil
        end
        if i.parameters[0].upcase[/PUSH SPEED/] != nil
          @push_speed = i.parameters[0].split[2].to_i
        end
        if i.parameters[0].upcase[/PUSH DISTANCE/] != nil
          @push_distance = i.parameters[0].split[2].to_i
        end
        if i.parameters[0].upcase[/PUSH SOUND/] != nil
          @push_sound = i.parameters[0].split[2]
        end
        if i.parameters[0].upcase[/PUSH TRIGGER/] != nil
          @push_trigger = true
        end
        if i.parameters[0].upcase[/TRASPASABLE/] != nil
          @traspasable = true
        end
      end
    end
  end
end

#=============================================================================
# â–’ Game_Player
#=============================================================================
class Game_Player
  #===========================================================================
  # â–‘ update
  #===========================================================================
  def update
    last_moving = moving?
    # Check if still pressing button after turning
    if $game_switches[1] and @turning
      if Input.dir4 == 0
        @turning = false
      else
        return
      end
    end
    unless moving? or $game_system.map_interpreter.running? or
           @move_route_forcing or $game_temp.message_window_showing
      if !$game_switches[1] or Input.dir4 == @direction
        case Input.dir4
        when 2
          dir = 2
          alt_dir = [4,6,8]
          push_x = 0
          push_y = 1
        when 4
          dir = 4
          alt_dir = [2,6,8]
          push_x = -1
          push_y = 0
        when 6
          dir = 6
          alt_dir = [2,4,8]
          push_x = 1
          push_y = 0
        when 8
          dir = 8
          alt_dir = [2,4,6]
          push_x = 0
          push_y = -1
        else
          dir = 0
          push_x = 0
          push_y = 0
        end
        if passable?(@x, @y, dir) and dir != 0
          case dir
          when 2
            move_down
          when 4
            move_left
          when 6
            move_right
          when 8
            move_up
          end
        elsif dir != 0
          case dir
          when 2
            turn_down
            check_event_trigger_touch(@x, @y+1)
          when 4
            turn_left
            check_event_trigger_touch(@x-1, @y)
          when 6
            turn_right
            check_event_trigger_touch(@x+1, @y)
          when 8
            turn_up
            check_event_trigger_touch(@x, @y-1)
          end
          if $game_map.passable?(@x, @y, dir)
            for event in $game_map.events.values
              if event.x == @x + push_x and event.y == @y + push_y
                next if event.through == true
                next if event.pushable == false
                next if event.moving? == true
                next if event.push_trigger == true
                next if event.push_direction.size >= 1 and 
                        !event.push_direction.include?(dir)
                if event.passable?(event.x, event.y, dir)
                  event.pushing = true
                else
                  if !event.push_in_diretion
                    if event.passable?(event.x, event.y, alt_dir[0])
                      dir = alt_dir[0]
                      event.pushing = true
                    elsif event.passable?(event.x, event.y, alt_dir[1])
                      dir = alt_dir[1]
                      event.pushing = true
                    elsif event.passable?(event.x, event.y, alt_dir[2])
                      dir = alt_dir[2]
                      event.pushing = true
                    end
                  end
                end
                if event.pushing == true
                  case dir
                  when 2
                    event.move_down
                  when 4
                    event.move_left
                  when 6
                    event.move_right
                  when 8
                    event.move_up
                  end
                  if event.push_speed != nil
                    event.old_speed = event.move_speed
                    event.move_speed = event.push_speed
                  end
                  if event.push_distance > 1
                    event.left_push = event.push_distance
                    event.pushing_direction = dir
                  end
                  if event.push_sound != nil
                    Audio.se_play("Audio/SE/" + event.push_sound)
                  end
                end
              end
            end
          end
        end
      else
        case Input.dir4
        when 2
          turn_down
          straighten
          @turning = true
        when 4
          turn_left
          straighten
          @turning = true
        when 6
          turn_right
          straighten
          @turning = true
        when 8
          turn_up
          straighten
          @turning = true
        end
      end
    end
    last_real_x = @real_x
    last_real_y = @real_y
    super
    if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
      $game_map.scroll_down(@real_y - last_real_y)
    end
    if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
      $game_map.scroll_left(last_real_x - @real_x)
    end
    if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
      $game_map.scroll_right(@real_x - last_real_x)
    end
    if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
      $game_map.scroll_up(last_real_y - @real_y)
    end
    unless moving?
      if last_moving
        result = check_event_trigger_here([1,2])
        if result == false
          unless $DEBUG and Input.press?(Input::CTRL)
            if @encounter_count > 0
              @encounter_count -= 1
            end
          end
        end
      end
      if Input.trigger?(Input::C)
        check_event_trigger_here([0])
        check_event_trigger_there([0,1,2])
        case @direction
        when 2
          dir = 2
          alt_dir = [4,6,8]
          push_x = 0
          push_y = 1
        when 4
          dir = 4
          alt_dir = [2,6,8]
          push_x = -1
          push_y = 0
        when 6
          dir = 6
          alt_dir = [2,4,8]
          push_x = 1
          push_y = 0
        when 8
          dir = 8
          alt_dir = [2,4,6]
          push_x = 0
          push_y = -1
        else
          dir = 0
          push_x = 0
          push_y = 0
        end
        for event in $game_map.events.values
          if event.x == @x + push_x and event.y == @y + push_y
            next if event.through == true
            next if event.pushable == false
            next if event.push_trigger == false
            next if event.moving? == true
            next if event.push_direction.size >= 1 and 
                    !event.push_direction.include?(dir)
            if event.passable?(event.x, event.y, dir)
              event.pushing = true
            else
              if !event.push_in_diretion
                if event.passable?(event.x, event.y, alt_dir[0])
                  dir = alt_dir[0]
                  event.pushing = true
                elsif event.passable?(event.x, event.y, alt_dir[1])
                  dir = alt_dir[1]
                  event.pushing = true
                elsif event.passable?(event.x, event.y, alt_dir[2])
                  dir = alt_dir[2]
                  event.pushing = true
                end
              end
            end
            if event.pushing == true
              case dir
              when 2
                event.move_down
              when 4
                event.move_left
              when 6
                event.move_right
              when 8
                event.move_up
              end
              if event.push_speed != nil
                event.old_speed = event.move_speed
                event.move_speed = event.push_speed
              end
              if event.push_distance > 1
                event.left_push = event.push_distance
                event.pushing_direction = dir
              end
              if event.push_sound != nil
                Audio.se_play("Audio/SE/" + event.push_sound)
              end
            end
          end
        end
      end
    end
  end
end
The two lines to edit for the switch are now lines 208 and 217.
 
Didn't cause me any grief when I tested it. And I didn't even edit that part of the script. :\
Are you using the SDK version or the non-SDK version? (And any other scripts that might edit the Game_Player update method?
(or pm me the Scripts.rxdata file and I'll edit it right into it)
 
Status
Not open for further replies.

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