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.

About encounters only in determined areas of a map...

Where can I find a working script that allows me to select the areas of a map where there are enemy encounters (equivalent to the grass in Pokemon games) so that in the other areas there aren't random encounters?

ps - i aint no expert...
 
I think this can be done by events.
First, normally make your room, putting random encounters on it. Then, on the start point of the room, make an event that has this command:
Change Encounter: Disable
And then, make the same event around every single tile of grass (NOT inside the grass!).
INSIDE each grass tile, make an event that has this command:
Change Encounter: Enable
There you have your pokemon encounter system! Hope I helped. :D
 
If it's a large area at all that you're talking about, even events that don't do anything until collision and have no graphics will add significantly to your lag issues.  It's possible to use conditional branches questioning the facing of the player, but that could lead to whole other issues:  if the player hits just the spot where you turn encounters on but doesn't cross over it, then turns back, encounters won't disable.  You could get over that by forcing the player to take a step forward whenever he crosses the event.  In either XP or VX, it should look something like this:
Player Touch Event
Code:
@>Set Move Route: Player
          :$>1 Step Forward
@>Conditional Branch: Player is Facing Down
     @>Change Encounter: Enable
     @>
      Else
     @>Change Encounter: Disable
     @>
      Branch End
@>
This would, of course, go on the north end of your field.  For the east end, check if facing left, west end checks right, and south end checks up.

For rectangular areas, if you're using VX, it may actually be beneficial to use a code snippet I posted.  It's located in this thread at the fifth post down.  With this little code inserted below Materials, you can do an event that looks something like the following:
Parallel Process Event:
Code:
@>Wait: 10 Frames
@>Conditional Branch: Script: get_distance(-1, [5,3]) < 4 and $game_player.y == 3
  (Insert the code from the other event here.)
This will check 6 times/second whether the player is within 3 tiles of the point (5, 3) on the map, and whether he's standing on the line y=3.  If both are true, it'll run the event.  Now, you can use this tactic to trigger a conditional by walking onto any point (rather than just where the event is), across any line (bounded by a distance from a given point, as done in the example I just gave), or by walking into any circular area.

Using this method is simplest if you're dealing with rectangles, but if you're using VX, you probably use Areas for that anyway.  It's also most efficient if you're dealing with large areas.

I will go check whether the method can port over to XP seamlessly (and I might smooth it out a bit more in the process.)  If it doesn't, I'll fix it and edit my post in the other thread to include it.  Either way, I'll fill you in with an edit to this post (or a reply, if somebody else has said something since.)

Quick edit:  On second thought, if you're using the line-checking option, you can check two parallel lines rather than stepping forward.  If the player's on the inner line, turn encounters on, and if on the outer line, turn them off.

Final edit:  The snippet works in both programs now, and I've improved the handling so you don't need so many stupid arguments in the call.  Feel free to use it.
 

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