[PSDK] Indoor Exit Arrow

6 Replies • 698 Views

This is an imitated script of the one made by Tustin2121 for Pokemon Essentials, I have made it possible to get the same desired effect for the PSDK.



How to use:

Make the exit event name "ExitArrow" and use this character graphic or any you prefer to appear when u stand near the exit.
Make sure the arrow points in the right direction.
Use Stop Animation in the Events window if you want it to be animated.
Script goes in your_project_folder/scripts

Code
################################################################################
# Simple Exit Arrows - by Tustin2121 and mustafa505
# To use, set the graphic of your exit warp event to an arrow with
# the desired hue and name it "ExitArrow" (without the quotes).
#
# The below code will do the work of hiding and showing the arrow when needed.
################################################################################
 
class Game_Map
  def load_events
  pxCheckExitArrows
    return unless @events_info
    $game_player.z = @events_info[:player]
    @events_info.each do |id, info|
      next unless (event = @events[id])
      next unless event.original_map == @map_id
      event.moveto(info[0], info[1])
      event.z = info[2]
      event.direction = info[3]
      event.instance_variable_set(:@move_route_index, info[4])
      event.__bridge = info[5]
      event.clear_starting
      event.check_event_trigger_auto
    end
    $game_player.check_event_trigger_here([1, 2])
    @events_info = nil
  end
end
class Game_Player < Game_Character
  # Run when the player turns.
  # The default version of this method is empty, so replacing it outright
  # like this is fine. You may want to double check, just in case, however.
  def pbCheckEventTriggerAfterTurning
    pxCheckExitArrows
  end
  def update
    return send(@update_callback) if @update_callback
    last_moving = moving?
    if moving? || $game_system.map_interpreter.running? ||
      @move_route_forcing || $game_temp.message_window_showing || @sliding # or follower_sliding?
      pxCheckExitArrows
      if $game_system.map_interpreter.running?
        @step_anime = false
        enter_in_walking_state if @state == :running
        pxCheckExitArrows(true)
      end
    else
      player_update_move
      player_move_on_cracked_floor_update if moving? && !last_moving
    end
    @wturn -= 1 if @wturn > 0
    last_real_x = @real_x
    last_real_y = @real_y
    super
    # _BUMP
=begin
    if(@cant_bump and moving?)
      @cant_bump=false
    end
=end
    update_scroll_map(last_real_x, last_real_y)
    update_check_trigger(last_moving) unless moving? || @sliding
  end
end
 
class Game_Character
  # Add accessors for some otherwise hidden options
  attr_accessor :step_anime
  attr_accessor :direction_fix
    def turn_down
    pxCheckExitArrows
    unless @direction_fix
      @direction = 2
      @stop_count = 0
    end
  end
 
  # Turn left unless direction fix
  def turn_left
    pxCheckExitArrows
    unless @direction_fix
      @direction = 4
      @stop_count = 0
    end
  end
 
  # Turn right unless direction fix
  def turn_right
    pxCheckExitArrows
    unless @direction_fix
      @direction = 6
      @stop_count = 0
    end
  end
 
  # Turn up unless direction fix
  def turn_up
    pxCheckExitArrows
    unless @direction_fix
      @direction = 8
      @stop_count = 0
    end
  end
end
 
# Checks if the player is standing next to the exit arrow, facing it.
def pxCheckExitArrows(init=false)
  px = $game_player.x
  py = $game_player.y
  if $game_map
  for game_event in $game_map.events.values
      next unless game_event
      next if !game_event.event.name.include?('ExitArrow')
      game_event.transparent
      case $game_player.direction
      when 2 #down
        game_event.transparent = !(px == game_event.x && py == game_event.y - 1)
      when 8 #up
        game_event.transparent = !(px == game_event.x && py == game_event.y + 1)
      when 4 #left
        game_event.transparent = !(px == game_event.x + 1 && py == game_event.y)
      when 6 #right
        game_event.transparent = !(px == game_event.x - 1 && py == game_event.y)
      end
      if init
        # This homogenizes the Exit Arrows to all act the same, that is
        # a slow flashing arrow. If you want to change the behavior,
        # change the values below.
        game_event.move_speed = 1
       
      end
    end
  end
end

Credits:
Tustin2121
mustafa505
Rey

« Last Edit: 06 November 2021, 21:58:46 by Rey »

Bonsoir,

Afin d'en aider plus d'un qui débute, je joins la capture d'écran de comment configurer l'évènement de sortie avec les flèches.  :)

Bien à vous
Bonsoir,

Afin d'en aider plus d'un qui débute, je joins la capture d'écran de comment configurer l'évènement de sortie avec les flèches.  :)

