Discount based on orderline property and other order line

Hi,

I was wondering on how to accomplish this scenario:

I want to give a 25 % discount on all order lines of a certain product type, except those with a custom property containing a certain value.

Furthermore, the discount should only be rewarded IF the order contains an order line of a certain type other than the ones that should receive the discount.

Essentially:

I have two order lines of type “Event”.
The second one added, has a custom property called “isOverflow”.

In this scenario, no discount should be added.

The user then adds a product of type “Membership”.

Now, a discount should be added to the first Event line only, and not the one with the “isOverflow” property or the Membership line.

If the user adds a new product, say “Book”, the discount should apply to that line also.