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

物品栏函数

[复制链接]
发表于 2008-12-14 20:25:40 | 显示全部楼层 |阅读模式
[jass]
//***************************************************************************
//*                                                                         *
//*                 Azeroth' Arcane Arena Inventory System                  *
//*                                                                         *
//*                    By Blade.dk - [email protected]                     *
//*                                                                         *
//*          http://aaa.wc3jass.com  -  http://www.wc3campaigns.net         *
//*                                                                         *
//***************************************************************************
//===========================================================================
// Configuration functions

constant function Cancel_ItemID takes nothing returns integer
    return 'I00K' // Rawcode of the Cancel item.
endfunction

constant function BackpackMenu_ItemID takes nothing returns integer
    return 'I009' // Rawcode of the Backpack item.
endfunction

constant function SwitchPage_ItemID takes nothing returns integer
    return 'I00N' // Rawcode of the Switch Page item.
endfunction

constant function EquipmentMenu_ItemID takes nothing returns integer
    return 'I00L' // Rawcode of the Equipment Menu item.
endfunction

constant function HeadFiller_ItemID takes nothing returns integer
    return 'I00M' // Rawcode of the Head item.
endfunction

constant function ArmorFiller_ItemID takes nothing returns integer
    return 'I00G' // Rawcode of the Armor item.
endfunction

constant function WeaponFiller_ItemID takes nothing returns integer
    return 'I00H' // Rawcode of the Weapon item.
endfunction

constant function ShieldFiller_ItemID takes nothing returns integer
    return 'I00I' // Rawcode of the Shield item.
endfunction

constant function AccessoryFiller_ItemID takes nothing returns integer
    return 'I00J' // Rawcode of the Accessory item.
endfunction

constant function BackpackSize takes nothing returns integer
    return 16 // The number of items that can be in a Hero's Backpack. MUST be a multiple of 4.
endfunction

constant function InventorySafeX takes nothing returns real
    return -2040.00 // The X coordinate of a safe place to place items, so computer units won't be able to pick the up.
endfunction

constant function InventorySafeY takes nothing returns real
    return 2040.00 // The Y coordinate of a safe place to place items, so computer units won't be able to pick the up.
endfunction

//===========================================================================
// Private functions - Do not modify them unless you know what you are doing!

function InventoryCache takes nothing returns gamecache
    if udg_AAAInventory == null then
        call FlushGameCache(InitGameCache("AAAInv.w3v"))
        set udg_AAAInventory = InitGameCache("AAAInv.w3v")
    endif
    return udg_AAAInventory
endfunction

function SetItemBonuses takes item i, integer dmg, integer arm, integer hp, integer mp, integer str, integer agi, integer int, integer abil_a,integer abil_b,integer abil_c,integer abil_d, string equipSlot, string equipFunc, string unequipFunc returns nothing
    local gamecache g = InventoryCache()
    local string s = I2S(CS_H2I(i))
    if equipSlot == "Head" or equipSlot == "Armor" or equipSlot == "Weapon" or equipSlot == "Shield" or equipSlot == "Accessory" then
        call StoreString(g, s, "equipmentslot", equipSlot)
        if dmg > 0 then
            call StoreInteger(g, s, "damage", dmg)
        endif
        if arm > 0 then
            call StoreInteger(g, s, "armor", arm)
        endif
        if hp > 0 then
            call StoreInteger(g, s, "hitpoints", hp)
        endif
        if mp > 0 then
           call StoreInteger(g, s, "manapoints", mp)
        endif
        if str > 0 then
            call StoreInteger(g, s, "strength", str)
        endif
        if agi > 0 then
            call StoreInteger(g, s, "agility", agi)
        endif
        if int > 0 then
            call StoreInteger(g, s, "intelligence", int)
        endif
//=====================================================
        if abil_a> 0 then
            call StoreInteger(g, s, "ability_a", PreloadAbility(abil_a))
        endif
        if abil_b> 0 then
            call StoreInteger(g, s, "ability_b", PreloadAbility(abil_b))
        endif   
        if abil_c> 0 then
            call StoreInteger(g, s, "ability_c", PreloadAbility(abil_c))
        endif   
        if abil_d> 0 then
            call StoreInteger(g, s, "ability_d", PreloadAbility(abil_d))
        endif

//==============================================================
        if equipFunc != "" and equipFunc != null then
            call StoreString(g, s, "OnEquip", equipFunc)
        endif
        if unequipFunc != "" and unequipFunc != null then
            call StoreString(g, s, "OnDrop", unequipFunc)
        endif
    endif
    set g = null
endfunction

//===========================================================================



//===========================================================================


function BackpackHasEmptySlots takes string s returns boolean
    local integer a = 1
    loop
        exitwhen a > BackpackSize()
        if GetTableItem(s, "BackpackItem"+I2S(a)) == null then
            return true
        endif
        set a = a+1
    endloop
    return false
endfunction

function QuickMenuHasEmptySlots takes string s returns boolean
    return GetTableItem(s, "QuickMenuItem1") == null or GetTableItem(s, "QuickMenuItem2") == null or GetTableItem(s, "QuickMenuItem3") == null or GetTableItem(s, "QuickMenuItem4") == null
endfunction

function IsItemFiller takes item i returns boolean
    local integer id = GetItemTypeId(i)
    return id == HeadFiller_ItemID() or id == ArmorFiller_ItemID() or id == WeaponFiller_ItemID() or id == ShieldFiller_ItemID() or id == AccessoryFiller_ItemID()
endfunction

function BackpackContainsItem takes string s, item i returns boolean
    local integer a = 1
    loop
        exitwhen a > BackpackSize()
        if GetTableItem(s, "BackpackItem"+I2S(a)) == i then
            return true
        endif
        set a = a+1
    endloop
    return false
endfunction

function QuickMenuContainsItem takes string s, item i returns boolean
    return GetTableItem(s, "QuickMenuItem1") == i or GetTableItem(s, "QuickMenuItem2") == i or GetTableItem(s, "QuickMenuItem3") == i or GetTableItem(s, "QuickMenuItem4") == i
endfunction

function IsEquipmentSlotValid takes string es returns boolean
    return es == "Head" or es == "Armor" or es == "Weapon" or es == "Shield" or es == "Accessory"
endfunction

function GetItemEquipmentSlot takes item i returns string
    return GetStoredString(InventoryCache(), I2S(CS_H2I(i)), "equipmentslot")
endfunction

function GetItemSlot takes unit u, item i returns integer
    local integer a = 0
    loop
        exitwhen a > 5
        if UnitItemInSlot(u, a) == i then
            return a
        endif
        set a = a + 1
    endloop
    return -1
endfunction

function SlotToFillerName takes integer s returns string
    if s == 0 then
        return "Head"
    elseif s == 1 then
        return "Armor"
    elseif s == 2 then
        return "Weapon"
    elseif s == 3 then
        return "Shield"
    elseif s == 4 then
        return "Accessory"
    else
        return "Cancel"
    endif
endfunction

function FillerNameToSlot takes string es returns integer
    if es == "Head" then
        return 0
    elseif es == "Armor" then
        return 1
    elseif es == "Weapon" then
        return 2
    elseif es == "Shield" then
        return 3
    elseif es == "Accessory" then
        return 4
    endif
    return 5
endfunction

function InventoryRemoveItem takes unit u, item i returns nothing
    call SetItemUserData(i, 1)
    call UnitRemoveItem(u, i)
    call SetItemPosition(i, InventorySafeX(), InventorySafeY())
    call SetItemVisible(i, false)
endfunction

function InventoryAddItem takes unit u, item i returns nothing
    call SetItemUserData(i, 0)
    call SetItemVisible(i, true)
    call UnitAddItem(u, i)
endfunction

