• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[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
 

Cokemonkey11

Spell Reviewer
Level 30
Joined
May 9, 2006
Messages
3,537
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/
 
Level 15
Joined
Dec 18, 2007
Messages
1,098
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