Replicating Ace Attorney's "Mood Matrix" Mechanic in RMMZ
Description:
Welcome to my first-ever tutorial! Inspired by the RPG Maker Web Blog post on making a book with pictures, we'll expand on that idea and create a new interactive scene in which the player can navigate freely between sets of pictures and text using the arrow keys and can call a choice menu at any time with the OK button.
Requirements:
Plugins: VisuStella ("VS") Message Core, Horror Effects, and Visual Text Windows. OR RMMZ's free TextPictures plugin. We'll use the VS plugins.
Resources: Any pictures involving the following emotions: Happiness, Anger, Sadness, and Surprise. I used Emojis. You will also need the icon set that comes with VisuStella's Sample Game Project (which is free). It contains icons for keys.
Background Knowledge: Everything we'll be working with is pretty basic, but I'll explain things as we go. The event commands we'll be working with are Control Variables, Loop, Conditional Branches, Show/Move Picture, and Labels. You might also want to read the Blog post "Make An In-Game Book With Pictures," as this is an extension of that idea.
Now, in the words of Ace Attorney character Athena Cykes...Let's do this!
Setup
Open your project and make a new event. Make the name and image whatever you want and you can leave all the other settings (Trigger, Movement, Conditions) the way they are.
It's important to know the dimensions of your screen. To find out, go to the Database > System 2 > Advanced Settings. Look at the Screen Width/Height. This tutorial assumes Width (x) = 1280 and Height (y) = 720. (Your UI dimensions don't matter.) We need this to know where to place pictures and text windows.
What Is the Mood Matrix?
I'll start by showing you what the end result will look like:
Don't worry about the black space. The screen is just larger than the default MAP001. As you can see, we have four emojis arranged in an rectangle (or "matrix," hence the name Mood Matrix). We also have two text boxes. These are the result of using VS's Visual Text Windows plugin.
In Ace Attorney: Dual Destines (and its sequel, Spirit of Justice), character Athena Cykes' keen sense of hearing allows her to sense what others are feeling. She can hear "discord" that arises when there are inconsistencies between what a person says and what they feel. The player navigates through a witness's testimony as different emojis light up at different intensities. The player must find inconsistencies between what the person is saying and which emojis light up (and how intensely they display). When the player points out an inconsistency, dialogue happens and the testimony is updated, with statements being added or replaced.
Here's the basic outline of how everything flows:
We play a little animation to start the whole thing.
We give the player a tutorial so they know what's happening.
We'll have four statements initially that the player can navigate freely through using the left/right arrow keys. They are as follows:
I am happy! (Glitch on Picture 1)
Whoa! You surprised me! (Glitch on Picture 3)
Now I'm angry! (Glitch on Pictures 2 and 4)
I'm okay now. (Glitch on Picture 1) Yeah, this guy has quite a changeable personality! We want to show each statement separately, along with the affected emojis. We also want to show an instruction window that tells the player what keys to press.
We'll run checks to see if the player is pressing the Left/Right buttons so they can navigate. In order to point out the inconsistency, we want the player to be able to press the OK button, which will bring up a choice menu like so (See image after list). We also want the player to be able to cancel out of the choice menu if he pressed Enter by accident. Depending on which screen the player is on, different selections will yield either the "right answer" or "wrong answer" dialogue. In this scene, the character says he's angry, but the Sad/Fear emoji is reacting as well. That's the contradiction!
Once the player gets a right answer, they've met an objective, so we do Objective += 1. When that happens, we "update and reboot" the Mood Matrix, which resets it to the beginning. But now, instead of "Now I'm angry!" the character says, "Okay, fine, I was angry because I was hiding my fear." This new statement replaces "Now I'm angry!"
We need a way for the player to exit the event. We'll just say the player has to select "Joy/Hope" on the new statement to trigger a little more dialogue and end the event.
Here's the picture showing the choice menu:
Now that we know what we want to do, let's get to doing it!
1. Placing the Pictures
First let's figure out where our emojis are on the screen. Here's what the Show Picture command asks for:
The picture's
number is used for reference purposes. The pictures shown in the screenshot of the final product are numbered 1-4 going clockwise from the upper-left.
A picture's
position indicates where it goes on the screen. We can choose whether we want our coordinates to be for the upper-left corner or the center. We're going to start with all four emojis in the center, transparent. Then we'll give them a little animation later in which they appear one-by-one and move to their respective positions. Thus, we need the center coordinates of the screen. Since the screen is 1280 by 270, x = 1280/2 = 640, and y = 720/2 = 360. Each of the pictures will be centered on the screen. Their opacity will be 0, making them transparent. (255 is no transparency.)
Scale may not be necessary depending on how you did your pictures. I just used the original images, which were 600x600, 640x640, and 334x334. I scaled them all down so they all were approximately 90x90. (See summary image.) Of course, if you use Paint or GIMP, you can just scale them down and not worry about scale in the picture commands.
Now let's tackle the final positions of these emojis. Let's define a box whose center is the center of the screen (640,360).
Remember, y coordinates start from the top of the screen. I decided to make the dimensions of my box 624 by 340. In placing the emojis, we'll use each picture's upper-left corner as the origin. Based on the dimensions of the box, we can calculate the coordinates of each corner of the box and use that to find the positions of the upper-left corners of the emojis. The image below is a summary of the data we need.
Next look at the following images, which show the opening animation of the Mood Matrix:
The Move Picture command uses the same values as the Show Picture command. Leave
easing at its default Linear setting. Check the "Wait for completion" box.
2. Giving a Tutorial
I next had a bit of dialogue, with the emojis animating to show the player what's going on. I used VS's Horror Effects plugin along with the Move Picture command to make the emojis glitch and change size depending on what the subject is feeling.
I run through each of the emotions and make each one glitch. Let's look at the arguments of the plugin commands. Picture ID(s) asks which picture you want to affect. I found the values shown above to be ideal. Make sure you use the Picture variants of these commands or it won't work right. And make sure you use Glitch Remove to remove the effect when you're done with it.
This is the next part of the event, where I glitch all the emojis and scale up the Happy and Surprise emojis using Move Picture:
Now we'll use Move Picture again to return the emojis to their standard size so we can start the real thing. You don't need to remove the glitches yet because of how this thing will flow. (It gets very non-linear; please bear with me.)
3. Making a Statement
We'll start by declaring some variables. First, set a variable to count how many right answers the player has. I called mine "Objective." Set it to 0. Now, as a sidebar, after declaring Objective, use the Label command to place a label called "Start" (or whatever else you want as long as it's unique and easy to remember) and then add a "Fadein Screen" command. I'll get to why we need these later. We're going to do a lot of label-jumping. Make sure your Start Label is placed AFTER Objective = 0!
Back to variables. This is where we start using the concepts from the RPGMakerWeb Blog's "Make An In-Game Book With Pictures." We'll define two variables, which I called Random1 and Random2. Random1 will represent the current "page" number the player is on, and Random2 will represent the previous "page" the player just left.
Now you'll want to remove the glitch effects from all the pictures (1-4).
Let's start making statement a, which is the "default" state of the event. First place a glitch effect on Picture 1. Now we'll use VS's Visual Text Windows plugin to make the statement and instruction window. Go to Plugin Commands and select "Text Window: Add/Change Settings." For ID, choose 1. This is just like a Picture's ID, a means to distinguish and control multiple text boxes. In "Text," write the following:
Code:
<Center>\I[346]/\I[347]: Select statement [Enter]: Pinpoint emotion
<Center> is a Message Core-specific Text Code that causes everything after it to be center-aligned. The \I[x] text code is used to get the arrow key icons to show up. We also need to tell the plugin where we want the text box to show up. We want it just below the emojis, so click "Customized Settings" in the Plugin Command and make it look like this:
Now use the same Plugin Command again, only change the ID to 2, because it's a different text box, and in "Text" write, "I am happy!" The coordinates are similar, but we change Y to 360 and Alignment-Vertical to Center. Now the statement will appear in the center of the screen.
These text boxed behave independently of any Show Text event. They're essentially like pictures, only you have to use the specific plugin commands to move them.
Not to be overlooked is a Wait Command to ensure the player can't just mash the buttons. 5 frames will suffice.
4. Navigation
This is where things get Loop-y. Let's add another Label called "Loop Start" (I'll explain why later...). Next, add a Loop. Make sure everything I say after this is inside the loop unless I specifically say otherwise! The loop is how we allow the player to navigate freely. Next we're going to check if our buttons are being triggered. Inside the Conditional Branch command, on tab 4, you'll see "Button." Select "Left" and "is being triggered." We use "triggered" so the player can't just hold down the arrows keys and potentially miss information. Do one of these for the Left, Right, and OK buttons. That's three branches.
The Left and Right buttons turn the page, which is controlled by Random1. The OK button has more to it. It brings up the choice menu. Inside the branch for the OK button, add a Show Text command that says, "Which emotion is out of place?" Then add a Show Choices Command with four options like below. Also, make sure the Cancel option is set to "Branch." I'll show you the first part:
This is how we achieve (part of) Step 4, the second right answer. Note the Jump to Label commands for "Right Answer 1", "Right Answer 2" and "Wrong Answer". Moving on...
The Sadness emoji is the right answer on Statement 3, and only on the first round. The Happiness emoji is the right answer on Statement 3 as well, but only after it's been replaced. Surprise and Anger will always be the wrong answer. After all the conditional branches for the buttons, we add a 1-frame wait.
Now we need to make sure the player can't go beyond the first or last page when navigating:
Now we'll tell the editor what to do when the player navigates to a certain page. We start by making a Conditional Branch to check if Ramdom1 does not equal Random2. We're checking to see if the player has turned the page. And if they have, we need to know which page they're on. So, we'll run a series of branches: If Random1 = 1, if Random1 = 2, etc., and change the "I am happy" text box.
Make sure that before you add a new glitch, you remove the ones from the page before and after the current one. We add another wait command after each change to limit button-mashing. Now let's discuss what happens when you get to Statement 3, "Now I'm angry!" We use another Conditional, but it has an Else branch. This'll take two pictures.
The two Ends mean the end of the Else branch and the end of the original If Random1 = 3 branch. After all of that, we add another Control Variables command: Random2 = Random1. We're updating the "old" page number to match the "new" one. To recap: Random1 and Random2 start out equal. If the player changes the page, then Random1 will no longer equal Random2. If that's the case, we get the value of Random1 and change the text box and the glitch effects. Then we update Random2 so they're equal and the whole loop starts again.
That is the end of the Loop command. Everything else is placed below the words "Repeat Above." Next we'll look at the commands that actually progress the event.
5. Update and Reboot
When the player selects a choice, it jumps out of the loop to one of the dialogue options below. Here's what happens if the player gets it wrong:
We have a short message and then jump back to the start of the loop. You must make sure that the text in Jump to Label exactly matches the original Label text or it won't work! This doesn't change what page they're on; it just brings you back to checking what page you're on.
6. Ending the Event
Here's what happens when you get it right the first time:
This brings us to another message and then gives the illusion of a restart by closing the text windows and fading out. Then the Objective variable increases, causing the Else branch from earlier to take effect, replacing Statement 3. Then we jump to the "Start" label, which is why I had you add a Fadein Screen command. This is also why you had to put the "Start" label after setting Objective to 0. If you didn't do that, the player would just keep going in circles.
Finally, let's check what happens when you get the second right answer:
We play a message and shut down the event by erasing all the pictures and text boxes, and reset all variables to 0. Doing it this way allows the player to redo the event, but f this is a one-time thing, make sure to add a Self Switch and a new page with said Self Switch as a condition. That will keep the event from running again.
This is just the barebones way of doing this. You can expand it to have more objectives, more statements. You could have multiple statements replacing each other using If...Else If...Else If...etc. I know this was a bit long, but thanks for reading! I hope you find this useful for your own project.
本贴来自国际rpgmaker官方论坛作者:WilsonE7处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:
https://forums.rpgmakerweb.com/threads/replicating-ace-attorneys-mood-matrix-mechanic-in-mz.135913/