function CreateExtendedInventory takes unit u returns nothing
    local item i
    local string s = NewTable()
    local integer a = 0
    loop
        exitwhen a > 5
        call RemoveItem(UnitItemInSlot(u, a))
        set a = a + 1
    endloop
    call GroupAddUnit(udg_AAAInventoryGroup, u)
    call AttachString(u, "InventoryTable", s)
    call SetTableInt(s, "CurrentMenu", 0)
    call SetTableInt(s, "CurrentBackpackPage", 1)
    call UnitAddItemToSlotById(u, EquipmentMenu_ItemID(), 4)
    set i = UnitItemInSlot(u, 4)
    call SetTableObject(s, "EquipmentMenu", i)
    call UnitAddItemToSlotById(u, BackpackMenu_ItemID(), 5)
    set i = UnitItemInSlot(u, 5)
    call SetTableObject(s, "BackpackMenu", i)
    set i = CreateItem(Cancel_ItemID(), 0, 0)
    call SetItemVisible(i, false)
    call SetTableObject(s, "Cancel", i)
    set i = CreateItem(SwitchPage_ItemID(), 0, 0)
    call SetItemVisible(i, false)
    call SetTableObject(s, "SwitchPage", i)
    call SetItemCharges(i, 1)
    set i = CreateItem(HeadFiller_ItemID(), 0, 0)
    call SetItemVisible(i, false)
    call SetTableObject(s, "HeadFiller", i)
    call SetTableObject(s, "HeadItem", i)
    set i = CreateItem(ArmorFiller_ItemID(), 0, 0)
    call SetItemVisible(i, false)
    call SetTableObject(s, "ArmorFiller", i)
    call SetTableObject(s, "ArmorItem", i)
    set i = CreateItem(WeaponFiller_ItemID(), 0, 0)
    call SetItemVisible(i, false)
    call SetTableObject(s, "WeaponFiller", i)
    call SetTableObject(s, "WeaponItem", i)
    set i = CreateItem(ShieldFiller_ItemID(), 0, 0)
    call SetItemVisible(i, false)
    call SetTableObject(s, "ShieldFiller", i)
    call SetTableObject(s, "ShieldItem", i)
    set i = CreateItem(AccessoryFiller_ItemID(), 0, 0)
    call SetItemVisible(i, false)
    call SetTableObject(s, "AccessoryFiller", i)
    call SetTableObject(s, "AccessoryItem", i)
    set i = null
endfunction

function DestroyExtendedInventory takes unit u returns nothing
    local string s = GetAttachedString(u, "InventoryTable")
    local item i
    local item t
    local integer a = 1
    if s == "" then
        set i = null
        set t = null
        return
    endif
    loop
        exitwhen a > BackpackSize()
        call RemoveItem(GetTableItem(s, "BackpackItem"+I2S(a)))
        set a = a + 1
    endloop
    set a = 1
    loop
        exitwhen a > 4
        call RemoveItem(GetTableItem(s, "QuickPage"+I2S(a)))
        set a = a + 1
    endloop
    call RemoveItem(GetTableItem(s, "EquipmentMenu"))
    call RemoveItem(GetTableItem(s, "BackpackMenu"))
    call RemoveItem(GetTableItem(s, "Cancel"))
    call RemoveItem(GetTableItem(s, "SwitchPage"))
    set a = 0
    loop
        exitwhen a > 4
        set i = GetTableItem(s, SlotToFillerName(a)+"Item")
        set t = GetTableItem(s, SlotToFillerName(a)+"Filler")
        if i != t then
            call RemoveItem(i)
        endif
        call RemoveItem(t)
        set a = a + 1
    endloop
    call DestroyTable(s)
    call GroupRemoveUnit(udg_AAAInventoryGroup, u)
    call AttachString(u, "InventoryTable", "")
    set i = null
    set t = null
endfunction

function InventoryError takes unit u, string e returns nothing
    call CS_Error(GetOwningPlayer(u), e)
    call PauseUnit(u, true)
    call IssueImmediateOrder(u, "stop")
    call PauseUnit(u, false)
endfunction

function CompressBackpack takes string s returns nothing
    local integer a = 1
    local item array t
    local integer b = 1
    local integer m = 0
    local integer e = 1
    local string l
    loop
        exitwhen a > BackpackSize()
        set l = "BackpackItem"+I2S(a)
        set t[a] = GetTableItem(s, l)
        call SetTableObject(s, l, null)
        set a = a + 1
    endloop
    set a = 1
    loop
        exitwhen a > BackpackSize()
        set b = e
        loop
            exitwhen b > BackpackSize()
            if t != null then
                call SetTableObject(s, "BackpackItem"+I2S(a), t)
                set e = b+1
                set m = m + 1
                set b = BackpackSize()+1
            endif
            set b = b + 1
        endloop
        set a = a + 1
    endloop
    set a = 1
    loop
        exitwhen a > BackpackSize()
        set t[a] = null
        set a = a + 1
    endloop
    call SetTableInt(s, "BackpackItemsCount", m)
endfunction

function AddItemToBackpack takes unit u, string s, item i returns nothing
    local integer a
    call CompressBackpack(s)
    set a = GetTableInt(s, "BackpackItemsCount")+1
    call SetTableObject(s, "BackpackItem"+I2S(a), i)
    call InventoryRemoveItem(u, i)
    call SetItemCharges(GetTableItem(s, "BackpackMenu"), a)
    call SetTableInt(s, "BackpackItemsCount", a)
endfunction

function AddItemToQuickMenu takes unit u, string s, item i, boolean f returns nothing
    local integer a = 1
    local string c
    local item t
    local string m
    loop
        exitwhen a > 4
        set c = "QuickMenuItem"+I2S(a)
        if GetTableItem(s, c) == null then
            call SetTableObject(s, c, i)
            call InventoryRemoveItem(u, i)
            set a = 4
        endif
        set a = a + 1
    endloop
    if f then
        call CompressBackpack(s)
    endif
    set t = null
endfunction

function InventorySwapMenu takes unit c, string s, integer o, integer m, integer op, integer np returns nothing
    local integer a = 1
    local integer b = 0
    local item i
    if o == 0 then
        loop
            exitwhen a > 6
            set i = UnitItemInSlot(c, a-1)
            if a < 5 then
                call SetTableObject(s, "QuickMenuItem"+I2S(a), i)
            endif
            call InventoryRemoveItem(c, i)
            set a = a + 1
        endloop
    elseif o == 1 then
        set a = 0
        loop
            exitwhen a > 4
            set i = UnitItemInSlot(c, a)
            call SetTableObject(s, SlotToFillerName(a)+"Item", i)
            call InventoryRemoveItem(c, i)
            set a = a + 1
        endloop
        set i = UnitItemInSlot(c, 5)
        call SetTableObject(s, "Cancel", i)
        call InventoryRemoveItem(c, i)
    elseif o == 2 then
        loop
            exitwhen a > 6
            set i = UnitItemInSlot(c, a-1)
            if a < 5 then
                call SetTableObject(s, "BackpackItem"+I2S((4*(op-1))+a), i)
            endif
            call InventoryRemoveItem(c, i)
            set a  = a + 1
        endloop
    endif
    set a = 1
    call SetTableInt(s, "CurrentMenu", m)
    if m == 0 then
        loop
            exitwhen a > 4
            set i = GetTableItem(s, "QuickMenuItem"+I2S(a))
            call InventoryAddItem(c, i)
            call SetItemPawnable(i, true)
            set a = a + 1
        endloop
        set i = GetTableItem(s, "EquipmentMenu")
        call InventoryAddItem(c, i)
        call UnitDropItemSlot(c, i, 4)
        set i = GetTableItem(s, "BackpackMenu")
        call InventoryAddItem(c, i)
        call UnitDropItemSlot(c, i, 5)
        call SetItemCharges(i, GetTableInt(s, "BackpackItemsCount"))
        call SetTableInt(s, "CurrentBackpackPage", 1)
    elseif m == 1 then
        set a = 0
        loop
            exitwhen a > 4
            set i = GetTableItem(s, SlotToFillerName(a)+"Item")
            call InventoryAddItem(c, i)
            call SetItemPawnable(i, false)
            set a = a + 1
        endloop
        set i = GetTableItem(s, "Cancel")
        call InventoryAddItem(c, i)
    elseif m == 2 then
        call CompressBackpack(s)
        loop
            exitwhen b >= 4 or a > BackpackSize()
            set i = GetTableItem(s, "BackpackItem"+I2S((4*(np-1))+a))
            if i != null then
                set b = b + 1
                call InventoryAddItem(c, i)
                call SetItemPawnable(i, false)
            endif
            set a = a + 1
        endloop
        call SetTableInt(s, "CurrentBackpackPage", np)
        set i = GetTableItem(s, "SwitchPage")
        call InventoryAddItem(c, i)
        call UnitDropItemSlot(c, i, 4)
        call SetItemCharges(i, np)
        set i = GetTableItem(s, "Cancel")
        call InventoryAddItem(c, i)
        call UnitDropItemSlot(c, i, 5)
    endif
    if GetLocalPlayer() == GetOwningPlayer(c) then
        call ClearTextMessages()
    endif
    set i = null
