If you want to get the most out of RPG Maker, learn Ruby.
In the meantime, lots of talented scripters have done the work for you. Every Friday, The Iron Shoe features a fun script and goes into detail about how to use it. It also covers a little bit of Ruby each time so you can make even more out of the script. And that’s just what we’re gonna do today!
In an attempt to freshen up boss encounters, Wednesday I talked about reddit user You_Ravel’s idea for an immortal boss. Once you get this boss’s health down to 0, the option to flee becomes available, and the party has to escape. We built it up with some events, and while it wasn’t the prettiest thing in the world, it worked really well – we could even distribute rewards after the fight or play a cutscene if we wanted.
The hitch was that the escaping skill which became active at the end of battle was an individual skill called “Flee.” It wasn’t using that Escape command that appears instead of something like “Fight.” Wouldn’t it be nice to use that instead? We can!
The window that draws escape can be found in the RPG Maker script section. Specifically, look for “Window_PartyCommand” in the list of scripts. Then, scroll down to around line 32, where you’ll see a function call “make_command_list.” It’ll look something like this:
The line that has escape in it? That’s the line that creates “escape” in the Party Command window. What’s a party command window? It’s the thing that that appears BEFORE the choices for an individual actor. It shows up once per turn and says “Fight” or “Escape.” And it’s what players normally use to flee battle.
In Ruby, we can condition a line of code on something happening using “if.” We can also condition a line of code on something not happening using “unless.” Here, we want to proceed as normal unless a pre-chosen switch is on. If that switch is on, we don’t want the window to offer the player the chance to Escape. So we change the line that reads:
add_command(Vocab::escape, :escape, BattleManager.can_escape?)
add_command(Vocab::escape, :escape, BattleManager.can_escape?) unless $game_switches[x]
In place of x at the very end, use the ID of a switch you’ve chosen for this particular boss battle. In my example, I’m using 5:
Back to the Boss
Let’s go the troop window for our boss. As before, on the first turn of battle, we want to add our immortal state. You can check out what that looks like in Wednesday’s post. But we ALSO want to turn our Inescapable Boss switch on at the beginning of the fight. This will disable escape – remember, escape is drawn UNLESS switch 5 is on.
Now, we also need to say that when the boss’s health is 0% or below, turn switch 5 off.
And that’s how we’re able to escape our boss from the Party Command window once his health is at 0%!
There are a few things that we need to do to make this neat and tidy:
- Notice that since we aren’t calling a Common Event, we don’t have the option to distribute rewards or call a cutscene after the boss like we did with Wednesday’s method. That’s ok, though; most of the time when we trigger a boss, we do it with the event command Battle Processing. With “can escape” enabled, you can actually decide what happens when a player escapes.
- Our escape isn’t 100% guaranteed, and will be conditioned on the same things that escapes are conditioned on. We’ll need to condition our escape formula on yet another switch – you can find it in the scripts.