|
这是一个被致命攻击后能保持1血无敌3秒的触发代码。
为什么这么做?就为了让它是被动,而且有CD。
原理,技能模板重生,0秒发动。
通过动态注册单位生命变化为小于0且存活来判断发动了技能
然后做相应动作。
BUG:
偶尔会出现触发不动作,导致满血满魔。
寻求解决方案!
[jass]
function BuQuWuDi takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit u = GetUnit(H2I(t),0)
local trigger tri = GetTrigger(H2I(t),1)
call SetUnitInvulnerable( u, false )
call FlushMission(H2I(t))
call DestroyTimer(t)
call TriggerRegisterUnitLifeEvent( tri, u, LESS_THAN, 0. )
//call BJDebugMsg( "重注册" )
set t = null
set u = null
set tri = null
endfunction
function BuQuFuHuo takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit u = GetUnit(H2I(t),0)
if IsUnitType(u, UNIT_TYPE_DEAD) == false then
//call BJDebugMsg( "设置不屈" )
call SelectUnitForPlayerSingle( u, GetOwningPlayer(u))
call TimerStart(t,3.0,false,function BuQuWuDi)
call SetUnitHP(u,1)
call SetUnitMP(u,GetReal(H2I(t),2))
else
call DestroyTrigger(GetTrigger(H2I(t),1))
//call BJDebugMsg( "注销" )
call FlushMission(H2I(t))
call DestroyTimer(t)
call SetUnitInvulnerable( u, false )
endif
set t = null
set u = null
endfunction
function BuQu_Actions takes nothing returns boolean
local unit u = GetTriggerUnit()
local timer t
if IsUnitType(u, UNIT_TYPE_DEAD) == false then
set t = CreateTimer()
call SaveAgent(H2I(t),0,u)
call SaveAgent(H2I(t),1,GetTriggeringTrigger())
call SaveRea(H2I(t),2,GetUnitMP(u))
call SetUnitInvulnerable( u, true )
call TimerStart(t,0.1,false,function BuQuFuHuo)
//call BJDebugMsg( "开始不屈" )
set t = null
endif
set u = null
return false
endfunction
function Trig_BuQu_Conditions takes nothing returns boolean
local unit u = GetTriggerUnit()
local trigger tri
if GetUnitAbilityLevel(u,'A0HB') == 1 and GetLearnedSkill() == 'A0HB' then
//call Debug("学习注册")
set tri = CreateTrigger()
call TriggerRegisterUnitLifeEvent( tri, u, LESS_THAN, 0. )
call TriggerAddCondition( tri, Condition( function BuQu_Actions ) )
set tri = null
endif
set u = null
return false
endfunction
function Trig_BuQufuhuo_Conditions takes nothing returns boolean
local unit u = GetTriggerUnit()
local trigger tri
if GetUnitAbilityLevel(u,'A0HB') >= 1 then
//call Debug("复活注册")
set tri = CreateTrigger()
call TriggerRegisterUnitLifeEvent( tri, u, LESS_THAN, 0. )
call TriggerAddCondition( tri, Condition( function BuQu_Actions ) )
set tri = null
endif
set u = null
return false
endfunction
function InitTrig_BuQu takes nothing returns nothing
local trigger tri = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( tri, EVENT_PLAYER_HERO_SKILL )
call TriggerAddCondition( tri, Condition( function Trig_BuQu_Conditions ) )
set tri = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( tri, EVENT_PLAYER_HERO_REVIVE_FINISH )
call TriggerAddCondition( tri, Condition( function Trig_BuQufuhuo_Conditions ) )
set tri = null
endfunction
[/jass] |
|