Event-Driven Torches in RPG Maker

Joe Vincent
6 min readJan 12, 2021

What is our main character to do in the dark without a source of light to guide them? In this tutorial we are going to cover the creation of a ring of light around the player.

Here is a gif of this effect in action:

Torch preview

Let’s begin!

Getting ready

Before we allow ourselves to jump right in and get started, let’s outline the steps necessary to create our in-game torch:

1. Determine the resolution of our game
2. Create a necessary “torch-light” graphic
3. Create a common event & put it all together
4. Test & Enjoy

In the next section we’ll dig into the system’s default plug-in to determine the game’s resolution.

Determine the resolution of our game

The easiest way to determine the resolution is to hop on your search engine of choice and type in “RPG Maker [version] default resolution”

Couldn’t have been any easier

But what if yours is different? How do you know? Where did they get that number from?

RPG Maker MV’s Plugin Manager (seen below) contains an item named “Community_Basic”. Open this to explore the plugin’s settings and script.

RPG Maker MV’s Plugin Manager

In this plugin we are looking for two named variables: screenWidth, and screenHeight. These variables’ values provide both the width and height of our game’s resolution respectively.

As we can see in the screenshot below, screenWidth equals 816 and screenHeight equals 624, thus giving us a screen resolution of:

816 x 624

Community_Basic Script — where we will find screenWidth and screenHeight

Let’s take this information forward and create the torch graphic.

Create a necessary “torch-light” graphic

Now that we have the screen resolution, we need to multiply it by 4 to get the boundaries of our torch. The reason why we are going 4 times larger, is that we need to take into account that the player isn’t locked on the center of the screen. They can move around in a small space and we need to keep the torch centered on them. Creating the graphic the size of the screen will limit the torch circle to the center.

Keeping this in mind, our new resolution should be:

816 * 4 = 3264
624 * 4 = 2496

3264 x 2496

Take this number and create a new graphic in your image-editing program of choice, and fill the image black.

3264 x 2496 black image

Take this black image and cut out a feathered circle from the direct center. The size and fade of which is up to personal preference.

Centered feathered circle cutout

That’s it! Save the image with a .png file format and import it into RPG Maker’s img/pictures folder using the Resource Manager (seen below)

Don’t forget to save it under pictures!

That’s all we need to do for the torch. In the next section we’ll create our common event and begin putting everything together!

Putting it all together

Common events, for the uninitiated, can be a little intimidating. But in essence, they’re simply events that aren’t tied to traditional tiles as most events are. They have their own triggers, calls and run independently, which will work perfectly in this instance.

The first thing to do is create the common event, and give it a ‘parallel’ trigger. This means it will run concurrently with everything else at the same time, but only when certain triggers are met. Set the trigger’s switch to a new one named “TorchNeeded”.

This will serve as our call to action. Do we need a torch? Yes? Activate the common event!

Torch Common Event

The contents section of the event will be relatively simple and straight forward. We’re going to be checking or setting the following:
1. Player’s X, Y positions.
2. Is the image present?
3. Image X, Y position

First, let’s get the Player’s X and Y positions and store them in appropriately-named variables.

Player’s X, Y Positions stored as variables

Next we need to check if the image is being shown or not. We have two main actions when it comes to pictures: show and move. We can call show repeatedly, but this will slow down the game as it needs to re-draw and re-enter into memory the entire image each frame. When we move it, we’re allowing it to remain in memory and are simply changing its position.

To check this, we will create a conditional branch with a new switch called “TorchPicture”.

If ‘TorchPicture’ is ON, we will simply call the move action. Otherwise we will show it, then turn the switch ‘TorchPicture’ ON.

Since the ‘TorchPicture’ is OFF by default, we need to create a switch control to turn it ON.

Turning the ‘TorchPicture’ switch on to view the Torch Picture

Then we follow that up with a Show Picture command. There’s a lot going on here. Unless you’re using other pictures, 1 will suffice. Add our previously created torch cutout image, set the image position’s origin to center; since our torch cutout is centered, and designate the photo’s location with the playerX, playerY variables.

Easy.

Lot happening here. Assign image, set origin to center, and designate the location with variables.

Now back up and head to the top half of our conditional, the part where we have established that the ‘TorchPicture’ switch is ON and we no longer need to show the image, but instead move the image.

Add in a Move Picture command. Use the same image number as previously, remembering to set the origin to center and designation with playerX and playerY. The new thing to notice however is the duration section.

Uncheck the Wait for Completion button and decrease the duration from 60 to 1. We don’t wait the torch to lag behind us as we move. We want it snappy.

Move picture command!

Incase there were any unclear explanations, below is what our final common event should look like:

The finished Common Event

Looks like we’re just about done. In the next section we will test the new common event out!

Test & Enjoy

For those who didn’t know, RPG Maker includes a built-in debugger. We’re going to access this to quickly test out our new torch event.

I’ve created a small map, added my player and have not added any other events.

Quick map for testing purposes.

During the game, press F9 to open the in-game debugger tool, which should look like the screenshot below:

In-game debugger tool, accessed by pressing F9 or fn+F9 on laptops

Turn on the TorchNeeded switch, and watch the magic happen.

Torch Debugger

Now the character will be able to walk freely around the map with the torch cutout overhead.

This should give you a solid foundation to build off of — all you need to do now is create an actual in-game trigger to turn on the TorchNeeded switch.

If you ever need to turn the torch back OFF, create an event that shuts both the TorchNeeded and TorchPicture switches OFF.

Enjoy!

--

--

Joe Vincent

I have been a hobbyist game developer for nearly two decades. I love burgers, programming, hiking and living life purposefully with my wife!