how to deal with groups and pick all

Nerfpl

New Member
Reaction score
53
Heres my trigger
JASS:
unction Trig_Recall_Func001002003 takes nothing returns boolean
    return ( GetOwningPlayer(GetFilterUnit()) == GetOwningPlayer(GetTriggerUnit()) )
endfunction

function Trig_Recall_Func002A takes nothing returns nothing
    call SetUnitPositionLoc( GetEnumUnit(), ->target <- )
endfunction

function Trig_Recall_Actions takes nothing returns nothing
    local location start = GetUnitLoc(GetTriggerUnit())
    local group grp = GetUnitsInRangeOfLocMatching(800.00, start, Condition(function Trig_Recall_Func001002003))
    local location target = GetRectCenter(gg_rct_HeroRez)
    call ForGroupBJ( grp, function Trig_Recall_Func002A )
    call RemoveLocation(start)
    call RemoveLocation(target)
    set start = null
    set target = null
    call DestroyGroup(grp)
    set grp = null
endfunction


How i can make is more simple? i need to pass target location to Func002A. Also with boolean. does it have to be so complicated? cant i just put my condition inside "GetUnitsInRange..."?
 

Naga'sShadow

Ultra Cool Member
Reaction score
49
GroupEnumUnitsInRangeOfLoc is indeed a function. And you can use null instead of providing a filter function. Note that I believe null leaks so you should point it to a function that always returns true rather than use null. Generally speaking anything that indents in the GUI is an absolute pain in the ass to write in JASS as it opens a new function.

I learned to use them by creating a new trigger, then create what I wanted in the GUI then convert it and copy the functions needed. Also use your function search tool and find out the parts of the function. For instance, don't use ForGroupBJ, when you can look it up and see that it calls ForGroup() with a self cleaning attachment. As far as keeping it all in one function, I don't believe that's possible.

And your function as written probably won't work as the second function is using the local targets from the third action function.
 

Kenny

Back for now.
Reaction score
202
You can use a ForGroup loop. Instead of actually using the ForGroup function, you kind of make you own, however it is within your main actions function, which has the bonus of being able to use local variables within the actions function. They go something like this:

JASS:
loop
    set u = FirstOfGroup(grp) // u must be a local unit variable
    exitwhen u == null // it will exit the loop when there are no more units within the group
    call GroupRemoveUnit(grp,u) // removes the current unit from the group, so it can do the same to the rest of them
    call SetUnitPositionLoc(u,target) // your actions you want done to the group
endloop


Thats basically it.
 

Nerfpl

New Member
Reaction score
53
kenny your option is quite good.

this may sound stupid cuz i answer to own thread but i found a other way.

i moved
local location target = GetRectCenter(gg_rct_HeroRez)
to Func002A
Actually it response to GetSpellLoc (i forgot how it was dont have WE open) etc inside that func so i think i found good way to deal with that
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top