endfunction

function EquipItem takes unit c, string s, item i, string es returns nothing
    local item e = GetTableItem(s, es+"Item")
    local item f = GetTableItem(s, es+"Filler")
    local string x
    local gamecache g = InventoryCache()
    local string m = I2S(CS_H2I(e))
    local integer v
    local string a
    local integer l
    call InventoryRemoveItem(c, i)
    call SetTableObject(s, es+"Item", i)
    if e != f then
        set x = GetStoredString(g, m, "OnDrop")
        if x != "" and x != null then
            call ExecuteFunc(x)
        endif
        set v = GetStoredInteger(g, m, "damage")
        if v > 0 then
            call UnitAddBonus(c, 0, -v)
        endif
        set v = GetStoredInteger(g, m, "armor")
        if v > 0 then
            call UnitAddBonus(c, 1, -v)
        endif
        set v = GetStoredInteger(g, m, "hitpoints")
        if v > 0 then
            call UnitAddBonus(c, 2, -v)
        endif
        set v = GetStoredInteger(g, m, "manapoints")
        if v > 0 then
            call UnitAddBonus(c, 3, -v)
        endif
        set v = GetStoredInteger(g, m, "strength")
        if v > 0 then
            call SetHeroStr(c, GetHeroStr(c, false)-v, true)
        endif
        set v = GetStoredInteger(g, m, "agility")
        if v > 0 then
            call SetHeroAgi(c, GetHeroAgi(c, false)-v, true)
        endif
        set v = GetStoredInteger(g, m, "intelligence")
        if v > 0 then
            call SetHeroInt(c, GetHeroInt(c, false)-v, true)
        endif
//===================================================
        set v = GetStoredInteger(g, m, "ability_a")
        if v > 0 then
            set a = "Ability_a"+I2S(v)
            set l = GetTableInt(s, a)-1
            call SetTableInt(s, a, l)
            if l < 1 then
                call UnitRemoveAbility(c, v)
            endif
        endif
        set v = GetStoredInteger(g, m, "ability_b")
        if v > 0 then
            set a = "Ability_b"+I2S(v)
            set l = GetTableInt(s, a)-1
            call SetTableInt(s, a, l)
            if l < 1 then
                call UnitRemoveAbility(c, v)
            endif
        endif
        set v = GetStoredInteger(g, m, "ability_c")
        if v > 0 then
            set a = "Ability_c"+I2S(v)
            set l = GetTableInt(s, a)-1
            call SetTableInt(s, a, l)
            if l < 1 then
                call UnitRemoveAbility(c, v)
            endif
        endif
        set v = GetStoredInteger(g, m, "ability_d")
        if v > 0 then
            set a = "Ability_d"+I2S(v)
            set l = GetTableInt(s, a)-1
            call SetTableInt(s, a, l)
            if l < 1 then
                call UnitRemoveAbility(c, v)
            endif
        endif        
//=======================================================
        call InventoryAddItem(c, e)
    endif
    set m = I2S(CS_H2I(i))
    set x = GetStoredString(g, m, "OnEquip")
    if x != "" and x != null then
        call ExecuteFunc(x)
    endif
    set v = GetStoredInteger(g, m, "damage")
    if v > 0 then
        call UnitAddBonus(c, 0, v)
    endif
    set v = GetStoredInteger(g, m, "armor")
    if v > 0 then
        call UnitAddBonus(c, 1, v)
    endif
    set v = GetStoredInteger(g, m, "hitpoints")
    if v > 0 then
        call UnitAddBonus(c, 2, v)
    endif
    set v = GetStoredInteger(g, m, "manapoints")
    if v > 0 then
        call UnitAddBonus(c, 3, v)
    endif
    set v = GetStoredInteger(g, m, "strength")
    if v > 0 then
        call SetHeroStr(c, GetHeroStr(c, false)+v, true)
    endif
    set v = GetStoredInteger(g, m, "agility")
    if v > 0 then
         call SetHeroAgi(c, GetHeroAgi(c, false)+v, true)
    endif
    set v = GetStoredInteger(g, m, "intelligence")
    if v > 0 then
        call SetHeroInt(c, GetHeroInt(c, false)+v, true)
    endif
//================================================
    set v = GetStoredInteger(g, m, "ability_a")
    if v > 0 then
        set a = "Ability_a"+I2S(v)
        set l = GetTableInt(s, a)+1
        call SetTableInt(s, a, l)
        call UnitAddAbility(c, v)
    endif
    set v = GetStoredInteger(g, m, "ability_b")
    if v > 0 then
        set a = "Ability_b"+I2S(v)
        set l = GetTableInt(s, a)+1
        call SetTableInt(s, a, l)
        call UnitAddAbility(c, v)
    endif
    set v = GetStoredInteger(g, m, "ability_c")     
     if v > 0 then
        set a = "Ability_c"+I2S(v)
        set l = GetTableInt(s, a)+1
        call SetTableInt(s, a, l)
        call UnitAddAbility(c, v)
    endif
    set v = GetStoredInteger(g, m, "ability_d")     
     if v > 0 then
        set a = "Ability_d"+I2S(v)
        set l = GetTableInt(s, a)+1
        call SetTableInt(s, a, l)
        call UnitAddAbility(c, v)
    endif   
//==============================================
    call InventorySwapMenu(c, s, 0, 0, 0, 0)
    set e = null
    set f = null
    set g = null
endfunction

function UnequipItem takes unit c, string s, item i, string es returns nothing
    local item f = GetTableItem(s, es+"Filler")
    local string x
    local gamecache g = InventoryCache()
    local string m = I2S(CS_H2I(i))
    local integer v
    local string a
    local integer l
    call AddItemToQuickMenu(c, s, i, false)
    call SetTableObject(s, es+"Item", f)
    call InventoryAddItem(c, f)
    call UnitDropItemSlot(c, f, FillerNameToSlot(es))
    set x = GetStoredString(g, m, "OnDrop")
    if x != "" and x != null then
        call ExecuteFunc(x)
    endif
    set v = GetStoredInteger(g, m, "damage")
    if v > 0 then
        call UnitAddBonus(c, 0, -v)
    endif
    set v = GetStoredInteger(g, m, "armor")
    if v > 0 then
        call UnitAddBonus(c, 1, -v)
    endif
    set v = GetStoredInteger(g, m, "hitpoints")
    if v > 0 then
        call UnitAddBonus(c, 2, -v)
    endif
    set v = GetStoredInteger(g, m, "manapoints")
    if v > 0 then
        call UnitAddBonus(c, 3, -v)
    endif
    set v = GetStoredInteger(g, m, "strength")
    if v > 0 then
        call SetHeroStr(c, GetHeroStr(c, false)-v, true)
    endif
    set v = GetStoredInteger(g, m, "agility")
    if v > 0 then
        call SetHeroAgi(c, GetHeroAgi(c, false)-v, true)
    endif
    set v = GetStoredInteger(g, m, "intelligence")
    if v > 0 then
        call SetHeroInt(c, GetHeroInt(c, false)-v, true)
    endif
