找回密码
 点一下
查看: 2909|回复: 7

万用物品合成系统

[复制链接]
发表于 2009-7-22 06:42:14 | 显示全部楼层 |阅读模式
内附演示和说明.

物品合成.w3x

180 KB, 下载次数: 464

评分

参与人数 1威望 +22 收起 理由
血戮魔动冰 + 22

查看全部评分

发表于 2009-7-22 06:51:20 | 显示全部楼层
把演示和说明发上来!!否则不给你加分~~~
回复

使用道具 举报

发表于 2009-7-22 07:06:58 | 显示全部楼层
……居然不理我…………只好帮你发了………………
[trigger]InitCombination
    事件
        地图初始化
    条件
    动作
        游戏缓存 - 创建游戏缓存,使用文件名: MapName.w3v
        设置 GC = (最后创建的游戏缓存)
        自定义代码: call ExecuteFunc("InitRecipe")
        -------- 以下动作可以删除 --------
        玩家 - 增加 99999 玩家1(红色) 的 现有黄金
        设置 CombineItem[0] = 没有物品
        设置 RecipeCount = 0
        设置 RecipeItemId[0] = RecipeItemId[0][/trigger]

[jass]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


//=====定义合成公式=====

function InitRecipe takes nothing returns nothing
//Lv1
//英勇面具=力量腰带+精灵皮靴+合成卷轴
call NewRecipe('I052','I01L',0,0,0,0,0)
call NewRecipe('I040','I052','I00H','I00F',0,0,0)
//灵巧头巾=精灵皮靴+法师长袍+合成卷轴
call NewRecipe('I04V','I01N',0,0,0,0,0)
call NewRecipe('I03S','I04V','I00F','I00L',0,0,0)
//勇气勋章=力量腰带+法师长袍+合成卷轴
call NewRecipe('I04G','I01M',0,0,0,0,0)
call NewRecipe('I037','I04G','I00H','I00L',0,0,0)
//大法师指环Lv1=贵族圆环+索比面具+合成卷轴
call NewRecipe('I04K','I01H',0,0,0,0,0)
call NewRecipe('I03C','I04K','I00M','I00T',0,0,0)
//大法师指环Lv2=大法师指环Lv1+合成卷轴
call NewRecipe('I03D','I04K','I03C',0,0,0,0)
//大法师指环LvMax=大法师指环Lv2+合成卷轴
call NewRecipe('I03E','I04K','I03D',0,0,0,0)
//战舰之舵=国王之冠+合成卷轴
call NewRecipe('I04O','I01O',0,0,0,0,0)
call NewRecipe('I03K','I04O','I00N',0,0,0,0)
//施魔护盾=强化盾+生命晶体
call NewRecipe('I03L','I01F','I00O',0,0,0,0)
//魔力之源=索比面具*2+合成卷轴
call NewRecipe('I058','I01Z',0,0,0,0,0)
call NewRecipe('I048','I058','I00T','I00T',0,0,0)
//影子风衣=法师长袍+精灵皮靴+闪避护符
call NewRecipe('I03I','I00L','I00F','I01S',0,0,0)
//雷霆晶石=魔法垂饰+合成卷轴
call NewRecipe('I055','I021',0,0,0,0,0)
call NewRecipe('I045','I055','I00R',0,0,0,0)
//疾风之靴=速度之靴+合成卷轴
call NewRecipe('I04Y','I022',0,0,0,0,0)
call NewRecipe('I03V','I04Y','I008',0,0,0,0)

//Lv2
//传送者笔记=传送卷轴+神秘腰带+魔法垂饰+合成卷轴
call NewRecipe('I04B','I023',0,0,0,0,0)
call NewRecipe('I01D','I04B','I007','I01T','I00R',0,0)
//医疗权杖=恢复指环+生命晶体+合成卷轴
call NewRecipe('I04H','I024',0,0,0,0,0)
call NewRecipe('I038','I04H','I00U','I00O',0,0,0)
//飓风权杖=法杖+法师长袍+索比面具+合成卷轴
call NewRecipe('I057','I025',0,0,0,0,0)
call NewRecipe('I047','I057','I011','I00L','I00T',0,0)
//飓风权杖=飓风权杖+合成卷轴
call NewRecipe('I047','I057','I047',0,0,0,0)
//净化之杖=闪电之球+法杖+合成卷轴
call NewRecipe('I04E','I026',0,0,0,0,0)
call NewRecipe('I034','I04E','I017','I011',0,0,0)
//大法师之手=加速手套+法师长袍+合成卷轴
call NewRecipe('I04J','I027',0,0,0,0,0)
call NewRecipe('I03B','I04J','I00E','I00L',0,0,0)
//神秘之剑=长剑+刃爪+合成卷轴
call NewRecipe('I050','I028',0,0,0,0,0)
call NewRecipe('I03Y','I050','I00X','I00W',0,0,0)
//战争兵器=铁锤+战斧+长剑
call NewRecipe('I03J','I00Z','I00Y','I00X',0,0,0)
//偏向之盾=施魔护盾+闪避护符
call NewRecipe('I01I','I03L','I01S',0,0,0,0)
//三棱盾=施魔护盾+神秘腰带+合成卷轴
call NewRecipe('I04A','I02C',0,0,0,0,0)
call NewRecipe('I01B','I04A','I03L','I01T',0,0,0)
//刀刃护甲=锁甲+神秘腰带+合成卷轴
call NewRecipe('I04F','I02D',0,0,0,0,0)
call NewRecipe('I035','I04F','I01W','I01T',0,0,0)

