|
发表于 2006-4-25 23:47:43
|
显示全部楼层
[jass]
function changelife_Actions takes nothing returns nothing
local trigger changelife = null
local unit triggerunit = null
local real life = 0
local real maxlife = 0
local real step = 0
local real lesslife = 0
local real greaterlife = 0
set triggerunit = GetTriggerUnit()
set life = GetUnitStateSwap(UNIT_STATE_LIFE, triggerunit)
set maxlife = GetUnitStateSwap(UNIT_STATE_MAX_LIFE, triggerunit)
//设置捕捉变化的频率.现在为最大生命*0.01就是每1%的变化捕捉一次.
set step = maxlife * 0.01
set lesslife = life - step
set greaterlife = life + step
if lesslife < 0.01 then
set lesslife = 0.01
endif
if greaterlife > maxlife - 0.01 then
set greaterlife = maxlife -0.01
endif
//=====================================================
//****************过程*****************
//=====================================================
call DisplayTextToForce( GetPlayersAll(), GetUnitName(triggerunit) + \"\'s life:\" + R2S(life) )
//=====================================================
set changelife = CreateTrigger()
call TriggerRegisterUnitStateEvent(changelife, triggerunit, UNIT_STATE_LIFE, LESS_THAN, life - step)
call TriggerRegisterUnitStateEvent(changelife, triggerunit, UNIT_STATE_LIFE, GREATER_THAN, life + step)
call TriggerAddAction( changelife, function changelife_Actions )
call DestroyTrigger( GetTriggeringTrigger() )
endfunction
function Trig_changelife_Conditions takes nothing returns boolean
return (GetLearnedSkill() == \'A000\')
endfunction
function Trig_changelife_Actions takes nothing returns nothing
local trigger changelife = null
local unit triggerunit = null
local real life = 0
set triggerunit = GetTriggerUnit()
set life = GetUnitStateSwap(UNIT_STATE_LIFE, triggerunit)
call DisplayTextToForce( GetPlayersAll(), GetUnitName(triggerunit) + \"\'s life:\" + R2S(life) )
set changelife = CreateTrigger( )
call TriggerRegisterUnitStateEvent(changelife, triggerunit, UNIT_STATE_LIFE, LESS_THAN, life - 1)
call TriggerRegisterUnitStateEvent(changelife, triggerunit, UNIT_STATE_LIFE, GREATER_THAN, life + 1 )
call TriggerAddAction( changelife, function changelife_Actions )
endfunction
//===========================================================================
function InitTrig_changelife takes nothing returns nothing
set gg_trg_changelife = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_changelife, EVENT_PLAYER_HERO_SKILL )
call TriggerAddCondition( gg_trg_changelife, Condition( function Trig_changelife_Conditions ) )
call TriggerAddAction( gg_trg_changelife, function Trig_changelife_Actions )
endfunction
[/jass]
又一次更新.按百分比捕捉.嗯嗯.
设不设为空.我认为没必要.因为本来就是局部变量了.
不过如果这样会导至内存泄漏的话.就需要了.嗯. |
|