|
发表于 2009-6-3 11:04:44
|
显示全部楼层
这个技能的问题在于那个“等待游戏时间0.01秒”,具体可以参考PolledWait代码
[codes=jass]
constant real bj_POLLED_WAIT_INTERVAL = 0.10
constant real bj_POLLED_WAIT_SKIP_THRESHOLD = 2.00
//===========================================================================
// We can't do game-time waits, so this simulates one by starting a timer
// and polling until the timer expires.
function PolledWait takes real duration returns nothing
local timer t
local real timeRemaining
if (duration > 0) then
set t = CreateTimer()
call TimerStart(t, duration, false, null)
loop
set timeRemaining = TimerGetRemaining(t)
exitwhen timeRemaining <= 0
// If we have a bit of time left, skip past 10% of the remaining
// duration instead of checking every interval, to minimize the
// polling on long waits.
if (timeRemaining > bj_POLLED_WAIT_SKIP_THRESHOLD) then
call TriggerSleepAction(0.1 * timeRemaining)
else
call TriggerSleepAction(bj_POLLED_WAIT_INTERVAL)
endif
endloop
call DestroyTimer(t)
endif
endfunction
[/codes] |
|