I want to add an app where you can call a character, i would like to do it by common event if possible and they say random things base on what is happening in the game at the moment does anyone know how i could do that? If anyone could help me that would be really helpful to me
Phone calls with random characters
RPG Maker MZ SupportYou would have to have some kind of table, matrix or array holding different things the person can say (strings of text). Then a script to call that entry in the table using a conditional statement if it returned true.
Actually, this could be done with a switch case too.
Actually, this could be done with a switch case too.
how would i write that i have no idea how to script
My first 7 or so tutorials were all about dialog options and several of them use Arrays and random selection.
You should probably be able to reference those to create multiple arrays for different things to randomly say in different situations/times and then use standard conditional branches to determine which array to pull a random phrase from.
Just look on my channel at the link below and go to the oldest of my MZ tutorials.
I hope they help.
You should probably be able to reference those to create multiple arrays for different things to randomly say in different situations/times and then use standard conditional branches to determine which array to pull a random phrase from.
Just look on my channel at the link below and go to the oldest of my MZ tutorials.
I hope they help.
Something like this:
Control variable 1 is the current weather
switch ($gameVariables.value(1)) {
case 0:
$gameMessage.add("It's sunny today!");
break;
case 1:
$gameMessage.add("I hate it when it rains like this");
break;
case 2:
$gameMessage.add("The snow is so beautiful.");
break;
}
Control variable 1 is the current weather
switch ($gameVariables.value(1)) {
case 0:
$gameMessage.add("It's sunny today!");
break;
case 1:
$gameMessage.add("I hate it when it rains like this");
break;
case 2:
$gameMessage.add("The snow is so beautiful.");
break;
}
You can spawn an array of things within a variable; Then you'll also need a second variable to temporary store & display the chosen ""phone call/random dialogue
*small disclaimer: this is from MV
1. Spawn your variable somewhere at the beginning of the game, with an array that contains all your dialogues:
2. On the map event, add this as script (it basically random picks an index [example] from your array var and stores it to a different var, then excludes from the array the chosen index to avoid having the same text twice in a row, although randomized):
//words = Math.randomInt($gameVariables.value(420).length);
//$gameVariables.setValue(240, $gameVariables.value(420)[words]);
//$gameVariables.value(420).splice(words, 1);
right after that, you can add a show text box with \v[240]
right after using your var, set it to 0 so you won't end up with two examplesOneAfterAnother
note1: in case you ran out of options within your variable, you can simply check if the variable is empty:
if: $gameVariables.value(420) == ""
repeat step 1
Hope it helps :hhappy:
*small disclaimer: this is from MV
1. Spawn your variable somewhere at the beginning of the game, with an array that contains all your dialogues:
2. On the map event, add this as script (it basically random picks an index [example] from your array var and stores it to a different var, then excludes from the array the chosen index to avoid having the same text twice in a row, although randomized):
//words = Math.randomInt($gameVariables.value(420).length);
//$gameVariables.setValue(240, $gameVariables.value(420)[words]);
//$gameVariables.value(420).splice(words, 1);
right after that, you can add a show text box with \v[240]
right after using your var, set it to 0 so you won't end up with two examplesOneAfterAnother
note1: in case you ran out of options within your variable, you can simply check if the variable is empty:
if: $gameVariables.value(420) == ""
repeat step 1
Hope it helps :hhappy:
The advice being given you is all good, but I fear it's too complex for your first effort with this. You should be able to come up with some version of this just with the basic event functions.
So you just make a series of conditionals based on possible values of Story.
etc.
So you presumably have a variable that's tracking where you are in your game's story. We'll call it Story.
So you just make a series of conditionals based on possible values of Story.
Code:
◆If:Story = 2
◆
:End
◆If:Story = 3
◆
:End
◆If:Story = 4
◆
:End
So you use the option right on the first tab of Control Variable to choose a random number. Then you reference that random number inside of each of those conditional branches above.
Code:
◆Control Variables:#0002 conversation = Random 1..3
◆If:Story = 2
◆If:conversation = 1
◆Text:None, Window, Bottom
:Text:Random thing 1 about story point 2
◆
:End
◆If:conversation = 2
◆Text:None, Window, Bottom
:Text:Random thing 2 about story point 2
◆
:End
◆If:conversation = 3
◆Text:None, Window, Bottom
:Text:Random thing 3 about story point 2
◆
:End
◆
:End
etc.
okay thank you guys
Original thread: https://forums.rpgmakerweb.com/threads/phone-calls-with-random-characters.156865/