Sokoban Puzzles

Koi

Veteran
Veteran
Joined
Aug 8, 2013
Messages
358
Reaction score
14
First Language
English
Primarily Uses
RMVXA
So I'm making a Sokoban puzzle in my game, but I'm not sure how to make it work...

Psst this is a Sokoban puzzle:



I looked up variables and got a basic idea of how to use them. Basically what I want is for movable rocks to activate a variable when placed on certain tiles, and when all have been correctly placed (4 of them in all), a door will open.

Please help?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
The easiest way is to just use Region IDs to paint the tiles where the boxes need to go, then have a parallel process event running on that map that does something like this:

Code:
Get Location Info (Event 1's region id) into a variableIf variable is not correct region id  Jump to Label 'fail'EndGet Location Info (Event 2's region id) into the same variableIf variable is not correct region id  Jump to Label 'fail'End... repeat for each event that represents a boxGet Location Info (last event's region id) into the same variableIf variable is not correct region id  Jump to Label 'fail'End# By this stage, all box events are on the correct tiles# do winning stuffSet Self Switch A on (controls next page on same event, which stops the parallel process from repeating)Label 'fail'Wait 5 frames (so there's no lag)
That way your events just have to worry about moving, and your 'success' check is entirely independent.
 

Koi

Veteran
Veteran
Joined
Aug 8, 2013
Messages
358
Reaction score
14
First Language
English
Primarily Uses
RMVXA
The easiest way is to just use Region IDs to paint the tiles where the boxes need to go, then have a parallel process event running on that map that does something like this:

Get Location Info (Event 1's region id) into a variableIf variable is not correct region id Jump to Label 'fail'EndGet Location Info (Event 2's region id) into the same variableIf variable is not correct region id Jump to Label 'fail'End... repeat for each event that represents a boxGet Location Info (last event's region id) into the same variableIf variable is not correct region id Jump to Label 'fail'End# By this stage, all box events are on the correct tiles# do winning stuffSet Self Switch A on (controls next page on same event, which stops the parallel process from repeating)Label 'fail'Wait 5 frames (so there's no lag)That way your events just have to worry about moving, and your 'success' check is entirely independent.
I can't read RGSS3, and I have no idea what Region IDs are. You'll have to forgive me, this is my first time working in RPG Maker.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
That is not RGSS3. It's just pseudocode - you can do it all with event commands.


- Get Location Info


- Conditional Branch (variable)


- Jump to Label


- Label


In your editor, there's an icon to do map editing, an icon to edit events, and the next icon is to edit the regions. Hit that, choose a single region from the palette, and click on all the destination tiles with it. Then you can use Get Location Info to get the region id of an event, and see if the event is on one of those tiles.


Oh wait - there's a mistake there. I thought you could select events and get the region id. You can't - it requires coordinates. So prior to each Get Location Info, you'd have to do a Change Variables to get each event's X and Y value, and use the variables in the Get Location Info to retrieve the region id.
 
Last edited by a moderator:

Koi

Veteran
Veteran
Joined
Aug 8, 2013
Messages
358
Reaction score
14
First Language
English
Primarily Uses
RMVXA
Oooh I see...

I'm still really confused. I best learn through being provided examples, if that's not too much trouble. I need to know what event commands to put on the tiles, the movable events, and for the door.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Yeah, I'm just doing it up now. And I realize you don't even need to use regions - if you're not using them for anything else, you can just assign a unique terrain tag to the map tile that you use for 'destinations', and poll that instead.


I'll post some screenshots in a couple of minutes (after I confirm that it's actually working properly).


Do you mind if I do this up as a tutorial and share with the community?
 
Last edited by a moderator:

Koi

Veteran
Veteran
Joined
Aug 8, 2013
Messages
358
Reaction score
14
First Language
English
Primarily Uses
RMVXA
Yeah, I'm just doing it up now. And I realize you don't even need to use regions - if you're not using them for anything else, you can just assign a unique terrain tag to the map tile that you use for 'destinations', and poll that instead.

I'll post some screenshots in a couple of minutes (after I confirm that it's actually working properly).

Do you mind if I do this up as a tutorial and share with the community?
That's a great idea! I'm sure more people would want to know how to make a puzzle like that for their game.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Ah well, I'm going through the steps and posting images for you anyway, so I may as well put it over in tutorials instead of a support thread :)


I'll update here when it's done.
 

voymasa

Veteran
Veteran
Joined
Jul 25, 2013
Messages
124
Reaction score
18
First Language
English
Primarily Uses
Shaz, would it be possible to simply set up X number of parallel process events that check to see if they are occupied by said object (i.e. the boulder) and while they are increment a single shared variable that when it equals the number of boulders (using a constant for that puzzle) it would run the puzzle solved event?

ex.

 - There are 4 boulders in the room and 4 "hotspots" to place them.

 - Each "hotspot" is an event that checks to see if the boulder is above them (as a parallel process)

   - If the "hotspot" is occupied, then increment the 'puzzlevariable' by 1.

   - Else, wait a few frames and try again.

 - When 'puzzlevariable' reaches 4, the door opens, or a chest unlock SE plays (you could even allow it to temporarily increment by 1 when the player steps on the 'hotspot', especially if it's a floor switch).

 - In the case of the player stepping on the last 'hotspot' to "complete" the puzzle, you could have the 'hotspot' decrement the variable every time it finds that nothing is on top of it (thus playing the unlock/open SE when the player steps on it, but then playing a close/lock SE when they step off, requiring them the use the boulders/boxes).

I hope my explanation is clear. 1 variable, 4 moveable objects (boulders/crates), 4 hotspots/switches
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
It would be possible, but not efficient. You'd have multiple parallel process events all running at the same time (=bad), and each one would have to compare its own position with that of every boulder event - not just ONE boulder event, because you could put any boulder on any hotspot. And you'd have to also check for a boulder being moved OFF a hotspot, as well as stop the parallel process event CONTINUING to increment the variable because the boulder stays on it. You would also need more than 1 variable - one for the counter of boulders correctly placed, and one for the X and Y location of the boulder and the X and Y location of the hotspot, for EACH boulder and hotspot (since they're running in parallel, you don't want to risk one event changing the variable while another one is still in the process of checking its value).


Could do it that way, but it'd be very messy.


My tutorial will take the approach I've described above (using only one event for each object, plus one additional event to test their positions), but it's certainly not the only approach you could take.


Here you go - tutorial complete.
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD

Forum statistics

Threads
105,868
Messages
1,017,074
Members
137,578
Latest member
JamesLightning
Top