Switching Parties

The NYC Games Forum Demo features a fun frictionless ice puzzle – the unique feature is that you have to switch between the Stranger (the main character) and Erik, a little boy you’re trying to rescue. I’ve talked a bit about how I generate ice puzzles randomly, and that’s no difference here. But this also uses a system of switching between parties on the same map. It’s not unheard of – remember Final Fantasy 6, in Kefka’s Tower? Or even on top of Narshe, defending the esper?

 

You know you remember this part.

You know you remember this part.

This isn’t the hardest thing in the world to do, and in fact, requires almost no scripting knowledge at all. (You can do it purely with events, but there will be lag during the transitions. I’ll explain below). So let’s get to it!

Yanfly To The Rescue

Unfortunately, RPG Maker doesn’t come with a quick-and-easy way to detect when a button is pushed, and boy do we want to make switching between parties easy. Don’t reinvent the wheel – Yanfly’s done it for you. This allows you to call a common event whenever a particular button is pressed. We’ll build all of our logic in that common event.

Variables and Switches

We need two switches. The first is a simple check to see if our button is going to do anything – remember Yanfly’s script is going to be called anywhere, even if that’s not appropriate. So we need to frame everything with a switch.

We also need a switch to check to see if you’re controlling Erik (if it’s off, we’ll say you’re controlling the Stranger). If we want to do a FF6-style multiparty system, this would be better represented with a variable.

We then need 3 variables for each party – their last known X, last known Y, and the direction they were facing.

Logic

Let’s say we’re controlling the Stranger when we press our transition button. We need to do a few things:

  • Store our X, Y, and Facing in some variables
  • Move a “dummy” into that place, so it looks like the Stranger is still there
  • Change our party; remove the Stranger, add Erik
  • Get rid of the Erik “dummy”
  • Move to where the Erik “dummy” was, face us in the correct direction

Some of this is easy – we can get the player’s x, y, and facing from the “Game Data” menu when setting a variable.

Use Game Data to get x, y, and facing, and store them as 6 different variables - 3 for party 1, 3 for party 2.

Use Game Data to get x, y, and facing, and store them as 6 different variables – 3 for party 1, 3 for party 2.

Dummies

Let’s talk about our dummies. We’ll need two of them – one for Erik, one for the Stranger (and obviously, if you’re doing more parties, one dummy for each party). But these themselves should have four pages – one facing each cardinal direction. Make sure they’re in this order:

  • Page 1 – facing down
  • Page 2 – facing left
  • Page 3 – facing right
  • Page 4 – facing up

Why that order? You might not know it, but each direction in RPG Maker is represented by a number, and you can find those right on your numpad on your keyboard! 2 is down, 4 is left, 6 is right, 8 is up. So what we’ve done with our page orders above is put them in number order, from lowest to highest. Now, we can set conditions on each.

Because conditions for pages are only variables X or over, we need to put them in numeric order.

Because conditions for pages are only variables X or over, we need to put them in numeric order.

Do that for the Stranger and for Erik, and you’ve got your dummies!

After we store our location in the variables, we’re going to set the event location of the dummy using Set Event Location. The RPG-Built In logic only takes a location and not a direction, but it doesn’t matter. Our dummies are handling their own facing, by using those 4 pages with conditions.

Let’s take a break and see what we have so far.

A

This is all preparation, making sure we save information about where we’re switching from.

Notice that all we’ve done on the else is set the variables assuming we control Erik. I also addeda little flash screen to cover up our transition – the player will be none the wiser 😉

But all of this so far is smoke and mirrors, we haven’t actually done any of the transition work!

Changing the Party

The trigger editor will allow you quite easily to change your party out as you need to:

Don't use initialize! It'll reset your person to the default, getting rid of levels, skills, and equipment.

Don’t use initialize! It’ll reset your person to the default, getting rid of levels, skills, and equipment.

Here’s the one bit of script to consider. You could use transfer player to move your player to the correct coordinates. But that has a tendency to take a little longer than I’d like. So I use a script. It’s easy! Each event has a function called moveto which takes an x and y, and plops you there immediately. Each also has set_direction, which takes 2,4,6, or 8 and makes the event face that direction. It’s quick and easy to use both of those to move our player.

To put it together, we’d use:

$game_player.moveto(x,y)

Where x = Erik’s last known X  (we stored that in a variable last time we transferred from Erik), and y = Erik’s last known Y. Then the next line

$game_player.set_direction(dir)

Where dir = Erik’s last known facing (again, in a variable). Your script might look like:

$game_player.moveto($game_variables[100], $game_variables[101])
$game_player.set_direction($game_variables[102])

So that you always reference the correct variable.

Make sure to set your switch correctly as to which party you’re using, get the unnecessary dummy out of the way (move him to some impossible to reach corner of the map) and you’re done!

Here’s my event in its entirety – it’s a little different, just because I have some wonky camera work (at the end). I also created a custom function called change_with_erik, but it just does those two lines of code above.

Play around with the look of your transition to your heart's content. Want the camera to pan instead of jump to the new location? Use Galv's camera control!

Play around with the look of your transition to your heart’s content. Want the camera to pan instead of jump to the new location? Use Galv’s camera control!

Now go out and make some multi-party games!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s