RPG Maker MZ

RPG Maker MZ

RedShell9 Nov 14, 2024 @ 10:52am
How do I randomise my entire party.
Strangely enough there is nothing to help me here for this. I found something that strangely looked like the code actually just lets you choose your own for some reason. I'd like it to happen on game start as well and of course for it to only happen once, I don't want rerolls. If this is the wrong place to ask for something like this please say.
< >
Showing 1-9 of 9 comments
Flame-kun Nov 14, 2024 @ 4:19pm 
Originally posted by RedShell9:
Strangely enough there is nothing to help me here for this. I found something that strangely looked like the code actually just lets you choose your own for some reason. I'd like it to happen on game start as well and of course for it to only happen once, I don't want rerolls. If this is the wrong place to ask for something like this please say.
Can you post this "strange code that looks like makes you can choose your party randomly"?

Joking aside, you could make an autorun event on the starting map, then use random on the control variables. Create a conditional branch after that refers to the RNG and voila! (don't forget to make another blank event page with self-switch so you don't stuck in infinite loop)
Crystal Sharrd Nov 14, 2024 @ 4:27pm 
You'll need to have a default character in the party. I'd recommend starting on an empty map with the party set to be initially transparent. Not entirely sure if this would work, but say you had six possible characters to start from:
• Remove the default character
• Run the following code in a script block, you'll need to set aside four variables, replacing var1 through var4 with their IDs.
$gameVariables.setValue(var1,Math.randomInt(6)+1); do { $gameVariables.setValue(var2,Math.randomInt(6)+1); } while ($gameVariables.value(var2) == $gameVariables.value(var1)); do { $gameVariables.setValue(var3,Math.randomInt(6)+1): } while ($gameVariables.value(var3) == $gameVariables.value(var1) || $gameVariables.value(var3) == $gameVariables.value(var2)); do { $gameVariables.setValue(var4,Math.randomInt(6)+1); } while ($gameVariables.value(var4) == $gameVariables.value(var1) || $gameVariables.value(var4) == $gameVariables.value(var2) || $gameVariables.value(var4) == $gameVariables.value(var3)); $gameParty.addActor($gameVariables.value(var1)); $gameParty.addActor($gameVariables.value(var2)); $gameParty.addActor($gameVariables.value(var3)); $gameParty.addActor($gameVariables.value(var4));

I don't know if there's a better way, and I can't test it at the moment, but it's how I'd do it.
RedShell9 Nov 15, 2024 @ 10:02am 
Originally posted by Crystal Sharrd:
You'll need to have a default character in the party. I'd recommend starting on an empty map with the party set to be initially transparent. Not entirely sure if this would work, but say you had six possible characters to start from:
• Remove the default character
• Run the following code in a script block, you'll need to set aside four variables, replacing var1 through var4 with their IDs.
$gameVariables.setValue(var1,Math.randomInt(6)+1); do { $gameVariables.setValue(var2,Math.randomInt(6)+1); } while ($gameVariables.value(var2) == $gameVariables.value(var1)); do { $gameVariables.setValue(var3,Math.randomInt(6)+1): } while ($gameVariables.value(var3) == $gameVariables.value(var1) || $gameVariables.value(var3) == $gameVariables.value(var2)); do { $gameVariables.setValue(var4,Math.randomInt(6)+1); } while ($gameVariables.value(var4) == $gameVariables.value(var1) || $gameVariables.value(var4) == $gameVariables.value(var2) || $gameVariables.value(var4) == $gameVariables.value(var3)); $gameParty.addActor($gameVariables.value(var1)); $gameParty.addActor($gameVariables.value(var2)); $gameParty.addActor($gameVariables.value(var3)); $gameParty.addActor($gameVariables.value(var4));

I don't know if there's a better way, and I can't test it at the moment, but it's how I'd do it.

This code seems good, I had to fix a colon to a semi colon though but that seems to be it with the code itself. It gave me an error for the variables not being defined though. I tried to make them all 0 to zero and it didn't work, I also tried making them int but it didn't work either it always said it wasn't defined.
Crystal Sharrd Nov 15, 2024 @ 2:21pm 
Originally posted by RedShell9:
Originally posted by Crystal Sharrd:
You'll need to have a default character in the party. I'd recommend starting on an empty map with the party set to be initially transparent. Not entirely sure if this would work, but say you had six possible characters to start from:
• Remove the default character
• Run the following code in a script block, you'll need to set aside four variables, replacing var1 through var4 with their IDs.
$gameVariables.setValue(var1,Math.randomInt(6)+1); do { $gameVariables.setValue(var2,Math.randomInt(6)+1); } while ($gameVariables.value(var2) == $gameVariables.value(var1)); do { $gameVariables.setValue(var3,Math.randomInt(6)+1): } while ($gameVariables.value(var3) == $gameVariables.value(var1) || $gameVariables.value(var3) == $gameVariables.value(var2)); do { $gameVariables.setValue(var4,Math.randomInt(6)+1); } while ($gameVariables.value(var4) == $gameVariables.value(var1) || $gameVariables.value(var4) == $gameVariables.value(var2) || $gameVariables.value(var4) == $gameVariables.value(var3)); $gameParty.addActor($gameVariables.value(var1)); $gameParty.addActor($gameVariables.value(var2)); $gameParty.addActor($gameVariables.value(var3)); $gameParty.addActor($gameVariables.value(var4));

