papal_vassalization = {
	name = CB_NAME_PAPAL_VASSALIZATION
	war_name = WAR_NAME_PAPAL_VASSALIZATION
	sprite = 32
	truce_days = 3650
	is_permanent = yes
	can_ask_to_join_war = yes
	allowed_to_target_tributaries = no
	
	defender_unoccupied_warscore = yes
	
	sort_priority = 840
	
	can_use_gui = {
		check_if_crusader_trigger = yes

		ROOT = {
				prestige = 5000
		}
	}
	
	on_add = {
		ROOT = {
			prestige = -5000
		}
	}

	can_use = {
		ROOT = {
			tier = EMPEROR
			NOT = { same_realm = FROM }
			NOT = { is_liege_or_above = FROM }
			mercenary = no
			is_nomadic = no
			religion = catholic
		}
		
		FROM = {
			lower_tier_than = ROOT
			NOT = {
				realm_size = 31
			}
			has_landed_title = k_papal_state
			in_revolt = no
			is_nomadic = no
			controls_religion = yes
			religion = catholic
			shares_realm_border_with = ROOT
		}
	}
	
	is_valid = {
		ROOT = {
			tier = EMPEROR
			religion = catholic
		}	
		FROM = {
			is_landed = yes
			has_landed_title = k_papal_state
			religion = catholic
			lower_tier_than = ROOT
		}
	}
	
	on_success = {
		ROOT = {
			show_scope_change = no
			participation_scaled_prestige = 1000
		}
		any_attacker = {
			limit = { NOT = { character = ROOT } }
			hidden_tooltip = { participation_scaled_prestige = 1000 }
		}
		FROM = {
			show_scope_change = no
			prestige = -1000
			set_defacto_liege = ROOT
		}
	}
	
	on_fail = {
		FROM = {
			show_scope_change = no
			participation_scaled_prestige = 500
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { participation_scaled_prestige = 500 }
		}
	}
	
	on_reverse_demand = {
		ROOT = {
			show_scope_change = no
			transfer_scaled_wealth = {
				to = FROM
				value = 2.0
			}
			add_trait = excommunicated
		}
		FROM = {
			show_scope_change = no
			participation_scaled_prestige = 1000
		}
		any_defender = {
			limit = { NOT = { character = FROM } }
			hidden_tooltip = { participation_scaled_prestige = 1000 }
		}
	}
	
	attacker_ai_victory_worth = {
		factor = -1 # always accept
	}
	
	attacker_ai_defeat_worth = {
		factor = 100
	}

	defender_ai_victory_worth = {
		factor = -1 # always accept
	}
	
	defender_ai_defeat_worth = {
		factor = 100
	}
	
	ai_will_do = { 
		factor = 1
		modifier = { #Focus on Coronation first.
			factor = 0.1
			has_dlc = "Holy Fury"
			ROOT = {
				is_feudal = yes
				OR = {
					religion = catholic
					religion = fraticelli
				}
				NOR = {
					trait = crowned_by_priest
					trait = crowned_by_bishop
					trait = crowned_by_pope
					trait = crowned_by_myself
				}
			}
		}
	}
}