//============================================
    set v = GetStoredInteger(g, m, "ability_a")
    if v > 0 then
        set a = "Ability_a"+I2S(v)
        set l = GetTableInt(s, a)-1
        call SetTableInt(s, a, l)
        if l < 1 then
            call UnitRemoveAbility(c, v)
        endif
    endif
    set v = GetStoredInteger(g, m, "ability_b")
    if v > 0 then
        set a = "Ability_b"+I2S(v)
        set l = GetTableInt(s, a)-1
        call SetTableInt(s, a, l)
        if l < 1 then
            call UnitRemoveAbility(c, v)
        endif
    endif
     set v = GetStoredInteger(g, m, "ability_c")
    if v > 0 then
        set a = "Ability_c"+I2S(v)
        set l = GetTableInt(s, a)-1
        call SetTableInt(s, a, l)
        if l < 1 then
            call UnitRemoveAbility(c, v)
        endif
    endif

     set v = GetStoredInteger(g, m, "ability_d")
    if v > 0 then
        set a = "Ability_d"+I2S(v)
        set l = GetTableInt(s, a)-1
        call SetTableInt(s, a, l)
        if l < 1 then
            call UnitRemoveAbility(c, v)
        endif
    endif   
//============================================
    set f = null
    set g = null
endfunction

function InventoryDragItemConditions takes nothing returns boolean
    local integer i = GetIssuedOrderId()
    return i > 852001 and i < 852008 and IsUnitInGroup(GetOrderedUnit(), udg_AAAInventoryGroup) and GetOrderTargetItem() != UnitItemInSlot(GetOrderedUnit(), i-852002)
endfunction

function InventoryDragItemActions takes nothing returns nothing
    local unit c = GetOrderedUnit()
    local string s = GetAttachedString(c, "InventoryTable")
    local item d = GetOrderTargetItem()
    local integer ts = GetIssuedOrderId()-852002
    local item t = UnitItemInSlot(c, ts)
    local integer m = GetTableInt(s, "CurrentMenu")

    local integer i = GetItemSlot(c, d)
    local item e = GetTableItem(s, "EquipmentMenu")
    local item b = GetTableItem(s, "BackpackMenu")
    local item ca = GetTableItem(s, "Cancel")
    local item sw = GetTableItem(s, "SwitchPage")
    local integer p = GetTableInt(s, "CurrentBackpackPage")
    local string es = GetItemEquipmentSlot(d)
    if m == 0 then
        if t == GetTableItem(s, "BackpackMenu") and d != e then
            if BackpackHasEmptySlots(s) then
                call AddItemToBackpack(c, s, d)
            elseif d != t and t == b then
                call InventoryError(c, "Backpack is full.")
            endif
        else
            if d == e and ts != 4 then
                call InventoryError(c, "Unable to drop this item.")
            elseif d == b and ts != 5 then
                call InventoryError(c, "Unable to drop this item.")
            elseif t == e and d != b then
                if IsEquipmentSlotValid(es) then
                    call EquipItem(c, s, d, es)
                else
                    call InventoryError(c, "Item is not equipable.")
                endif
            elseif ts == 5 and d != b  then
                call InventoryError(c, "Can not add this item to your backpack.")
            endif
        endif
    elseif m == 1 then
        if t == ca then
            if QuickMenuHasEmptySlots(s) then
                call UnequipItem(c, s, d, es)
            else
                call InventoryError(c, "Quick page is full.")
            endif
        else
            call InventoryError(c, "Unable to drop this item.")
        endif
    elseif m == 2 then
        if t == ca and d != sw then
            if QuickMenuHasEmptySlots(s) then
                call AddItemToQuickMenu(c, s, d, true)
                call InventorySwapMenu(c, s, 2, 2, p, p)
            else
                call InventoryError(c, "Quick page is full.")
            endif
        elseif t == sw then
            call InventoryError(c, "Unable to drop this item.")
        elseif t == ca and d != sw then
            call InventoryError(c, "Unable to drop this item.")
        elseif d == ca and ts != 5 then
            call InventoryError(c, "Unable to drop this item.")
        elseif d == sw and ts != 4 then
            call InventoryError(c, "Unable to drop this item.")
        endif
    endif
    set c = null
    set d = null
    set t = null
    set e = null
    set b = null
    set ca = null
    set sw = null
endfunction

function InventoryUnitUsesItemConditions takes nothing returns boolean
    local integer i = GetItemTypeId(GetManipulatedItem())
    return IsUnitInGroup(GetManipulatingUnit(), udg_AAAInventoryGroup) and (i == Cancel_ItemID() or i == BackpackMenu_ItemID() or i == SwitchPage_ItemID() or i == EquipmentMenu_ItemID())
endfunction

function InventoryUnitUsesItemActions takes nothing returns nothing
    local unit c = GetManipulatingUnit()
    local string s = GetAttachedString(c, "InventoryTable")
    local item m = GetManipulatedItem()
    local integer g = GetItemCharges(m)
    local string ts = ""
    local integer ti = 0
    local integer a
    local integer e = GetTableInt(s, "CurrentMenu")
    local integer i = GetItemTypeId(m)
    local integer o = GetTableInt(s, "CurrentBackpackPage")
    local integer n = o + 1
    if n > BackpackSize()/4 then
        set n = 1
    endif
    if m == GetTableItem(s, "Cancel") then
        set ti = Cancel_ItemID()
        set ts = "Cancel"
    elseif m == GetTableItem(s, "BackpackMenu") then
        set ti = BackpackMenu_ItemID()
        set ts = "BackpackMenu"
    elseif m == GetTableItem(s, "EquipmentMenu") then
         set ti = EquipmentMenu_ItemID()
        set ts = "EquipmentMenu"
    elseif m == GetTableItem(s, "SwitchPage") then
        set ti = SwitchPage_ItemID()
        set ts = "SwitchPage"
    endif
    if g == 0 and (i == BackpackMenu_ItemID() or i == SwitchPage_ItemID()) then
        set a = GetItemSlot(c, m)
        call RemoveItem(m)
        call UnitAddItemToSlotById(c, ti, a)
        set m = UnitItemInSlot(c, a)
        call SetTableObject(s, ts, m)
        call SetItemCharges(m, g+1)
    else
        call SetItemCharges(m, 0)
    endif
    call CompressBackpack(s)
    if i == EquipmentMenu_ItemID() then
        call InventorySwapMenu(c, s, e, 1, 0, 0)
    elseif i == BackpackMenu_ItemID() then
        call InventorySwapMenu(c, s, e, 2, o, o)
    elseif i == SwitchPage_ItemID() then
        call InventorySwapMenu(c, s, e, 2, o, n)
    elseif i == Cancel_ItemID() then
        call InventorySwapMenu(c, s, e, 0, o, o)
        call SetItemCharges(GetTableItem(s, "BackpackMenu"), GetTableInt(s, "BackpackItemsCount"))
    endif
    set c = null
    set m = null
endfunction

function UnitReAddItem_Child takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local string s = GetAttachmentTable(t)
    local unit u = GetTableUnit(s, "Unit")
    local item i = GetTableItem(s, "Item")
    if IsItemOwned(i) and not UnitHasItem(u, i) then
        call SetItemUserData(i, 2)
    endif
    call UnitAddItem(u, i)
    call UnitDropItemSlot(u, i, GetTableInt(s, "Slot"))
    call ClearTable(s)
    call DestroyTimer(t)
    set t = null
    set u = null
    set i = null
endfunction

function UnitReAddItem takes unit u, item i, integer s returns nothing
    local timer t = CreateTimer()
    local string a = GetAttachmentTable(t)
    call SetTableObject(a, "Unit", u)
    call SetTableObject(a, "Item", i)
    call SetTableInt(a, "Slot", s)
    call TimerStart(t, 0, false, function UnitReAddItem_Child)
    set t = null
endfunction

