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

Status
Not open for further replies.
Level 13
Joined
Nov 22, 2006
Messages
1,260
I wanted to create a boolexpr that filters all enemies of owner of caster, but i'm not sure how to do that, how to transfer unit to that function? Or do I have to use handles?

example:

JASS:
function TargetCondition takes nothing returns boolean
    return IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(<caster>??)
endfunction

function Actions takes nothing returns nothing
    local unit c = GetTriggerUnit()
    local boolexpr b = Condition(function TargetCondition)
    local group g = CreateGroup()
    call GroupEnumUnitsInRange(g, GetUnitX(c), GetUnitY(c), 500, b)
    ....
    ....
    ....
endfunction

How do I do this?
 
use a BJ global, since it's an instant pass.

Eg.

JASS:
function TargetCondition takes nothing returns boolean
    return IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(bj_ghoul[100]) )
endfunction
function Actions takes nothing returns nothing
    local group g = CreateGroup()
    set bj_ghoul[100] = GetTriggerUnit()
    call GroupEnumUnitsInRange(g, GetUnitX(c), GetUnitY(c), 500, Filter(function TargetCondition))
endfunction
 
Yeah, never thought of that.....thanks everybody, UnMi, your idea would work, but this example I showed was not the one I had in my spell, that Condition was in the other function where there are no event responses. PurplePoot, yeah, that works, just remember the GUI Pick Every Unit In Region Matching, in this 'matching' GetTriggerUnit() would work. Anyways thanks for help :D
 
It may occur in some situations, that you want to pass other variables to filters. That can be done with the "looping through group" method.
JASS:
loop
set u = FirstOfGroup(g)
call GroupRemoveUnit(u,g)
exitwhen u == null
if <filtering> then
//do actions
endif
endloop
But I heared that this is slower than the "filtering" method.
 
Status
Not open for further replies.
Back
Top