# Unwrapping a packet of cards

#### Fenix2222

##### Villager
How can I manage to create it? I mean, each card has its rarity: a legendary card is hard to find, so you have a low chance to open a pack with it. How can I simulate these percentages? Example: common cards 60% of chance to find (give item) this card.
Rare card 20% etc...

#### Andar

##### Veteran
basically a lot of control variable and conditional branches.

control variable can give you a random number, for example between 1 and 100
then check the result with the conditional branch, from 1-5 you give legendary card, from 6-20 you give rare card, from 21 to 40 you give uncommon card, from 41 to 100 you give common card.

you should read into weight mathematics (example: https://ovate.github.io/andar-tips/weight-calc.html) and make a complete card table before you even start to program the event however, because that will be an extreme and tedious list of all cards and you'll mess it up without carefull planning.

#### Wavelength

##### MSD Strong
Like Andar said, it can all be done with random numbers, conditional branches, and clever use of Show Picture. I would set up the eventing by first choosing a rarity (e.g. if number is between 1 and 5 give legendary, 6 to 15 rare, 16 to 30 uncommon, 31 to 100 common), and then within each rarity you could have a second, evenly distributed random number to choose which card of that rarity to award.

In the long run - especially if you're planning to do more complex stuff like allowing re-rolls or filling out a collection of all cards that have been obtained - you will want to move onto JavaScript programming to do this. It will save you a lot of time and make it easier to scale when you start adding in more features.

#### Fenix2222

##### Villager
Like Andar said, it can all be done with random numbers, conditional branches, and clever use of Show Picture. I would set up the eventing by first choosing a rarity (e.g. if number is between 1 and 5 give legendary, 6 to 15 rare, 16 to 30 uncommon, 31 to 100 common), and then within each rarity you could have a second, evenly distributed random number to choose which card of that rarity to award.

In the long run - especially if you're planning to do more complex stuff like allowing re-rolls or filling out a collection of all cards that have been obtained - you will want to move onto JavaScript programming to do this. It will save you a lot of time and make it easier to scale when you start adding in more features.
How can I make "if number is between" in a simple way? Should I use 2 conditional branches? (ex: if var(x) is >1 ---> if var(x) is < 5 then card(x) appears).

#### Wavelength

##### MSD Strong
How can I make "if number is between" in a simple way? Should I use 2 conditional branches? (ex: if var(x) is >1 ---> if var(x) is < 5 then card(x) appears).
Basically yes. You could set it up in nested branches like this:
Control Variables: Set Variable #1 to number between 1 and 100
Conditional Branch: If Variable #1 is less than or equal to 5
..Do processing for legendary card
Else
..Conditional Branch: If Var #1 is less than or equal to 15
....Do processing for rare card
..Else
....Cond Branch: If Var #1 is <= 30
......Do processing for uncommon card
....Else
......Do processing for common card
....End Branch
..End Branch
End Branch

#### Andar

##### Veteran
How can I make "if number is between" in a simple way?
no need for that if you sort your conditional branches correctly.
if x< 5 go label 1
if x< 20 go label 2
if x < 40 go label 3

the x=4 will never go to label 2 even if it theoretically fulfills the condition, because it was send away to label 1 before that condition was even checked.

### Latest Profile Posts

Added console to my content thread here
Sweet nostalgia. My fave Final Fantasy game.
Steam page is now live!

just discovered thig game called Willowbrooke Post... beautiful artstyle if I do say so myself... does anyone know what this kind of style is called??
In one of my game projects, I am working on an arena where you can fight combatants or bet on monsters, and, man, it is taking so long, lmao. I do not think that it helps that I am using an evented combat system with a lot of things that I have to edit.

Threads
115,423
Messages
1,089,742
Members
150,169
Latest member
switchstone