//Lv3
//潜行者之甲=影子风衣+长剑+合成卷轴
call NewRecipe('I04U','I02E',0,0,0,0,0)
call NewRecipe('I03R','I04U','I03I','I00X',0,0,0)
//埃苏尼之心=医疗权杖+大法师指环LvMax
call NewRecipe('I03A','I024','I03E',0,0,0,0)
//银色十字徽章=灵魂宝石+合成卷轴
call NewRecipe('I054','I02G',0,0,0,0,0)
call NewRecipe('I043','I054','I01E',0,0,0,0)
//神秘手套=加速手套+合成卷轴
call NewRecipe('I051','I02H',0,0,0,0,0)
call NewRecipe('I03Z','I051','I00E',0,0,0,0)
//霜华之锋=神秘之剑+霜冻之球+合成卷轴
call NewRecipe('I056','I02I',0,0,0,0,0)
call NewRecipe('I046','I056','I03Y','I019',0,0,0)
//玛诺洛斯战枪=战争兵器+火焰之球+合成卷轴
call NewRecipe('I04X','I02J',0,0,0,0,0)
call NewRecipe('I03U','I04X','I03J','I016',0,0,0)
//弑君者=腐蚀之球+神秘之剑+合成卷轴
call NewRecipe('I04N','I02K',0,0,0,0,0)
call NewRecipe('I03H','I04N','I018','I03Y',0,0,0)
//远古战斧=战争兵器+天灾骨钟+合成卷轴
call NewRecipe('I053','I02L',0,0,0,0,0)
call NewRecipe('I042','I053','I03J','I013',0,0,0)
//毁灭之爪=刃爪+合成卷轴
call NewRecipe('I04T','I02M',0,0,0,0,0)
call NewRecipe('I03Q','I04T','I00W',0,0,0,0)
//碎骨雷锤=矿铲+铁锤+合成卷轴
call NewRecipe('I04Z','I02A',0,0,0,0,0)
call NewRecipe('I03X','I04Z','I01A','I00Z',0,0,0)

//Lv4
//幻影权杖=魔力之源+原神之星+法杖+合成卷轴
call NewRecipe('I04M','I02N',0,0,0,0,0)
call NewRecipe('I03G','I04M','I048','I01Q','I011',0,0)
//破法者之刃=净化之杖+大法师之手
call NewRecipe('I03W','I034','I03B',0,0,0,0)
//死亡领主护盾=施魔护盾+魔法垂饰+火焰风衣+合成卷轴
call NewRecipe('I02Q','I04Q',0,0,0,0,0)
call NewRecipe('I03N','I04Q','I01Y','I00R','I01G',0,0)
//死亡领主皇冠=生命晶体+雷霆晶石+国王之冠+合成卷轴
call NewRecipe('I04R','I02P',0,0,0,0,0)
call NewRecipe('I03O','I04R','I00O','I045','I00N',0,0)
//上帝之戒=忍耐姜歌+战歌之鼓+天灾骨钟+风暴狮角+灵魂宝石
call NewRecipe('I01C','I012','I013','I014','I015','I01E',0)
//镜之铠=刀刃护甲+偏向之盾+钢盔
call NewRecipe('I044', 'I035','I01I','I01V',0,0,0)
//光明圣堂=三棱盾+锁甲+钢盔+合成卷轴
call NewRecipe('I04C','I02T',0,0,0,0,0)
call NewRecipe('I01J','I04C','I01B','I01W','I01V',0,0)
//狮心=三棱盾+灵魂宝石+合成卷轴
call NewRecipe('I04W','I02U',0,0,0,0,0)
call NewRecipe('I03T','I04W','I01B','I01E',0,0,0)

