MZ Is there a way to check if a player cannot move?

In my game you can step on jump pads that fling you across the room. You can also move blocks. The idea is, if your landing path isn't clear, you die.

the idea is to check if the player can move and/or is standing on a solid object. If they are, I can run a common event for their death. However I cannot seem to find a way to check if the player can currently move. Is there a way to check that?
There are two unrelated concepts of "cannot move". It could mean "can't take a step on the map", or "can't take an action in battle".

From your description, it sounds like you're looking for the first one. So, basically, you want to know if the player is surrounded by impassable tiles, right?

To determine whether it's currently possible for the player to move in a particular direction, the script call is:

JavaScript:
$gamePlayer.canPass($gamePlayer.x, $gamePlayer.y, DIR)

Replace DIR with the direction number from the numeric keypad. By default, diagonals are not supported; if you do need diagonals though, there's a separate script call for that which works a bit differently.

That's for one direction. If you need all 4, just repeat the same call 4 times, each with a different direction, and separated by &&. Or, alternatively, go the cool route and use reduce:

JavaScript:
[2,4,6,8].some(DIR => $gamePlayer.canPass($gamePlayer.x, $gamePlayer.y, DIR))

For this one, you don't need to substitute DIR – the call automatically does that for you with each of the 4 directions and returns whether any of them are viable.

Note: That will check for blocking events as well as tiles. If for some reason you only want to check tiles, just use isMapPassable instead of canPass.
Checking against Region ID seems like the most painless way to do what you want. If they land on a tile with Region ID x, they live. If not, or if they land on a tile with Region ID y, they die.
That's definitely a valid approach as well. It does mean you need to carefully mark all the tiles where you're stuck, but it's a bit more flexible in that it could catch cases where there are two isolated tiles that are connected to each other but can't be escaped from.
There are two unrelated concepts of "cannot move". It could mean "can't take a step on the map", or "can't take an action in battle".

From your description, it sounds like you're looking for the first one. So, basically, you want to know if the player is surrounded by impassable tiles, right?

To determine whether it's currently possible for the player to move in a particular direction, the script call is:

JavaScript:
$gamePlayer.canPass($gamePlayer.x, $gamePlayer.y, DIR)

Replace DIR with the direction number from the numeric keypad. By default, diagonals are not supported; if you do need diagonals though, there's a separate script call for that which works a bit differently.

That's for one direction. If you need all 4, just repeat the same call 4 times, each with a different direction, and separated by &&. Or, alternatively, go the cool route and use reduce:

JavaScript:
[2,4,6,8].some(DIR => $gamePlayer.canPass($gamePlayer.x, $gamePlayer.y, DIR))

For this one, you don't need to substitute DIR – the call automatically does that for you with each of the 4 directions and returns whether any of them are viable.

Note: That will check for blocking events as well as tiles. If for some reason you only want to check tiles, just use isMapPassable instead of canPass.
That worked perfectly, thank you! The only issue I'm running into is in regards to events. It appears that since by default you can move out of an event even if it is the same as character, the check doesn't count it, which is a bit of a problem. I think the region IDs could work as a workaround (as in, checking if the event and the player are in the same ID) but is there another way?

EDIT: Realizing now that the region ID may not be possible for a chunk of cases. I have a region ID to tell if the player is near a ledge, which the player can land in, so I couldn't have two. Hm...
It's true that an event usually imposes no passbility restrictions on other characters occupying the same tile. There's one exception (I think), but it might not be of use to you – if it's set to Below Characters and uses an impassable tile as its image, I believe it will forbid you from stepping off of it. But there's no way (without plugins) to replicate this if you're using a character image (rather than a tile image) or if it's set to Same As Characters or Above Characters.

You can, however, simply test if an event is on the same tile as the player. Perhaps that'll be sufficient for your use-case?
That would be sufficient, yes!

Original thread: https://forums.rpgmakerweb.com/threads/is-there-a-way-to-check-if-a-player-cannot-move.182843/