function CountHeroItemsOfType takes unit triggeringUnit, integer itemRawCode returns integer // returns the number of specified items
local integer i = 0
local integer itemsFound = 0
loop
if (GetItemTypeId(UnitItemInSlot(triggeringUnit, i) == itemRawCode) then
set itemsFound = itemsFound + 1 // Then we've found the item we're looking for; so add one to "items found"
endif
// stuff for the loop; nothing special:
set i = i + 1
exitwhen i >= 5
endloop
return itemsFound // returns the value "number of items found of rawcode 'ankh'
endfunction
function Actions takes nothing returns nothing
// function CountHeroItemsOfType requires two parameters; the first one is a unit, the second is the rawcode of the item.
if CountHeroItemsOfType(GetTriggerUnit(),'ankh') >= 2 then // Inputs GetTriggerUnit() as the parameter unit, 'ankh' as the item rawcode.
// Actions (do your stuff here)
endif
endfunction