Yes. You can use event counter from campaign script as condition in EDB. For example, this is from EBII:
Code:
recruit_pool "hellenistic infantry hoplitai haploi" 1 0.03 1 0 requires factions { cul_1, cul_3, f_pontos, } and event_counter ecThorakitaiReform 1 and not hidden_resource baktria and hidden_resource eastern and hidden_resource hellen2 or hidden_resource hellen1
recruit_pool "hellenistic infantry hemithorakitai" 1 0.03 1 0 requires factions { cul_1, cul_3, f_pontos, } and not event_counter ecThorakitaiReform 1 and not hidden_resource baktria and hidden_resource eastern and hidden_resource hellen2 or hidden_resource hellen1
This shows one unit-Hoplitai Haploi-recruitable only after event Thorakitai Reform fires, while the other unit is recruitable only before.
So if the gunpowder discovery is coded as an event, and I believe it is so even in vanilla, you can use it. Just make sure that the buildings you're trying to remove are not a prerequisite for something.