|
发表于 2011-1-24 00:27:16
|
显示全部楼层
本来我遇到过类似的问题,不过因为那是个学习用的例子,没使用价值,就没继续研究下去
然后我看楼主的代码,结果发现还需要牵扯出一系列别的代码,我找到其他部分后,大致弄成了这样子
function Spell takes nothing returns boolean
    return GetSpellAbilityId()=='A000'
endfunction
function DelayedDamageTimer takes nothing returns nothing
    local string lf5=H2Tx(GetExpiredTimer())
    local unit lEU=GetUnit(lf5,"Unit")
    call SetUnitState(lEU,UNIT_STATE_LIFE,GetUnitState(lEU,UNIT_STATE_LIFE)+GetReal(lf5,"Damage"))
endfunction
function DelayedDamage takes unit pEU,real pf7 returns nothing
    local timer ltt=CreateTimer()
    local string lf5=H2Tx(ltt)
    call SetReal(lf5,"Damage",pf7)
    call SetHandle(lf5,"Unit",pEU)
    call TimerStart(ltt,0,false,function DelayedDamageTimer)
endfunction
function DelayedDamageCheck takes unit pEU,real pf7 returns nothing
    local real lf9=GetUnitState(pEU,UNIT_STATE_MAX_LIFE) //设置lf9为最大生命值
   local real lFa=GetUnitState(pEU,UNIT_STATE_LIFE)//设置lFa为当前生命值
    if pf7>(lf9-lFa)then //如果所受伤害大于最大生命值-当前生命值
        if pf7>=lFa then //如果所受伤害大于等于当前生命值
            call SetUnitState(pEU,UNIT_STATE_LIFE,lf9) //设置单位满血
            call DelayedDamage(pEU,pf7-(lf9-lFa)) //调用××函数,开启定时器,加回“所受伤害-(最大生命值-当前生命值)”的值
        else
            call DelayedDamage(pEU,pf7)//调用××函数,开启定时器,加回所受伤害
        endif
    else
        call SetUnitState(pEU,UNIT_STATE_LIFE,GetUnitState(pEU,UNIT_STATE_LIFE)+pf7))//直接设置单位生命值为当前生命值+所受伤害
    endif
endfunction
function Heal takes nothing returns nothing
    local integer k=GetHandleId(GetTriggeringTrigger())
    local real df=LoadReal(udg_HT,k,1)
    if(df<GetEventDamage())then
    call DestroyEffect(LoadEffect(udg_HT,k,2))
    call DisableTrigger(GetTriggeringTrigger())
    call SaveBoolean(udg_HT,k,4,true)
    elseif(GetEventDamage()>0)then
    call DelayedDamageCheck(GetTriggerUnit(),GetEventDamage())
    call SaveReal(udg_HT,k,1,df-GetEventDamage())
    endif
endfunction
function Setting takes nothing returns nothing
    local trigger heal=CreateTrigger()
    local integer k=GetHandleId(heal)
    local triggeraction fct=TriggerAddAction(heal,function Heal)
    call TriggerRegisterUnitEvent(heal,GetSpellTargetUnit(),EVENT_UNIT_DAMAGED)
    call UnitRemoveBuffsBJ(1,GetSpellTargetUnit())
    call SaveReal(udg_HT,k,1,80+30*GetUnitAbilityLevel(GetTriggerUnit(),'A000')
    call SaveEffectHandle(udg_HT,k,2,AddSpecialEffectTarget("xxx.mdx",GetSpellTargetUnit(),"chest"))
    call SavePlayerHandle(udg_HT,k,3,GetOwningPlayer(GetTriggerUnit()))
    call SaveBoolean(udg_HT,k,4,false)
    call PolledWait(15)
    if(LoadBoolean(udg_HT,k,4)==false)then
        call DestroyEffect(LoadEffectHandle(udg_HT,k,2))
    endif
    call TriggerRemoveAction(heal,fct)
endfunction
function InitTrig_test002 takes nothing returns nothing
    local trigger gg_trg_test002 = CreateTrigger( )
    call TriggerRegisterAnyUnitEventBJ(gg_trg_test002,EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_test002,Condition(function Spell))
    call TriggerAddAction(gg_trg_test002,function Setting)
endfunction
还几个函数不知道怎么弄出来
H2Tx
GetReal
SetReal
SetHandle |
|