function InventoryDropItemConditions takes nothing returns boolean
    local integer i = GetItemTypeId(GetManipulatedItem())
    if not IsUnitInGroup(GetManipulatingUnit(), udg_AAAInventoryGroup) then
        return false
    endif
    if (i == EquipmentMenu_ItemID() or i == BackpackMenu_ItemID() or i == Cancel_ItemID() or i == SwitchPage_ItemID()) and (GetItemUserData(GetManipulatedItem()) == 0) then
        return true
    endif
    if GetItemUserData(GetManipulatedItem()) == 2 then
        call SetItemUserData(GetManipulatedItem(), 0)
        return false
    endif
    return GetTableInt(GetAttachedString(GetManipulatingUnit(), "InventoryTable"), "CurrentMenu") > 0 and (GetItemUserData(GetManipulatedItem()) == 0)
endfunction

function InventoryDropItemActions takes nothing returns nothing
    local unit c = GetManipulatingUnit()
    local string s = GetAttachedString(c, "InventoryTable")
    local item i = GetManipulatedItem()
    local integer d = GetItemTypeId(i)
    if GetItemType(i) == ITEM_TYPE_CHARGED and GetItemCharges(i) == 0 then
         set d = GetTableInt(s, "CurrentBackpackPage")
         call InventorySwapMenu(c, s, 2, 2, d, d)
    elseif d == EquipmentMenu_ItemID() or d == SwitchPage_ItemID() then
        call UnitReAddItem(c, i, 4)
        call CS_Error(GetOwningPlayer(c), "Unable to drop this item.")
    elseif d == BackpackMenu_ItemID() or d == Cancel_ItemID() then
        call UnitReAddItem(c, i, 5)
        call CS_Error(GetOwningPlayer(c), "Unable to drop this item.")
    elseif GetTableInt(s, "CurrentMenu") > 0 then
        call UnitReAddItem(c, i, GetItemSlot(c, i))
        call CS_Error(GetOwningPlayer(c), "Can only drop items from the quick menu.")
    endif
    set c = null
    set i = null
endfunction

function InventoryOrderConditions takes nothing returns boolean
    if not IsUnitInGroup(GetOrderedUnit(), udg_AAAInventoryGroup) or GetIssuedOrderId() != OrderId("smart") or GetOrderTargetItem() == null then
        return false
    endif
    return GetTableInt(GetAttachedString(GetOrderedUnit(), "InventoryTable"), "CurrentMenu") > 0
endfunction

function InventoryOrderActions takes nothing returns nothing
    local unit c = GetOrderedUnit()
    local string s = GetAttachedString(c, "InventoryTable")
    call InventorySwapMenu(c, s, GetTableInt(s, "CurrentMenu"), 0, GetTableInt(s, "CurrentBackpackPage"), 0)
    call IssueTargetOrder(c, "smart", GetOrderTargetItem())
    set c = null
endfunction

function Init_AAAInventory takes nothing returns nothing
    local trigger t = CreateTrigger()
    local trigger u = CreateTrigger()
    local trigger d = CreateTrigger()
    local trigger o = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER)
    call TriggerAddCondition(t, Condition( function InventoryDragItemConditions))
    call TriggerAddAction(t, function InventoryDragItemActions)
    call TriggerRegisterAnyUnitEventBJ( u, EVENT_PLAYER_UNIT_USE_ITEM )
    call TriggerAddCondition(u, Condition(function InventoryUnitUsesItemConditions))
    call TriggerAddAction(u, function InventoryUnitUsesItemActions)
    call TriggerRegisterAnyUnitEventBJ( d, EVENT_PLAYER_UNIT_DROP_ITEM )
    call TriggerAddCondition(d, Condition(function InventoryDropItemConditions))
    call TriggerAddAction(d, function InventoryDropItemActions)
    call TriggerRegisterAnyUnitEventBJ(o, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER)
    call TriggerAddCondition(o, Condition(function InventoryOrderConditions))
    call TriggerAddAction(o, function InventoryOrderActions)
    set t = null
    set u = null
    set d = null
    set o = null
endfunction

//===========================================================================
function InitTrig_AAAInventory takes nothing returns nothing
    call ExecuteFunc("Init_AAAInventory")
endfunction

[/jass]
发表于 2008-12-14 21:31:54 | 显示全部楼层


连功能都不讲一下的饿?

过长~~~~~~无时间饿
回复

使用道具 举报

发表于 2008-12-14 21:32:42 | 显示全部楼层
建议 过长的弄成文本然后

解说多些
回复

使用道具 举报

发表于 2008-12-14 21:32:55 | 显示全部楼层
  [s:166]


有何用处?
回复

使用道具 举报

 楼主| 发表于 2008-12-30 20:22:58 | 显示全部楼层
另外一个装备系统
[jass]
function FixHero takes unit hero, integer playernumber returns nothing
    local integer a = 1
    loop
        exitwhen a > udg_int
        call UnitAddAbility( hero, udg_AAAbilities[a] )
        call UnitRemoveAbility( hero, udg_AAAbilities[a] )
        call UnitAddAbility( hero, udg_h[a] )
        set a = a + 1
    endloop
    set a = 1
    loop
        exitwhen a > udg_int
        call SetPlayerAbilityAvailable( Player(playernumber-1), udg_AAAbilities[a], false )
        call SetPlayerAbilityAvailable( Player(playernumber-1), udg_h[a], false )
        set a = a + 1
    endloop
    call UnitAddAbility( hero, 'A000' )
    call UnitAddAbility( hero, 'A00O' )
    call UnitAddAbility( hero, 'A00P' )
    call UnitAddAbility( hero, 'A023' )
    call UnitAddAbility( hero, 'A024' )
    call UnitAddAbility( hero, 'A025' )
    call UnitAddAbility( hero, 'A026' )
    call UnitAddAbility( hero, 'A027' )
    call SetPlayerAbilityAvailable( Player(playernumber-1), 'A027', false )
    set hero = null
endfunction

function GetConvertedInteger takes integer i returns string
    if i >= 1 and i <= 2 then //Shoulder
        return "1"
    elseif i >= 3 and i <= 5 then //Head
        return "2"
    elseif i >= 6 and i <= 7 then //Neck
        return "3"
    elseif i >= 8 and i <= 9 then //Finger
        return "4"
    elseif i >= 10 and i <= 11 then //Right Hand
        return "5"
    elseif i >= 12 and i <= 13 then //Chest
        return "6"
    elseif i >= 14 and i <= 14 then //Left Hand
        return "7"
    elseif i >= 15 and i <= 16 then //Wrist
        return "8"
    elseif i >= 17 and i <= 18 then //Feet
        return "9"
    elseif i >= 19 and i <= 20 then //Legs
        return "10"
    elseif i >= 21 and i <= 22 then //Hands
        return "11"
    endif
    return ""
endfunction

function SetArmor takes unit hero, integer amount, boolean increase returns nothing
    local integer a = 1
    if increase then
        loop
            exitwhen a > amount
            call IncUnitAbilityLevel( hero, 'A00O' )
            set a = a + 1
        endloop
    else
        loop
            exitwhen a > amount
            call DecUnitAbilityLevel( hero, 'A00O' )
            set a = a + 1
        endloop
    endif
    set hero = null
endfunction

function SetDamage takes unit hero, integer amount, boolean increase returns nothing
    local integer a = 1
    if increase then
        loop
            exitwhen a > amount
            call IncUnitAbilityLevel( hero, 'A00P' )
            set a = a + 1
        endloop
    else
        loop
            exitwhen a > amount
            call DecUnitAbilityLevel( hero, 'A00P' )
            set a = a + 1
        endloop
    endif
    set hero = null
endfunction

function SetMove takes unit hero, integer amount, boolean increase returns nothing
    local integer a = 1
    if increase then
        loop
            exitwhen a > amount
            call IncUnitAbilityLevel( hero, 'A026' )
            set a = a + 1
        endloop
    else
        loop
            exitwhen a > amount
            call DecUnitAbilityLevel( hero, 'A026' )
            set a = a + 1
        endloop
    endif
    set hero = null
endfunction