Bien à vous
You don't need to use a conditional branch, event sprite is handled is by the script.
Just set to Stop Animation as true and I set custom move route here and Direction fix to make sure arrow does not face player

« Last Edit: 11 April 2021, 13:12:01 by Mustafa »

I tried the script and got this error:

Message :
uninitialized constant Events

Type : NameError
Script : 00010 simple_exit_arrow.rb (user)
Ligne : 56
Date : 16/09/2021 21:56:19
Game Version : 256
Logiciel : Pokémon SDK 25.4

And indeed if I use VS Code search function to search
Events.onMapSceneChange
(line 56) it can't find anything. What can I do?

Rey

Modérateur

Your problem does not seem to be related at all with Mustafa's script. Your problem comes from the file 00010 simple_exit_arrow.rb.
Your problem comes from the file 00010 simple_exit_arrow.rb.

Exactly where I pasted the script we're talking about.
Reuploading the script here as I was told it was missing from the attachment.
Spoiler
################################################################################
# Simple Exit Arrows - by Tustin2121 and mustafa505
# To use, set the graphic of your exit warp event to an arrow with
# the desired hue and name it "ExitArrow" (without the quotes).
#
# The below code will do the work of hiding and showing the arrow when needed.
################################################################################
 
class Game_Map
  def load_events
  pxCheckExitArrows
    return unless @events_info
    $game_player.z = @events_info[:player]
    @events_info.each do |id, info|
      next unless (event = @events[id])
      next unless event.original_map == @map_id
      event.moveto(info[0], info[1])
      event.z = info[2]
      event.direction = info[3]
      event.instance_variable_set(:@move_route_index, info[4])
      event.__bridge = info[5]
      event.clear_starting
      event.check_event_trigger_auto
    end
    $game_player.check_event_trigger_here([1, 2])
    @events_info = nil
  end
end
class Game_Player < Game_Character
  # Run when the player turns.
  # The default version of this method is empty, so replacing it outright
  # like this is fine. You may want to double check, just in case, however.
  def pbCheckEventTriggerAfterTurning
    pxCheckExitArrows
  end
  def update
    return send(@update_callback) if @update_callback
    last_moving = moving?
    if moving? || $game_system.map_interpreter.running? ||
      @move_route_forcing || $game_temp.message_window_showing || @sliding # or follower_sliding?
      pxCheckExitArrows
      if $game_system.map_interpreter.running?
        @step_anime = false
        enter_in_walking_state if @state == :running
        pxCheckExitArrows(true)
      end
    else
      player_update_move
      player_move_on_cracked_floor_update if moving? && !last_moving
    end
    @wturn -= 1 if @wturn > 0
    last_real_x = @real_x
    last_real_y = @real_y
    super
    # _BUMP
=begin
    if(@cant_bump and moving?)
      @cant_bump=false
    end
=end
    update_scroll_map(last_real_x, last_real_y)
    update_check_trigger(last_moving) unless moving? || @sliding
  end
end
 
class Game_Character
  # Add accessors for some otherwise hidden options
  attr_accessor :step_anime
  attr_accessor :direction_fix
    def turn_down
    pxCheckExitArrows
    unless @direction_fix
      @direction = 2
      @stop_count = 0
    end
  end
 
  # Turn left unless direction fix
  def turn_left
    pxCheckExitArrows
    unless @direction_fix
      @direction = 4
      @stop_count = 0
    end
  end
 
  # Turn right unless direction fix
  def turn_right
    pxCheckExitArrows
    unless @direction_fix
      @direction = 6
      @stop_count = 0
    end
  end
 
  # Turn up unless direction fix
  def turn_up
    pxCheckExitArrows
    unless @direction_fix
      @direction = 8
      @stop_count = 0
    end
  end
end
 
# Checks if the player is standing next to the exit arrow, facing it.
def pxCheckExitArrows(init=false)
  px = $game_player.x
  py = $game_player.y
  if $game_map
  for game_event in $game_map.events.values
      next unless game_event
      next if !game_event.event.name.include?('ExitArrow')
      game_event.transparent
      case $game_player.direction
      when 2 #down
        game_event.transparent = !(px == game_event.x && py == game_event.y - 1)
      when 8 #up
        game_event.transparent = !(px == game_event.x && py == game_event.y + 1)
      when 4 #left
        game_event.transparent = !(px == game_event.x + 1 && py == game_event.y)
      when 6 #right
        game_event.transparent = !(px == game_event.x - 1 && py == game_event.y)
      end
      if init
        # This homogenizes the Exit Arrows to all act the same, that is
        # a slow flashing arrow. If you want to change the behavior,
        # change the values below.
        game_event.move_speed = 1
       
      end
    end
  end
end


« Last Edit: 06 November 2021, 21:54:34 by Rey »


There was an error while thanking
Thanking...