| 02-14-2007, 11:19 PM | #1 |
Hi all, for one of my spells I need to pick a random unit from units in a fixed range. What is the best way to do this? I used: JASS:call GroupEnumUnitsInRangeCounted( g, x, y, range, Condition( function Spell_Group_Conditions ), 1 ) but, for some reason, it doesn't work (it picks ALL the units in range), why? I also tried to use: JASS:call GroupEnumUnitsInRange( g, x, y, range, Condition( function Spell_Group_Conditions ) ) set u = FirstOfGroup( g ) But the unit is not chosen random, it's always the same. Any Help? Thanks. |
| 02-15-2007, 02:07 AM | #2 |
Do this: JASS:call GroupEnumUnitsInRange( g, x, y, range, Condition( function Spell_Group_Conditions ) ) set u = GroupPickRandomUnit(g) //... That should work for you. |
| 02-15-2007, 08:59 AM | #3 | |
Quote:
|
| 02-15-2007, 12:00 PM | #4 |
Nah, but it's the easiest. If you do it without the BJ, you need to monitor the % chance, reduce with each passing unit in the group, etc. The BJ was made to make life easier, and it does. :P Just use the BJ, it's not like it leaks. |
| 02-15-2007, 12:57 PM | #5 |
Ok, so I think I will use that function; but why GroupEnumUnitsInRangeCounted doesn't work? Thanks! |
| 02-16-2007, 09:13 AM | #6 | |
Quote:
Some BJ's are utter crap though, like the BJFunctions which do the exact same thing as the functions they call |
