function Unit000000_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( 'ratf', 50 )
call RandomDistAddItem( 'gmfr', 50 )
set itemID = RandomDistChoose( )
if (trigUnit != null) then
call UnitDropItem( trigUnit, itemID )
else
call WidgetDropItem( trigWidget, itemID )
endif
// Item set 1
call RandomDistReset( )
call RandomDistAddItem( 'ckng', 75 )
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
function CreateUnitsForPlayer0 takes nothing returns nothing
local player p = Player(0)
local unit u
local integer unitID
local trigger t
local real life
set u = CreateUnit( p, 'hfoo', -4.9, -5.6, 31.170 )
set t = CreateTrigger( )
call TriggerRegisterUnitEvent( t, u, EVENT_UNIT_DEATH )
call TriggerRegisterUnitEvent( t, u, EVENT_UNIT_CHANGE_OWNER )
call TriggerAddAction( t, function Unit000000_DropItems )
endfunction