function SetDodge takes unit hero, integer amount, boolean increase returns nothing
    local integer a = 1
    if increase then
        loop
            exitwhen a > amount
            call IncUnitAbilityLevel( hero, 'A028' )
            set a = a + 1
        endloop
    else
        loop
            exitwhen a > amount
            call DecUnitAbilityLevel( hero, 'A028' )
            set a = a + 1
        endloop
    endif
    set hero = null
endfunction

function SetHpMana takes unit hero, integer amount, boolean increase, boolean hp returns nothing
    local integer a = 1
    if hp then
        if increase then
            loop
               exitwhen a > amount
                call UnitAddAbility( hero, 'A00U' )
                call SetUnitAbilityLevel( hero, 'A00U', '2' )
                call UnitRemoveAbility( hero, 'A00U' )
                set a = a + 1
            endloop
        else
            loop
                exitwhen a > amount
                call UnitAddAbility( hero, 'A00S' )
                call SetUnitAbilityLevel( hero, 'A00S', '2' )
                call UnitRemoveAbility( hero, 'A00S' )
                set a = a + 1
            endloop
        endif
    else
        if increase then
            loop
                exitwhen a > amount
                call UnitAddAbility( hero, 'A00V' )
                call SetUnitAbilityLevel( hero, 'A00V', '2' )
                call UnitRemoveAbility( hero, 'A00V' )
                set a = a + 1
            endloop
        else
            loop
                exitwhen a > amount
                call UnitAddAbility( hero, 'A00T' )
                call SetUnitAbilityLevel( hero, 'A00T', '2' )
                call UnitRemoveAbility( hero, 'A00T' )
                set a = a + 1
            endloop
        endif
    endif
    set hero = null
endfunction

function SetStat takes unit hero, integer amount, boolean increase, string stat returns nothing
    local integer a = 1
    if stat == "int" then
        if increase then
            loop
                exitwhen a > amount
                call IncUnitAbilityLevel( hero, 'A023' )
                set a = a + 1
            endloop
        else
            loop
                exitwhen a > amount
                call DecUnitAbilityLevel( hero, 'A023' )
                set a = a + 1
            endloop
        endif
    elseif stat == "str" then
        if increase then
            loop
                exitwhen a > amount
                call IncUnitAbilityLevel( hero, 'A024' )
                set a = a + 1
            endloop
        else
            loop
                exitwhen a > amount
                call DecUnitAbilityLevel( hero, 'A024' )
                set a = a + 1
            endloop
        endif
    elseif stat == "agi" then
        if increase then
            loop
                exitwhen a > amount
                call IncUnitAbilityLevel( hero, 'A025' )
                set a = a + 1
            endloop
        else
            loop
                exitwhen a > amount
                call DecUnitAbilityLevel( hero, 'A025' )
                set a = a + 1
            endloop
        endif
    endif
    set hero = null
endfunction

function TestSET takes integer i, integer playernumber, unit u, boolean increase returns nothing
    if i == 2 or i == 5 or i == 7 or i == 9 or i == 11 or i == 13 or i == 16 or i == 18 or i == 20 or i == 22 then
        if increase then
            set udg_SET_Arcanist[playernumber] = udg_SET_Arcanist[playernumber] + 1
            if udg_SET_Arcanist[playernumber] >= 2 then
                call SetArmor(u, 2, true)
            endif
        else
            set udg_SET_Arcanist[playernumber] = udg_SET_Arcanist[playernumber] - 1
            if udg_SET_Arcanist[playernumber] >= 1 then
                call SetArmor(u, 2, false)
            endif
        endif
    endif
    set u = null
endfunction
[/jass]
回复

使用道具 举报

 楼主| 发表于 2008-12-30 20:26:22 | 显示全部楼层
