• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[JASS] Conditions with parameters

Status
Not open for further replies.

LoreKeeper

L

LoreKeeper

Heya :)

I'm relatively new to GUI/JASS but I've gotten over the majority of initial hurdles. Something that has me stumped since yesterday, though, has cropped up that I've been trying to resolve (the current solution has to make use of a global, which I'm trying to avoid).

JASS:
function RepelActivationConditions takes nothing returns boolean
    ..simplified..
    elseif (IsUnitAlly(GetFilterUnit(), GetOwningPlayer(udg_RepelTrap)) == true) then
        return false
    elseif     ..simplified..
    endif
    return true
endfunction

The actual condition is called to match units in range to particular criteria. The matching occurs after initial waiting, so GetTriggerUnit and the like should be unavailable. How can I pass the unit or owning player along to the condition-function without making use of a global?

I've tried:

JASS:
function RepelActivationConditions takes player A returns boolean

But I haven't found a way to call it -

JASS:
set g = GetUnitsInRangeOfLocMatching(150.00, l, Condition(function RepelActivationConditions(A)))

- does not compile :(

Any tricks or ideas?
 
allright, this is called The JASS way to do it...

JASS:
    local group g = CreateGroup()
    local unit u
    call GroupEnumUnitsInRangeOfLoc( g, l, range, null )
    loop
        set u = FirstOfGroup( g )
        exitwhen u == null
        if Condition then
            actions
        endif
        call GroupRemoveUnit( g, u )
        set u = null
    endloop
    call DestroyGroup( g )
    set g = null

Coincidentally, this also avoids the use of the extremely leaky ForGroup() function.
 
Status
Not open for further replies.
Back
Top