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

[Solved] What's the use of ForGroup

Status
Not open for further replies.
SOLVED!
I was wondering about something...What's the use of ForGroup if there is GroupEnumUnitsInRange?...

Which do you preffer and faster?...
JASS:
function MR_FILTER takes nothing returns boolean
    if IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO)==false then
        call KillUnit(GetFilterUnit())
    endif
    return false
endfunction

function TEST takes nothing returns nothing
    call GroupEnumUnitsInRange(bj_lastCreatedGroup, GetUnitX(u), GetUnitY(u), 500, Filter(function MR_FILTER))
endfunction

JASS:
function MR_FILTER takes nothing returns nothing
    if IsUnitType(GetEnumUnit(), UNIT_TYPE_HERO)==false then
        call KillUnit(GetEnumUnit())
    endif
endfunction

function TEST takes nothing returns nothing
    call GroupEnumUnitsInRange(bj_lastCreatedGroup, GetUnitX(u), GetUnitY(u), 500, null)
    call ForGroup(bj_lastCreatedGroup, function MR_FILTER)
endfunction
 
Last edited:
Level 17
Joined
Apr 27, 2008
Messages
2,455
Now that makes sense, GroupEnumUnitsInRange cant recall a group while ForGroup can...wow thanks, it clears up a lot!...

Actually it clears the group and adds each filtered unit each time you return true on the boolexpr call.
If you don't need to keep units during time, you can always return false, use a static group (as the GROUP_ENUM of the library GroupUtils) and code directly inside the boolexpr of the GroupEnum.

EDIT : Just like you did in fact :p
 
Status
Not open for further replies.
Top