Moving player to walk-able tiles

Hi all,

I'm trying to figure out the simplest means in which I can get a player to move to a contiguous tile that allows passage, when their X and Y coordinates could be at almost anywhere on the map that they're allowed to walk.

This would be executed via some kind of event (or events), ideally a single common event.

Whichever way they're facing, I would like them to try 2 steps backward if possible, 1 if that's not possible, and then go into more options if neither of those are achieved (like, forward stepping, or stepping to the left or right).

If one step backwards is successful as mentioned, I would like to try for another one before looking at those other options.

This needs to account for other events on the map that the player can't walk through.

Thanks!

EDIT: I'm looking for a solution that doesn't use regions, just because the map is already loaded with a bunch of them for other systems in place. Also, because this is a method I wish to use widely throughout the game, it would be impractical to go through every map required and double-handle the walk-able tiles by putting regions over the top of them.
Iam not sure if i correctly understand your problem, but here maybe a workaround.

Before you Teleport to this Map, Fade your Screen out manualy, than teleport without fade, to any position on that map.
Now on that map you got an Parallel Event, its Eventpagecode is:
Teleport Player without fade to the wanted position on this map, than manualy fade in the screen again than Eventcommand Erase Event (Thatway its deleted until map is reentered)
If this isnt working for you, than a different solution with position checks and more is needed.
I'm a bit confused as well, I think what you're asking is easily solved by...
http://www.yanfly.moe/wiki/Move_Route_Core_(YEP) and a simple movement route. Set it to wait/skip, 1 Step Backward, 1 Step Backward, "this.moveToPoint(x, y)" (that already path finds up to 12 iterations and avoids impassible tiles/events).... And if you use game variables for X and Y "this.moveToPoint($gameVariables.value(#), $gameVariables.value(#))" then you can keep feeding the movement route new locations till you get bored.

...But I'm also not 100% certain that's what you're asking. :hswt:
Yes of course making the player "through On" and speed up, moving him while screen is faded out and check after every step if the tile he is on
is passable or not. than turn through off and fade screen in and reduce speed again and or teleport back to other map. (Atleast in Theory =))
if you want to do this manually for some reason, you need to use the command "get location info" on the tile you want to check for passability or anything else.
However this approach is tedious, so it would be better if you tell us what you want to do instead of how you want to do it. (description of a mechanic is how to do, description of what the player should experience ingame is what to do)
Hi @Andar

Sure, running from battle from on-map encounters. The battles themselves are the default kind, not some kind of active battle system stuff.

The encounters may activate because they are prompted through auto-run in some cases, or because the player steps on a region, or because the player comes too close to the patrolling enemy.

It varies, but those 3 possibilities pretty much cover it.
Why dont you teleport them back to the Map Coordinate/Place where the Battle got triggered?

Do i get this correctly?
1. You trigger a Fight on the Game Map.
2. You than initiate a standard Battle.
3. Afterwards the Player is standing again on the Map tile where the battle got triggered.
4. What is the problem? does the battle restart all the time? can't the player move away from that event/Region?

I dont understand what happens which should not, and i dont understand what is not happening but should happen.
Also dont jump on Regions, Events and promptations at once, let us struggle with one of them at a time, so we are able to understand the problem.

Big Guess: To escape From Events which triggered a Battle.
Activate a Selfswitch after battle, that selfswitch is pagecondition for higher numbered parallel Eventpage.
Mark through if Event shall be passable for that period of time
Eventcode: Wait 300Frames , turn self switch A Off again.

---------------------------------------
So after each battle the Enemy will blink and be passable for 5 seconds and dont trigger a new fight, so the player can safely walk away from it without retriggering it. (That would be into the direction what andar was asking for)

So, please give more details, help us to help you.
2 problems here.

1) There is not a specific tile in which a battle can be triggered. Events run toward the player, and the battle triggers when they touch. So warping then to where the battle started is a problem in itself.

2) Enemies stepping backward from the player is not the dynamic I’m trying to achieve. Yes, I could make the events step backward and for the player to walk past them, but that would defeat the purpose of an enemy guarding an area that the player cannot pass until they are defeated.

Going back to my original question - I’ve looked into getting the player X and Y’s position, but I don’t know how to check if a tile is passable. Any thoughts on that, anyone?

Thanks!
You could try this script call, e.g. in Conditional Branch > Script:
Code:
$gamePlayer.canPass($gamePlayer.x, $gamePlayer.y, 2)
Replace 2 with the appropriate numpad direction: 2 = down, 4 = left, 6 = right, 8 = up. In theory this'll return true iff the player can pass in that direction. 😮‍💨

For a globally-applicable solution, you'd be looking at an "inverse" pathfinding algorithm, i.e. one that seeks to increase distance from the target rather than reduce it. I imagine it'd be doable by making a copy of the existing pathfinding algorithm with some of the conditions flipped? 😴
Thanks @caethyril !

That will do the trick! I can also just do a bit more math in the same script to get the enemy’s x and y and work with that as well.

Cheers!
to2: I didnt said one word about events making a step backward in my last post.

to1: it doesnt matter from where the battle got initiated,because after a standard battle, the player will automatically be teleported back to the point where the battle started.

I cant get any useful information out of your answers to my questions, thatway i can't do anything for you.
Have a nice Day.
Sorry @Bex - I’m having trouble understanding what you’re getting at. Apologies for the confusion.
Thread closed IgnoreMeProblem reported as Solved by the OP.

Original thread: https://forums.rpgmakerweb.com/threads/moving-player-to-walk-able-tiles.113688/