HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Untested Equal Unit Inventory Swap

09-16-2004, 04:41 AM#1
weaaddar
Thanks to the new 1.17beta natives we can now do a full unit inventory swap without the messy need for adding and removing items. This function should run in linear time, is much less code, and will do as its name suggests swap two units inventories.
Code:
function Hero_swapInv takes unit hero, unit hero2 returns nothing
	local integer i=0
	local item it=null
	loop
		exitwhen i>5
		set it=UnitRemoveItemFromSlot(hero2,i)
		call UnitDropItemSlot(hero2,UnitItemInSlot(hero,i),i)
		call UnitDropItemSlot(hero,it,i)
		set i=i+1
	endloop
	set it=null
endfunction
Would anybody be willing to test it out for me? (Try it with Droppables, it would be interesting, but unneccessary if it works with undroppables as well).