• 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] IsUnitEnemy does not work somehow

Status
Not open for further replies.
Level 3
Joined
May 19, 2008
Messages
32
hi im working on a simple filter but for some reason the IsUnitEnemy(unit,player) always returns true. I use this simple filter

JASS:
function DpBoolExp takes nothing returns boolean
    local unit u = GetFilterUnit()
    local player p =GetFilterPlayer()
    
    local boolean b = IsUnitEnemy(u,p)
     
    set p=null
    set u=null

    return b
endfunction

that is called up using

JASS:
local boolexpr filter=Condition(function DpBoolExp)
call GroupEnumUnitsInRange(gEff,x1,y1,DAM_RANGE(), filter )
and some units in range are enemy units (i checked using player ips) ... the two players atack each other onsight ... so i guess they must be enmies ... and i put the in different forces

any ideas?
 
Level 22
Joined
Dec 31, 2006
Messages
2,216
I think it's the GetFilterPlayer() which is the problem. When you use "GroupEnumUnits..." functions those functions will only transfer the units it will check to the filter and then the filter will return true or false and if it returns true it will add the unit to the group.
Just set the player to a global variable and replace GetFilterPlayer() with that variable.
 
Level 3
Joined
May 19, 2008
Messages
32
im pretty certain its the IsUnitEnemy() that does not work, ive printed out the player ids for every unit in the GroupEnumUnits() together with the GetFilterPlayer() ids ... and they are displayed correctly ... but the IsUnitEnemy() always returns true ... or false i forgot ...

anyways the thread is really old 13.06. !!! and im not using filters anymore...havent seen anyone who does... if you know that filters are fast and one should use them plz let me know

@Rui when you use Enum-functions to get a group of units e.g., the function has a booleanexpr as an argument to filter out all units that you dont want to have. as far as i understand ... and ive been known to be wrong ... the booleanexpr is basically a function that returns boolean, in this case that function is called up every time Enum wants to add a unit to the group, and to get that unit or whatever you can use GetFilterUnit() ect. just like you use GetTriggerUnit() with triggers...

sorry if that was too long/short/wrong :p
 
Status
Not open for further replies.
Top