[jass]
globals
trigger gg_trg_OverwhelmingDisaster
hashtable udg_Hash = InitHashtable()
unit udg_u
endglobals
function Trig_OverwhelmingDisaster_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A000' ) ) then
        return false
    endif
    return true
endfunction
function c2 takes nothing returns boolean
    return (IsPlayerEnemy(GetOwningPlayer(udg_u),GetOwningPlayer(GetFilterUnit())) == true)
endfunction
function c3 takes nothing returns boolean
    return (IsUnitAliveBJ(GetFilterUnit()) == true)
endfunction
function c1 takes nothing returns boolean
    return GetBooleanAnd(c2(),c3())
endfunction
function a1 takes nothing returns nothing
    call UnitDamageTarget(udg_u,GetEnumUnit(),75.00,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_MAGIC,WEAPON_TYPE_WHOKNOWS)
endfunction
//球体坠落
function ball takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local unit u = LoadUnitHandle(udg_Hash,GetHandleId(t),0)
    local unit u2 = LoadUnitHandle(udg_Hash,GetHandleId(t),4)
    local real r = LoadReal(udg_Hash,GetHandleId(t),1)
    local real r2 = LoadReal(udg_Hash,GetHandleId(t),2)
    local real r3 = LoadReal(udg_Hash,GetHandleId(t),3)
    local location l = GetUnitLoc(u)
    local location l2 = PolarProjectionBJ(l,(r/20),r3)
    local group g
    call SetUnitX(u,GetLocationX(l2))
    call SetUnitY(u,GetLocationY(l2))
    call SetUnitFlyHeight(u,(GetUnitFlyHeight(u)-25),0)
    set r2 = r2-(r/20)
    call SaveReal(udg_Hash,GetHandleId(t),2,r2)
    if r2 == 0 then
        call FlushChildHashtable(udg_Hash,GetHandleId(t))
        call DestroyTimer(t)
        set udg_u = u2
        set g = GetUnitsInRangeOfLocMatching(100,l2,Condition(function c1))
        call ForGroup(g,function a1)    
        call KillUnit(u)
        call DestroyGroup(g)
    endif
    call RemoveLocation(l)
    call RemoveLocation(l2)
endfunction
//能量球升高
function lift takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local timer t2
    local unit u = LoadUnitHandle(udg_Hash,GetHandleId(t),0)
    local location l = GetUnitLoc(u)
    local location l2
    local location l3
    local integer i = 1
    local integer i2
    local group g
    if GetUnitFlyHeight(u) < 500 then
        call SetUnitFlyHeight(u,(GetUnitFlyHeight(u)+5),0)
    else
        set udg_u = u
        set g = GetUnitsInRangeOfLocMatching(600,l,Condition(function c1))
        if CountUnitsInGroup(g) > 0 then
            set i2 = GetRandomInt(1,5)
            loop
                exitwhen i > i2
                set t2 = CreateTimer()
                call CreateNUnitsAtLoc(1,'e001',GetOwningPlayer(u),l,270)
                set l2 = GetUnitLoc(GetLastCreatedUnit())
                set l3 = GetUnitLoc(GroupPickRandomUnit(g))
                call SaveUnitHandle(udg_Hash,GetHandleId(t2),0,GetLastCreatedUnit())
                call SaveReal(udg_Hash,GetHandleId(t2),1,DistanceBetweenPoints(l2,l3))
                call SaveReal(udg_Hash,GetHandleId(t2),2,DistanceBetweenPoints(l2,l3))
                call SaveReal(udg_Hash,GetHandleId(t2),3,AngleBetweenPoints(l2,l3))
                call SaveUnitHandle(udg_Hash,GetHandleId(t2),4,LoadUnitHandle(udg_Hash,GetHandleId(t),1))
                call RemoveLocation(l2)
                call RemoveLocation(l3)
                call TimerStart(t2,0.01,true,function ball)
                set i = i+1
            endloop
            set i = 1
            set i2 = 5-i2
            loop
                exitwhen i > i2
                set t = CreateTimer()
                call CreateNUnitsAtLoc(1,'e002',GetOwningPlayer(u),l,270)
                set l2 = GetUnitLoc(GetLastCreatedUnit())
                set l3 = GetUnitLoc(GroupPickRandomUnit(g))
                call SaveUnitHandle(udg_Hash,GetHandleId(t2),0,GetLastCreatedUnit())
                call SaveReal(udg_Hash,GetHandleId(t2),1,DistanceBetweenPoints(l2,l3))
                call SaveReal(udg_Hash,GetHandleId(t2),2,DistanceBetweenPoints(l2,l3))
                call SaveReal(udg_Hash,GetHandleId(t2),3,AngleBetweenPoints(l2,l3))
                call SaveUnitHandle(udg_Hash,GetHandleId(t2),4,LoadUnitHandle(udg_Hash,GetHandleId(t),1))
                call RemoveLocation(l2)
                call RemoveLocation(l3)
                call TimerStart(t2,0.01,true,function ball)
                set i = i+1
            endloop
            call DestroyGroup(g)
        endif
        call KillUnit(u)
        call FlushChildHashtable(udg_Hash,GetHandleId(t))
        call DestroyTimer(t)
    endif          
endfunction
//施放技能
function Trig_OverwhelmingDisaster_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local location l = GetUnitLoc(u)
    local timer t = CreateTimer()
    call CreateNUnitsAtLoc(1,'e000',GetOwningPlayer(u),l,270)
    call RemoveLocation(l)
    call SaveUnitHandle(udg_Hash,GetHandleId(t),0,GetLastCreatedUnit())
    call SaveUnitHandle(udg_Hash,GetHandleId(t),1,u)
    call TimerStart(t,0.01,true,function lift)
endfunction
//===========================================================================
function InitTrig_OverwhelmingDisaster takes nothing returns nothing
    set gg_trg_OverwhelmingDisaster = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_OverwhelmingDisaster, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_OverwhelmingDisaster, Condition( function Trig_OverwhelmingDisaster_Conditions ) )
    call TriggerAddAction( gg_trg_OverwhelmingDisaster, function Trig_OverwhelmingDisaster_Actions )
endfunction
[/jass]
我猜是lift那出错了,运行时会创建出很多e001和e002(而且不被记到哈希表中),这是为什么呢 |