About a year back, using RPG Maker VX Ace, I created a tutorial on making a “Sanctuary” Spell. With this spell, the player could transport their character to a safe location in “another dimension” and then transport themselves back to right where they were when they were done.
Luckily, this tutorial still works perfectly fine in RPG Maker MV, because recently, someone asked me an interesting question about it:
And what do you know, it’s next week!
Well, Alex, you are right, that WAS a great tutorial. But also, making a skill cooldown on an out of combat utility spell (or item) is a great idea. There are several ways you could do this. I’m going to focus on one specific way, that I find the most direct, and least cumbersome.
But first, Oh No!, there was a mistake in my original tutorial. If you used the Sanctuary spell while in your Sanctuary, you would be stuck there forever. Unable to leave. This could be a game breaking bug if left in, so let’s fix this.
All it takes is to first toss the Map ID into a generic count variable (if you need guidance on how to do this, read the Sanctuary Spell tutorial), then use a conditional branch. If the variable matches the Map ID of your sanctuary, have it tell the player it can’t be used while in the sanctuary. If it doesn’t, proceed with the event we made in the old tutorial in the else branch. Remember to use a generic variable, not your memorized Map ID variable, if you use that, it will mess up teleporting back! Also, remember to reset your generic variable at the end of the event. You always want to keep your generic variables zeroed out when not in use.
Now that I’ve fixed up my own mistake (SHAAAAAME), it’s time to move on to the meat of the tutorial. Giving the Sanctuary Spell a timer. What we want is for the timer to start the moment the character teleports back to the base map from the Sanctuary. Then, if you try to cast the spell while the timer is still running, it tells you that you need to wait.
Now, I know what you are thinking: Let’s use the Control Timer event command! Well, we can. It does work, but I’m going to use a different way for two reasons:
- The Timer shows up on the screen. I don’t think this is necessary for a single spell cooldown.
- You only have one Timer. If you used this for a spell that could be cast at any time, this would tie up the Timer for your entire game.
So instead, I’m going to use A variable, the wait command, and a loop. This will need to be in a Common Event. With most of my tutorials using Common Events, I’ve just been calling them. But now, we’ll use another method. With your second common event, we’ll want it in Parallel Process, to run the countdown in the background, and with the condition of a switch being on, the switch saying you’ve used Sanctuary then gone back to the map.
This means that this event will run WHENEVER Switch 001 is on. No matter what. This is really useful for things you need to run in the background based on specific circumstances, rather than being directly called from an event.
So now, we need to do two things. We need to flip on the Sanctuary Used switch, and set the Sanctuary Timer variable to the number of seconds we want it to run. In Alex’s question, it was 10 minutes, but for mine I’m just going to do 1 minute, for ease of testing. So I’ll put in 60, for 60 seconds. The easiest place to put this? In the transfer event that moves you back to the world after leaving the sanctuary!
Putting it here starts the timer the moment you go back to the main maps and abandon your Sanctuary.
The next step is to go back to the Sanctuary Timer Common Event. Let’s build up what we need. So we have the Sanctuary Timer variable, that is the number of seconds to wait. And then the Sanctuary Used switch, which is what needs to turn off when it hits zero. This is just a very simple loop! Inside the loop, have it wait 60 frames (1 second), then subtract one from the Sanctuary Timer variable. Then, using a conditional branch, when the variable hits 0, break the loop. After the loop is broken, you flip off the Sanctuary Used switch.
I’m sure you are asking, why not just have it do a wait 3600 frames? Well, by having it count down a variable, we can use the message from when you cast the spell and the timer is still running to tell you how long you have to wait.
And adjusting the spell to not work while the Sanctuary Used switch is on is the only thing left to do. Once again, broken down like this, I imagine you’ve already gotten it figured out. Go back to your Sanctuary Spell Common Event. Set a Conditional Branch. If Sanctuary Used is ON, have it give a message that details how many more seconds until you can cast it.
Using \V[n] will replace that tag with the number of the nth variable!
And to finish things off, throw all of the rest of the event into the Else branch of that Conditional Branch.
And that concludes that. This could have been accomplished in several different ways. With eventing, there isn’t just one way to do most things. In fact, this may not even be the ideal way to do this. But it does work. And you can check out the demo here if you have more questions!
Would you have done this differently? Do you see any flaws in my process? Any questions on how to use this technique for other things? Or even how to make the countdown based on something other than time? Join us in the comments section below!