scope DivineShieldItem initializer InitTrig
function Conditions takes nothing returns boolean
return GetItemTypeId(GetManipulatedItem()) == 'I000'
endfunction
function GetInventoryIndexOfItem takes unit u, item it returns integer
local integer i=0
loop
if (UnitItemInSlot(u, i) != null) and (UnitItemInSlot(u, i) == it) then
return i
endif
set i=i+1
exitwhen i>=bj_MAX_INVENTORY
endloop
return 0
endfunction
function Actions takes nothing returns nothing
local integer i=GetInventoryIndexOfItem(GetTriggerUnit(), GetManipulatedItem())
call UnitRemoveItem(GetTriggerUnit(), GetManipulatedItem())
call UnitAddItem(GetTriggerUnit(), GetManipulatedItem())
call UnitDropItemSlot(GetTriggerUnit(), GetManipulatedItem(), i)
endfunction
//===========================================================================
function InitTrig takes nothing returns nothing
local trigger DivineShieldItem=CreateTrigger()
local integer i=0
loop
exitwhen i==16
call TriggerRegisterPlayerUnitEvent(DivineShieldItem,Player(i),EVENT_PLAYER_UNIT_USE_ITEM,ANTILEAKFILTER)
set i = i + 1
endloop
call TriggerAddCondition(DivineShieldItem, Condition(function Conditions))
call TriggerAddAction(DivineShieldItem, function Actions)
set DivineShieldItem=null
endfunction
endscope