[jass]
function InitTrig_Disable_Abilities takes nothing returns nothing
    local integer a = 1
    local integer b = 0
    set udg_gc = InitGameCache("cache")
    set udg_int = 22
    //DISABLED VERSIONS
    //EMPTY SPE
    set udg_h[1] = 'A015'//Shoulder Shoulder
    set udg_h[2] = 'A015'//Shoulder Mantle
    set udg_h[3] = 'A00W'//Head Crown
    set udg_h[4] = 'A00W'//Head Helm
    set udg_h[5] = 'A00W'//Head Hood
    set udg_h[6] = 'A00X'//Neck Amulet
    set udg_h[7] = 'A00X'//Neck Talisman
    set udg_h[8] = 'A00Y'//Finger Ring
    set udg_h[9] = 'A00Y'//Finger Ring
    set udg_h[10] = 'A00Z'//RightHand Sword
    set udg_h[11] = 'A00Z'//RightHand Staff
    set udg_h[12] = 'A010'//Chest
    set udg_h[13] = 'A010'//Chest Robe
    set udg_h[14] = 'A011'//LeftHand Shield
    set udg_h[15] = 'A012'//Bracelet Bracelet
    set udg_h[16] = 'A012'//Bracelet Binding
    set udg_h[17] = 'A013'//Feet Boots
    set udg_h[18] = 'A013'//Feet Boots
    set udg_h[19] = 'A014'//Legs Legs
    set udg_h[20] = 'A014'//Legs Leggings
    set udg_h[21] = 'A016'//Hands Gloves
    set udg_h[22] = 'A016'//Hands Gloves
    //ITEMS
    set udg_AAItems[1] = 'I000'//Plate Shoulders
    set udg_AAItems[2] = 'I00I'//Arcanist Mantle
    set udg_AAItems[3] = 'I00C'//Death Crown
    set udg_AAItems[4] = 'I001'//Helm of Kings
    set udg_AAItems[5] = 'I00G'//Arcanist Hood
    set udg_AAItems[6] = 'I002'//Amulet of Death
    set udg_AAItems[7] = 'I00L'//Arcanist Talisman
    set udg_AAItems[8] = 'I003'//Ring of Intelligence
    set udg_AAItems[9] = 'I00K'//Arcanist Ring
    set udg_AAItems[10] = 'I004'//Sword of Retribution
    set udg_AAItems[11] = 'I00H'//Arcanist Staff
    set udg_AAItems[12] = 'I005'//Thrall's Pride
    set udg_AAItems[13] = 'I00F'//Arcanist Robes
    set udg_AAItems[14] = 'I006'//Shield of Protection
    set udg_AAItems[15] = 'I007'//Bracelet of Power
    set udg_AAItems[16] = 'I00E'//Arcanist Bindings
    set udg_AAItems[17] = 'I008'//Leather Boots
    set udg_AAItems[18] = 'I00B'//Arcanist Boots
    set udg_AAItems[19] = 'I009'//Hunter's Legs
    set udg_AAItems[20] = 'I00J'//Arcanist Leggings
    set udg_AAItems[21] = 'I00A'//Gloves of Invulnerability
    set udg_AAItems[22] = 'I00D'//Arcanist Gloves
    //ABILITY
    set udg_AAAbilities2[1] = 'A00C'//Plate Shoulders
    set udg_AAAbilities2[2] = 'A01K'//Arcanist Mantle
    set udg_AAAbilities2[3] = 'A00Q'//Death Crown
    set udg_AAAbilities2[4] = 'A00D'//Helm of Kings
    set udg_AAAbilities2[5] = 'A01O'//Arcanist Hood
    set udg_AAAbilities2[6] = 'A00E'//Amulet of Death
    set udg_AAAbilities2[7] = 'A01N'//Arcanist Talisman
    set udg_AAAbilities2[8] = 'A00F'//Ring of Intelligence
    set udg_AAAbilities2[9] = 'A01J'//Arcanist Ring
    set udg_AAAbilities2[10] = 'A00G'//Sword of Retribution
    set udg_AAAbilities2[11] = 'A01L'//Arcanist Staff
    set udg_AAAbilities2[12] = 'A00H'//Thrall's Pride
    set udg_AAAbilities2[13] = 'A01Q'//Arcanist Robes
    set udg_AAAbilities2[14] = 'A00I'//Shield of Protection
    set udg_AAAbilities2[15] = 'A00J'//Bracelet of Power
    set udg_AAAbilities2[16] = 'A01R'//Arcanist Bindings
    set udg_AAAbilities2[17] = 'A00K'//Leather Boots
    set udg_AAAbilities2[18] = 'A01S'//Arcanist Boots
    set udg_AAAbilities2[19] = 'A00L'//Hunter's Legs
    set udg_AAAbilities2[20] = 'A01M'//Arcanist Leggings
    set udg_AAAbilities2[21] = 'A00M'//Gloves of Invulnerability
    set udg_AAAbilities2[22] = 'A01P'//Arcanist Gloves
    //ABILITY SPE
    set udg_AAAbilities[1] = 'A001'//Plate Shoulders¨
    set udg_AAAbilities[2] = 'A021'//Arcanist Mantle
    set udg_AAAbilities[3] = 'A00R'//Death Crown
    set udg_AAAbilities[4] = 'A002'//Helm of Kings
    set udg_AAAbilities[5] = 'A01Z'//Arcanist Hood
    set udg_AAAbilities[6] = 'A003'//Amulet of Death
    set udg_AAAbilities[7] = 'A020'//Arcanist Talisman
    set udg_AAAbilities[8] = 'A004'//Ring of Intelligence
    set udg_AAAbilities[9] = 'A01U'//Arcanist Ring
    set udg_AAAbilities[10] = 'A005'//Sword of Retribution
    set udg_AAAbilities[11] = 'A01W'//Arcanist Staff
    set udg_AAAbilities[12] = 'A006'//Thrall's Pride
    set udg_AAAbilities[13] = 'A01T'//Arcanist Robes
    set udg_AAAbilities[14] = 'A007'//Shield of Protection
    set udg_AAAbilities[15] = 'A008'//Bracelet of Power
    set udg_AAAbilities[16] = 'A01X'//Arcanist Bindings
    set udg_AAAbilities[17] = 'A009'//Leather Boots
    set udg_AAAbilities[18] = 'A01V'//Arcanist Boots
    set udg_AAAbilities[19] = 'A00A'//Hunter's Legs
    set udg_AAAbilities[20] = 'A022'//Arcanist Leggings
    set udg_AAAbilities[21] = 'A00B'//Gloves of Invulnerability
    set udg_AAAbilities[22] = 'A01Y'//Arcanist Gloves
    //EQUIP
    set udg_Function[1] = "A00C" //Plate Shoulders
    set udg_Function[2] = "A01K" //Arcanist Mantle
    set udg_Function[3] = "A00Q" //Death Crown
    set udg_Function[4] = "A00D" //Helm of Kings
    set udg_Function[5] = "A01O" //Arcanist Hood
    set udg_Function[6] = "A00E" //Amulet of Death
    set udg_Function[7] = "A01N" //Arcanist Talisman
    set udg_Function[8] = "A00F" //Ring of Intelligence
    set udg_Function[9] = "A01J" //Arcanist Ring
    set udg_Function[10] = "A00G" //Sword of Retribution
    set udg_Function[11] = "A01L" //Arcanist Staff
    set udg_Function[12] = "A00H" //Thrall's Pride
    set udg_Function[13] = "A01Q" //Arcanist Robes
    set udg_Function[14] = "A00I" //Shield of Protection
    set udg_Function[15] = "A00J" //Bracelet of Power
    set udg_Function[16] = "A01R" //Arcanist Bindings
    set udg_Function[17] = "A00K" //Leather Boots
    set udg_Function[18] = "A01S" //Arcanist Boots
    set udg_Function[19] = "A00L" //Hunter's Legs
    set udg_Function[20] = "A01M" //Hunter's Legs
    set udg_Function[21] = "A00M" //Gloves of Invulnerability
    set udg_Function[22] = "A01P" //Gloves of Invulnerability
    //UNEQUIP
    set udg_Function2[1] = "A001" //Plate Shoulders
    set udg_Function2[2] = "A021" //Plate Shoulders
    set udg_Function2[3] = "A00R" //Death Crown
    set udg_Function2[4] = "A002" //Helm of Kings
    set udg_Function2[5] = "A01Z" //Helm of Kings
    set udg_Function2[6] = "A003" //Amulet of Death
    set udg_Function2[7] = "A020" //Amulet of Death
    set udg_Function2[8] = "A004" //Ring of Intelligence
    set udg_Function2[9] = "A01U" //Ring of Intelligence
    set udg_Function2[10] = "A005" //Sword of Retribution
    set udg_Function2[11] = "A01W" //Sword of Retribution
    set udg_Function2[12] = "A006" //Thrall's Pride
    set udg_Function2[13] = "A01T" //Thrall's Pride
    set udg_Function2[14] = "A007" //Shield of Protection
    set udg_Function2[15] = "A008" //Bracelet of Power
    set udg_Function2[16] = "A01X" //Bracelet of Power
    set udg_Function2[17] = "A009" //Leather Boots
    set udg_Function2[18] = "A01V" //Leather Boots
    set udg_Function2[19] = "A00A" //Hunter's Legs
    set udg_Function2[20] = "A022" //Hunter's Legs
    set udg_Function2[21] = "A00B" //Gloves of Invulnerability
    set udg_Function2[22] = "A01Y" //Gloves of Invulnerability
    //
    call FixHero(gg_unit_Hpal_0000,1)
    call FixHero(gg_unit_Hamg_0037,3)
    call FixHero(gg_unit_Hmkg_0038,2)
endfunction


[/jass]

[jass]
function A00C takes nothing returns nothing//Plate Shoulders
    call SetArmor(GetTriggerUnit(), 2, true)
endfunction
function A01K takes nothing returns nothing//Arcanist Mantle
    call SetArmor(GetTriggerUnit(), 4, true)
    call SetStat(GetTriggerUnit(), 3, true, "int")
endfunction
function A00Q takes nothing returns nothing//Death Crown
    call SetHpMana(GetTriggerUnit(), 25, true, true)
    call SetDamage(GetTriggerUnit(), 3, true)
endfunction
function A00D takes nothing returns nothing//Helm of Kings
    call SetArmor(GetTriggerUnit(), 2, true)
    call SetStat(GetTriggerUnit(), 1, true, "int")
    call SetStat(GetTriggerUnit(), 1, true, "str")
    call SetStat(GetTriggerUnit(), 1, true, "agi")
endfunction
function A01O takes nothing returns nothing//Arcanist Hood
    call SetHpMana(GetTriggerUnit(), 40, true, false)
    call SetHpMana(GetTriggerUnit(), 10, true, true)
endfunction
function A00E takes nothing returns nothing//Amulet of Death
    call SetDamage(GetTriggerUnit(), 4, true)
endfunction
function A01N takes nothing returns nothing//Arcanist Talisman
    call SetStat(GetTriggerUnit(), 4, true, "int")
endfunction
function A00F takes nothing returns nothing//Ring of Intelligence
    call SetStat(GetTriggerUnit(), 2, true, "int")
    call SetHpMana(GetTriggerUnit(), 15, true, false)
endfunction
function A01J takes nothing returns nothing//Arcanist Ring
    call SetArmor(GetTriggerUnit(), 2, true)
    call SetHpMana(GetTriggerUnit(), 15, true, false)
endfunction
function A00G takes nothing returns nothing//Sword of Retribution
    call SetDamage(GetTriggerUnit(), 8, true)
endfunction
function A01L takes nothing returns nothing//Arcanist Staff
    call SetStat(GetTriggerUnit(), 2, true, "int")
    call SetDamage(GetTriggerUnit(), 7, true)
endfunction
function A00H takes nothing returns nothing//Thrall's Pride
    call SetArmor(GetTriggerUnit(), 10, true)
    call SetDodge(GetTriggerUnit(), 3, true)
endfunction
function A01Q takes nothing returns nothing//Arcanist Robes
    call SetArmor(GetTriggerUnit(), 6, true)
    call SetStat(GetTriggerUnit(), 5, true, "int")
