Yo Gab-bar Gab-bar: Challenge Solutions (and Dev Blog!)

A few weeks ago I featured Yanfly’s gab bar script as a Friday script, and I issued three levels of challenges:

Beginner Challenge

Set up a common event parallel process that, every five minutes, chooses a random party member and has them say a catch phrase unique to that party member.

Intermediate Challenge

As above, but add a variety of catch phrases for each member, and have one chosen at random.

Advanced Challenge

As above, but instead of a catch phrase, create a dialogue between two present party members.

As it turns out, I do something like this in Vidar! So to answer this challenge, I thought I’d walk you through the process as I did it.

The Background

In one of the quests in Vidar, it’s possible for various ghosts in the ice cave to join your party (to a maximum of 3). There’s no combat in Vidar, so “joining your party” really just means following you along until you bring them to a specific location. But while they’re along for the ride, boy are they chatty. Every 30 seconds, someone from the conga line will offer some tidbit (the goal of which is to feed the player story information without disrupting the game).

Beginner Challenge

Within RPG Maker’s “game interpreter” class, I added a new function called ghost_gab. This gets called every 30 seconds as long as the quest is active, with a common event.

ghost_gab itself does a few things. First, it creates an array of gabber actor IDs in the party. Then it chooses one at random. Using a case statement, we can set the variable “string” depending on which gabber was chosen. We have an actor id (chosen_gabber), we have a string (string), and we can pass both of these to Yanfly’s script to have a random ghost gab his catch phrase at us.

Caption

Using .sample on an array picks one at random. Here, the array of possible gabbers includes any actor with an ID above 2.

Intermediate Challenge

From here, it’s two very simple steps to add a variety of catchphrases. First, in the case statement, make an array of possible strings for each gabber. Then, set the string to one chosen at random (using .sample)

Each array can be as long as you want, and don't need to be equal.

Each array can be as long as you want, and don’t need to be equal.

Now, once a gabber is chosen, the case statement gives us a list of all possible things they can say. We grab one at random, and pass it to Yanfly’s script.

Advanced Challenge

Here, things get complicated. First, each gabber needs two arrays. One which is the same as in the intermediate challenge, a list of solo lines. The second is an array of arrays, each one containing 1) the other ghost’s ID, 2) the first line of dialogue, 3) the second line of dialogue. Got all that? Let’s take a look at the merchant’s:

The joint gabs array contains other arrays, each with three arguments - the ID of the other dialogue participant, what the merchant says, and what the other person says in response.

The joint gabs array contains other arrays, each with three arguments – the ID of the other dialogue participant, what the merchant says, and what the other person says in response.

Next, the ghost_gab function needs to know which two arrays we’re dealing with. So, in our case statement, we say something like:

Ghost Gab

Two arrays per case statement – an array of solo hits, and one of duets.

We grab a random one from the double_gab_array as we did before, with sample. In Vidar, I have some additional restrictions: you won’t see the same gab twice, and solo gabs go in order, so as to better tell a story. So when a grab one from the single_gab_array, I just want the first in line:

Choosing our two strings, but following different rules for each.

Choosing our two strings, but following different rules for each.

Next we need to see if the double_gab can be called. We ask if it exists (it won’t if all of the double gabs for our chosen gabber have been played once already). We also ask if the dialogue partner is in the party. If both conditions are satisfied, we play the double gab.

If not, we play the single gab.

The system will work regardless of how many extra gabs we add to our arrays.

The system will work regardless of how many extra gabs we add to our arrays.

And that’s how we coax the ghosts in Vidar to share their story. Sometimes, with each other.

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