UnitDropItem
- Parameters
-
inUnit unit
inItemID integer
- comment
- bug
Leaks handle
droppedItem
: In Jass you must set local variables that hold agents (or any child type) tonull
at the end of functions to avoid reference counter leaks.- patch
1.00
- Source
- Blizzard.j
- return type
item
- Source code
function UnitDropItem takes unit inUnit, integer inItemID returns item local real x local real y local real radius = 32 local real unitX local real unitY local item droppedItem if (inItemID == -1) then return null endif set unitX = GetUnitX(inUnit) set unitY = GetUnitY(inUnit) set x = GetRandomReal(unitX - radius, unitX + radius) set y = GetRandomReal(unitY - radius, unitY + radius) set droppedItem = CreateItem(inItemID, x, y) call SetItemDropID(droppedItem, GetUnitTypeId(inUnit)) call UpdateStockAvailability(droppedItem) return droppedItem endfunction