//Lv5
//创世者=灵魂晶石+原神之星+血羽之心+毁灭号角
call NewRecipe('I036','I01E','I01P','I01Q','I01R',0,0)
//兽性呼唤·地狱战斧=毁灭号角*2+战斧+合成卷轴
call NewRecipe('I04D','I030',0,0,0,0,0)
call NewRecipe('I01K','I04D','I01R','I01R','I00Y',0,0)
//鹰之号角·十字军弓=短弓+血羽之心*2+合成卷轴
call NewRecipe('I059','I02W',0,0,0,0,0)
call NewRecipe('I049','I059','I01P','I01P','I010',0,0)
//宙斯之力·神属权杖=雷霆晶石+原神之星*2+合成卷轴
call NewRecipe('I04L','I02X',0,0,0,0,0)
call NewRecipe('I03F','I04L','I01Q','I01Q','I045',0,0)
//时之轮= 魔力之源+灵魂宝石+合成卷轴
call NewRecipe('I04P','I02Y',0,0,0,0,0)
call NewRecipe('I03M','I04P','I048','I01E',0,0,0)
//死神之镰=战争兵器+棍棒+合成卷轴
call NewRecipe('I04S','I02Z',0,0,0,0,0)
call NewRecipe('I03P','I04S','I03J','I00V',0,0,0)
//辉光·幻化之刃=神秘之剑+火焰之球+霜冻之球+闪电之球
call NewRecipe('I041','I03Y','I016','I017','I019',0,0)
//圣剑·Blade=神秘之剑+灵魂晶石+合成卷轴
call NewRecipe('I04I','I032',0,0,0,0,0)
call NewRecipe('I039','I04I','I03Y','I01E',0,0,0)
endfunction[/jass]


[jass]function h2i takes handle h returns integer
return h
return 0
endfunction
function i2u takes integer i returns unit
return i
return null
endfunction

function Trig_InitShop_Conditions takes nothing returns boolean
    if GetUnitTypeId(GetSoldUnit()) == 'e000' then
        call RemoveUnit(GetSoldUnit())
        call SelectUnitForPlayerSingle(i2u(GetStoredInteger(udg_GC,"NextBuild",I2S(h2i(GetTriggerUnit())))),GetOwningPlayer(GetSoldUnit()))
    endif
    return false
endfunction

function CreateShop takes nothing returns nothing
    local real x = GetUnitX(GetFilterUnit())
    local real y = GetUnitY(GetFilterUnit())
    local unit u1 = CreateUnit(Player(15),'n00D',x,y,270)
    local unit u2 = CreateUnit(Player(15),'n00E',x,y,270)
    local unit u3 = CreateUnit(Player(15),'n00F',x,y,270)
    local unit u4 = CreateUnit(Player(15),'n00G',x,y,270)
    call AddUnitToStock(GetFilterUnit(),'e000',1,1)
    call AddUnitToStock(u1,'e000',2,2)
    call AddUnitToStock(u2,'e000',3,3)
    call AddUnitToStock(u3,'e000',4,4)
    call AddUnitToStock(u4,'e000',5,5)
    call StoreInteger(udg_GC,"NextBuild",I2S(h2i(GetFilterUnit())),h2i(u1))
    call StoreInteger(udg_GC,"NextBuild",I2S(h2i(u1)),h2i(u2))
    call StoreInteger(udg_GC,"NextBuild",I2S(h2i(u2)),h2i(u3))
    call StoreInteger(udg_GC,"NextBuild",I2S(h2i(u3)),h2i(u4))
    call StoreInteger(udg_GC,"NextBuild",I2S(h2i(u4)),h2i(GetFilterUnit()))
endfunction

function ShopFilterFunc takes nothing returns boolean
    if GetUnitTypeId(GetFilterUnit())=='n006' then
        call CreateShop()
    endif
    return false
endfunction

function Trig_InitShopButton_Conditions takes nothing returns boolean
    local group g = CreateGroup()
    call GroupEnumUnitsOfPlayer(g,Player(15),Condition(function ShopFilterFunc))
    set gg_trg_InitShopButton = CreateTrigger()
    call TriggerRegisterPlayerUnitEvent(gg_trg_InitShopButton,Player(15),EVENT_PLAYER_UNIT_SELL,null)
    call TriggerAddCondition(gg_trg_InitShopButton,Condition(function Trig_InitShop_Conditions))
    call DestroyGroup(g)
    set g = null
    return false
endfunction

function InitTrig_InitShopButton takes nothing returns nothing
    set gg_trg_InitShopButton = CreateTrigger()
    call TriggerRegisterTimerEventSingle(gg_trg_InitShopButton, 0.1)
    call TriggerAddCondition(gg_trg_InitShopButton, Condition(function Trig_InitShopButton_Conditions))
endfunction[/jass]
回复

使用道具 举报

发表于 2009-7-22 07:15:47 | 显示全部楼层
hmmm,我怎么觉得很像老狼的那个物品合成系统……
回复

使用道具 举报

发表于 2009-7-22 07:21:46 | 显示全部楼层
效率一点都不高……O(n*m)………………
回复

使用道具 举报

发表于 2009-7-22 09:12:21 | 显示全部楼层
效率……对能写出需要执行7秒的8皇后问题解法的某猪头来说是被忽略的……(后来被优化到0.3秒了,差距巨大啊……)
回复

使用道具 举报

发表于 2009-7-22 10:03:02 | 显示全部楼层
!!!!!!!!!!!啊!!!!!!!!!!!!!!!!
我受不了了…………………………………………
回复

使用道具 举报

发表于 2009-7-22 10:43:41 | 显示全部楼层
缓存的时代已经过去了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 点一下

本版积分规则

Archiver|移动端|小黑屋|地精研究院

GMT+8, 2024-11-24 15:04 , Processed in 0.308689 second(s), 25 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表