A SOKOBAN puzzle is one where you have to push objects, one step at a time, onto specific locations, and the puzzle is complete when all objects are where they're meant to be. The challenge is to keep yourself free to move, while not moving any objects into a wall or corner where you can't get it out again.
Koi asked for help to create one of these, and as I'm listing the individual steps, figured it might be of interest to others.
This is a sokoban puzzle (image comes from Koi's support thread)
Spoiler
Step 1 - Draw your map
Mark in the walkable areas and borders, and place the destination tiles to indicate the destination for the objects (these must be passable tiles)
Spoiler
Step 2 - Make destination tiles 'special'
You can do this using terrain tags or regions.
To use terrain tags, just go to your Tileset tab, find your 'special' tile, and change its terrain id to something that's not in use elsewhere.
To use region ids, go to the region layer and paint with a single region id over the special tiles.
SpoilerTerrain Tags:
Region IDs:
Step 3 - Add your movable objects
There are a few ways you can set this up.
For something that rolls, you will want Walking Animation checked, but for something that does not have animations or directions, you'll want Walking Animation UNchecked and Direction Fix checked. Leave all the other options UNchecked.
Decide on your trigger - you can either leave it as Action Button, and make the player press space to move it, or just set it to Player Touch, which means just the player moving into it will force it to move.
The event commands are JUST to move the object away from the player (you may or may not want to add a sound effect) - we're not going to do any position checks or puzzle validation here. Make sure you check the Skip if Cannot Move box. It's up to you whether you want to add a Wait for Completion or not.
Make one, verify that it works, and then copy and paste it so all the objects are on their starting positions.
Spoiler
By now, you should be able to set your player position, and walk around pushing the objects in front of you. They should get caught in the corners or on the walls.
Step 4 - Check for puzzle complete
We'll use one "controller" event to monitor what's happening on the map and poll the object locations to see when the puzzle is complete.
It will run as a parallel process, checking every few frames to see where everything is. By default, a parallel process event will run all the commands listed, then will go back to the top and repeat the process, until we do something to tell it to stop.
When the puzzle is complete, it'll display a message and stop any further checks.
At this point, you will want to reward your player for completing the puzzle, and maybe stop them from pushing the objects around any more.
Step 4a - Get first event's X and Y coordinates, and find the terrain tag or region id at that location on the map
Spoiler
Step 4b - Compare with the 'special' terrain tag or region id
If it's not the 'special' terrain tag or region id, this object is not on its final tile and the puzzle is not solved. We don't need to check any more events, so just skip to the end, ready for the next iteration.
Spoiler
Step 4c - Repeat the test for all other movable object events
Copy and paste those lines so there's one group for each event. Then change the event ID in each group, so at the end you're doing the check for each of your movable object events
Spoiler
Step 4d - Success!!!
All objects are on the correct type of tile. Do whatever needs to be done to let the player know they've succeeded, and end the puzzle.
Spoiler
Step 4e - Failure
Just wait a few frames to avoid lag, then by default the event will start running from the top again.
Spoiler
Add your player's starting location in the correct spot, and play away.
本贴来自国际rpgmaker官方论坛作者:Shaz处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:
https://forums.rpgmakerweb.com/threads/make-a-sokoban-puzzle.16667/