Hey, ya’ll!

Guess I’m really bored so I’m going to write another random tutorial!

Do you like it when an NPC says the same thing, over and over? No? Well, we can change that up!

This tutorial actually works in RPG Maker MZ and MV (and probably most others?) but for this tutorial I will be using MZ!

First we are going to start pretty simple. The goal will be to randomly set a variable between 0-2 and have Reida say something different depending on what number it ends up as.

In the end, this is what the event will look like:

I’ll walk you through each step:

First we are going to create a new Variable, and I call this one RandomNumber. Get in the habit of giving your Variables and Switches very descriptive names as you can easily forget what VarWhatever is.

RPG Maker already makes it very easy to get a random number in their Control Variables command:

We just need to Set the variable to Random and choose our numbers: 0-2 for this event. That will result into Variable 1 being given the value of 0, 1 or 2 each time this code is run (when the player interacts with our NPC):

Next we will create some Conditional Branches. If this is true, do this:

We are going to test a Variable, our RandomNumber variable, and we are going to test if it is equal to 0. If it is, it will run the code inside the event command, then go onto the next things in the event.

For this event, we will want a conditional branch testing if Random Number is equal to 0, equal to 1 and equal to 2, like above.

Now inside the conditional branch, put a message box!

Put whatever random greeting you want. I also put ‘Random Number = \V[1]’ so that in game, you can actually see that Variable 1 = 0. The \V[ ] is a text code that tells the program to write the value of whatever variable number you put inside the [ ] in this case, we are checking variable 1, our random number variable: \V[1].

Now do the same with your conditional branches for RandomNumber = 1 and RandomNumber = 2. Again, this is how the event looks when we are done:

Notice each text box is checking the same variable! However, when we play it in the game, we will see a different number!

And that’s the basics! Obviously for an actual game you wouldn’t want our line checking our variable value, but that’s the basics of getting an NPC to say different things each time you talk to them!

How would you edit this to do something different? What if we wanted to check a game switch instead of a variable?

We can do that, too!

Take a look at this event:

This event will say something different if the game switch #1 TalkedToReida is On. Right now, we haven’t set the switch to go on, so if you set this guy up in the game right now, he will never say that first text box. He will only say what is in the Else statement.

Conditional Branches, btw, can not only test if something is true and run code, but they can also run code if that condition ends up being false, and that is what the Else branch is for.

Now, let’s set this event up, and then head over into our Reida girl from before and put in a Control Switch command:

Now Reida should look like this:

Let’s play our game and test this out. First you’re going to want to talk to the guy before talking to Reida:

Now go over and talk to Pricilla/Reida. In game, nothing different should be seen. She’ll still give us her randomly chosen dialog. However, we had her event switch on the first Game Switch, so now let’s go talk to the red haired guy again:

Now he says something different! But of course, the way he is set up he will continue to only say this line, but if we combine what we did with Reida’s event with his event, we can create an array of different dialogue based on randomness and what has happened in the game.

Hopefully, this gives you some ideas to work with to make your NPCs more dynamic and interesting! I have more tips to make this dialogue even more interesting, but I’ll save that for another tutorial!

God bless and keep creating!
Meike Kima

Leave a Reply