Warcraft III resources & community, 2003–2006 · archived

GetUnitsInRangeOfLocMatching

8 posts
#1

GetUnitsInRangeOfLocMatching

I'm using GetUnitsInRangeOfLocMatching and I want to set a group = units in range 500 points of casting range of units that are allied...So what I'm left with is: GetUnitsInRangeOfLocMatching(500.00, GetUnitLoc(GetSpellAbilityUnit()), <blank>)

What is the code I need to insert into the <blank> to restrict the selection only to allied units (preferably to allied units of the unit casting the ability)
#2
blank? -_-
What you need there is a boolexpr as parameter.
You would have to use an additional function, which returns boolean...and you would have to use gamecache to give that code function the unit...which is bothersome.
Now since we are using JASS, let's do the group looping:

...
local location loc = GetUnitLoc(GetSpellAbilityUnit())
local rect loc_rect = GetRectFromCircleBJ(loc,500) //Creates a rect from the location with a radius of 500
local group ally_group = CreateGroup() //creates a group
local unit first
call GroupEnumUnitsInRect(ally_group,loc_rect,null)
//All units within the rect are in the group now
loop
    set first = FirstOfGroup(ally_group)
    exitwhen ( first == null )
        if ( not IsUnitAlly(first, GetTriggerPlayer() )) then//If the first of the group is not an ally
            call GroupRemoveUnit(ally_group,first)//He will be removed
        endif
    endloop

Voila, better than boolexpr.
#3
...
local group g = CreateGroup()
local unit u
call GroupEnumUnitsInRange(g,500,GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()), null)
loop
    set u = FirstOfGroup(g)
    exitwhen u == null
    if IsUnitAlly(first, GetOwningPlayer(GetTriggerUnit()) ) then//this is the filter, checking oif the unit is an ally
        call GroupRemoveUnit(g,u)
    endif
endloop
#4
>>.....
That function...you cheat!!...
#5
what?

do u mean the fact that i used your code as a rough basis for mine, to avoid typing out the alt ForGroup method bc my cousin was nagging me to get off the computer?

or do u mean GroupEnumUnitsInRange? :P
#6
Uh...
You cheat, end of discussion!!
>_<
#7
Not the most professional point of view... ^^
#8
lol... but it shows he needs to work on his JASSing more ( dont we all? )