What is your server language. This can be done, but because of the complexity it would probably require some hand scripting in the language you are using.
I would probably write a function to handle it and then write a calculation that refers to that function.
Does it need to account for quantity as well... for instance if you buy two of item1 and one of item2 would you get $10 off? You would need to account for all of this in your calculation.