- Joined
- Jun 21, 2012
- Messages
- 431
Someone explain to me how to achieve this function (based on The Filtering System):
JASS:
struct Hit
readonly static constant integer ENEMY=0x1
readonly static constant integer ALLY=0x2
readonly static constant integer STRUCTURE=0x4
readonly static constant integer NON_STRUCTURE=0x8
readonly static constant integer HERO=0x10
readonly static constant integer NON_HERO=0x20
readonly static constant integer IMMUNE=0x40
readonly static constant integer NON_IMMUNE=0x80
readonly static constant integer VISIBLE=0x100
readonly static constant integer INVISIBLE=0x200
readonly static constant integer GROUND=0x400
readonly static constant integer FLYING=0x800
readonly static constant integer MELEE=0x1000
readonly static constant integer RANGED=0x2000
endstruct
JASS:
private static method filterGroup takes nothing returns boolean
local integer f=eventLoop.filter
local integer id=GetUnitId(GetFilterUnit())
local player p=GetOwningPlayer(eventLoop.dummy)
local boolean array b
local integer i=0
//call BJDebugMsg(GetPlayerName(p))
call BJDebugMsg(I2S(eventLoop.filter))
if f>0x2000 then
set f=f-0x2000
if IsUnitType(GetUnitById(id),UNIT_TYPE_RANGED_ATTACKER) then
return false
endif
endif
if f>0x1000 then
set f=f-0x1000
if IsUnitType(GetUnitById(id),UNIT_TYPE_MELEE_ATTACKER) then
return false
endif
endif
if f>0x800 then
set f=f-0x800
if IsUnitType(GetUnitById(id),UNIT_TYPE_FLYING) then
return false
endif
endif
if f>0x400 then
set f=f-0x400
if IsUnitType(GetUnitById(id),UNIT_TYPE_GROUND) then
return false
endif
endif
if f>0x200 then
set f=f-0x200
if IsUnitInvisible(GetUnitById(id),p) then
return false
endif
endif
if f>0x100 then
set f=f-0x100
if IsUnitVisible(GetUnitById(id),p) then
return false
endif
endif
if f>0x80 then
set f=f-0x80
if not IsUnitType(GetUnitById(id),UNIT_TYPE_MAGIC_IMMUNE) then
return false
endif
endif
if f>0x40 then
set f=f-0x40
if IsUnitType(GetUnitById(id),UNIT_TYPE_MAGIC_IMMUNE) then
return false
endif
endif
if f>0x20 then
set f=f-0x20
if not IsUnitType(GetUnitById(id),UNIT_TYPE_HERO) then
return false
endif
endif
if f>0x10 then
set f=f-0x10
if IsUnitType(GetUnitById(id),UNIT_TYPE_HERO) then
return false
endif
endif
if f>0x8 then
set f=f-0x8
if not IsUnitType(GetUnitById(id),UNIT_TYPE_STRUCTURE) then
return false
endif
endif
if f>0x4 then
set f=f-0x4
if IsUnitType(GetUnitById(id),UNIT_TYPE_STRUCTURE) then
return false
endif
endif
if f>0x2 then
set f=f-0x2
if IsUnitAlly(GetUnitById(id),p) then
return false
endif
endif
if f>0x1 then
set f=f-0x1
if IsUnitEnemy(GetUnitById(id),p) then
return false
endif
endif
//call BJDebugMsg(GetPlayerName(p))
//call BJDebugMsg(I2S(eventLoop.filter))
return true
endmethod