# Crown level (de jure) laws
# Laws ending with 0 will be default laws at game start

de_jure_laws = {

	# CROWN AUTHORITY

	crown_authority_0 = {
		group = crown_authority
		default = yes

		feudal_opinion = 5
		city_opinion = 5
		temple_opinion = 5

		city_vassal_min_levy = 0.00
		castle_vassal_min_levy = 0.00
		temple_vassal_min_levy = 0.00

		potential = {
			NOT = { has_dlc = "Conclave" }

			holder_scope = {
				is_tribal = no
				is_nomadic = no
			}
		}

		allow = {
			trigger_if = {
				limit = {
					OR = {
						has_law = crown_authority_0
						has_law = crown_authority_1
						has_law = crown_authority_2
						has_law = crown_authority_3
						has_law = crown_authority_4
					}
				}

				has_law = crown_authority_1
			}
		}

		pass_effect = {
			# log = "crown_authority_0 pass ([This.GetFullBaseName])"
			decreased_crown_authority_effect = yes
		}

		effect = {
			# log = "crown_authority_0 ([This.GetFullBaseName])"
			revoke_law = crown_authority_1
			revoke_law = crown_authority_2
			revoke_law = crown_authority_3
			revoke_law = crown_authority_4
			set_the_kings_peace = no
			set_the_kings_full_peace = no
			set_protected_inheritance = no
			set_allow_title_revokation = no
			set_allow_free_infidel_revokation = no
			# set_allow_free_revokation = no
			# set_appoint_generals = no
			# set_appoint_regents = no
		}

		ai_will_do = {
			factor = 0
		}
	}

	crown_authority_1 = {
		group = crown_authority

		feudal_opinion = -5
		city_opinion = -5
		temple_opinion = -5

		city_vassal_min_levy = 0.20
		castle_vassal_min_levy = 0.20
		temple_vassal_min_levy = 0.20

		potential = {
			is_law_potential = crown_authority_0
		}

		allow = {
			OR = {
				has_law = crown_authority_0
				has_law = crown_authority_2
			}
		}

		pass_effect = {
			# log = "crown_authority_1 pass ([This.GetFullBaseName])"

			if = {
				limit = { has_law = crown_authority_0 }
				increased_crown_authority_effect = yes
			}
			else = {
				decreased_crown_authority_effect = yes
			}
		}

		effect = {
			# log = "crown_authority_1 ([This.GetFullBaseName])"
			revoke_law = crown_authority_0
			revoke_law = crown_authority_2
			revoke_law = crown_authority_3
			revoke_law = crown_authority_4
			set_the_kings_peace = no
			set_the_kings_full_peace = no
			set_protected_inheritance = no
			set_allow_title_revokation = yes
			set_allow_free_infidel_revokation = no
			# set_allow_free_revokation = no
			# set_appoint_generals = yes
			# set_appoint_regents = no
		}

		ai_will_do = {
			factor = 1

			trigger = {
				has_law = crown_authority_0
			}
		}
	}

	crown_authority_2 = {
		group = crown_authority

		feudal_opinion = -10
		city_opinion = -10
		temple_opinion = -10

		city_vassal_min_levy = 0.40
		castle_vassal_min_levy = 0.40
		temple_vassal_min_levy = 0.40

		potential = {
			is_law_potential = crown_authority_0
		}

		allow = {
			OR = {
				has_law = crown_authority_1
				has_law = crown_authority_3
			}

			holder_scope = {
				show_scope_change = no

				is_republic = no

				custom_tooltip = {
					text = TT_NOT_UNREFORMED_PAGAN

					OR = {
						is_unreformed_pagan_trigger = no
						religion_openly_bon_or_reformed_trigger = yes
					}
				}
			}
		}

		pass_effect = {
			# log = "crown_authority_2 pass ([This.GetFullBaseName])"

			if = {
				limit = { has_law = crown_authority_1 }
				increased_crown_authority_effect = yes
			}
			else = {
				decreased_crown_authority_effect = yes
			}
		}

		effect = {
			# log = "crown_authority_2 ([This.GetFullBaseName])"
			revoke_law = crown_authority_0
			revoke_law = crown_authority_1
			revoke_law = crown_authority_3
			revoke_law = crown_authority_4
			set_the_kings_peace = yes
			set_the_kings_full_peace = no
			set_protected_inheritance = no
			set_allow_title_revokation = yes
			set_allow_free_infidel_revokation = yes
			# set_allow_free_revokation = no
			# set_appoint_generals = yes
			# set_appoint_regents = no
		}

		ai_will_do = {
			factor = 0.01

			trigger = {
				has_law = crown_authority_1
			}
		}
	}

	crown_authority_3 = {
		group = crown_authority

		feudal_opinion = -20
		city_opinion = -20
		temple_opinion = -20

		city_vassal_min_levy = 0.60
		castle_vassal_min_levy = 0.60
		temple_vassal_min_levy = 0.60

		potential = {
			is_law_potential = crown_authority_0
		}

		allow = {
			OR = {
				has_law = crown_authority_2
				has_law = crown_authority_4
			}

			holder_scope = {
				show_scope_change = no

				is_republic = no

				custom_tooltip = {
					text = TT_NOT_UNREFORMED_PAGAN

					OR = {
						is_unreformed_pagan_trigger = no
						religion_openly_bon_or_reformed_trigger = yes
					}
				}
			}
		}

		pass_effect = {
			# log = "crown_authority_3 pass ([This.GetFullBaseName])"

			if = {
				limit = { has_law = crown_authority_2 }
				increased_crown_authority_effect = yes
			}
			else = {
				decreased_crown_authority_effect = yes
			}
		}

		effect = {
			# log = "crown_authority_3 ([This.GetFullBaseName])"
			revoke_law = crown_authority_0
			revoke_law = crown_authority_1
			revoke_law = crown_authority_2
			revoke_law = crown_authority_4
			set_the_kings_peace = yes
			set_the_kings_full_peace = no
			set_protected_inheritance = yes
			set_allow_title_revokation = yes
			set_allow_free_infidel_revokation = yes
			# set_allow_free_revokation = no
			# set_appoint_generals = yes
			# set_appoint_regents = yes
		}

		ai_will_do = {
			factor = 0.005

			trigger = {
				has_law = crown_authority_2
				ruled_years >= 20
			}
		}
	}

	crown_authority_4 = {
		group = crown_authority

		feudal_opinion = -30
		city_opinion = -30
		temple_opinion = -30

		city_vassal_min_levy = 0.80
		castle_vassal_min_levy = 0.80
		temple_vassal_min_levy = 0.80

		potential = {
			is_law_potential = crown_authority_0
		}

		allow = {
			has_law = crown_authority_3

			holder_scope = {
				show_scope_change = no

				is_republic = no

				custom_tooltip = {
					text = TT_NOT_UNREFORMED_PAGAN

					OR = {
						is_unreformed_pagan_trigger = no
						religion_openly_bon_or_reformed_trigger = yes
					}
				}
			}
		}

		pass_effect = {
			# log = "crown_authority_4 pass ([This.GetFullBaseName])"
			increased_crown_authority_effect = yes
		}

		effect = {
			# log = "crown_authority_4 ([This.GetFullBaseName])"
			revoke_law = crown_authority_0
			revoke_law = crown_authority_1
			revoke_law = crown_authority_2
			revoke_law = crown_authority_3
			set_the_kings_peace = yes
			set_the_kings_full_peace = yes
			set_protected_inheritance = yes
			set_allow_title_revokation = yes
			set_allow_free_infidel_revokation = yes
			# set_allow_free_revokation = yes
			# set_appoint_generals = yes
			# set_appoint_regents = yes
		}

		ai_will_do = {
			factor = 0.001

			trigger = {
				has_law = crown_authority_3
				ruled_years >= 20
			}
		}
	}

	# INVESTITURE

	# Papal Investiture
	investiture_law_0 = {
		group = investiture_law

		potential = {
			holder_scope = {
				show_scope_change = no

				### ACR ###
				trigger_if = {
					limit = {
						NOR = {
							religion = catholic
							religion = fraticelli
						}
					}
					religion_scope = {
						persistent_event_target:religion_title = { has_title_flag = acr_uses_investiture }
					}
				}
				trigger_else = {
					OR = {
						religion = catholic
						religion = fraticelli
					}
				}
				#### ACR ###
				#trigger_if = {
				#	limit = {
				#		OR = {
				#			has_global_flag = acr_pagan_papal
				#			has_global_flag = acr_pagan_antipopes
				#		}
				#		has_dlc = "Holy Fury"
				#		religion_group = pagan_group
				#		has_religion_feature = religion_theocratic_head
				#		NOR = {
				#			religion = britannic_pagan
				#			religion = promethean_pagan
				#		}
				#	}
				#	OR = {
				#		religion = celtic_pagan_reformed
				#		religion = hellenic_pagan_reformed
				#		religion = egyptian_pagan_reformed
				#		religion = baltic_pagan_reformed
				#		religion = tengri_pagan_reformed
				#		religion = finnish_pagan_reformed
				#		religion = aztec_pagan_reformed
				#		religion = slavic_pagan_reformed
				#		religion = west_african_pagan_reformed
				#		religion = zun_pagan_reformed
				#		religion = norse_pagan_reformed
				#		religion = bon_pagan_reformed
				#	}
				#}
				#trigger_else_if = {
				#	limit = {
				#		OR = {
				#			has_global_flag = acr_pagan_papal
				#			has_global_flag = acr_pagan_antipopes
				#		}
				#		NOT = { has_dlc = "Holy Fury" }
				#		religion_group = pagan_group
				#		is_not_unreformed_pagan_trigger = yes
				#		NOR = {
				#			religion = britannic_pagan
				#			religion = promethean_pagan
				#		}
				#	}
				#	OR = {
				#		religion = celtic_pagan_reformed
				#		religion = hellenic_pagan_reformed
				#		religion = egyptian_pagan_reformed
				#		religion = baltic_pagan_reformed
				#		religion = tengri_pagan_reformed
				#		religion = finnish_pagan_reformed
				#		religion = aztec_pagan_reformed
				#		religion = slavic_pagan_reformed
				#		religion = west_african_pagan_reformed
				#		religion = zun_pagan_reformed
				#		religion = bon_pagan_reformed
				#	}
				#}
				#trigger_else_if = {
				#	limit = {
				#		OR = {
				#			has_global_flag = acr_pagan_papal
				#			has_global_flag = acr_pagan_antipopes
				#		}
				#		religion = zoroastrian
				#	}
				#	d_zoroastrian = { has_holder = yes }
				#}
				#trigger_else_if = {
				#	limit = {
				#		OR = {
				#			has_global_flag = acr_pagan_papal
				#			has_global_flag = acr_pagan_antipopes
				#		}
				#		religion = manichaean
				#	}
				#	d_army_light = { has_holder = yes }
				#}
				#trigger_else_if = {
				#	limit = {
				#		OR = {
				#			has_global_flag = acr_pagan_papal
				#			has_global_flag = acr_pagan_antipopes
				#		}
				#		religion = jewish
				#	}
				#	d_jewish = { has_holder = yes }
				#}
				#trigger_else_if = {
				#	limit = {
				#		OR = {
				#			has_global_flag = acr_pagan_papal
				#			has_global_flag = acr_pagan_antipopes
				#		}
				#		religion = promethean_pagan
				#	}
				#	d_promethean_pagan = { has_holder = yes }
				#}
				#trigger_else_if = {
				#	limit = { religion = britannic_pagan }
				#	k_britannic_pagan = { has_holder = yes }
				#}
				#trigger_else = {
				#	OR = {
				#		religion = catholic
				#		religion = fraticelli
				#	}
				#}

				is_tribal = no
				is_nomadic = no
				NOT = { rightful_religious_head = THIS }
			}
		}

		allow = {
			trigger_if = {
				limit = {
					OR = {
						religion = catholic
						religion = fraticelli
					}
				}
				year >= 1000
			}
		}

		pass_effect = {
			# log = "investiture_law_0 ([This.GetFullBaseName])"
		}

		effect = {
			# log = "investiture_law_0 pass ([This.GetFullBaseName])"
			revoke_law = investiture_law_1
			set_investiture = head
		}

		ai_will_do = {
			factor = 0
		}

		default_selection = {
			factor = 1
		}
	}

	# Free Investiture
	investiture_law_1 = {
		group = investiture_law

		rel_head_opinion = -30
		free_invest_vassal_opinion = 10 # vassals with bishops will appreciate this law
		temple_all_opinion = 10 # Bishops will tend to be more loyal to the Crown

		potential = {
			is_law_potential = investiture_law_0
		}

		allow = {
			holy_order = no
		}

		pass_effect = {
			# log = "investiture_law_1 ([This.GetFullBaseName])"
		}

		effect = {
			# log = "investiture_law_1 pass ([This.GetFullBaseName])"
			revoke_law = investiture_law_0
			set_investiture = any
		}

		ai_will_do = {
			factor = 0.002 # Rare to do this

			trigger = {
				holder_scope = {
					trait = cynical
				}
			}
		}

		default_selection = {
			factor = 1
		}
	}
}