I don't know if there's a better way, and I can't test it at the moment, but it's how I'd do it.

This code seems good, I had to fix a colon to a semi colon though but that seems to be it with the code itself. It gave me an error for the variables not being defined though. I tried to make them all 0 to zero and it didn't work, I also tried making them int but it didn't work either it always said it wasn't defined.
What was the specific error message?
I'll try to test it myself tonight.
RedShell9 Nov 15, 2024 @ 3:41pm 
Originally posted by Crystal Sharrd:
Originally posted by RedShell9:

This code seems good, I had to fix a colon to a semi colon though but that seems to be it with the code itself. It gave me an error for the variables not being defined though. I tried to make them all 0 to zero and it didn't work, I also tried making them int but it didn't work either it always said it wasn't defined.
What was the specific error message?
I'll try to test it myself tonight.

The thing is a reference error, it says specifically var1 is not defined but of course it would then probably mean the rest are not either.
Crystal Sharrd Nov 15, 2024 @ 4:02pm 
Originally posted by RedShell9:
Originally posted by Crystal Sharrd:
What was the specific error message?
I'll try to test it myself tonight.

The thing is a reference error, it says specifically var1 is not defined but of course it would then probably mean the rest are not either.
Like I said, replace those with the IDs of the variables you're using. So if you're using variables 8-11 for it, you'd replace var1, var2, var3, and var4 with 8, 9, 10, 11, i.e. the first line would be:
$gameVariables.setValue(8, Math.randomInt(6)+1);
RedShell9 Nov 15, 2024 @ 4:27pm 
Originally posted by Crystal Sharrd:
Originally posted by RedShell9:

The thing is a reference error, it says specifically var1 is not defined but of course it would then probably mean the rest are not either.
Like I said, replace those with the IDs of the variables you're using. So if you're using variables 8-11 for it, you'd replace var1, var2, var3, and var4 with 8, 9, 10, 11, i.e. the first line would be:
$gameVariables.setValue(8, Math.randomInt(6)+1);

Ok so problem, idk what you mean by IDs because there's 20 of these guys and there's 4 variables. Or is there something I'm missing? Sorry if this sounds extremely stupid.
Crystal Sharrd Nov 15, 2024 @ 5:01pm 
Originally posted by RedShell9:
Originally posted by Crystal Sharrd:
Like I said, replace those with the IDs of the variables you're using. So if you're using variables 8-11 for it, you'd replace var1, var2, var3, and var4 with 8, 9, 10, 11, i.e. the first line would be:
$gameVariables.setValue(8, Math.randomInt(6)+1);

Ok so problem, idk what you mean by IDs because there's 20 of these guys and there's 4 variables. Or is there something I'm missing? Sorry if this sounds extremely stupid.
ID would be the variable's number. A project starts with twenty variables by default, but you can change the amount by editing an event, checking the box next to Variable, clicking the box with the number in it next Variable, and selecting Change Maximum. The reason for the four variables is because a party can have a maximum of four members. I'll see if I can work up a sample project and upload it to the Steam Workshop.
Here, I hope this helps if you still don't understand the code: https://steamcommunity.com/sharedfiles/filedetails/?id=3366474741
Last edited by Crystal Sharrd; Nov 15, 2024 @ 5:49pm
RedShell9 Nov 16, 2024 @ 2:04am 
Originally posted by Crystal Sharrd:
Originally posted by RedShell9:

Ok so problem, idk what you mean by IDs because there's 20 of these guys and there's 4 variables. Or is there something I'm missing? Sorry if this sounds extremely stupid.
ID would be the variable's number. A project starts with twenty variables by default, but you can change the amount by editing an event, checking the box next to Variable, clicking the box with the number in it next Variable, and selecting Change Maximum. The reason for the four variables is because a party can have a maximum of four members. I'll see if I can work up a sample project and upload it to the Steam Workshop.
Here, I hope this helps if you still don't understand the code: https://steamcommunity.com/sharedfiles/filedetails/?id=3366474741

ok so ye I'm stupid lol, I swapped out the variable with 1 2 3 and 4 and it just worked. Thanks a lot btw, I will do my best with this gimmick.
< >
Showing 1-9 of 9 comments
Per page: 1530 50