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

[Solved] What's the use of ForGroup

Status
Not open for further replies.
Level 29
Joined
Mar 10, 2009
Messages
5,016
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