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

[JASS] unit group

Status
Not open for further replies.
Level 16
Joined
Mar 3, 2006
Messages
1,564
umm is there a better pick random units than the get random sub group option in jass ? thx
not sure tht would work i need it to pick every unit in unit group but after it picks tht unit it needs to be removed if tht would work for it cool could u show me how to set it up tho im not really sure how to and thx

I don't understand, do you want to pick random unit from a unit group or do you want to remove a unit from a group.

More details please ?
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Guys, using FirstOfGroup is not a "true" random, see this test map for yourselves.
It ALWAYS starts with the left ones first, and goes to the right, like there is some pattern, a direct pattern perhaps.

It is always better to use this method;
  • Actions
    • Set TempGroup = (Random 1 units from UnitGroup)
    • Unit Group - Pick every unit in TempGroup and do (Actions)
      • Loop - Actions
        • Unit Group - Remove (Picked unit) from UnitGroup
    • Custom script: call DestroyGroup(udg_TempGroup)
As I have ran several tests, it always has a random target in 5 sets of experiments I did - compared to using FirstOfGroup, always return the same set, following the same direct pattern which is not truly random at all.
 

Attachments

  • FirstOfGroup Is Not Truly Random.w3x
    13.1 KB · Views: 28
Level 33
Joined
Mar 27, 2008
Messages
8,035
Remember you have to use 2 Group for this case, to clean the leak, else it would leak.
Using a direct reference of (Random N Units From Unit Group) will make it both leak (leak from the Unit Group itself, Leak from the Unit Group) if you don't set it to variables.

And if I'm not mistaken, using set bj_wantDestroyGroup = true in this case doesn't work as it will destroy the Unit Group first before it is used, therefore no actual Unit Group is used.
 
Status
Not open for further replies.
Top