首先是timerdatasystem... 下面每个函数都需要的
library TDS initializer TDS_init
globals
integer udg_Max = 0
integer array udg_Flu
integer udg_TDSid
timer array udg_Timer
boolean array udg_DS_Used //占用判定
real MOVETIMER_TIMEOUT=0.02 //移动函数循环时间
//_____________________可用数据______________________________
real array udg_DS_angle
real array udg_DS_speed
real array udg_DS_distance
real array udg_DS_x
real array udg_DS_y
real array udg_DS_speed_x
real array udg_DS_speed_y
integer array udg_DS_times
boolean array udg_DS_hastarget
player array udg_DS_player
effect array udg_DS_effect
string array udg_DS_effectPath
unit array udg_DS_whichUnit
//___________________________________________________________
endglobals
function CreateTimerId takes nothing returns integer
set udg_Max = udg_Max + 1
if udg_Flu[udg_Max] == 0 then
set udg_DS_Used[udg_Max] = true
return udg_Max
endif
set udg_DS_Used[udg_Flu[udg_Max]] = true
return udg_Flu[udg_Max]
endfunction
function GetTimerId takes nothing returns integer
return GetHandleId(GetExpiredTimer()) - udg_TDSid
endfunction
function DestroyTimerId takes integer tid returns nothing
if udg_DS_Used[tid] then //只对占用的id操作
call PauseTimer(udg_Timer[tid])
set udg_Flu[udg_Max] = tid
set udg_DS_Used[tid] = false
set udg_Max = udg_Max - 1
debug call BJDebugMsg("TimerIdMax="+I2S(udg_Max))
endif
endfunction
function TDS_init takes nothing returns nothing
local integer c = 1
local location l = Location(0,0)
set udg_TDSid = GetHandleId(l)
call RemoveLocation(l)
set l = null
loop
exitwhen c >= 8000
set udg_Timer[c] = CreateTimer()
set c = c + 1
endloop
endfunction
endlibrary
library TDS initializer TDS_init
globals
integer udg_Max = 0
integer array udg_Flu
integer udg_TDSid
timer array udg_Timer
boolean array udg_DS_Used //占用判定
real MOVETIMER_TIMEOUT=0.02 //移动函数循环时间
//_____________________可用数据______________________________
real array udg_DS_angle
real array udg_DS_speed
real array udg_DS_distance
real array udg_DS_x
real array udg_DS_y
real array udg_DS_speed_x
real array udg_DS_speed_y
integer array udg_DS_times
boolean array udg_DS_hastarget
player array udg_DS_player
effect array udg_DS_effect
string array udg_DS_effectPath
unit array udg_DS_whichUnit
//___________________________________________________________
endglobals
function CreateTimerId takes nothing returns integer
set udg_Max = udg_Max + 1
if udg_Flu[udg_Max] == 0 then
set udg_DS_Used[udg_Max] = true
return udg_Max
endif
set udg_DS_Used[udg_Flu[udg_Max]] = true
return udg_Flu[udg_Max]
endfunction
function GetTimerId takes nothing returns integer
return GetHandleId(GetExpiredTimer()) - udg_TDSid
endfunction
function DestroyTimerId takes integer tid returns nothing
if udg_DS_Used[tid] then //只对占用的id操作
call PauseTimer(udg_Timer[tid])
set udg_Flu[udg_Max] = tid
set udg_DS_Used[tid] = false
set udg_Max = udg_Max - 1
debug call BJDebugMsg("TimerIdMax="+I2S(udg_Max))
endif
endfunction
function TDS_init takes nothing returns nothing
local integer c = 1
local location l = Location(0,0)
set udg_TDSid = GetHandleId(l)
call RemoveLocation(l)
set l = null
loop
exitwhen c >= 8000
set udg_Timer[c] = CreateTimer()
set c = c + 1
endloop
endfunction
endlibrary