• 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] GetUnitsInRangeOfLocMatching

Status
Not open for further replies.
Level 2
Joined
Apr 21, 2006
Messages
21
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)
 
Level 5
Joined
Feb 16, 2006
Messages
151
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:
JASS:
...
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.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
JASS:
...
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
 
Status
Not open for further replies.
Top