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 to reveal the contents. The lockpick can then be bought in a store, found in a chest, given by an NPC or as a monster drop.
Creating The Lockpick
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.
Creating The Chest
Next we need to create the chest itself, "Chest 6", using the basic chest template (from Chapter 1). However, we have to check whether the player 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 player possesses a lockpick. If not, a message will pop up stating that fact.
Defining Success or Failure
Next, under this Branch, 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 (from Chapter 3) 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 "Conditions" switch to "Chest 6 ON" on Page 2.
Erratum: Due to a bug, the randomized branch will process after the chest has been opened, giving you two random messages instead of one. The fix is to reset the Randomizer variable to zero.
Next, of course, we need to create an NPC or event 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 create a barrel with an infinite supply of lockpicks to replenish in case you run out, so set up the event and in the Event Commands, add 5 lockpicks to the player’s inventory.
When you pick the locked chest, you’ll receive one of the three responses and if you run out of lockpicks, return to the barrel to get some more.
We can now move onto Chapter 7: Monster-In-A-Box.
You must log in to post a comment.