Warcraft III resources & community, 2003–2006 · archived

Need to in making allrandom mode

11 posts
#1

Need to in making allrandom mode

Hi i got a question, i am making some footmen map, i got stuck at the trigger of making a allrandom mode. When i create a -ar mode, it works fine, but the problems is it always random the same unit for each players. Can any pls tell me how to solve this problem or give me an example of how to make a allrandom mode for footmen game thx!!
#2
Event: Map initialization
Conditions:
Actions: Set heroes[1] = bloodmage
set heroes[2] = paladin
set heroes[3] = archmage
(and so on. the variable heroes being a unit type array with the number of max heroes you have as the array number)

Event: player 1(red) types -ar as an exact match
Conditions:
Actions: Pick all players in matching player is a user = true and matching player is playing = true and do loop actions
- create 1 heroes[random number from 1 to (max number of heroes) for picked player at picked players start location(or w/e region)
#3
That doesnt prevent double or more same heroes.
If he don't mind thats fine else i could post a random script without double heroes
#4
the problem, is i understand it, is not that the SAME UNIT is given to SEVERAL players
but more that EVERY TIME there are the same units given to the same players as in the turn/s before...

There is no randomizer in singleplayer. Therefore if you want to test a somewhat random trigger you should do it in multiplayer. The more players the better the randomizing function of WC3



and for randomly giving each player a hero without giving one twice - this shall work

variables
integer tmp_1 = length of your array
integer tmp_2 = 0
unittype array heroes[] = your heroes(starting with heroes[0])

Trigger
event: whatever
condition:
- whatever
- tmp_1 >= 0
actions:
- <some code of yours>

- set tmp_2 = random integer between 0 and tmp_1
- create Heroes[tmp_2] for ...

- if tmp_2 = tmp_1 then
- - set tmp_1 = tmp_1 - 1
- else
- - set Heroes[tmp_2] = Heroes[tmp_1]
- - set tmp_1 = tmp_1 - 1
- endif

<some more code of yours>
#5
I didnt try it out but i don't think that it prevents game from giving same heroes.
You have to check for given heroes each time you randomized that number.
Your trigger checks for maximum array size... why that ?

Or got i sumthing wrong ?
#6
ok, i'll try to explain it a bit.

i pick a random unit from that array
(e.g. index = 3/7)
then i move the last value of the array to the position the unit i gave was in
(herores[3] = heroes[7])
then i reduce the length of the array by one (not the real length, but the length that is considered for giving heroes)

now i have no hero within my array that ha sbeen given to anyone already

hope it's understandable, for i do not have the time thinking about it for more than a few seconds - i'm mapping atm
#7
Heroes[1] = Hero 1
Heroes[2] = Hero 2
etc
heroes[7] = Hero 7

You pick heroes[3] out of those 7
Then you set the pick range from 7 to 6
That means hero 7 cant be picked anymore. It doesnt mean hero 3 won't be used again.
#8
tmp = 0
max = 7

Heroes[1] = a
Heroes[2] = b
...
Heroes[7] = g

-> hero choose (tmp = 3)
-> create Heroes[tmp]
-> set Heroes[tmp] = Heroes[max]

Heroes[1] = a
Heroes[2] = b
Heroes[3] = g //set to the value of Heroes[max]
...
Heroes[7] = g


-> set max = 6

Heroes[7] is no longer choosable


is it more understandable this way?
#9
Yeah that way it should work
And its way shorter than my randomizer. Not easier though ;)

Ich wär nie darauf gekommen das so zu machen :lol:
#10
tja, da sieht man mal, wozu es nützlich is, wenn man n weilchen programmiert und sich so des ein oder andere angewöhnt ^^
(und für mich IST esa einfacher ^^ - weil kürzer als der rest ^^)

thats life ^^ nobody is perfect - i'm nobody ^^
#11
Ich bin nie über html hinausgekommen beim 'programmieren' *g* Aber das schöne is ja das es immer ne menge wege zum ziel gibt und das nachher niemand sieht welchen man genommen hat


Shorter = better , thats true. Ashes on my head :D
I suck ;)