RPG Maker Times

Smile Game Builder and RPG Maker Tutorials, Plugins, Resources, Windowskins

Chapter 6: Picking Locks – The Complete Chests Tutorial

Continuing with the Chest Tutorials, we will now create a locked chest that can be opened with a lockpick. Of course, factored into the equation is that there is the possibility the lockpick will break, but if the lock is successfully “picked” then the chest will open.

The first thing we need to do is create the lockpick. In the Items tab of the Database, make the lockpick a Common Item. This will be the “key” for the chest.

Next we need to create the chest itself, “Chest 6“, using the basic chest template (from Part 1). However, we have to check whether the Hero has a lockpick first, otherwise the chest will remain locked.

This is created with a Branch Condition, thus:

Branch if lockpick Possessed

: Else Handler
Message: The chest is locked!
: You don't have a lockpick!

: End

This will check to see if the Hero possesses a lockpick. If not, a message will pop up stating that fact.

Next, we’ll set up the “Randomizer” variable to determine success or failure. In this case, set it to a random number between 1 and 3, creating additional Branch Conditions based on the random result.

If Randomizer is 1, this is where the chest opens and the event commands are placed here, calling the Random Contents Common Event and turning the “Chest 6” switch on. If Randomizer is 2, you fail to pick the lock. And if Randomizer is 3, the lockpick breaks, not forgetting to remove the lockpick from the inventory.

The completed routine is:

Branch if lockpick Possessed
Variable Oper: [0001:Randomizer] Set, Rnd [1-3]
Branch if Var [0001:Randomizer] is 1
Play Sound: open1
Message: You pick the lock and the chest opens!
Move Event: This Event, Face Right
Wait: 0.2 Sec
Move Event: This Event, Face Up
Wait: 0.2 Sec
Move Event: This Event, Face Left
Wait: 0.2 Sec
Call Event: Random Contents
Switch Operation: [0007:Chest 6 Opened] ON

: End
Branch if Var [0001:Randomizer] is 2
Message: You fail to pick the lock!

: End
Branch if Var [0001:Randomizer] is 3
Message: The lockpick breaks!
Change Items: lockpick 1 Remove

: End
: Else Handler
Message: The chest is locked!
: You don't have a lockpick!

: End

Don’t forget to set the Preconditions switch to “Chest 6 ON” on Page 2.

Next, of course, we need to create an NPC that will give you the lockpick. You can either place it in a shop or have the NPC gift it to you. For the purposes of this demo, we’ll choose the latter, so set up the NPC event and in the Event Commands, check if a lockpick is already possessed. If so, he won’t give another; if not, he’ll give you another one.

Branch if lockpick Possessed
Message: You already have a lockpick!

: Else Handler
Message: Have a lockpick!

: End

Categories

Archives

Follow me on Twitter

Sponsored Ad

Sponsored Ad


Hi-Tex House Pack Vol. 1

For Smile Game Builder

The Hi-Tex House Pack Vol. 1 contains 297 assets: 284 house wall terrains and 13 models. Get your copy for only $5!
© 2008-2018, Companion Wulf. All Rights Reserved.