• 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.

Item bonuses

Status
Not open for further replies.
Level 6
Joined
Nov 10, 2006
Messages
181
JASS:
 Item bonuses[/b]

Is there a way I can find out how much bonus a Item is giving? Like Agility, Strenght, Intellgience , attack speed , armour , etc.

Some Minor Issues

[code=jass]library BackpackSys

globals
                                  
private constant integer BackpackId = 'BAG1'
    //Change this to the ID of the backpack item in your map.
endglobals

private struct Data
    integer array ItemType[6]
    integer array Charges[6]
    integer array UserData[6]
    static method Create takes unit u returns Data
        local Data d = Data.create()
        local integer i = 0
        local item it
        local integer id
        loop
            set it = UnitItemInSlot(u, i)
            set id = GetItemTypeId(it)
            if GetSpellAbilityId() == BackpackId then
                set d.ItemType[i] = id
                set d.Charges[i] = GetItemCharges(it)
                set d.UserData[i] = GetItemUserData(it)
                call RemoveItem(it)
            else
                set d.ItemType[i] = 0
                set d.Charges[i] = 0
                set d.UserData[i] = 0
            endif
            set i = i + 1
            exitwhen i > 6
        endloop
        set it = null
        return d
    endmethod
endstruct

function ActivateBackpack takes unit whichUnit returns nothing
    local Data d1
    local Data d2 = GetUnitUserData(whichUnit)
    local integer i = 0
    local item it
    if GetSpellAbilityId() == BackpackId then
        set d1 = Data.Create(whichUnit)
        if d2 != 0 then
            loop
                if d2.ItemType[i] != 0  then
                    set it = UnitAddItemById(whichUnit, d2.ItemType[i])
                    call SetItemCharges(it, d2.Charges[i])
                    call SetItemUserData(it, d2.UserData[i])
                endif
                set i = i + 1
                exitwhen i > 6
            endloop
        endif
        call d2.destroy()
        call SetUnitUserData(whichUnit, d1)
    endif
    set it = null
endfunction

endlibrary

When I have full inventory, both from backpack and hero and I cast the spell, one item will always drop, any clues on why that happen?
 
Level 13
Joined
Mar 16, 2008
Messages
941
I think it's possible to get get the stats of an item, but that only includes str/agi/int and some others (create a dummy hero, save his stats in a variable, add the item and subtract these values). A backpack that gives stats with items in it needs to have every item saved with all stats, at least I don't know another way of doing this :/
 
Status
Not open for further replies.
Top