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

Status
Not open for further replies.
Level 8
Joined
Jul 3, 2011
Messages
251
Hi guys, i am making a spell but i am stuck on unit groups, im not really sure how to do them in JASS, everything else i know fine except groups, so could someone please make me a really simple example of setting a unit group of units in range of something, then picking a random unit in that group? Rep + credits and my gratitude.
 
Level 17
Joined
Feb 11, 2011
Messages
1,860
Hope this helps:

JASS:
function Group_Actions takes nothing returns nothing
    call KillUnit(GetEnumUnit())
endfunction

JASS:
function Group takes nothing returns nothing
    call GroupEnumUnitsInRangeOfLoc(Your_Group, Your_Point, Your_Radius, Your_Filters)
    call ForGroup(Your_Group, function Group_Actions)
endfunction
 
Level 17
Joined
Feb 11, 2011
Messages
1,860
JASS:
function Group_Actions takes nothing returns nothing
    call KillUnit(GetEnumUnit())
endfunction

function Group takes nothing returns nothing
    local real x = Your_X_Co-ord
    local real y = Your_Y_Co-ord
    call GroupEnumUnitsInRange(Your_Group, x, y, Your_Radius, Your_Filters)
    call ForGroup(Your_Group, function Group_Actions)
endfunction
 
Status
Not open for further replies.
Top