globals
hashtable P_hash = InitHashtable()
hashtable round_hash = InitHashtable()
endglobals
function angxy takes real x1,real y1,real x2,real y2 returns real
return bj_RADTODEG * Atan2(y2-y1,x2-x1)
endfunction
function disxy takes real x1,real y1,real x2,real y2 returns real
return SquareRoot((x2 - x1)*(x2 - x1)+(y2 - y1)*(y2 - y1))
endfunction
function round_time takes nothing returns nothing
local integer one = GetHandleId(GetExpiredTimer())
local unit u = LoadUnitHandle(round_hash,one,1)
local unit A_u = LoadUnitHandle(round_hash,one,2)
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local real M_x = GetUnitX(A_u)
local real M_y = GetUnitY(A_u)
local real E_time = LoadReal(round_hash,one,12)
local real ang = LoadReal(round_hash,one,14)+5
local real index = LoadReal(round_hash,one,13)+1
local real space = LoadReal(round_hash,one,11)
local real lxl = LoadReal(round_hash,one,15)
local real s = LoadReal(round_hash,one,16)
local real time = LoadReal(round_hash,one,17)
local string Effect = LoadStr(round_hash,one,18)
set s = s +lxl
call SaveReal (round_hash,one,16,s)
call SaveReal(round_hash,one,13,index)
set M_x = x + (space+s) * (CosBJ(ang))
set M_y = y + (space+s) * (SinBJ(ang))
call DestroyEffect(AddSpecialEffect(Effect,M_x,M_y))
call SaveReal(round_hash,one,14,ang)
call SetUnitX(A_u,M_x)
call SetUnitY(A_u,M_y)
set u = null
set A_u = null
if index > E_time*(1/time) then
set u = null
set A_u = null
call FlushChildHashtable(round_hash,one)
call DestroyTimer(GetExpiredTimer())
endif
endfunction
function round takes unit u1 , unit u2 ,real time ,real E_time,real lxl,string Effect returns nothing
local timer t= CreateTimer()
local integer one = GetHandleId(t)
local real x = GetUnitX(u1)
local real y = GetUnitY(u1)
local real M_x = GetUnitX(u2)
local real M_y = GetUnitY(u2)
local real space = disxy (x,y,M_x,M_y)
local real A = angxy (x,y,M_x,M_y)
call SaveReal(round_hash,one,17,time)
call SaveReal(round_hash,one,15,lxl)
call SaveReal(round_hash,one,14,A)
call SaveUnitHandle(round_hash,one,1,u2)
call SaveUnitHandle(round_hash,one,2,u1)
call SaveReal(round_hash,one,10,E_time)
call SaveReal(round_hash,one,11,space)
call SaveReal(round_hash,one,12,E_time)
call SaveStr(round_hash,one,18,Effect)
call TimerStart(t,time,true,function round_time)
set u1 = null
set u2 = null
endfunction
复制过去直接能用了。 |