endfunction
function A00I takes nothing returns nothing//Shield of Protection
    call SetArmor(GetTriggerUnit(), 4, true)
    call SetDodge(GetTriggerUnit(), 7, true)
endfunction
function A00J takes nothing returns nothing//Bracelet of Power
    call SetStat(GetTriggerUnit(), 3, true, "str")
endfunction
function A01R takes nothing returns nothing//Arcanist Bindings
    call SetStat(GetTriggerUnit(), 2, true, "int")
endfunction
function A00K takes nothing returns nothing//Leather Boots
    call SetArmor(GetTriggerUnit(), 3, true)
    call SetMove(GetTriggerUnit(), 4, true)
endfunction
function A01S takes nothing returns nothing//Arcanist Boots
    call SetArmor(GetTriggerUnit(), 3, true)
    call SetMove(GetTriggerUnit(), 8, true)
endfunction
function A00L takes nothing returns nothing//Hunter's Legs
    call SetArmor(GetTriggerUnit(), 6, true)
endfunction
function A01M takes nothing returns nothing//Arcanist Leggings
    call SetArmor(GetTriggerUnit(), 3, true)
endfunction
function A00M takes nothing returns nothing//Gloves of Invulnerability
    call SetArmor(GetTriggerUnit(), 2, true)
endfunction
function A01P takes nothing returns nothing//Arcanist Gloves
    call SetArmor(GetTriggerUnit(), 2, true)
endfunction

function Trig_Equip_Arms_Copy_Actions takes nothing returns nothing
    local integer a = 1
    local unit u = GetTriggerUnit()
    local string s = I2S(GetPlayerId(GetOwningPlayer(u)))
    loop
        exitwhen a > udg_int
        if GetItemTypeId(GetManipulatedItem()) == udg_AAItems[a] and not GetStoredBoolean(udg_gc, s, GetConvertedInteger(a)) then
            call UnitRemoveAbility( u, udg_h[a] )
            call UnitAddAbility( u, udg_AAAbilities[a] )
            call ExecuteFunc( udg_Function[a] )
            call RemoveItem( GetManipulatedItem() )
            call StoreBoolean(udg_gc, s, GetConvertedInteger(a), true)
            call ForceUIKeyBJ( GetOwningPlayer(u), "I" )
            call TestSET(a, GetPlayerId(GetOwningPlayer(u)), u, true)
            return
        endif
        set a = a + 1
    endloop
    set u = null
endfunction

//===========================================================================
function InitTrig_Equip takes nothing returns nothing
    set gg_trg_Equip = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Equip, EVENT_PLAYER_UNIT_USE_ITEM )
    call TriggerAddAction( gg_trg_Equip, function Trig_Equip_Arms_Copy_Actions )
endfunction


[/jass]

[jass]
function Trig_Unequip_Arms_Copy_2_Conditions takes nothing returns boolean
    return ( GetSpellAbilityId() != 'A00N' )
endfunction

function A001 takes nothing returns nothing
    call SetArmor(GetTriggerUnit(), 2, false)
endfunction
function A021 takes nothing returns nothing
    call SetArmor(GetTriggerUnit(), 4, false)
    call SetStat(GetTriggerUnit(), 3, false, "int")
endfunction
function A00R takes nothing returns nothing
    call SetHpMana(GetTriggerUnit(), 25, false, true)
    call SetDamage(GetTriggerUnit(), 3, false)
endfunction
function A002 takes nothing returns nothing
    call SetArmor(GetTriggerUnit(), 2, false)
    call SetStat(GetTriggerUnit(), 1, false, "int")
    call SetStat(GetTriggerUnit(), 1, false, "str")
    call SetStat(GetTriggerUnit(), 1, false, "agi")
endfunction
function A01Z takes nothing returns nothing
    call SetHpMana(GetTriggerUnit(), 40, false, false)
    call SetHpMana(GetTriggerUnit(), 10, false, true)
endfunction
function A003 takes nothing returns nothing
    call SetDamage(GetTriggerUnit(), 4, false)
endfunction
function A020 takes nothing returns nothing
    call SetStat(GetTriggerUnit(), 4, false, "int")
endfunction
function A004 takes nothing returns nothing
    call SetStat(GetTriggerUnit(), 2, false, "int")
    call SetHpMana(GetTriggerUnit(), 15, false, false)
endfunction
function A01U takes nothing returns nothing
    call SetArmor(GetTriggerUnit(), 2, false)
    call SetHpMana(GetTriggerUnit(), 15, false, false)
endfunction
function A005 takes nothing returns nothing
    call SetDamage(GetTriggerUnit(), 8, false)
endfunction
function A01W takes nothing returns nothing
    call SetStat(GetTriggerUnit(), 2, false, "int")
    call SetDamage(GetTriggerUnit(), 7, false)
endfunction
function A006 takes nothing returns nothing
    call SetArmor(GetTriggerUnit(), 10, false)
    call SetDodge(GetTriggerUnit(), 3, false)
endfunction
function A01T takes nothing returns nothing
    call SetArmor(GetTriggerUnit(), 6, false)
    call SetStat(GetTriggerUnit(), 5, false, "int")
endfunction
function A007 takes nothing returns nothing
    call SetArmor(GetTriggerUnit(), 4, false)
    call SetDodge(GetTriggerUnit(), 7, false)
endfunction
function A008 takes nothing returns nothing
    call SetStat(GetTriggerUnit(), 3, false, "str")
endfunction
function A01X takes nothing returns nothing
    call SetStat(GetTriggerUnit(), 2, false, "int")
endfunction
function A009 takes nothing returns nothing
    call SetArmor(GetTriggerUnit(), 3, false)
    call SetMove(GetTriggerUnit(), 4, false)
endfunction
function A01V takes nothing returns nothing
    call SetArmor(GetTriggerUnit(), 3, false)
    call SetMove(GetTriggerUnit(), 8, false)
endfunction
function A00A takes nothing returns nothing
    call SetArmor(GetTriggerUnit(), 6, false)
endfunction
function A022 takes nothing returns nothing
    call SetArmor(GetTriggerUnit(), 3, false)
endfunction
function A00B takes nothing returns nothing
    call SetArmor(GetTriggerUnit(), 2, false)
endfunction
function A01Y takes nothing returns nothing
    call SetArmor(GetTriggerUnit(), 2, false)
endfunction

function Trig_Unequip_Arms_Copy_2_Actions takes nothing returns nothing
    local integer a = 1
    local unit u = GetTriggerUnit()
    local string s = I2S(GetPlayerId(GetOwningPlayer(u)))
    loop
        exitwhen a > udg_int
        if GetSpellAbilityId() == udg_AAAbilities2[a] and GetStoredBoolean(udg_gc, s, GetConvertedInteger(a)) then
            call UnitRemoveAbility( u, udg_AAAbilities[a] )
            call UnitAddAbility( u, udg_h[a] )
            call UnitAddItemByIdSwapped( udg_AAItems[a], u )
            call ExecuteFunc(udg_Function2[a])
            call FlushStoredBoolean(udg_gc, s, GetConvertedInteger(a))
            call ForceUIKeyBJ( GetOwningPlayer(u), "I" )
            call TestSET(a, GetPlayerId(GetOwningPlayer(u)), u, false)
            return
        endif
        set a = a + 1
    endloop
    set u = null
endfunction

//===========================================================================
function InitTrig_Unequip takes nothing returns nothing
    set gg_trg_Unequip = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Unequip, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_Unequip, Condition( function Trig_Unequip_Arms_Copy_2_Conditions ) )
    call TriggerAddAction( gg_trg_Unequip, function Trig_Unequip_Arms_Copy_2_Actions )
endfunction


[jass]

[/jass]
回复

使用道具 举报

发表于 2008-12-30 20:28:39 | 显示全部楼层
LZ沉浸在自己的领域中呢...
回复

使用道具 举报

发表于 2008-12-31 10:16:13 | 显示全部楼层
物品和技能都需要地图才能体现..
发演示吧
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-24 17:26 , Processed in 0.075137 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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