I know each test event should have a 1 in 3 chance of any rewards when triggered to update the gold balance. However, it seems to work when it wants to. If I have 30G... the second chest with the same event set-up will trigger 0G. The only options are to gain 50, 25, or lose 25. I'm confused if I set the event correctly because there is no condition of picking 0G as a reward. The second page is just blank for the self switch to prevent opening the chest constantly.
Random Chest Reward Variables
RPG Maker MZ SupportThat event can never pick the +25 or -25 options. Can you see why?
👋
+25 only happens if the variable is equal to 1 and equal to 2, which will never happen. Same thing with -25: it only happens if the variable is equal to 1, 2, and 3.
Just move those branches so that they're not nested inside one another.
Just move those branches so that they're not nested inside one another.
I opt with caethyril answer, but I also personally set the variable on top before
opening the chest.
or the switch A inside each, but it can work the way you have further.
another way to make loot chest is to contain 3 items or gold values without
a variable use, so it just take a random loot inside the array, similair like this:
which might be corrected:
I dont know about the bottom line though, but its around that which can
be shorter and more effective, but its up to you 🙂
opening the chest.
Code:
Play sound
Variable 1-3
if variable = 1
+50 gold
end
if variable = 2
+25 gold
end
if variable = 3
-25 gold
end
switch A ON
or the switch A inside each, but it can work the way you have further.
another way to make loot chest is to contain 3 items or gold values without
a variable use, so it just take a random loot inside the array, similair like this:
which might be corrected:
JavaScript:
GoldLoot = [50,25,-25];
GoldLoot = GoldLoot[Math.floor(Math.random() * GoldLoot.length)];
$gameParty.gainGold(GoldLoot, 1);
I dont know about the bottom line though, but its around that which can
be shorter and more effective, but its up to you 🙂
Mega tip, make this a common event.
The above is right and would get you where you need to be. A common event would be helpful if this is a common thing, but for a one-off, any event should be just as good. Your problem is that you've got some nested conditionals there; you could also fix it by adding 'else' statements, which I like just for the sake of grouping things together (it probably looks messy to some people, though). You'll start to catch these things as you keep making; just always be sure to keep an eye on what you're actually asking an event to do.
additionally, move the self-switch command to the bottom.
the self-switch is to activate the second page, and that should only happen after the first page is completed.
setting the self-switch earlier will create a risk that the remaining commands are abandoned - not in this specific case because that has no multiframe commands, but don't learn those procedures wrong or you'll have problems with later and more complex events.
the self-switch is to activate the second page, and that should only happen after the first page is completed.
setting the self-switch earlier will create a risk that the remaining commands are abandoned - not in this specific case because that has no multiframe commands, but don't learn those procedures wrong or you'll have problems with later and more complex events.
Original thread: https://forums.rpgmakerweb.com/threads/random-chest-reward-variables.159550/