|
发表于 2010-6-22 22:47:47
|
显示全部楼层
[codes=jass]function knightattackdown takes nothing returns boolean
call UnitRemoveAbility(GetTriggerUnit(),'Aakb')
//call DestroyTrigger(GetTriggeringTrigger())
return false
endfunction
function knightattackup takes nothing returns boolean
//local trigger trg=CreateTrigger()
//call TriggerRegisterUnitLifeEvent(trg,GetTriggerUnit(), GREATER_THAN,GetUnitState(GetTriggerUnit(),UNIT_STATE_MAX_LIFE)*0.52)
//call TriggerAddCondition(trg,Condition(function knightattackdown))
call UnitAddAbility(GetTriggerUnit(),'Aakb')
//call SaveTriggerHandle(udg_HT[2],GetHandleId(GetTriggerUnit()),StringHash("trg"),trg)
return false
endfunction
function Trig_knight_Condition takes nothing returns boolean
if GetSpellAbilityId()=='A00F' then
return true
else
return false
endif
endfunction
function xiuziyin takes nothing returns boolean
local unit me=GetTriggerUnit()
local trigger trg=GetTriggeringTrigger()
local unit knight
local integer i=0
local real life
local trigger trglife
local integer a=LoadInteger(udg_HT[2],GetHandleId(udg_company),StringHash("knightlifeboolean"))
loop
exitwhen i>5
set knight =CreateUnit(GetOwningPlayer(me),'hkni',GetUnitX(me),GetUnitY(me),0)
set trglife=CreateTrigger()
call TriggerRegisterUnitLifeEvent(trglife,knight,LESS_THAN_OR_EQUAL, GetUnitState(knight,UNIT_STATE_MAX_LIFE)*0.5)
call TriggerAddCondition(trglife,Condition(function knightattackup))
call SaveTriggerHandle(udg_HT[2],GetHandleId(knight),StringHash("trglifeup"),trglife)
set trglife=CreateTrigger()
call TriggerRegisterUnitLifeEvent(trglife,knight,GREATER_THAN, GetUnitState(knight,UNIT_STATE_MAX_LIFE)*0.5)
call TriggerAddCondition(trglife,Condition(function knightattackdown))
call SaveTriggerHandle(udg_HT[2],GetHandleId(knight),StringHash("trglifedown"),trglife)
call AddSpecialEffect("Abilities\\\\Spells\\\\Orc\\\\FeralSpirit\\\\feralspiritdone.mdl",GetUnitX(knight),GetUnitY(knight))
call SaveUnitHandle(udg_HT[2],StringHash("knight"+I2S(i)),StringHash("knight"),knight)
if a!=0 then
set life=LoadReal(udg_HT[2],StringHash("knightlife"+I2S(i)),StringHash("knight"))
call FlushChildHashtable(udg_HT[2],StringHash("knightlife"+I2S(i)))
call DisplayTimedTextToForce(udg_players,2,R2S(life))
if life==0 then
set life=1
endif
call SetUnitLifePercentBJ(knight,life)
endif
set i=i+1
endloop
set a=1
call SaveInteger(udg_HT[2],GetHandleId(udg_company),StringHash("knightlifeboolean"),a)
set me=null
set knight=null
call DestroyTrigger(trg)
set trg=null
return false
endfunction
function Trig_knight_Actions takes nothing returns nothing
local unit me=GetTriggerUnit()
local real angle=GetUnitFacing(me)*bj_PI/180
local unit knight1
local integer i=0
local real life
local integer a=LoadInteger(udg_HT[2],GetHandleId(udg_company),StringHash("knight"))+2
local trigger trg
loop
exitwhen i>5
set knight1=LoadUnitHandle(udg_HT[2],StringHash("knight"+I2S(i)),StringHash("knight"))
call FlushChildHashtable(udg_HT[2],StringHash("knight"+I2S(i)))
if knight1!=null then
call AddSpecialEffect("Abilities\\\\Spells\\\\Orc\\\\FeralSpirit\\\\feralspiritdone.mdl",GetUnitX(knight1),GetUnitY(knight1))
set life=GetUnitLifePercent(knight1)
//call DisplayTimedTextToForce(udg_players,2,I2S(GetHandleId(LoadTriggerHandle(udg_HT[2],GetHandleId(knight1),StringHash("trg")))))
call SaveReal(udg_HT[2],StringHash("knightlife"+I2S(i)),StringHash("knight"),life)
//call DestroyTrigger(LoadTriggerHandle(udg_HT[2],GetHandleId(knight1),StringHash("trg")))
call DestroyTrigger(LoadTriggerHandle(udg_HT[2],GetHandleId(knight1),StringHash("trglifeup")))
call DestroyTrigger(LoadTriggerHandle(udg_HT[2],GetHandleId(knight1),StringHash("trglifedown")))
call FlushChildHashtable(udg_HT[2],GetHandleId(knight1))
call RemoveUnit(knight1)
endif
set i=i+1
endloop
if ModuloInteger(a,2)==0 then
set trg=CreateTrigger()
call TriggerRegisterUnitEvent(trg,me,EVENT_UNIT_SPELL_FINISH)
call TriggerAddCondition(trg,Condition(function xiuziyin))
endif
set a=a+1
if a==10 then
set a=2
endif
call SaveInteger(udg_HT[2],GetHandleId(udg_company),StringHash("knight"),a)
endfunction
//===========================================================================
function InitTrig_knight takes nothing returns nothing
set gg_trg_knight = CreateTrigger( )
call TriggerRegisterUnitEvent( gg_trg_knight, gg_unit_Hblm_0002, EVENT_UNIT_SPELL_EFFECT )
call TriggerAddCondition(gg_trg_knight,Condition(function Trig_knight_Condition))
call TriggerAddAction( gg_trg_knight, function Trig_knight_Actions )
endfunction[/codes]
以上为方案1,2个触发在一开始就注册,最后一起删除 |
|