Hello there, I'm trying to make it so that when a certain event runs, it will randomize the equipment of all party members.
The party members are all static, but the event takes into account what class would be and changes the loadout accordingly. I think I know the answer, but it never hurts to ask, so, my question is: Is there anyway to do this besides "the long way" via conditional branches. Like, is there a shortcut? Only asking because I'm planning on having like, 35 classes, each with 3 different weapons and 3 of each armour type, so it'll be a bit of a slog to do.
Thanks in advance.
yes and no
it can't be done with events alone, but if you add a few script commands it is much easier.
However script commands have their own limitations, and it depends on how your equipment is organised to make the scripts easy or difficult.
first, search for the topic that contains the script equivalents of the event commands for whatever maker you're using - there is a different one for each of the makers.
In the script for the equip command, you can replace the ID of the equipment with a random function.
and that is where your database makes or breaks it. If for example all your swords are one after another (like weapon ID 20 to 34), then you can make a single command randombetween20and34 to get a random sword.
If your swords are scattered through the ID list (like 1,8,13,17,25,...) then it will require a much more complex function to find a random sword.
It could be done a bit more efficiently by outsourcing it to a JavaScript function, but that's still tedious. I guess the question is...is it really necessary to do, gameplay-wise? As opposed to simply starting all of the characters with generic equipment that any class can use...or giving them money for a shop, or something.
Is your idea of this random choice of equipment actively adding anything to the game for the player?
Thanks, Andar. I'll try that. Might save a bit of time. Yeah, all of the stuff is grouped together by what I want to equip on them, so it's probably easier to go that route.
I wouldn't say it's vital to my game, or even necessary, or heck, probably won't even be noticed, if I'm gonna be honest. But, I feel that it would be a benefit to include it, so I'll keep it in, but I appreciate the concern.
Thanks for the help.
Okay, my first question: is every database slot an actual item of equipment, or do you have any placeholders/dividers/things that wouldn't be good if they were chosen at random?
Nah, there's separators, I could take them out, I guess.
Do the separators all have the same name? It doesn't really matter either way, I have a solution that'll work if not.
That doesn't seem to work, thanks for trying though. I think I'll just end up doing it the long way.
It does work, I literally did it in my test project before I posted the code. 😛 But I can certainly work with you to figure out why it doesn't seem to work for you. What do you mean by it doesn't work, exactly?
Well, it pops up with an error in another plugin when I run it. If I remove that plugin, the error goes to the next one.
The error is... "SyntaxError: Unexpected Token =>" When I call it from an event (Which is what I was assuming I did with it, wasn't 100% sure).
Even if I remove all the other Plugins I have, it still gives me that error.
Wasn't implying that it didn't work, btw. I just assumed I was using it wrong.
What version of MV do you have? If it's saying => is an unexpected token that sounds like your version of node.js doesn't support arrow functions, meaning it's likely out of date.
You know that's probably it. I haven't used MV in a while. I'll check that and give it another shot. Thanks for reminding me about that.
EDIT: Yep, that was it. Just needed to update. The script is working great. Just a question, if there's some equipment I don't want to randomize, would I just change the -1 in "const randomEquip = slotEquipment[Math.randomInt(slotEquipment.length - 1)]" to a bigger number? Assuming all the stuff I don't want randomized is at the bottom of the list?