Using Key Items to Trigger Events

This article shows how you can set up events to respond when the player uses a key item on the event.

This is the second part of the series on Event Trigger Labels, a concept that allows developers to partition their event sequences into different sections marked by labels and choosing which section to execute depending on how the event was triggered.

In the first part, Assigning Multiple Action Triggers to your Events, we explored a problem where I wanted to be able to interact with an NPC in two different ways depending on my intent: to talk to the NPC, or to challenge it to a card battle.

We can extend our trigger labels beyond simply buttons; we can also use key items! In order to add this functionality, you will need to install the following script: Key Item Trigger Labels

The Situation

Suppose you are exploring a dungeon called the Forgotten Pyramids and you come across a room full of treasure. Of course, the room is blocked by a door. No matter how hard you try, it simply does not open when you try to interact with the door.

UsingKeyItemEventTriggers2

Basic Setup

We start with the basic setup where the player interacts with the door and is unsuccessful.

UsingKeyItemEventTriggers1

Designing a Key Item

We want to design a mechanism to open this door. Let’s say the pyramids were a part of some technologically advanced civilization and they had some tablets that were used to interface with highly secure doors.

UsingKeyItemEventTriggers3

There are three things that you need to set:

  1. The ID of the item
  2. Whether it’s a key item or not
  3. Whether it is consumable or not

We will be using key items to interact with this event, so it must be a key item.

Because we will be “using” the item, there may be cases where you actually want the item to be consumed once it has been successfully used. We would like to be able to re-use our tablet throughout the dungeon, but you could just as easily make it so that it crumbles after one use.

Creating the Key Item Trigger

A key item trigger is a label that uses the following name:

keyitem?(ID)

Where you specify the ID of the item that will trigger it.

Our sequence of events is as follows: when the player shows the tablet in front of the door, the door will respond to the tablet. To show that it responds, I start by having the door flash using the Character Flash script, to show that it is resonating with the tablet while the protagonist asserts that the door is indeed responding to your item use. I then do something with the door, which I have omitted.

Remember to partition your event page into different sections, with the appropriate trigger label:

UsingKeyItemEventTriggers5
Things to note in this event: our key item triggered section will be triggered by item 1. Looking back at our item database, I’ve set the mysterious tablet as ID 1.

Now we can go into the game and test our key item trigger. By default, the script assigns the Y button to open the key-item menu, which is the “S” key on your keyboard. You can configure this to a different button if necessary.

Pressing the Y button, it will bring up the key item menu:

UsingKeyItemEventTriggers4

Select the item to use it, and watch the door respond to your trigger.

UsingKeyItemEventTriggers6

And now the door might disappear or open to let you through!

Summary

We have just set up a door that will be triggered when you use a key item. And this is not just a normal event that simply checks whether you have the item in your inventory and asks if you wish to use it or not.

Instead, the player must make the connection that the tablet can be used to trigger the door, effectively adding a layer of complexity to your game.

By combining key item triggers with normal button triggers, you can set up events that are extremely complex with a number of various conditions and triggers, requiring the player to find clues how to proceed. Or, simply try everything they can hoping one of them is the key to the puzzle.

As a reminder, the Key Item Trigger Labels script must be installed in your project, along with the main Event Trigger Labels.

Moving Forward

At this point, we have seen two kinds of action triggers:

  • Buttons
  • Key Items

There’s even more that you can use to trigger events, which we will see in later tutorials in the series. For now, you can provide feedback or share how you have used trigger labels in your own project.

Spread the Word

If you liked the post and feel that others could benefit from it, consider tweeting it or sharing it on whichever social media channels that you use. You can also follow @HimeWorks on Twitter or like my Facebook page to get the latest updates or suggest topics that you would like to read about.

 

You may also like...

2 Responses

  1. Michal says:

    Yay! So useful! I LOVE THIS!

    • Hime says:

      You can help spread the word by sharing it with everyone you know! Maybe someone will come up with an idea that takes things even further.

Leave a Reply to Hime Cancel reply

Your email address will not be published. Required fields are marked *