City17
4 years
Function GetRandomSubGroup
- Line
- 4953
- Location
- blizzard.j
- Constant?
- no
- Type
- function
- Arguments
- integer count, group sourceGroup
- Returns
- group
| 4953 | function GetRandomSubGroup takes integer count, group sourceGroup returns group |
| 4954 | local group g = CreateGroup() |
| 4955 | |
| 4956 | set bj_randomSubGroupGroup = g |
| 4957 | set bj_randomSubGroupWant = count |
| 4958 | set bj_randomSubGroupTotal = CountUnitsInGroup(sourceGroup) |
| 4959 | |
| 4960 | if (bj_randomSubGroupWant <= 0 or bj_randomSubGroupTotal <= 0) then |
| 4961 | return g
|
| 4962 | endif
|
| 4963 | |
| 4964 | set bj_randomSubGroupChance = I2R(bj_randomSubGroupWant) / I2R(bj_randomSubGroupTotal) |
| 4965 | call ForGroup(sourceGroup, function GetRandomSubGroupEnum) |
| 4966 | return g
|
| 4967 | endfunction
|