|
[jass]//===================================================================================================
//==MonsterRefersh
//===================================================================================================
constant integer SYD_TypeUnitInfo_Type = 1
constant integer SYD_TypeUnitInfo_Length = 2
constant integer SUT_RefershPoint = 1
constant integer SMD_RefershPoint_Base = 0
constant integer SMD_RefershPoint_Time = 1
constant integer SMD_RefershPoint_Value = 2
constant integer SMD_RefershPoint_Length = 3
constant integer SMD_RefershPoint_AcquireRange = 4
constant integer SMD_RefershPoint_DataLength = 4
integer SYS_CurrentTypeUnitInfoIndex = 1
integer SYS_CurrentTypeUnitIndex = 1
constant integer SRD_MaxNum = 0
constant integer SRD_StartTime = 1
constant integer SRD_LinkIndex = 2
constant integer SRD_BaseInfoLength = 2
integer SYS_RefershPoint_CurrentIndex = 1
//===================================================================================================
group SYS_RefershPointGroup
timer SYS_RefershPointTimer
integer array SYS_TypeUnit_Count
integer array SYS_TypeUnit_Id
integer array SYS_TypeUnit_LinkIndex
integer array SYS_TypeUnitData
integer array SYS_TypeUnitDataEx
unit array SYS_RefershPoint_Unit
integer array SYS_RefershPoint_Data
//===================================================================================================
//===================================================================================================
//==MonsterRefersh
//===================================================================================================
function TypeUnitRegister takes integer id,integer LinkIndex returns integer
local integer idEx = BlizzardId2Int(id)
local integer tmp = GetHashIndex(idEx)
local integer c = 0
local integer ci = SYS_TypeUnit_Count[tmp]
if(SYS_TypeUnit_Count[tmp]==null or SYS_TypeUnit_Count[tmp]==0)then
set SYS_TypeUnit_Count[tmp] = 1
else
set SYS_TypeUnit_Count[tmp] = SYS_TypeUnit_Count[tmp] + 1
endif
loop
exitwhen(c>ci)
if(SYS_TypeUnit_Id[tmp]==0 or SYS_TypeUnit_Id[tmp]==null)then
set SYS_TypeUnit_Id[tmp] = id
set SYS_TypeUnit_LinkIndex[tmp] = LinkIndex
return tmp
set c = c + 1
elseif(SYS_TypeUnit_Id[tmp]==id)then
return 0
endif
set tmp = GetNextHashIndex(tmp)
endloop
return 0
endfunction
function TypeUnit_GetIndex takes integer id returns integer
local integer idEx = BlizzardId2Int(id)
local integer tmp = GetHashIndex(idEx)
local integer c = 0
local integer ci = SYS_TypeUnit_Count[tmp]
if(SYS_TypeUnit_Count[tmp]==null or SYS_TypeUnit_Count[tmp]==0)then
return 0
endif
loop
exitwhen(c>ci)
if(SYS_TypeUnit_Id[tmp]==id)then
return tmp
elseif(SYS_TypeUnit_Id[tmp]!=null)then
set c = c + 1
endif
set tmp = GetNextHashIndex(tmp)
endloop
return 0
endfunction
//=====================================================
function RefershPoint_Register takes integer time,integer AcquireRange,integer val returns integer
set SYS_CurrentTypeUnitIndex = SYS_CurrentTypeUnitInfoIndex + SMD_RefershPoint_DataLength + 1
set SYS_TypeUnitData[SYS_CurrentTypeUnitInfoIndex+SMD_RefershPoint_Base] = SUT_RefershPoint
set SYS_TypeUnitData[SYS_CurrentTypeUnitInfoIndex+SMD_RefershPoint_Length] = 0
set SYS_TypeUnitData[SYS_CurrentTypeUnitInfoIndex+SMD_RefershPoint_AcquireRange] = AcquireRange
set SYS_TypeUnitData[SYS_CurrentTypeUnitInfoIndex+SMD_RefershPoint_Time] = time
set SYS_TypeUnitData[SYS_CurrentTypeUnitInfoIndex+SMD_RefershPoint_Value] = val
return SYS_CurrentTypeUnitInfoIndex
endfunction
function RefershPoint_RegisterEnd takes nothing returns nothing
set SYS_TypeUnitData[SYS_CurrentTypeUnitInfoIndex+SMD_RefershPoint_Length] = SYS_CurrentTypeUnitIndex - SYS_CurrentTypeUnitInfoIndex - SMD_RefershPoint_DataLength - 2
set SYS_CurrentTypeUnitInfoIndex = SYS_CurrentTypeUnitIndex
endfunction
function RefershPoint_AddTypeUnit takes integer uId,integer uValue returns nothing
set SYS_TypeUnitData[SYS_CurrentTypeUnitIndex] = uId
set SYS_TypeUnitDataEx[SYS_CurrentTypeUnitIndex] = uValue
set SYS_CurrentTypeUnitIndex = SYS_CurrentTypeUnitIndex + 1
endfunction
//=====================================================
function RefershPoint_Init takes unit u, integer num returns boolean
local integer index = SYS_RefershPoint_CurrentIndex
local integer InfoIndex = SYS_TypeUnit_LinkIndex[TypeUnit_GetIndex(GetUnitTypeId(u))]
local integer i
if(InfoIndex<=0)then
return false
endif
if(SYS_TypeUnitData[InfoIndex+SMD_RefershPoint_Base]!=SUT_RefershPoint)then
return false
endif
call SetUnitUserData(u,index)
call UnitAddAbility(u,'Aloc')
set SYS_RefershPoint_Unit[index] = u
set SYS_RefershPoint_Data[index+SRD_StartTime] = -1
set SYS_RefershPoint_Data[index+SRD_MaxNum] = num
set SYS_RefershPoint_Data[index+SRD_LinkIndex] = InfoIndex
set i = SYS_RefershPoint_CurrentIndex + SRD_BaseInfoLength + 1
set SYS_RefershPoint_CurrentIndex = SYS_RefershPoint_CurrentIndex + SRD_BaseInfoLength + num + 1
loop
exitwhen(i>=SYS_RefershPoint_CurrentIndex)
set SYS_RefershPoint_Data = 0
set i = i + 1
endloop
return true
endfunction
function RefershPoint_CreateMonster takes unit u,integer uIndex,integer uMaxNum,integer vIndex,integer vMaxNum,integer Value,integer AcquireRange returns nothing
local integer i = vIndex
local integer j = 0
local integer uId
local integer uValue
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local real facing = GetUnitFacing(u)
local integer val = 0
local real r = I2R(AcquireRange)
loop
exitwhen(val>=Value or j>=uMaxNum)
set i = GetRandomInt(vIndex,vIndex + vMaxNum)
set uId = SYS_TypeUnitData
set uValue = SYS_TypeUnitDataEx
set val = val + uValue
set SYS_RefershPoint_Unit[uIndex+j] = CreateUnit(GetOwningPlayer(u),uId,x,y,facing)
call SetUnitAcquireRange(SYS_RefershPoint_Unit[uIndex+j],r)
set j = j + 1
endloop
endfunction
function RefershPoint_CheckRefersh takes unit u returns boolean
local integer index = GetUnitUserData(u)
local integer InfoIndex
local integer uMaxNum
local integer tLength
local integer tValue
local integer i
local integer iMax
local integer j
local integer sTime
local integer AcquireRange
if(index<=0 or SYS_RefershPoint_Unit[index]!=u)then
return false
endif
set InfoIndex = SYS_RefershPoint_Data[index+SRD_LinkIndex]
if(SYS_TypeUnitData[InfoIndex+SMD_RefershPoint_Base]!=SUT_RefershPoint)then
return false
endif
set sTime = SYS_RefershPoint_Data[index+SRD_StartTime]
set uMaxNum = SYS_RefershPoint_Data[index+SRD_MaxNum]
if(sTime<=0)then
set i = index + SRD_BaseInfoLength + 1
set iMax = index + SRD_BaseInfoLength + uMaxNum
set j = uMaxNum
loop
exitwhen(i>iMax)
if(GetUnitState(SYS_RefershPoint_Unit,UNIT_STATE_LIFE)<=0.0)then
set SYS_RefershPoint_Unit = null
set j = j - 1
endif
set i = i + 1
endloop
if(j>0)then
return false
else
set i = SYS_TypeUnitData[InfoIndex+SMD_RefershPoint_Time]*100
set SYS_RefershPoint_Data[index+SRD_StartTime] = GetSystemTime() + i + sTime*i
return false
endif
elseif(sTime<=GetSystemTime())then
set tLength = SYS_TypeUnitData[InfoIndex+SMD_RefershPoint_Length]
set tValue = SYS_TypeUnitData[InfoIndex+SMD_RefershPoint_Value]
set AcquireRange = SYS_TypeUnitData[InfoIndex+SMD_RefershPoint_AcquireRange]
set SYS_RefershPoint_Data[index+SRD_StartTime] = 0
call RefershPoint_CreateMonster(u,index+SRD_BaseInfoLength + 1,uMaxNum,InfoIndex+SMD_RefershPoint_DataLength + 1,tLength,tValue,AcquireRange)
return true
endif
return false
endfunction
function MonsterRefersh_Filter takes nothing returns boolean
if(GetUnitAbilityLevel(GetFilterUnit(),SYD_UnitIgnoreSkill)<=0 or GetUnitUserData(GetFilterUnit())>0)then
return false
endif
return RefershPoint_Init(GetFilterUnit(),6)
endfunction
function MonsterRefersh_Code takes nothing returns nothing
call RefershPoint_CheckRefersh(GetEnumUnit())
endfunction
function MonsterRefersh_Loop takes nothing returns nothing
call ForGroup(SYS_RefershPointGroup,function MonsterRefersh_Code)
endfunction
function MonsterRefershSystemInit takes nothing returns nothing
set SYS_RefershPointGroup = CreateGroup()
set SYS_RefershPointTimer = CreateTimer()
call GroupEnumUnitsInRange(SYS_RefershPointGroup,0,0,99999,Condition(function MonsterRefersh_Filter))
call TimerStart(SYS_RefershPointTimer,1.0,true,function MonsterRefersh_Loop)
endfunction[/jass] |
评分
-
查看全部评分
|