• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Help needed, random numbering

Status
Not open for further replies.
Level 11
Joined
Jul 28, 2007
Messages
920
Ok, i am making maps similar to card shuffle, ( card game ), so i had one system but it seems it has bugs... so what i need is IDEA, how to create some system, that makes when player uses spell to give him one random item of 60 avalible items, like u have deck of 60 cards(items) so when u use spell u must get one of those card, but cards have limitation, like, common cards - u can have only 6 of them, so u can get it only 6 times, 7th time u wont get it, u will get another, IDEA pls :D

or i need just how to give 60 variables diffrent numbers,
at the start game will give diffrent numbers to 60 variables.
Var1=2
Var2=4
Var3=5
next game
Var1=4
Var2=2
Var3=5
next game
Var1=5
Var2=2
Var3=4
and so on...
 
Level 11
Joined
Jul 28, 2007
Messages
920
Set Var1 = Random number between 1 and 60
Set Var2 = Random number between 1 and 60

Var1 = 4
Var2 = 4

this must not happen... so... there are was to prevent this, but, i want to see it, i have probably long ways... ccc so all numbers >>must be diffrent<<
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
The easiest way would be:

var[1] = 1
var[2] = 2
var[3] = 3
var[4] = 4
...

After doing so up to 60 times, pick 2 random variables (between 1 and 60, I assume?), and swap their values. e.g.

  • For integer A from 1 to 400 do:
    • set random1 = random int between 1 and 60
    • set random2 = random int between 1 and 60
    • set temp = var[random1]
    • set var[random1] = var[random2]
    • set var[random2] = temp
 
Status
Not open for further replies.
Top