pte_liberate_papal_states_heretic = {
	category = 6
	power_projection = no
	power_cost_base = 0
	prestige_base = 1.4
	ae_base = 0
	warscore_cost = {
		all_provinces = 0.0
		no_provinces = 25.0
		owner_keeps = 0.0
		conquered = 0.0
		returned_core = 0.0
		released_nation = 0.0
		cancelled_subject = 0.0
		concede_colonial_region = 0.0
	}
	warscore_cap = -1
	requires_demand_independence = no
	is_make_subject = no
	requires_is_allowed = yes

	is_visible = {
		religion = catholic
		NOT = { tag = PAP }
		NOT = { overlord_of = PAP }
		118 = {
			country_or_subject_holds = FROM
		}
		is_in_war = {
			attacker_leader = ROOT
			defender_leader = FROM
			casus_belli = cb_pte_liberate_papal_states
		}
		FROM = {
			NOT = { tag = PAP }
			religion_group = christian
			NOT = { religion = catholic }
		}
	}
	is_allowed = {
		118 = {
			custom_trigger_tooltip = {
				tooltip = PTE_PROVINCE_CONTROLLED_BY_OUR_SIDE
				controller = {
					OR = {
						is_in_war = {
							attackers = THIS
							attackers = ROOT
							defenders = FROM
						}
						is_in_war = {
							defenders = THIS
							defenders = ROOT
							attackers = FROM
						}
					}
				}
			}
		}
	}
	effect = {
		if = {
			limit = {
				NOT = { exists = PAP }
			}
			set_country_flag = releasing_pope
		}
		118 = {
			cede_province = PAP
			add_core = PAP
		}
		if = {
			limit = {
				has_country_flag = releasing_pope
			}
			clr_country_flag = releasing_pope
			PAP = {
				change_government = theocracy
				change_religion = catholic
				add_government_reform = papacy_reform
				adopt_reform_progress = ROOT
			}
		}
		PAP = {
			if = {
				limit = {
					ai = yes
				}
				set_capital = 118
			}
			add_opinion = {
				who = ROOT
				modifier = pte_liberated_papal_states
			}
		}
		add_papal_influence = 35
		FROM = {
			add_truce_with = PAP
		}
	}
	ai_weight = {
		export_to_variable = {
			variable_name = ai_value
			value = 100
		}
		limit = {
			always = yes
		}
	}
}