Or make a variable.
Trigger 1
Unit sells an item
Item sold = Your Item
Set Variable_X = Variable_X + 1
Trigger 2
Unit dies
Your Condition (if any)
Add 5 x Variable_X to owner of killing unit.
Something like that.
Can't you just trigger it?
a unit finishes the effect of an ability.
ability equal to bla bla
set temp point position of casting unit
create XX units at temp point facing degrees of casting unit.
destroy temp point.