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.

How do you make tiles that player can walk on but not events

I was wondering if there is a way on RPG Maker XP tilesets to make a spot that the player can walk on but not the events, I don't know what "Counter Flag" and "Terrain Tag" mean while putting a tileset in or what they do, but if they help in any way with spots that only player can walk on, please I would like to know what they do.

In one city in my game, there is grass, and a path, I want the player to be able to walk on the path AND the grass, but I only want the events to be able to walk around on the path, NOT the grass.

If there is a way to do this would somebody please tell me?
:angel:
Thank you
 
Events without the Trough flag set will not walk on other events unless they have the Trough flag set. This even holds true if it's an event with empty graphics, so you can fence in areas you don't want events to walk on. If there's to many areas which needs to be fenced in this won't be a very appealing solution though.
 

Zeriab

Sponsor

It sounds like there are many areas to be fenced by blank events, so I suggest using terrain tags.
I have made a script which restricts events movement based on the terrain tag of the tiles.

This is a script which can be used to make events as well as the player to stick to a specific terrain tag or don't allow them to enter a specific terrain tag.

Code:
class Game_Character

  attr_accessor :terrain_tag

  alias_method(:zeriab_terrain_tag_passable, :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)

    if terrain_tag 

      if (terrain_tag > 0 && $game_map.terrain_tag(new_x,new_y) != terrain_tag) ||

         (terrain_tag < 0 && $game_map.terrain_tag(new_x,new_y) == -terrain_tag)

        return false

      end

    end

    return zeriab_terrain_tag_passable(x, y, d)

  end

end

 

class Game_Event < Game_Character

  alias_method(:zeriab_terrain_tag_init, :initialize)

  

  def initialize(map_id, event)

    zeriab_terrain_tag_init(map_id, event)

    if event.name.include?('<t>')

      self.terrain_tag = $game_map.terrain_tag(x, y)

    elsif !(/<t=(\d*)>/ =~ event.name).nil?

      self.terrain_tag = $1.to_i

    elsif !(/<t=-(\d*)>/ =~ event.name).nil?

      self.terrain_tag = -($1.to_i)

    end

  end

end

For events:
Put <t> in the name and it will keep to tiles of the same terrain tag as the one it starts on.
Put <t=3> in the name to make it stick to tiles with terrain tags = 3. If it is outside it will simply not move, it can turn, but it cannot move.
Put <t=-1> in the name to prevent it from moving onto tiles with terrain tag = 1.

If you want to change it dynamically you will have to do something like $game_map.event[42].terrain_tag = 5 to change it. Setting it to nil removes the terrain tag. Setting it to a negative number prevents entering such a tile.
Note that it will reset on map change. (To whatever is in the name or nil)

For the player:
$game_player.terrain_tag = 2
The player cannot go to a tile which has a different terrain tag than 2.
$game_player.terrain_tag = nil
Disable the terrain tag restriction, the player can now move normally.
$game_player.terrain_tag = -4
The player cannot move to a tile which have terrain tag 4.

*hugs*
- Zeriab

Please let me know if you have any problems.

*hugs*
- Zeriab
 
I tried the script, and I put <t=-1> as the events name, and then I pu the grass as terrain 1, but the event still walks on the grass as well
Is there anything else I'm suppost to do?

EDIT: Nevermind! I figured it out. Thanks a lot!
 

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