function GetFakeItem takes item i returns integer
if GetBooleanOr(GetItemTypeId(i) == 'I000',GetItemTypeId(i) == 'I001') then
return 'I000'
endif
call BJDebugMsg("|cffff0000Error:|r Item Database doesn't fit with target item.")
return 'texp'
endfunction
function GetRealItem takes item i returns integer
if GetBooleanOr(GetItemTypeId(i) == 'I000',GetItemTypeId(i) == 'I001') then
return 'I001'
endif
call BJDebugMsg("|cffff0000Error:|r Item Database doesn't fit with target item.")
return 'texp'
endfunction
//===========================================================================
function Trig_Getting_Owner_Actions takes nothing returns nothing
local integer i
local unit u=GetTriggerUnit()
local integer itemid
loop
exitwhen GetBooleanOr(udg_Item[i]==GetManipulatedItem(),i>udg_Item_Max)
set i=i+1
endloop
if i>udg_Item_Max then
return
endif
if udg_Item_Owner[i]!=GetOwningPlayer(u) then
set itemid=GetFakeItem(GetManipulatedItem())
else
set itemid=GetRealItem(GetManipulatedItem())
endif
call RemoveItem(GetManipulatedItem())
call UnitAddItemById(u,itemid)
set udg_Item[i]=GetLastCreatedItem()
set u=null
endfunction
//===========================================================================
function InitTrig_Getting_Owner takes nothing returns nothing
set gg_trg_Getting_Owner = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Getting_Owner, EVENT_PLAYER_UNIT_PICKUP_ITEM )
call TriggerAddAction( gg_trg_Getting_Owner, function Trig_Getting_Owner_Actions )
endfunction