• 🏆 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!

Need to in making allrandom mode

Status
Not open for further replies.
Level 2
Joined
Apr 17, 2006
Messages
5
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!!
 
Level 4
Joined
Aug 11, 2005
Messages
101
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)
 
Level 6
Joined
Feb 18, 2005
Messages
263
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>
 
Level 6
Joined
Feb 18, 2005
Messages
263
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
 
Level 6
Joined
Feb 18, 2005
Messages
263
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?
 
Level 6
Joined
Feb 18, 2005
Messages
263
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 ^^
 
Status
Not open for further replies.
Top