|
发表于 2009-7-3 14:45:03
|
显示全部楼层
function IsUnitInvulnerable takes unit u returns boolean
return GetUnitAbilityLevel(u,'Avul')>0
endfunction
function IsUnitMagicImmune takes unit u returns boolean
return IsUnitType(u,UNIT_TYPE_MAGIC_IMMUNE)
endfunction
function IsUnitPhysicalImmune takes unit u returns boolean
return IsUnitType(u,UNIT_TYPE_ETHEREAL)
endfunction
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(IsUnitInvulnerable(cu))then
        if(not(GetTuCheckCond(i,SUF_Invulnerable)))then
        return false
    endif
    endif
    if(IsUnitMagicImmune(cu))then
        if(not(GetTuCheckCond(i,SUF_MagicImmune)))then
        return false
    endif
    endif
    if(IsUnitType(cu,UNIT_TYPE_STRUCTURE))then
        if(not(GetTuCheckCond(i,SUF_Building)))then
        return false
    endif
    endif
    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_AttackAble,not(IsUnitPhysicalImmune(cu)),chkValue)
    set chkValue = DoTuCheckCond(i,SUF_MagicAble,not(IsUnitMagicImmune(cu)),chkValue)
    if(chkValue==2)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 |
|