• 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] Filtering Units

Status
Not open for further replies.
Ok,thanks.
Just 1 thing,why is it 'return false' at Bribe's example? Shouldn't it be:
JASS:
function filterOnlyHeroes takes nothing returns boolean
    return IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO)
endfunction
Off-topic: Internal error strikes again :con:

he also wrote "do things"
if you want to use all units only once it is much faster to let the filter function return false and do all actions in the filter
if you want to use the units more then once your soultion would be right of course
for the first solution it would be better to use a global group 'cause it always leaks a little bit if you destroy a group and the group won't have any units in it anyway since you always return false
 
Level 20
Joined
Jul 6, 2009
Messages
1,885
Instead of making a new thread,i thought of asking here again.

Don't use "in range of loc". Use "in range".

JASS:
function filterOnlyHeroes takes nothing returns boolean
    if IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO) then
        // do things
    endif
    return false
endfunction
//
call GroupEnumUnitsInRange(bj_lastCreatedGroup, 0.0, 0.0, 500.0, Filter(function filterOnlyHeroes))

If i use global group,do i have to destroy it afterwards to prevent leak? Since in this case,it will be empty as everything will be done in filter.
 
Status
Not open for further replies.
Top