function Trig_Item_Conditions takes nothing returns boolean
return GetItemType(GetManipulatedItem())==ITEM_TYPE_ARTIFACT
endfunction
function Trig_Item_Actions takes nothing returns nothing
local unit u=GetTriggerUnit()
local integer i=0
local integer m=0
loop
exitwhen i==6
set i=i+1
if GetItemType(UnitItemInSlotBJ(u, i))==ITEM_TYPE_ARTIFACT then
set m=m+GetItemCharges(UnitItemInSlotBJ(u, i))
endif
endloop
loop
exitwhen GetUnitAbilityLevel(u,'A000')==0
call UnitRemoveAbility(u,'A000')
endloop
if m>0 then
if m> 100 then
set m=100
endif
call UnitAddAbility(u,'A000')
call SetUnitAbilityLevel(u,'A000',m)
endif
set u=null
set i=0
set m=0
endfunction
//===========================================================================
function InitTrig_Item takes nothing returns nothing
set gg_trg_Item = CreateTrigger( )
call TriggerAddAction( gg_trg_Item, function Trig_Item_Actions )
call TriggerAddCondition(gg_trg_Item, Condition(function Trig_Item_Conditions))
call TriggerRegisterAnyUnitEventBJ( gg_trg_Item, EVENT_PLAYER_UNIT_PICKUP_ITEM )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Item, EVENT_PLAYER_UNIT_DROP_ITEM )
// We do the following to prevent first time lag, just replace the unit with any unit in your map
call UnitAddAbility(bj_lastCreatedUnit,'A000')
call SetUnitAbilityLevel(bj_lastCreatedUnit,'A000',100)
call UnitRemoveAbility(bj_lastCreatedUnit,'A000')
endfunction