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

Random Button

Status
Not open for further replies.
Level 9
Joined
Oct 17, 2009
Messages
370
Your standard random selection trigger.

Create an integer array and fill it with the hero types available.
Then just choose a random index from it and ceate that hero type.

That easy.

For finite choice of heroes, simply remove them from the array.

ive noticed one thing when i did like this... if i in the first map choose random FIRST of all players, and i get for example blademaster, i will get blademaster if i pick random first too the next time i play,
or if i use the random integer to just set a integer variable to a number, it will be the same number every game i play...
 
Level 8
Joined
Jul 11, 2008
Messages
104
Your standard random selection trigger.

Create an integer array and fill it with the hero types available.
Then just choose a random index from it and ceate that hero type.

That easy.

For finite choice of heroes, simply remove them from the array.

I want to do this for units, not heroes.

Also, how do I form it into a trigger (GUI) after I create the variable?
 
Level 19
Joined
Feb 25, 2009
Messages
2,004
ive noticed one thing when i did like this... if i in the first map choose random FIRST of all players, and i get for example blademaster, i will get blademaster if i pick random first too the next time i play,
or if i use the random integer to just set a integer variable to a number, it will be the same number every game i play...

To prevent that, simply test the map, quit the game, save the map, close WE, open WE, open your map, test again.
 
Level 9
Joined
Oct 17, 2009
Messages
370
OFFTOPIC WARNING: didnt work, in my map i was using random spawn places for all players when he choosed his hero, like this
event:
A unit enters Herochosen <gen>
condition:
Triggering unit is a hero equal to true
actions:
Set temppoint = random point in playable map area
Move entering unit to temppoint
call Removelocation( temppoint )


I tested alone and the first hero i created was going into a river unable to move (sadly enough but it doesnt matter now) and the second one almost in the middle of the map. the next time i tested it (the next day so i restarted) the first one spawned in the river again and the second one in the middle
 
Level 15
Joined
Aug 31, 2009
Messages
776
There's an option in the editor called "Used Fixed Random Seed". I'm not entirely sure, but I was always told to turn this option off, and I've never encountered this 'same value from a random generator' problem since I turned it off.

It's in the Editor Preferences I think.
 
Status
Not open for further replies.
Top