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!
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))
I just want to assign group,not pick each unit and do actions,so would this work?
JASS:
function MyFunction takes nothing returns nothing
local group g
call GroupEnumUnitsInRange(g, 0.0, 0.0, 500.0, Filter(IsUnitType(GetFilterUnit()),UNIT_TYPE_HERO)
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
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))
That would be the kinda same thing as a local.
You just create the group once and at the end of your actions you just clear the group. (call ClearGroup(group g))
Use bj_lastCreatedGroup. Never destroy it, and never create it. It is a perpetual group that is always preserved by the game since one of the latest patches.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.