|
计算公式
[jass]
globals
hashtable udg_ht
constant real udg_steptime = 0.03
constant real udg_stepspeed = 20
endglobals
function movemissile takes nothing returns nothing
local integer i = GetHandleId(GetExpiredTimer())
local unit missile = LoadUnitHandle(udg_ht,i,0)
local real n = LoadReal(udg_ht,i,1)
local real m = LoadReal(udg_ht,i,2)
local real a = LoadReal(udg_ht,i,3)
local real l0 = LoadReal(udg_ht,i,4)
local real x0 = LoadReal(udg_ht,i,5)
local real y0 = LoadReal(udg_ht,i,6)
local real z0 = LoadReal(udg_ht,i,7)
local real t = LoadReal(udg_ht,i,8)
local real l = t * udg_stepspeed
local real x = l * Cos(a) + x0
local real y = l * Sin(a) + y0
local real h = n * l * l / 1000000 + m * l / 10000 + z0
local location loc = null
if l > l0 then
call PauseTimer(GetExpiredTimer())
call DestroyTimer(GetExpiredTimer())
set missile = null
call FlushChildHashtable(udg_ht,i)
return
endif
call SaveReal(udg_ht,i,8,t + 1)
call SetUnitX(missile,x)
call SetUnitY(missile,y)
set loc = Location(x,y)
if GetLocationZ(loc) > h + 10 then
call RemoveUnit(missile)
call PauseTimer(GetExpiredTimer())
call DestroyTimer(GetExpiredTimer())
call RemoveLocation(loc)
set loc = null
set missile = null
call FlushChildHashtable(udg_ht,i)
return
endif
call SetUnitFlyHeight(missile,h - GetLocationZ(loc),0)
endfunction
function aim takes unit missile ,real k ,real xs ,real ys ,real zs ,real xa ,real ya , real za returns nothing
local real h = za - zs
local real l = SquareRoot((xa - xs) * (xa - xs) + (ya - ys) * (ya - ys))
local real a = Atan((ya - ys) / (xa - xs))
local real m = 2 * (k * l + SquareRoot(k * l * (k * l - h ))) * 10000 / l
local real n = (h - m * l / 10000) * 1000000 / l / l
local timer t = CreateTimer()
local integer i = GetHandleId(t)
if xa - xs < 0 then
set a = a + 3.1415926
endif
call SaveUnitHandle(udg_ht,i,0,missile)
call SaveReal(udg_ht,i,1,n)
call SaveReal(udg_ht,i,2,m)
call SaveReal(udg_ht,i,3,a)
call SaveReal(udg_ht,i,4,l)
call SaveReal(udg_ht,i,5,xs)
call SaveReal(udg_ht,i,6,ys)
call SaveReal(udg_ht,i,7,zs)
call SaveReal(udg_ht,i,8,0)
call TimerStart(t,udg_steptime,true,function movemissile)
set t = null
endfunction
function aimlocation takes unit missile , real k ,location l0 , location l1 returns nothing
call aim(missile,k,GetLocationX(l0),GetLocationY(l0),GetLocationZ(l0),GetLocationX(l1),GetLocationY(l1),GetLocationZ(l1))
endfunction
[/jass] |
评分
-
查看全部评分
|