Code: Select all
function Mn takes unit MN,integer Mo returns item
local item MO
if(Mo==-1)then
return null
endif
set MO=CreateItem(Mo,GetUnitX(MN)+GetRandomReal(-32,32),GetUnitY(MN)+GetRandomReal(-32,32))
call SetItemDropID(MO,GetUnitTypeId(MN))
call UpdateStockAvailability(MO)
set LK=MO
set MO=null
return LK
endfunction
function Mp takes nothing returns nothing
local widget MP=null
local unit Mq=null
local integer MQ=0
local boolean Mr=true
set MP=bj_lastDyingWidget
if(MP==null)then
set Mq=GetTriggerUnit()
endif
if(Mq!=null)then
set Mr=not IsUnitHidden(Mq)
if(Mr and GetChangingUnit()!=null)then
set Mr=(GetChangingUnitPrevOwner()==Player(12))
endif
endif
if(Mr)then
call RandomDistReset()
call RandomDistAddItem('I01W',10)
call RandomDistAddItem(-1,90)
set MQ=RandomDistChoose()
if(Mq!=null)then
call Mn(Mq,MQ)
else
call WidgetDropItem(MP,MQ)
endif
endif
set bj_lastDyingWidget=null
call DestroyTrigger(GetTriggeringTrigger())
endfunction
function MR takes nothing returns nothing
local widget MP=null
local unit Mq=null
local integer MQ=0
local boolean Mr=true
set MP=bj_lastDyingWidget
if(MP==null)then
set Mq=GetTriggerUnit()
endif
if(Mq!=null)then
set Mr=not IsUnitHidden(Mq)
if(Mr and GetChangingUnit()!=null)then
set Mr=(GetChangingUnitPrevOwner()==Player(12))
endif
endif
if(Mr)then
call RandomDistReset()
call RandomDistAddItem('I047','d')
set MQ=RandomDistChoose()
if(Mq!=null)then
call Mn(Mq,MQ)
else
call WidgetDropItem(MP,MQ)
endif
endif
set bj_lastDyingWidget=null
call DestroyTrigger(GetTriggeringTrigger())
endfunction
I tried to make the code as easy to view as I know how, hope it helps.