• 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] 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?
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
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
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
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
 
Level 11
Joined
Jul 12, 2005
Messages
764
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.
Top