|
这段代码是实现单位跳跃的,奇怪的是,语法没检查出错,但好像没有执行,问题貌似在HASHTABLE上,有没有高人指点一下
function ParabolaToMoveUnitActions takes nothing returns nothing
local integer parentKey = GetHandleId(GetExpiredTimer())
local integer i = LoadInteger(udg_HT,parentKey,6)
local real angle = LoadReal( udg_HT,parentKey,1)
local real m = LoadReal( udg_HT,parentKey,4 ) / 50
local real a = LoadReal( udg_HT,parentKey,3 ) / 2
local real b = LoadReal( udg_HT,parentKey,2 )
local real A = b/(a*a)
local real x
local real y
local unit u = LoadUnitHandle(udg_HT,parentKey,5)
local real tempx
local real tempy
call BJDebugMsg( "TRIGSTR_003" )
set i = i + 1
set x = m*i
set y = -A*(x-a)*(x-a)+b
set tempx = GetUnitX(u) + m * Cos(angle*bj_DEGTORAD)
set tempy = GetUnitY(u) + m * Sin(angle*bj_DEGTORAD)
call SetUnitX( u, tempx )
call SetUnitY( u, tempy )
call SetUnitFacing( u, angle )
call SetUnitFlyHeight( u, y, 0.00 )
call RemoveSavedInteger(udg_HT,parentKey,5)
call SaveInteger( udg_HT,parentKey,5,i )
call BJDebugMsg( "TRIGSTR_003" )
if x>=(2*a) then
call SetUnitFlyHeight( u, GetUnitDefaultFlyHeight(u), 0.00 )
call FlushChildHashtable( udg_HT,parentKey)
call DestroyTimer( GetExpiredTimer() )
endif
endfunction
function ParabolaToMoveUnit takes unit u,real high,real distance,real speed,real angel returns nothing
local timer t = null
local integer parentKey
if (GetUnitState(u,UNIT_STATE_LIFE) > 0.00) and (distance > 0.00) and (speed > 0.00) then
set t = CreateTimer()
set parentKey = GetHandleId(t)
call UnitAddAbility( u,'Arav' )
call SaveReal( udg_HT,parentKey,1,angel )
call SaveReal( udg_HT,parentKey,2 ,high )
call SaveReal( udg_HT,parentKey,3 ,distance )
call SaveReal( udg_HT,parentKey,4,speed )
call SaveUnitHandle(udg_HT,parentKey,5,u )
call SaveInteger(udg_HT,parentKey,6,0)
call BJDebugMsg( "TRIGSTR_003" )
call TimerStart( t, 0.02, true, function ParabolaToMoveUnitActions )
else
call BJDebugMsg( "TRIGSTR_003" )
call DestroyTimer(t)
endif
set t = null
endfunction |
|