Chaos Project

RPG Maker => RPG Maker Scripts => Script Troubleshooting => Topic started by: Karltheking4 on January 18, 2011, 12:24:49 am

Title: Terrain tag of tile in front of player
Post by: Karltheking4 on January 18, 2011, 12:24:49 am
I was wondering if anyone knows how to check the terrain tag id of the tile directly infront of the player?
At the moment I have an invisable event going to the spot in front of the player, and check it's terrain tag like that, but I'm guessing there is a simplier and probably more lag free way of checking the tile in front, but I can't find it for the life of me!

The second (kind of related) question, is how can I get the player to stop moving for a second? The closest I've got is a move route with a wait 4 frames command in it, I think it was working, but it doesn't want to do anything anymore :/

Thanks :)
Title: Re: Terrain tag of tile in front of player
Post by: ForeverZer0 on January 18, 2011, 01:00:13 am
Place this below Game_Player.
The variable you define will always be equal to the terrain tag value of the tile in front of the player.

class Game_Player
 
  TERRAIN_VARIABLE = 45
  # Set to the variable that will store the terrain tag of the tile
  # directly in front of player
 
  alias check_front_terrain check_event_trigger_there
  # Have variable refresh every time player takes a step.
  def check_event_trigger_there(triggers)
    # Get coordinates of the tile in front of player.
    front_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
    front_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
    # Set defined variable to its terrain tag value.
    $game_variables[TERRAIN_VARIABLE] = $game_map.terrain_tag(front_x, front_y)
    # Call normal method.
    check_front_terrain(triggers)
  end
end
Title: Re: Terrain tag of tile in front of player
Post by: Karltheking4 on January 18, 2011, 01:13:30 am
It would have been enough to tell me you can use this:
$game_map.terrain_tag(front_x, front_y)

But thanking you greatly for the code aswell :)