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: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:
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.