|
本帖最后由 chyj4747 于 2012-11-3 21:22 编辑
要求(能同时检测物品数量和物品使用次数+通用1.20-1.26)例如 散失之刃 需要法师长袍+“欢欣之刃x2”| 医疗宝石 需要 "治疗卷轴(使用次数大于等于2) 生命之石x2" 给我点思路吧 想不出来怎么做 不要杰斯(Jass) 不要帮我讲YDWE 那个系统不但没法检测使用次数而且有问题
仅无法检测使用次数
function NewRecipe takes integer i0,integer i1,integer i2,integer i3,integer i4,integer i5,integer i6 returns nothing
local integer array a
local integer b
local integer n=0
set udg_RecipeCount = udg_RecipeCount+1
set udg_RecipeItemId[udg_RecipeCount*10+9] = i0
set a[0]=i1
set a[1]=i2
set a[2]=i3
set a[3]=i4
set a[4]=i5
set a[5]=i6
loop
exitwhen a[n] == 0
set b = GetStoredInteger(udg_GC,I2S(a[n]),"ItemRecipeCount")
call StoreInteger(udg_GC,I2S(a[n]),"ItemRecipeCount",b+1)
call StoreInteger(udg_GC,I2S(a[n]),"ItemRecipe"+I2S(b),udg_RecipeCount)
set udg_RecipeItemId[udg_RecipeCount*10+n] = a[n]
set n=n+1
endloop
endfunction
function RecipeCheck takes unit u,integer rec returns boolean
local integer n
local integer i = 0
local integer array A
local integer array B
local integer c
local integer d = 5
loop
set B=udg_RecipeItemId[rec*10+i]
exitwhen B==0
set A=GetItemTypeId(UnitItemInSlot(u,i))
set i = i+1
endloop
set n = i-1
set c = n
loop
exitwhen i>=6
set A=GetItemTypeId(UnitItemInSlot(u,i))
set i = i+1
endloop
loop
set i=0
loop
exitwhen A==B[0]
if i==d then
return false
endif
set i=i+1
endloop
exitwhen c==0
set A=A[d]
set B[0]=B[c]
set B[c]=i
set c=c-1
set d=d-1
endloop
set B[0]=i
set i=0
loop
set udg_CombineItem=UnitItemInSlot(u,i)
exitwhen i>=5
set i=i+1
endloop
set d = 5-n
if n>0 then
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Items\\AIsm\\AIsmTarget.mdl",u,"origin"))
endif
loop
call RemoveItem(udg_CombineItem[B[n]])
exitwhen n==0
set udg_CombineItem[B[n]] = udg_CombineItem[n+d]
set n=n-1
endloop
call UnitAddItemById(u,udg_RecipeItemId[rec*10+9])
return true
endfunction
function ItemCombine takes unit u,item it returns nothing
local integer r
local integer i=0
loop
set r = GetStoredInteger(udg_GC,I2S(GetItemTypeId(it)),"ItemRecipe"+I2S(i))
exitwhen r==0
if RecipeCheck(u,r) then
return
endif
set i=i+1
endloop
endfunction
function Trig_Combination_Conditions takes nothing returns boolean
call ItemCombine(GetTriggerUnit(),GetManipulatedItem())
return false
endfunction
function InitTrig_Combination takes nothing returns nothing
set gg_trg_Combination=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_Combination,EVENT_PLAYER_UNIT_PICKUP_ITEM)
call TriggerAddCondition(gg_trg_Combination,Condition(function Trig_Combination_Conditions))
endfunction |
|