EVENT – Open / Close Doors

twitter

This is a short tutorial on how to create functional doors (that open and close) on a map; including how to add a key/lock condition.

If you use the Quick Event Creation – Door option, you get a door that is good for transporting your player to another map.  But they aren’t very useful for as doors that simply open and close.  These doors are normally placed on a wall and will transport the player to another map.  When created they look something like this:

Door example 1

There are several problems with this, not the least of which is the door only works one way.  You could enter the room but not come back out again.  To make that possible would require a second event.   Also, when you use the door it “teleports” you to the other side of the wall, including the screen dimming effect.  This isn’t what we want.

Fortunately we can create a functional door with just a few modifications of the quick script.  To begin with, create a room with an entrance the player can walk through and then add the door event so that it looks like this:

Door example 2Next open the door event and you should see a script that looks like this:

@>Play SE: ‘Open1’, 80, 100

@>Set Move Route: This event (Wait)

:                                 : $>Turn Left

:                                 : $>Wait: 3 frame(s)

:                                 : $>Turn Right

:                                 : $>Wait: 3 frame(s)

:                                 : $>Turn Up

:                                 : $>Through ON

@>Set Move Route: Player (Skip, Wait)

:                                 : $>1 Step Forward

@>Play SE: ‘Move’, 80, 100

@>Transfer Player:[Map] (000,000)

@>

The Map and coordinates after Transfer Player will depend on where you set the destination for the door, but otherwise the event script should look exactly as above.   To modify this into a door that simply opens, lets the player walk through, and then closes after is pretty simple and quick.

First we delete the Transfer command, it won’t be needed.

Next we add an extra “1 Step Forward” command in the Set Move Route

Finally, we add an extra Set Move Route for the door to close it.

Our Event should now look like this:

@>Play SE: ‘Open1’, 80, 100

@>Set Move Route: This event (Wait)

:                                 : $>Turn Left

:                                 : $>Wait: 3 frame(s)

:                                 : $>Turn Right

:                                 : $>Wait: 3 frame(s)

:                                 : $>Turn Up

:                                 : $>Through ON

@>Set Move Route: Player (Skip, Wait)

:                                 : $>1 Step Forward

:                                 : $>1 Step Forward

@>Play SE: ‘Move’, 80, 100

@>Set Move Route: This event

:                                 : $>Wait: 30 frame(s)

:                                 : $>Turn Right

:                                 : $>Wait: 3 frame(s)

:                                 : $>Turn Left

:                                 : $>Wait: 3 frame(s)

:                                 : $>Turn Down

:                                 : $>Through OFF

@>

The second Step Forward command will move the player one more tile forward (for a total of two) so that they are just on the other side of the door.

You may have already noticed the second Move Route for the door is almost the reverse of the first one, this is because we are telling it to play the graphics in reverse order so that it will look like the door is closing.  The last state Turn Down, is the door in the closed position (Turn Up is the door in the fully open position).

Finally, we set with Through OFF (to make the door impassible again) and we also uncheck the “Wait for Completion” option on the last Move Route (we don’t want to player to have to wait for the door to close before they can move)>

That’s it.  This gives you a door you can open by merely walking up and touching it.  It works both ways (from the top or the bottom).


Suppose we want the door to require a key to open?  That’s easy enough to add, we just use a Condition Branch.  But first we need to add a key item to our item database.  I’m assuming you know how to do this, (F9 to open the database, Items tab, increase max number of items by 1, then create a “door key” item); I called my key “Door Key”.  Now we’re ready to modify the above script.

We add a condition branch and on tab 4 of we use the Item condition ###: Door Key in Inventory (where ### is the item number).  Then cut and paste our previous script into the first option of the Condition Branch.

In the @>Else branch you could add some text saying something like “You need the door key to open this door.”

Your even should now look like this

@>Condition Branch: [Door Key] in Inventory

@>Play SE: ‘Open1’, 80, 100

@>Set Move Route: This event (Wait)

:                                 : $>Turn Left

:                                 : $>Wait: 3 frame(s)

:                                 : $>Turn Right

:                                 : $>Wait: 3 frame(s)

:                                 : $>Turn Up

:                                 : $>Through ON

@>Set Move Route: Player (Skip, Wait)

:                                 : $>1 Step Forward

:                                 : $>1 Step Forward

@>Play SE: ‘Move’, 80, 100

@>Set Move Route: This event

:                                 : $>Wait: 30 frame(s)

:                                 : $>Turn Right

:                                 : $>Wait: 3 frame(s)

:                                 : $>Turn Left

:                                 : $>Wait: 3 frame(s)

:                                 : $>Turn Down

:                                 : $>Through OFF

@>

:  Else

@>Text: -,-, Normal, Bottom

:           : You need the door key to open this door.

@>

: Branch End

@>

That’s all there is too it.  If your character has the Door Key in their inventory the door will open for them and close after allowing them through, if not they will get a text message telling them they need the key.   If you’re doing a sci-fi theme, maybe its the Yellow Key Card, or the Red Key Card (or the Bronze Key, the Iron Key, the Skeleton Key, you get the idea).  This can be useful for restricting parts of a map the player is moving around on, perhaps as part of a larger puzzle they have to solve in order to complete a quest.

Happy gaming and keep being creative!

twitter

Comments are closed.