A few questions for a puzzle game

I am posting new questions to this thread regularly!

Q&A:
Spoiler: Is there some way to check if there is an event in a certain tile or if it is empty?
This is true only if there are zero events at x = 1, y = 2:
Code:
$gameMap.eventIdXy(1, 2) === 0
This is true only if there is at least one event at x = 1, y = 2:
Code:
$gameMap.eventIdXy(1, 2) > 0
This is true only if event #3 is at x = 4, y = 5 (I use this one a lot):
Code:
$gameMap.event(3).pos(4, 5)
Spoiler: How to make a puzzle reset on demand and otherwise be kept as it?
Regarding puzzle locks: what I've done in my case is avoid trying to pre-empt every possible "stuck" configuration and instead just provide the player reliable access to one (or more) "reset buttons". By default the engine will reset all events to their starting positions whenever you arrive from a different map. Yanfly has a Save Event Locations plugin that allows you to remember event positions. 😂
Spoiler: Can I make it so that a pushable block will act as a floor block if accessed from a different height?
It should be possible with two facts about the engine that are often overlooked.

1) the engine uses ceiling tiles to simulate a two-level-dungeon. Ceiling tiles are on the A4 Tilesheet (half of those are walls and the other half ceiling/tops fitting to those walls) and they are passable only from other ceiling tiles or by override - you cannot go there from regular floor tiles.
an override is any passable decoration placed on a regular floor or wall tile next to the ceiling tiles, usually a ladder but anything goes.

2) if an event uses a tile as a graphic instead of a sprite (scroll down, the tiles are below the sprites) then the event gains the properties of that tile for passability.

I haven't tested this, but if you make your events use tile instead of the usual sprites you should be able to make paths with it, and if those tiles have ceiling passability it should not be possible to walk on them from the regular floor.

however, there are two parts that might get tricky with the eventing and mapping here, and I never tried it myself.
a - you'll need to be very carefull of placing decorations as those can give passability to top and might break your puzzle

b - it might be tricky to get the event to move on player command if it is passible

My initial thread:
Hi guys, so I am having some ideas for a puzzle games and I figured out I will be using MV since I own it and since I am familiar with how RPG Maker works in general. I have a few questions that I need to figure out:
1. Do we have a proper way to check if square (X, Y) contains a certain event, one or more events from a certain range, any event of if it is empty?
2. Can we stack multiple conditions in an if or should I go with the non-elegant way of stacking multiple ifs?
3. Can we record the position of all (or a range of) events in a room if certain conditions are met?

I am giving you a small example of what I need that for.
If we have a puzzle like that...
upload_2018-7-1_3-53-13.png

We have one player in a small room and he has to push the stones in such a manner so that he/she opens a clearance. I want to be able to reset the room upon re-entry (maybe I should do the check when the player is leaving). There are three (at least this is how many I see) positions that can lead to soft-lock here:
- If B4 contains a block
- If A2 contains a block AND A4 is empty
- If C2 contains a block AND C4 is empty
Upon first entry these are the three positions that are a soft-lock and I want if the player leaves through the door they entered to force reset the room to the initial state. I want the game to remember the state of the stones in any other case.
What would you suggest me to use? As far as I remember VX and VX Ace always reset all the rooms. I have not tried MV yet but I guess for practical reasons it will be the same here as well. And my puzzle gameplay would really, really benefit if the game keeps track of the rooms.
Thank you in advance!
I am thinking of a workaround that may be easier to implement when I upscale the puzzles and the conditions for a soft-lock become orders of magnitude more. It may be proper to have a plugin or something that forces the game to keep the position of all events in the room and activate it with a command like: <SaveRoom> or however this stuff happens in MV. Then to run a parallel process with multiple IFs and if one IF is met then to have <ForceRestart> command or something like that which effectively allows MV to do what it is supposed to do.
Other proper thing may be to ask the game to safe the room if the players uses the oposite entrance to leave it. For example if the player solves the puzzle and leaves for the next room then the game should remember the position of the events. However, if he/she re-enters and then leave from the same entrance the puzzle will be restarted and it may lead to a soft-lock if the player needs to backtrack or at least to limit his/her backtracking ability (and this will be important). So I think maybe of having the game keep track of the initial position and for one or more additional "solved" positions. Thus allowing me to:
IF the player leaves through the right door the game should check if the left entrance is open and if it is it should keep the position of the events as a "solved" position.
IF the player leaves through the left door (which is the one that will initially lead to the room) the game should check if the puzzle has been solved and if the oposite entrance is clear. If both of these are correct the game should re-write the new "solved" position and if one of it is not correct then it should force reset the room to the initial state.
Does that make sense to you?
Sorry for the multiple entries from me but I figured out I will leave it as an additional post since it is a totally separate thought.
You can get the X & Y coordinates of a given event using Control Variables commands. These variables can then be used in branches to check positions and such. That said, I've created a short series of push-puzzles (Steam Workshop link if you're interested) and ended up using script calls most of the time just because it's so much more convenient! Here's a few examples, used in the Script box of a Conditional Branch command:
  • This is true only if there are zero events at x = 1, y = 2:
    Code:
    $gameMap.eventIdXy(1, 2) === 0
  • This is true only if there is at least one event at x = 1, y = 2:
    Code:
    $gameMap.eventIdXy(1, 2) > 0
  • This is true only if event #3 is at x = 4, y = 5 (I use this one a lot):
    Code:
    $gameMap.event(3).pos(4, 5)

Regarding puzzle locks: what I've done in my case is avoid trying to pre-empt every possible "stuck" configuration and instead just provide the player reliable access to one (or more) "reset buttons". By default the engine will reset all events to their starting positions whenever you arrive from a different map. Yanfly has a Save Event Locations plugin that allows you to remember event positions. 😂

