|
范例函数:
call TargetUnitCheck(CheckUnit,CompareUnit,SUF_Enemy+SUF_Nature+SUF_NoneTarget)
/////////////////////////////
constant integer SUF_Ally = 2
constant integer SUF_Enemy = 4
constant integer SUF_Nature = 8
constant integer SUF_Flying = 16
constant integer SUF_Ground = 32
constant integer SUF_IsHero = 64
constant integer SUF_NotHero = 128
constant integer SUF_Alive = 256
constant integer SUF_Dead = 512
constant integer SUF_NoneSelf = 1024
constant integer SUF_NoneTarget = 2048
/////////////////////////////
function GetTuCheckCond takes integer i,integer cType returns boolean
return Mod(i,cType*2)/cType==1
endfunction
function DoTuCheckCond takes integer i,integer cType,boolean chk,integer chkValue returns integer
local integer c = 0
local integer p = 0
if(GetTuCheckCond(i,cType))then
set c = 1
if(chk)then
set p = 1
endif
endif
return IMax(chkValue/2,c)*2 + IMax(Mod(chkValue,2),p)
endfunction
function TargetUnitCheck takes unit cu,unit su,integer i returns boolean
local integer chkValue = 0
local boolean ally = IsUnitAlly(cu,GetOwningPlayer(su))
local boolean enemy = IsUnitEnemy(cu,GetOwningPlayer(su))
local boolean alive = GetUnitState(cu,UNIT_STATE_LIFE)>0
if(GetTuCheckCond(i,SUF_NoneSelf) and cu==su)then
return false
endif
if(GetTuCheckCond(i,SUF_NoneTarget) and cu==SYS_GroupTarget)then
return false
endif
set chkValue = 0
set chkValue = DoTuCheckCond(i,SUF_Alive,alive,chkValue)
set chkValue = DoTuCheckCond(i,SUF_Dead,not(alive),chkValue)
if(chkValue==2)then
return false
elseif(chkValue==0 and not(alive))then
return false
endif
//============
set chkValue = 0
set chkValue = DoTuCheckCond(i,SUF_Ally,ally,chkValue)
set chkValue = DoTuCheckCond(i,SUF_Enemy,enemy,chkValue)
set chkValue = DoTuCheckCond(i,SUF_Nature,not(ally) and not(enemy),chkValue)
if(chkValue==2)then
return false
endif
//============
set chkValue = 0
set chkValue = DoTuCheckCond(i,SUF_IsHero,IsUnitType(cu,UNIT_TYPE_HERO),chkValue)
set chkValue = DoTuCheckCond(i,SUF_NotHero,not(IsUnitType(cu,UNIT_TYPE_HERO)),chkValue)
if(chkValue==2)then
return false
endif
//============
set chkValue = 0
set chkValue = DoTuCheckCond(i,SUF_Flying,IsUnitType(cu,UNIT_TYPE_FLYING),chkValue)
set chkValue = DoTuCheckCond(i,SUF_Ground,IsUnitType(cu,UNIT_TYPE_GROUND),chkValue)
if(chkValue==2)then
return false
endif
return true
endfunction
///////////////////////////// |
评分
-
查看全部评分
|