NOT = {independent = yes} means that the decision can only be taken as a vassal, which, if I under it, is the opposite of what you want.
For the second part, just replace
withCode:liege = { NOT = { religion = ROOT } religion_group = ROOT NOT = { religion_authority = 0.9 } }
Since only reformed/unreformed are heresies of each other but not of other pagan religions, this will no longer try to convert other forms of paganism.Code:liege = { NOT = { religion = ROOT } OR = { ROOT = { is_heresy_of = PREV } is_heresy_of = ROOT } NOT = { religion_authority = 0.9 } }
This will work even if the reformed version is the heresy (which, given the first change, is likely). If you only want it to work when unreformed is the heresy, use this instead:
Code:liege = { NOT = { religion = ROOT } ROOT = { is_heresy_of = PREV } NOT = { religion_authority = 0.9 } }
Thank you for your input, I am testing your code now. I changed the NOT = { independent = yes } to now properly be NOT = { independent = no }. For whatever reason I am still allowed to convert to reformed, through selecting the character portrait, with both variations of this code. I'm going to test this some more to see if the ai will convert, so far it has not on the previous template, and to see if your code stopped the courtier conversions.