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

JASS Unit Groups

Status
Not open for further replies.
Level 7
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