| 02-21-2009, 01:43 AM | #1 |
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 This is suppose to be on when a unit cast a spell (Backpack ability) , and then it takes the current items on the unit/hero slots and then move them to a "Backpack" and when the unit recast the spell , the items are taken out from the "Backpack" to the "hero". So now the item switching back and forth works, now I need to know how do I use UnitProperties to give the hero/unit the mod when in the backpack. Bug spotted, When I have 6 items at the hero and 6 at the backpack, and when I "switch" it , one item always seem to drop on the ground |
| 02-22-2009, 01:12 AM | #2 |
bump |
