|
楼主 |
发表于 2011-6-7 10:25:44
|
显示全部楼层
[jass]
function KYKY takes unit pKw returns boolean
if IsUnitType(pKw,UNIT_TYPE_STRUCTURE) and GetUnitAbilityLevel(pKw,'Adts')>0 then
return true
endif
return false
endfunction
function KXKX takes unit pKw returns unit
local string lf5=H2Tx(pKw)
return GetUnit(lf5,"TowerAI|TowerTarget")
endfunction
function Trig_TowerAI_Conditions takes nothing returns boolean
local unit lKw=GetAttacker()
local unit lKZ
if not(KYKY(lKw))then
return false
endif
if(CVReturnUnit(lKw)!=null)then
return false
endif
set lKZ=KXKX(lKw)
if(lKZ==null)then
return true
endif
if(GetUnitState(lKZ,UNIT_STATE_LIFE)<1)then
return true
endif
if(IsUnitInRange(lKw,lKZ,GetUnitAcquireRange(lKw)))then
return false
endif
return true
endfunction
function KyKy takes unit pKw,unit pFB returns nothing
local string lf5=H2Tx(pKw)
call SetHandle(lf5,"TowerAI|TowerTarget",pFB)
endfunction
function Trig_TowerAI_Actions takes nothing returns nothing
local unit lKw=GetAttacker()
local group lgg=CreateGroup()
local unit luu
local real lK1
local real lK2=151.
local unit lK3=null
call GroupEnumUnitsInRange(lgg,GetUnitX(lKw),GetUnitY(lKw),GetUnitAcquireRange(lKw),null)
loop
set luu=FirstOfGroup(lgg)
exitwhen luu==null
call GroupRemoveUnit(lgg,luu)
if IsUnitEnemy(luu,GetOwningPlayer(lKw))then
set lK1=GetUnitState(luu,UNIT_STATE_LIFE)
if lK1<lK2 and lK1>1 and GetUnitTypeId(luu)!='o00C'then
set lK2=lK1
set lK3=luu
endif
endif
endloop
call KyKy(lKw,lK3)
if lK3!=null then
call DisableTrigger(GetTriggeringTrigger())
call IssueTargetOrderById(lKw,OrderId("attack"),lK3)
if GetOwningPlayer(lKw)==udg_pA_DTAX_SEPlayers[0]then
call SetUnitAnimation(lKw,"attack alternate")
endif
call EnableTrigger(GetTriggeringTrigger())
endif
call DestroyGroup(lgg)
endfunction
function StartTrigger_TowerAI takes nothing returns nothing
set gg_trg_TowerAI=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_TowerAI,EVENT_PLAYER_UNIT_ATTACKED)
call TriggerAddCondition(gg_trg_TowerAI,Condition(function Trig_TowerAI_Conditions))
call TriggerAddAction(gg_trg_TowerAI,function Trig_TowerAI_Actions)
endfunction
function InitTrig_TowerAI takes nothing returns nothing
endfunction
[/jass] |
|