@Hell_Master: that's the exact same thing, but with leaks
.
@Apoclypse : This is really confusing, and i don't get it. Is there any other easier way to select a random hero ?
(ap0calypse*)
How exactly confusing?
There's no easier way if you want to do it properly (this is already a really easy trigger).
The amount of heroes that can be randomed:
-
Set HeroTypeCount = 3
The heroes that can be randomed:
-
Set HeroType[1] = Hero A
-
Set HeroType[2] = Hero B
-
Set HeroType[3] = Hero C
This will decide which hero will get randomed:
-
Set RandInt = (Random integer number between 1 and HeroTypeCount)
It will create a random integer from 1 to the amount of heroes, meaning that every hero has an equal chance to get picked.
Now we can actually create the hero:
-
Unit - Create 1 HeroType[RandInt] for (Picked player) at TempLoc1 facing Default building facing degrees
Remember: RandInt is an integer between 1 and the amount of heroes.
If it is, say, 2, then HeroType[2] will get created - which equals Hero B (as seen above).
These functions make sure that a hero can only be picked once (if some AI randoms Hero A, then that hero cannot be picked again)
-
Set HeroType[RandInt] = HeroType[HeroTypeCount]
-
Set HeroTypeCount = (HeroTypeCount - 1)
You do not need to worry about this too much: it does what it's meant to do, and that's it
.
If you do want to allow multiple players having the same hero, simply remove these actions.
And last but not least:
-
Set TempLoc1 = ((Picked player) start location)
-
Custom script: call RemoveLocation(udg_TempLoc1)
These actually came before, but I left them out on purpose.
They only fulfill a single role: remove the location leak. Leaks cause mid-to late-game lag and are to be avoided at all times.