function ItemTable000000_DropItems takes nothing returns nothing
local widget trigWidget = null
local unit trigUnit = null
local integer itemID = 0
local boolean canDrop = true
set trigWidget = bj_lastDyingWidget
if (trigWidget == null) then
set trigUnit = GetTriggerUnit()
endif
if (trigUnit != null) then
set canDrop = not IsUnitHidden(trigUnit)
if (canDrop and GetChangingUnit() != null) then
set canDrop = (GetChangingUnitPrevOwner() == Player(PLAYER_NEUTRAL_AGGRESSIVE))
endif
endif
if (canDrop) then
// Item set 0
call RandomDistReset( )
call RandomDistAddItem( 'phea', 10 )
call RandomDistAddItem( 'shea', 33 )
call RandomDistAddItem( 'pghe', 33 )
call RandomDistAddItem( -1, 24 )
set itemID = RandomDistChoose( )
if (trigUnit != null) then
call UnitDropItem( trigUnit, itemID )
else
call WidgetDropItem( trigWidget, itemID )
endif
// Item set 1
call RandomDistReset( )
call RandomDistAddItem( 'mnst', 25 )
call RandomDistAddItem( 'pgma', 50 )
call RandomDistAddItem( -1, 25 )
set itemID = RandomDistChoose( )
if (trigUnit != null) then
call UnitDropItem( trigUnit, itemID )
else
call WidgetDropItem( trigWidget, itemID )
endif
endif
set bj_lastDyingWidget = null
call DestroyTrigger(GetTriggeringTrigger())
endfunction
// ...
// creating the unit that is pre-placed on the map
set u = BlzCreateUnitWithSkin( p, 'nftr', 610.5, -74.7, 170.990, 'nftr' )
set t = CreateTrigger( )
call TriggerRegisterUnitEvent( t, u, EVENT_UNIT_DEATH )
call TriggerRegisterUnitEvent( t, u, EVENT_UNIT_CHANGE_OWNER )
call TriggerAddAction( t, function ItemTable000000_DropItems )