Need Random Logic

I want to make a Rougelike game and I want to have a scene where the player will get to choose a power-up to the items presented to the player. So obviously I need to use random. My idea is that I will use RandomInRange and value is depends on how many items I will put then use it as a condition to spawn the item equivalent to the chosen number. For ex. 1 = Health, 2 = Attack, 3 = Speed, etc. But the problem with this is that sometimes the Random will pick a number twice so the item will be shown twice. All I want is to have a Random items shown atleast 3 without duplications. Hope someone help me with this. Thanks in advance!:heart:

When things get complicated, it often helps to state your objective/mechanic in natural language, e.g.: “While all the slots aren’t filled with different items: pick a random item, check if it’s already in a slot, and if it’s not, place it on the leftmost available slot. While a used item is picked, pick again.”
Then try to convert the natural language to events.

*While is a bit special and will crash the game if not used properly.
https://wiki.gdevelop.io/gdevelop5/events/while

2 Likes

Can you give me the exact conditions I will use in While? I get the idea but I don’t know how to do the “While all the slots aren’t filled with different items: pick a random item"

Well, either you check that the last slot is filled, either you use a FilledSlotCount variable and increment it for each slot.