does this work?
in any case, can I have your permission to use this code (after modifying the value a bit) in one of my cb overhauls (that is for public release)?
Yes it seem to work great for preventing embargo wars against republic leaders of whom you have a good opinion.
The vanilla CB asks whether the person you're declaring war on is the leader of a republic, or whether he has a vassal that is a republic, and I simply added an opinion check of that republic's leader. Checking the agressor's opinion of characters that are part of the republic and own trade posts in the aggressor's country is a bit more complicated.
I see. What I ideally would like to do is that a ruler, for example the duchy of Barcelona can´t embargo, for example the republic of Genoa, if he has an opinion of 40 or more with all genoese patricians that own trade posts in his realm. Since this is mainly directed at playing as a patrician, (I don´t know if the AI would care about the opinion of the rulers where it has trade posts, or how to make it care). So if I play as a patrician, I would have to send gifts and send my chancellor to improve relations with the rulers where I have trade posts and since the embargo cb would only be prohibited if all trade post owners of the same republic has a good relation whith the ruler, I would have to take over other patrician families trade posts and gain a monopoly in that realm to make sure the trade posts are safe. And as new characters inherits on both ends, I would have to maintain the good relations.
But as you say it seem very complicated. I´ll play around with the codes in 00_cb_types a little to see if I can make it work, maybee trade_post_owner that is used in the seize_trade_post cb could be used in some way, (I have not a clue)

. Otherwise I use your sugestion, it fills the main purpose I just have to be the leader of the republic or else I can´t prevent my trade posts from being sacked.
If characters won't use the CB in that situation, even if the option exists, I'd have to mess around with the AI--I don't know how to do that. If they can't use the CB then well, they can't. That's what I went with here. If you made it a bit more complex you could make it so the opinion only mattered for the AI and not player characters, which come to think of it is probably a good idea, if you don't want to be locked out of using the CB due to your own character's opinion (which is hard to change).
If they
can`t use the cb will suffice. I havn`t really thought about making the change only aply to the AI since I was trying to make it, for the player as the merchant republic point of view, but that would be a good idea. Thanks for your help.
