|
global:
integer  array              SYS_ItemId
integer array SYS_ItemInitIndex_Count
integer  array              SYS_SkillId
----------------------------------------------------
[jass]
function Mod takes integer m, integer d returns integer
    return m - (m / d) * d
endfunction
function Mod_EX takes integer m, integer d,integer p returns integer
    return (m - (m / d) * d)/p
endfunction
function BlizzardId2Int takes integer b returns integer
   local integer k = b
   local integer n
   local integer s = 0
   set n = Mod(k,256)
   set s = s+BlizzardId2IntSingle(n)
   set k = k - n
   set n = Mod_EX(k,65536,256)
   set s = s+BlizzardId2IntSingle(n)*36
   set k = k - n
   set n = Mod_EX(k,16777216,65536)
   set s = s+BlizzardId2IntSingle(n)*1296
   set k = k - n
   set n = k/16777216
   set s = s+BlizzardId2IntSingle(n)*46656
   return s
endfunction
function GetHashIndex takes integer i returns integer
    return Mod(i,8191)+1
endfunction
function GetNextHashIndex takes integer i returns integer
    return Mod(i*33,8191)+1
endfunction
function GetItemHashIndexById takes integer id returns integer
    local integer idEx = BlizzardId2Int(id)
    local integer tmp = GetHashIndex(idEx)
    local integer c = 0
    local integer i = 0
    local integer ci = SYS_ItemInitIndex_Count[tmp]
    loop
       exitwhen(c>ci)
       if(SYS_ItemId[tmp]!=null)then
          if(SYS_ItemId[tmp]==id)then
              return tmp
          endif
          set c = c + 1
       endif
       set tmp = GetNextHashIndex(tmp)
       set i = i + 1
    endloop
    return 0
endfunction
function RegisterItemHashIndexById takes integer id returns integer
    local integer idEx = BlizzardId2Int(id)
    local integer tmp = GetHashIndex(idEx)
    local integer c = 0
    local integer i = 0
    local integer ci = SYS_ItemInitIndex_Count[tmp]
    if(SYS_ItemInitIndex_Count[tmp]==null or SYS_ItemInitIndex_Count[tmp]==0)then
        set SYS_ItemInitIndex_Count[tmp] = 1
    else
        set SYS_ItemInitIndex_Count[tmp] = SYS_ItemInitIndex_Count[tmp] + 1
    endif
    loop
       exitwhen(c>ci)
       if(SYS_ItemInitIndex[tmp]==0)then
          set SYS_ItemId[tmp] = id
          return tmp
          set c = c + 1
       elseif(SYS_ItemId[tmp]==id)then
          return 0
       endif
       set tmp = GetNextHashIndex(tmp)
       set i = i + 1
    endloop
    return 0
endfunction
[/jass]
Sample:
[jass]
----------------------------
RegisterItemSkill:
local integer index
set index = RegisterItemHashIndexById('I000')
set SYS_SkillId = 'A000'
----------------------------
GetItemSkill:
local integer itemId = GetItemTypeId(itm)
local integer index = GetItemHashIndexById(itemId)
return SYS_SkillId[index]
[/jass] |
评分
-
查看全部评分
|