|
中影三年级
  
人生太失望了 - UID
- 140432
- 帖子
- 2800
- 力量
- 217
- 敏捷
- 186
- 智力
- 167
- 生命
- 2998
- 魔法
- 166
- 注册时间
- 2007-11-4
|
20楼
大 中
小 发表于 2008-10-30 17:54 只看该作者
COPY JASSCODEJASS:
function U2I takes unit u returns integer
return u
return 0
endfunction
function gc takes nothing returns gamecache
if udg_gc==null then
set udg_gc=InitGameCache("DMCN.w3v")
call StoreInteger(gc(),"Main","BagCount",3)
endif
return udg_gc
endfunction
function SetBagCount takes integer i returns nothing
if i>=1 then
call StoreInteger(gc(),"Main","BagCount",i)
endif
endfunction
function GetBagIndex takes unit u returns integer
return GetStoredInteger(gc(),"U"+I2S(U2I(u)),"BagIndex")
endfunction
function GetItemId takes unit u,integer i,integer j returns integer
return GetStoredInteger(gc(),"U"+I2S(U2I(u)),"B"+I2S(i)+"I"+I2S(j))
endfunction
function GetItemCount takes unit u,integer i,integer j returns integer
return GetStoredInteger(gc(),"U"+I2S(U2I(u)),"B"+I2S(i)+"C"+I2S(j))
endfunction
function FindItemLoc takes unit u,item i returns integer
local integer j=0
loop
exitwhen j>5
exitwhen UnitItemInSlot(u,j)==i
set j=j+1
endloop
return j
endfunction
function CheckItem takes unit u,item i returns integer
local integer j=0
loop
exitwhen j>5
if j!=FindItemLoc(u,i) then
exitwhen GetItemTypeId(UnitItemInSlot(u,j))==GetItemTypeId(i)
endif
set j=j+1
endloop
return j
endfunction
function SaveBag takes unit u returns nothing
local integer i=1
loop
exitwhen i>6
call StoreInteger(gc(),"U"+I2S(U2I(u)),"B"+I2S(GetBagIndex(u))+"I"+I2S(i),GetItemTypeId(UnitItemInSlot(u,i-1)))
call StoreInteger(gc(),"U"+I2S(U2I(u)),"B"+I2S(GetBagIndex(u))+"C"+I2S(i),GetItemCharges(UnitItemInSlot(u,i-1)))
set i=i+1
endloop
endfunction
function GetBag takes unit u returns nothing
local integer j=1
local integer c
loop
exitwhen j>6
if UnitItemInSlot(u,j-1)!=null then
call RemoveItem(UnitItemInSlot(u,j-1))
endif
set c=GetItemId(u,GetBagIndex(u),j)
if c!=0 then
call UnitAddItemToSlotById(u,c,j-1)
call SetItemCharges(GetLastCreatedItem(),GetItemCount(u,GetBagIndex(u),j))
endif
set j=j+1
endloop
set j=0
endfunction
//更换包裹,i小于0则反向
function SwapBag takes integer i returns nothing
local unit u=GetTriggerUnit()
local integer n=GetBagIndex(u)
call SaveBag(u)
if n+i>=GetStoredInteger(gc(),"Main","BagCount") then
set n=0
elseif n+i<0 then
set n=GetStoredInteger(gc(),"Main","BagCount")-1
else
set n=n+i
endif
call StoreInteger(gc(),"U"+I2S(U2I(u)),"BagIndex",n)
call DisplayTextToForce(GetForceOfPlayer(GetOwningPlayer(u)),GetUnitName(u)+"|cff00ff00切换到第r"+I2S(n+1)+"|cff00ff00个物品栏|r")
call GetBag(u)
endfunction
//获得物品时找到原来的物品进行叠加,包括物品不在当前物品栏
function GetItem takes nothing returns nothing
local unit u=GetTriggerUnit()
local item i=GetManipulatedItem()
local integer n=GetStoredInteger(gc(),"Main","BagCount")
local integer j=0
local integer k=CheckItem(u,i)
local integer c
call DisableTrigger(GetTriggeringTrigger())
if k<6 then
call SetItemCharges(UnitItemInSlot(u,k),GetItemCharges(UnitItemInSlot(u,k))+GetItemCharges(i))
call RemoveItem(i)
else
loop
exitwhen j>=n
if j!=GetBagIndex(u) then
set k=1
loop
exitwhen k>6
if GetItemId(u,j,k)==GetItemTypeId(i) then
set c=GetItemCharges(i)+GetItemCount(u,j,k)
call StoreInteger(gc(),"U"+I2S(U2I(u)),"B"+I2S(j)+"C"+I2S(k),c)
call RemoveItem(i)
set k=6
set j=n
endif
set k=k+1
endloop
endif
set j=j+1
endloop
endif
call EnableTrigger(GetTriggeringTrigger())
endfunctionShingo Jass Highlighter 0.4
|