|
[jass]
function H2I takes handle H returns integer
return H
return 0
endfunction
function I2T takes integer I returns timer
return I
return null
endfunction
function I2U takes integer I returns unit
return I
return null
endfunction
function I2GC takes integer I returns gamecache
return I
return null
endfunction
function print takes nothing returns nothing
local integer HOfItem
local integer HOfItemV
local gamecache GcOfS
local timer t
local unit who
local item Item=GetEnumItem()
local real x
local real y
local integer n
if ( IsItemVisible(Item) == false ) then
set HOfItem=GetItemUserData(Item)
set GcOfS=I2GC(HOfItem)
set HOfItemV=GetStoredInteger(GcOfS,"Item","int")
if HOfItemV==H2I(Item) then
set n=GetStoredInteger(GcOfS,"Timer","int")
set t=I2T(GetStoredInteger(GcOfS,"Timer","H"))
set who=I2U(GetStoredInteger(GcOfS,"Unit","int"))
set x=GetUnitX(who)+5
set y=GetUnitX(who)+5
set n=n+1
call SetUnitX(who,x)
call SetUnitX(who,y)
call StoreReal(GcOfS,"Unit","x",x)
call StoreReal(GcOfS,"Unit","y",y)
call StoreInteger(GcOfS,"Timer","int",n)
endif
endif
if n>30 then
call RemoveItem( Item )
set n=0
call StoreInteger(GcOfS,"Timer","int",n)
call PauseTimer(t)
call DestroyTimer(t)
call FlushGameCache( GcOfS )
endif
set GcOfS=null
endfunction
function TmCode takes nothing returns nothing
call EnumItemsInRect(GetPlayableMapRect(),null,function print)
endfunction
function startOO takes unit who returns nothing
local item ItemForCache
local integer HOfItem
local gamecache GcOfS
local integer HOfUnit
local string SOfUnit
local real xOfUnit=GetUnitX(who)
local real yOfUnit=GetUnitY(who)
local timer T=CreateTimer()
set SOfUnit=I2S(H2I(who))+".w3v"
set GcOfS = InitGameCache(SOfUnit)
set ItemForCache = CreateItem('kybl', 0, 0)
call SetItemVisibleBJ( false, ItemForCache )
set HOfItem=H2I(GcOfS)
call SetItemUserData( ItemForCache, HOfItem )
call StoreInteger(GcOfS,"Unit","int",H2I(who))
call StoreInteger(GcOfS,"Item","int",H2I(ItemForCache))
call DisplayTextToPlayer( Player(0), 0, 0,I2S(GetStoredInteger(GcOfS,"Item","int")) )
call StoreReal(GcOfS,"Unit","x",xOfUnit)
call StoreReal(GcOfS,"Unit","y",yOfUnit)
call StoreInteger(GcOfS,"Timer","int",0)
call StoreInteger(GcOfS,"Timer","H",H2I(T))
call TimerStart(T,0.10,true,function TmCode)
endfunction
[/jass]
目的是想做个不用全局变量的 gamecache 不过现在的东西感觉还是在耍赖
还有高手不要说我渣
只是无聊啊~~~~~ |
|