• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Inventory system

Status
Not open for further replies.
Level 4
Joined
Mar 23, 2009
Messages
78
Hi there :)
i'm trying to make my own inventory system, based on a spellbook. there's a doll, and (first) ability based on channel used to remove item from spellbook. i got a trouble - based-on-channel ability (switcher) adds into the end of "item" (spell) list of a spellbook instead of placing into removed doll/previous ability slot. How can i make it add into the right slot?

Here's a
Code:
function InitAll takes nothing returns nothing
    local integer c=1

    loop
        exitwhen c>10
        set udg_ITEMS_ONHERO[c]=c
        set c=c+1
    endloop

    set udg_ABILITY_BASE[1] ='A008'//"Item" list, doll slots are 1-10
    set udg_ABILITY_BASE[2] ='A003'
    set udg_ABILITY_BASE[3] ='A00N'
    set udg_ABILITY_BASE[4] ='A009'
    set udg_ABILITY_BASE[5] ='A00F'
    set udg_ABILITY_BASE[6] ='A00B'
    set udg_ABILITY_BASE[7] ='A00D'
    set udg_ABILITY_BASE[8] ='A00H'
    set udg_ABILITY_BASE[9] ='A00J'
    set udg_ABILITY_BASE[10]='A00L'
    set udg_ABILITY_BASE[11]='A004ю//Sword switcher

    set udg_ITEM_BASE[11] ='I000'//Sword id
endfunction

//Removing abilities, changing value in array
function UnEquipItem takes unit t_unit, integer item_slot returns nothing
    local integer c=1

    loop
        exitwhen c>10
        call UnitRemoveAbility ( t_unit, udg_ABILITY_BASE[udg_ITEMS_ONHERO[c]] )

        set c=c+1
    endloop
  
    set udg_ITEMS_ONHERO[item_slot]=item_slot
endfunction

//Adding "items" back
function EquipItems takes unit t_unit returns nothing
    local integer c=1

    loop
        exitwhen c>10
        call UnitAddAbility ( t_unit, udg_ABILITY_BASE[udg_ITEMS_ONHERO[c]] )
        call SetPlayerAbilityAvailable ( GetOwningPlayer(t_unit), udg_ABILITY_BASE[udg_ITEMS_ONHERO[c]], false )

        set c=c+1
    endloop
endfunction

//Equipping an item (sword)
function ItemStartEquip takes unit t_unit, integer item_id returns nothing
    local integer c=1
    
    loop
        exitwhen c>999
        if udg_ITEM_BASE[c]==item_id then
             if c>10 and c<101 then
                 
                 call UnEquipItem ( t_unit, 2 )
                 set udg_ITEMS_ONHERO[2]=c
                 
                
                 call EquipItems ( t_unit )
             else
             endif
        else
        endif

        set c=c+1
    endloop
endfunction

i could post a whole map if you need.
 
Level 4
Joined
Mar 23, 2009
Messages
78
Thanx for a sample.

Problem is solved by adding and removing all abilities for a first slot, then for a second, and etc to a dummy unit on a map initialization.
 
Status
Not open for further replies.
Top