You might consider making the map "exit" events something like this:
Code:
◆Fadeout Screen
◆Comment:Check for puzzle in "stuck" position and reset if appropriate.
◆Transfer Player:Next map (0,0) (Fade: None)
◆Fadein Screen
Hmm, thank you. That last one might work but I am not sure how to implement the reset button storywise. I will find that out if that is the most elegant option though.

And about these script calls you used to check the tiles, would I need an additional plugin to use them or not?
Yes, the script calls I mentioned are all from the basic MV code, no plugins required. ^_^

Not sure if it's the most elegant method, but it is certainly one of the easiest! xP Naturally, the "reset button" doesn't literally need to be a button. The room entrance would work OK as long as you can be sure it's always accessible. =)
I figured it out. It will be a button. I will assign it a key and it will be your first special ability. I know how to tie it up to the story and to even make some puzzles out of this mechanic where you need to restart previously solved puzzles to solve them again when entering from a different door.
I would like to continue the thread and ask my puzzle mechanics questions in here instead of posting different threads. Do you think it will be proper?
Okay, I know you will like the idea... ( 😀 ) so one more, do you know if I can make the player to be able to walk over pushable blocks if he access them from the right height? For example you should be able to arrange some blocks and then to be able to walk and jump on them when you climb a ladder and access them from above.
I feel I would have to go for a super specific script to be able to do this but hope dies last. My other best guess is that I will need to include a line in the "ladder" event that will swap the passability of the blocks and the ground so that you cannot walk through the ground tiles but can walk over the blocks. I guess I will have to use a switch so that I can make the block non-pushable when you need to walk on them but I am really not sure if they will take priority over the ground which will become non-passable and I do not know how to make the ground non-passable as well.
I was wondering about this sort of thing too!

I think you're right about having a switch or something to track the player's "height". You can use a Change Tileset command to make the ground tiles impassable: just change to a copy of the current tileset with altered passability settings. I'm less sure about how to make the tiles with blocks on them passable, though, since for some reason MV appears to decide passability only based on the tileset...

Edit: see @Andar's post below, you just need to use a tileset graphic for the events and it should work out~! 😂
do you know if I can make the player to be able to walk over pushable blocks if he access them from the right height? For example you should be able to arrange some blocks and then to be able to walk and jump on them when you climb a ladder and access them from above.
It should be possible with two facts about the engine that are often overlooked.

1) the engine uses ceiling tiles to simulate a two-level-dungeon. Ceiling tiles are on the A4 Tilesheet (half of those are walls and the other half ceiling/tops fitting to those walls) and they are passable only from other ceiling tiles or by override - you cannot go there from regular floor tiles.
an override is any passable decoration placed on a regular floor or wall tile next to the ceiling tiles, usually a ladder but anything goes.

2) if an event uses a tile as a graphic instead of a sprite (scroll down, the tiles are below the sprites) then the event gains the properties of that tile for passability.

I haven't tested this, but if you make your events use tile instead of the usual sprites you should be able to make paths with it, and if those tiles have ceiling passability it should not be possible to walk on them from the regular floor.

however, there are two parts that might get tricky with the eventing and mapping here, and I never tried it myself.
a - you'll need to be very carefull of placing decorations as those can give passability to top and might break your puzzle

b - it might be tricky to get the event to move on player command if it is passible
Andar: Thank you, this helps a lot. In fact I plan on using parallax mapping so this would not be an issue. I will most probably not use the editor mapping at all except for this function to create tilesets if it works.

caethyril: So this plugin will allow me to pass on tile if there is a passable event ot it like moving platform, or block I pushed into a whole to create a bridge etc.?
That means that I may have the proper solution to my previous problem: It basically will allow you push the block since they will be the same priority as you. The whole floor will be filled with a certain region tiles. I will find a script that make region tiles non-passable (I know there is one out there). The last step of the ladder I will call an event that will make the floor region non-passable and I will just flick a switch that will change all block events to passable, non-interactable events. With your plugin (if it does what I think it does) I will be able to finish this one.

So I have an alternative solution to what Andar suggested. I will reflect on that later. I guess both will work and I will just need to pick the one that will be easier for me to use.

Also, I wanted to ask if you feel that it will be proper to keep track of all my questions and the solutions with a Q&A section in the first post? I think it will be neat.
@kartacha The plugin I wrote is unnecessary with what @Andar said, so I've edited it out of my post. 😅 You can set the passabilities in the tileset and just use the tile. More control, fewer events, better all round! It works, you just need to make sure the tile you use is set to be passable in the database. (Silly me was testing with impassable tiles before... 😴)
Your solution was closer to what I was thinking and I liked it anyway! Okay. I will now do some answer management of my thread. Expect more questions soon!
Your solution was closer to what I was thinking and I liked it anyway! Okay. I will now do some answer management of my thread. Expect more questions soon!
new questions should go in new topics, report this one to be closed if the questions are answered.
@Andar, I was trying to keep the forum clean since I will have a ton of questions in the 1-2 months to come. All of the questions I thought of keeping in this thread will be basics of puzzle creating so I figured out it will be better if I do this in a single thread and keep it easy for newcomers to follow the thread. Please check the first post out and if you still decide that it will be better to close the thread I will.
the rules require one topic for each question for better searchability and to prevent people with similiar but different problems to cluster up in a single topic. because nothing causes as much confusion as mixing up different support cases in one topic.
check the forum rules in the help section on top. Some rules are different here than on other forums, but that is because this forum is focused on game development and bughunting, and those rules have been proven in enough other cases that the few exceptions shouldn't matter.
Thread closed IgnoreMe

Original thread: https://forums.rpgmakerweb.com/threads/a-few-questions-for-a-puzzle-game.97099/