• 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] All Random?

Status
Not open for further replies.

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Add all heroes to an intiger array and randomy select one and create it for a player while setting that index (layer) in boolean array to true. Repeate for the other players and if that layer (index) is true in the boolean it moves onto the next. Not truely random but random enough.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
With a Unit Type array called RandomHeroes, this is the easiest way.

  • Initialization
    • Events
      • Map Initialization
    • Conditions
    • Actions
      • Set RandomHeroes[0] = Paladin
      • Set RandomHeroes[1] = Mountain King
      • Set RandomHeroes[2] = Blood Mage
      • Set RandomHeroes[3] = Archmage
      • (so on)
  • Random Hero
    • Events
      • Your Event Here
    • Conditions
      • Your Conditions Here
    • Actions
      • Unit - Create 1 RandomHeroes[(Random Integer Number between 0 and (the highest number you used in your array))] for (player) at (point) facing (degrees)
 
Level 6
Joined
Mar 2, 2006
Messages
306
initialization: you need 3 global variables: RandomHeroes array (see above, make it 1-based), integer RandomMax (initialy set to 15 or how many heroes you have at start) and integer array RandomIndex[1..Max]. use a for-loop to set RandomIndex[a] to a (so that RandomIndex[3]==3, RandomIndex[4]==4 and so on)

now:
  • Actions
    • Set R = (Random Integer Number between 1 and RandomMax)
    • Unit - Create 1 RandomHeroes[RandomIndex[R]] for someplayer at wherever facing whatever
    • Set RandomIndex[R] = RandomIndex[RandomMax]
    • Set RandomMax = RandomMax -1
    • If RandomMax == 0
    • Then - Actions
      • we ran out of heroes (for next time; no error here).
      • do something to disable further selection...
there. every index (every number from 1 to max) can be selected only once because after that, we take the one from the end and put it in place of the selected element. simple.
 
Level 3
Joined
Dec 30, 2005
Messages
37
i tryed the way you showed here .. but it still doesnt create me a random hero .. the first time it gave me random heroes .. but all the time the same heroes ... i mean ... every time i had hero X and player 2 hero Y but never both the same hero ... and the second time i tried and nothing apeard .. could you please post a full triger bassed system ? i'm trying with 10 heroes for start ... please help me smbdy .. .ty
 
Status
Not open for further replies.
Top