• 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.

[Trigger] Random Card Generator

Status
Not open for further replies.
Level 1
Joined
Jun 5, 2009
Messages
5
Hey I was wondering if somone could help me with a porblem I'm having.
I need to create a trigger that when ran will draw a random "card" from the "deck". Normally this wouldnt be a problem to do, however in the deck there are mutliples of the same card. For example theres 2 fire cards, and 3 water cards. Then after the card is drawn the overall unmber of cards is reduced and then when there is zero cards left, the deck is set back to its intial number of cards.
I hope thats clear...
So can someone make this for me?

Thanks

SNOW37
 
If you're asking someone to make it for you, this belongs in the requests section.

But we can nudge you in the right direction.

Create a variable array (unit array? what are "cards"?) And select a random unit (get random int from 0 to 51, for a 52 card deck in example). then set array[int]=null once it's been drawn.

Try it ;)
 
Level 1
Joined
Jun 5, 2009
Messages
5
"cards" are items that get added to the unit when they get drawn. And i'm using hash tables but I'll try it your way and see wut happens.
Also I rather just do it myself but if I cant then i'll put in the request section/
 
Ok, key things are these:

1) You must Create the Hashtable.
2) You must store the cards in the Hashtable
e.g. Save <Item1> as 0 of 0 in Hashtable.
Save <Item2> as 0 of 1 in Hashtable.
Save <Item3> as 0 of 2 in Hashtable.
....
3) You use a random integer to get a random card. You should use:
Load 0 of (Random Integer between 0 and X) in Hashtable.
4) You create the item and give it to the hero.

This is the basic idea. If you have any problems, please do say so.

PS: If you do not need to classify the cards and such, item type arrays work better.
 
Status
Not open for further replies.
Top