function Comb_conds takes nothing returns boolean
return GetItemTypeId(GetManipulatedItem()) == 'I01F'//The Item that simulats the recipe
endfunction
//=======================================================================
function CountItemsInInventory takes unit who, integer itemType returns integer
local integer i = 0 //Item slots available
local integer num = 0 //Item Amount
loop
exitwhen i > 5
if GetItemTypeId(UnitItemInSlot(who,i)) == itemType then //don't replace this! It's a parameter
set num = num + 1 //for this function so that it can
endif //be used in any situation!
set i = i + 1
endloop
return num
endfunction
//=======================================================================
function I_dunno_what_i_am_doing takes nothing returns nothing
local unit who = GetTriggerUnit()
local integer i = 0
local effect ef
local integer IR= 'I01F' //Item that simulates the recipe
local integer IB= 'I012' // rawcode of the item i buyed 3 times
local integer IG= 'I00D' //rawcode of the item that will replace the recipe and the 3 items (the comboniation)
local integer cnt = 0
if CountItemsInInventory(who,IB) > 2 then
call RemoveItem(GetManipulatedItem())
loop
exitwhen i > 5 or cnt > 2
if GetItemTypeId(UnitItemInSlot(who,i)) == IB then
call RemoveItem(UnitItemInSlot(who,i))
set cnt = cnt + 1
endif
set i = i + 1
endloop
set ef = AddSpecialEffectTarget("Abilities\\Spells\\Items\\AIsm\\AIsmTarget.mdl", who, "origin")
call UnitAddItemById(who,IG)
endif
set who = null
call DestroyEffect(ef)
set ef = null
endfunction
//===============================================================================
function InitTrig_Combination1 takes nothing returns nothing
local integer index = 0
set gg_trg_Combination1 = CreateTrigger()
loop
exitwhen index == 16
call TriggerRegisterPlayerUnitEvent(gg_trg_Combination1, Player(index), EVENT_PLAYER_UNIT_PICKUP_ITEM, null)
set index = index + 1
endloop
call TriggerAddCondition( gg_trg_Combination1, Condition( function Comb_conds) )
call TriggerAddAction( gg_trg_Combination1, function I_dunno_what_i_am_doing)
endfunction