|
globals
hashtable hash = InitHashtable()
endglobals
function H2I takes handle h returns integer
return GetHandleId(h)
endfunction
function Kef_Check takes unit m, unit u returns boolean//匹配条件
return ( IsUnitType(u, UNIT_TYPE_STRUCTURE) == false ) and ( IsUnitAliveBJ(u) == true ) and ( IsUnitEnemy(u, GetOwningPlayer(m)) == true )
endfunction
function Getdis takes unit u, real x, real y returns real//获取距离
return SquareRoot(( Pow((GetUnitX(u) - x), 2.00) + Pow((GetUnitY(u) - y), 2.00) ))
endfunction
function Getang takes real x0, real y0, unit u returns real//获取角度
local real x1 = GetUnitX(u)
local real y1 = GetUnitY(u)
return Atan2(( y1 - y0 ), ( x1 - x0 ))
endfunction
function Kef_Move takes nothing returns nothing//选取&位移动作
local integer i = H2I(GetExpiredTimer())
local real x = LoadReal( hash, i, 0 )
local real y = LoadReal( hash, i, 1 )
local real a
local real d
local real k = 11//位移距离
local unit m = LoadUnitHandle( hash, i, 'hero' )
local unit u = GetFilterUnit()
if ( Kef_Check(m, u) ) then
set a = Getang( x, y, u )//获取角度
set d = Getdis( u, x, y )//获取距离
if ( d <= 300 ) then//判断在圈内还是在圈外
set k = -k
endif
//单位位移
call SetUnitX( u, GetUnitX(u) + k * Cos(a) )
call SetUnitY( u, GetUnitY(u) + k * Sin(a) )
endif
set m = null
set u = null
endfunction
function Kef_Start takes nothing returns nothing//施法延迟动作&单位位移动作
local integer i = H2I(GetExpiredTimer())
local integer j = 0
local real x = LoadReal( hash, i, 0 )
local real y = LoadReal( hash, i, 1 )
local real time = LoadReal( hash, i, 2 )//持续时间
local real n = LoadReal( hash, i, 'numb' )//动作次数
local boolean b = LoadBoolean( hash, i, 'bool' )
local effect eff = LoadEffectHandle( hash, i, 'effc' )
local group g = CreateGroup()
if ( b ) then//判断该计时器为施法延迟计时器还是循环选取的计时器
set n = n + 1
loop//将圆外圈的点分为16个,并逐次选取
exitwhen j > 15
call GroupEnumUnitsInRange( g, x + 300 * Cos( 22.5 * j * bj_DEGTORAD ), y + 300 * Sin( 22.5 * j * bj_DEGTORAD ), 75, function Kef_Move )
set j = j + 1
endloop
call DestroyGroup(g)
if ( n > time ) then//持续时间之后的动作
call DestroyEffect(eff)
call FlushChildHashtable( hash, i )
call DestroyTimer(GetExpiredTimer())
else
call SaveReal( hash, i, 'numb', n )
endif
else//施法延迟后的动作
call DestroyEffect(eff)
call SaveEffectHandle( hash, i, 'effc', AddSpecialEffect("kineticfield_fx_stand.mdx", x, y) )
call SaveReal( hash, i, 'numb', 0 )//开始计算动作次数
call SaveBoolean( hash, i, 'bool', true )
call TimerStart( GetExpiredTimer(), 0.02, true, function Kef_Start )//重新开启该计时器,并将b变为true
endif
set g = null
set eff = null
endfunction
function Kef_Base takes nothing returns nothing//触发器动作
local unit m = GetTriggerUnit()
local real x = GetSpellTargetX()
local real y = GetSpellTargetY()
local timer t = CreateTimer()
local integer i = H2I(t)
call SaveReal( hash, i, 0, x )
call SaveReal( hash, i, 1, y )
call SaveReal( hash, i, 2, ( GetUnitAbilityLevel(m, 'A000') * 0.5 + 2 ) / 0.02 )//持续时间
call SaveBoolean( hash, i, 'bool', false )//延迟判断的布尔值
call SaveUnitHandle( hash, i, 'hero', m )
call SaveEffectHandle( hash, i, 'effc', AddSpecialEffect("kineticfield_fx_start.mdx", x, y) )
call TimerStart( t, 1.2, false, function Kef_Start )//施法延迟计时器
set m = null
set t = null
endfunction
function Kef_Spell takes nothing returns boolean
if ( GetSpellAbilityId() == 'A000' ) then
call Kef_Base()
endif
return true
endfunction
//===========================================================================
function InitTrig_Kef takes nothing returns nothing
set gg_trg_Kef = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( gg_trg_Kef, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Kef, Condition( function Kef_Spell ) )
endfunction
这个是别的论坛里看见的技能虽然上面写了注释不过还是有许多地方看不懂谁帮我把里面意思翻译下 |
|