|
发表于 2009-10-12 20:24:22
|
显示全部楼层
…………是想做击退嘛?
简单:
[jass]
globals
gamecache GC = null
endglobals
function GetGC takes nothing returns gamecache
if GC == null then
call FlushGameCache( InitGameCache( "GC.w3v" ) )
set GC = InitGameCache( "GC.w3v" )
endif
return GC
endfunction
constant function H2I takes handle h returns integer
return h
return 0
endfunction
constant function I2U takes integer i returns unit
return i
return null
endfunction
function Push_Act takes nothing returns nothing
local string hs = I2S( H2I( GetExpiredTimer() ) )
local unit u = I2U( GetStoredInteger( GetGC(), hs, "u" ) )
local real dist = GetStoredReal( GetGC(), hs, "dist" )
local real x = GetUnitX(u) + dist * Cos(GetUnitFacing(u) * bj_DEGTORAD)
local real y = GetUnitY(u) + dist * Sin(GetUnitFacing(u) * bj_DEGTORAD)
call SetUnitX( u, x )
call SetUnitY( u, y )
call FlushStoredMission( GetGC(), hs )
call DestroyTimer( GetExpiredTimer() )
endfunction
function Push takes unit u, real dist, real time returns nothing
local timer t = CreateTimer()
local string hs = I2S( H2I( t ) )
call StoreInteger( GetGC(), hs, "u", H2I( u ) )
call StoreReal( GetGC(), hs, "dist", dist )
call TimerStart( t, time, false, function Push_Act )
endfunction
[/jass]
在time秒后,将单位u向他面对的方向瞬移dist距离。
只是个小小的示范 |
|