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

law_groups = {
	crown_authority = {
		law_type = realm
		allowed_for_councillors = no
	}
	investiture_law = {
		law_type = realm
		allowed_for_councillors = no
	}
	out_of_realm_inheritance_law = {
		law_type = realm
		allowed_for_councillors = yes
	}
	kings_peace = {
		law_type = realm
		allowed_for_councillors = no
	}
}

de_jure_laws = {

# CROWN AUTHORITY

	crown_authority_0 = {
		show_as_title = yes
		group = crown_authority
		default = yes
		
		feudal_opinion = 5
		city_opinion = 5
		temple_opinion = 5
		
		potential = {
			holder_scope = {
				is_tribal = no
				is_nomadic = no
			}
		}
		allow = {
			NOT = {
				empire = {
					NOT = { title = PREV }
					holder_scope = {
						OR = {
							character = ROOT
							is_liege_of = ROOT
						}
					}
				}
			}
			OR = {
				has_law = crown_authority_1
				NOR = {
					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
				}
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				has_law = crown_authority_1
			}
		}
		pass_effect = {
			hidden_tooltip = {
				if = {
					limit = {
						has_law = crown_authority_1
						holder_scope = { NOT = { has_character_flag = centralize_without_penalties } }
						e_placeholder = { has_title_flag = startup }
					}
					any_de_jure_vassal = {
						limit = {
							OR = {
								religion = ROOT
								is_liege_or_above = ROOT
							}
						}
						opinion = {
							who = ROOT
							modifier = opinion_lowered_crown_authority
							months = 120
						}
					}
					holder_scope = { hidden_tooltip = { character_event = { id = PlusFaction.200 days = 1 } } }
				}
			}
		}
		effect = {
			hidden_tooltip = {
				revoke_law = crown_authority_0
				revoke_law = crown_authority_1
				revoke_law = crown_authority_2
				revoke_law = crown_authority_3
				revoke_law = crown_authority_4
			}
		}
		
		vassal_limit = 10
	}
	
	crown_authority_1 = {
		show_as_title = yes
		group = crown_authority
		potential = {
			holder_scope = {
				is_tribal = no
				is_nomadic = no
			}
		}
		allow = {
			NOT = {
				empire = {
					NOT = { title = PREV }
					holder_scope = {
						OR = {
							character = ROOT
							is_liege_of = ROOT
						}
					}
				}
			}
			OR = {
				has_law = crown_authority_0
				has_law = crown_authority_2
			}
			OR = {
				has_law = crown_authority_2
				holder_scope = { prestige = 500 }
			}
			OR = {
				has_law = crown_authority_2
				holder_scope = { NOT = { trait = uncrowned } }
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				NOT = { has_law = crown_authority_0 }
			}
		}
		pass_effect = {
			hidden_tooltip = {
				if = {
					limit = {
						has_law = crown_authority_0
						has_title_flag = do_not_destroy
					}
					clr_title_flag = do_not_destroy
				}
				if = { 
					limit = {
						has_law = crown_authority_0
						holder_scope = { NOT = { has_character_flag = centralize_without_penalties } }
						e_placeholder = { has_title_flag = startup }
					}
					any_de_jure_vassal = {
						limit = {
							OR = {
								religion = ROOT
								is_liege_or_above = ROOT
							}
						}
						opinion = {
							who = ROOT
							modifier = opinion_increased_authority
							months = 120
						}
					}
					holder_scope = { hidden_tooltip = { character_event = { id = PlusFaction.200 days = 1 } } }
				}
				if = {
					limit = {
						has_law = crown_authority_2
						holder_scope = { NOT = { has_character_flag = centralize_without_penalties } }
						e_placeholder = { has_title_flag = startup }
					}
					any_de_jure_vassal = {
						limit = {
							OR = {
								religion = ROOT
								is_liege_or_above = ROOT
							}
						}
						opinion = {
							who = ROOT
							modifier = opinion_lowered_crown_authority
							months = 120
						}
					}
					holder_scope = { hidden_tooltip = { character_event = { id = PlusFaction.200 days = 1 } } }
				}
			}
		}
		effect = {
			hidden_tooltip = {
				revoke_law = crown_authority_0
				revoke_law = crown_authority_1
				revoke_law = crown_authority_2
				revoke_law = crown_authority_3
				revoke_law = crown_authority_4
			}
		}
		
		castle_vassal_max_levy = 0.05
		city_vassal_max_levy = 0.05
		temple_vassal_max_levy = 0.05

		castle_vassal_min_levy = 0.05
		city_vassal_min_levy = 0.05
		temple_vassal_min_levy = 0.05
		
		vassal_limit = 7
		demesne_size = 1
	}
	
	crown_authority_2 = {
		show_as_title = yes
		group = crown_authority
		
		feudal_opinion = -5
		city_opinion = -5
		temple_opinion = -5

		potential = {
			holder_scope = {
				is_tribal = no
				is_nomadic = no
			}
		}		
		allow = {
			holder_scope = {
#				is_republic = no 
				
				custom_tooltip = { 
					text = TT_NOT_UNREFORMED_PAGAN
					hidden_tooltip = {
						OR = {
							is_pagan_religion = no
							is_reformed_pagan_religion = yes
						}
					}
				}
			}
			NOT = {
				empire = {
					NOT = { title = PREV }
					holder_scope = {
						OR = {
							character = ROOT
							is_liege_of = ROOT
						}
					}
				}
			}
			OR = {
				has_law = crown_authority_1
				has_law = crown_authority_3
			}
			OR = {
				has_law = crown_authority_3
				holder_scope = { prestige = 1000 }
			}
			OR = {
				has_law = crown_authority_3
				holder_scope = { NOT = { trait = uncrowned } }
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				NOT = { has_law = crown_authority_1 }
			}
		}
		pass_effect = {
			hidden_tooltip = {
				if = { 
					limit = {
						has_law = crown_authority_1
						holder_scope = { NOT = { has_character_flag = centralize_without_penalties } }
						e_placeholder = { has_title_flag = startup }
					}
					any_de_jure_vassal = {
						limit = {
							OR = {
								religion = ROOT
								is_liege_or_above = ROOT
							}
						}
						opinion = {
							who = ROOT
							modifier = opinion_increased_authority
							months = 120
						}
					}
					holder_scope = { hidden_tooltip = { character_event = { id = PlusFaction.200 days = 1 } } }
				}
				if = {
					limit = {
						has_law = crown_authority_3
						holder_scope = { NOT = { has_character_flag = centralize_without_penalties } }
						e_placeholder = { has_title_flag = startup }
					}
					any_de_jure_vassal = {
						limit = {
							OR = {
								religion = ROOT
								is_liege_or_above = ROOT
							}
						}
						opinion = {
							who = ROOT
							modifier = opinion_lowered_crown_authority
							months = 120
						}
					}
					holder_scope = { hidden_tooltip = { character_event = { id = PlusFaction.200 days = 1 } } }
				}
			}
		}
		effect = {
			hidden_tooltip = {
				revoke_law = crown_authority_0
				revoke_law = crown_authority_1
				revoke_law = crown_authority_2
				revoke_law = crown_authority_3
				revoke_law = crown_authority_4
			}
		}
		castle_vassal_max_levy = 0.1
		city_vassal_max_levy = 0.1
		temple_vassal_max_levy = 0.1

		castle_vassal_min_levy = 0.1
		city_vassal_min_levy = 0.1
		temple_vassal_min_levy = 0.1
		
		vassal_limit = 4
		demesne_size = 2
	}
	
	crown_authority_3 = {
		show_as_title = yes
		group = crown_authority
		
		feudal_opinion = -10
		city_opinion = -10
		temple_opinion = -10

		potential = {
			holder_scope = {
				is_tribal = no
				is_nomadic = no
			}
		}		
		allow = {
			holder_scope = { 
				is_republic = no 
				custom_tooltip = {
					text = TT_NOT_UNREFORMED_PAGAN
					hidden_tooltip = {
						OR = {
							is_pagan_religion = no
							is_reformed_pagan_religion = yes
						}
					}
				}
			}

			NOT = {
				empire = {
					NOT = { title = PREV }
					holder_scope = {
						OR = {
							character = ROOT
							is_liege_of = ROOT
						}
					}
				}
			}
			OR = {
				has_law = crown_authority_2
				has_law = crown_authority_4
			}
			OR = {
				has_law = crown_authority_4
				holder_scope = { prestige = 2500 }
			}
			OR = {
				has_law = crown_authority_4
				holder_scope = { NOT = { trait = uncrowned } }
			}
			OR = {
				has_law = crown_authority_4
				NOT = { title = e_byzantium }
				holder_scope = { trait = strong_basileus }
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				NOT = { has_law = crown_authority_2 }
			}
		}
		pass_effect = {
			hidden_tooltip = {
				if = { 
					limit = {
						has_law = crown_authority_2
						holder_scope = { NOT = { has_character_flag = centralize_without_penalties } }
						e_placeholder = { has_title_flag = startup }
					}
					any_de_jure_vassal = {
						limit = {
							OR = {
								religion = ROOT
								is_liege_or_above = ROOT
							}
						}
						opinion = {
							who = ROOT
							modifier = opinion_increased_authority
							months = 120
						}
					}
					holder_scope = { hidden_tooltip = { character_event = { id = PlusFaction.200 days = 1 } } }
				}
				if = {
					limit = {
						has_law = crown_authority_4
						holder_scope = { NOT = { has_character_flag = centralize_without_penalties } }
						e_placeholder = { has_title_flag = startup }
					}
					any_de_jure_vassal = {
						limit = {
							OR = {
								religion = ROOT
								is_liege_or_above = ROOT
							}
						}
						opinion = {
							who = ROOT
							modifier = opinion_lowered_crown_authority
							months = 120
						}
					}
					holder_scope = { hidden_tooltip = { character_event = { id = PlusFaction.200 days = 1 } } }
				}
			}
		}
		effect = {
			hidden_tooltip = {
				revoke_law = crown_authority_0
				revoke_law = crown_authority_1
				revoke_law = crown_authority_2
				revoke_law = crown_authority_3
				revoke_law = crown_authority_4
			}
		}
		castle_vassal_max_levy = 0.15
		city_vassal_max_levy = 0.15
		temple_vassal_max_levy = 0.15

		castle_vassal_min_levy = 0.15
		city_vassal_min_levy = 0.15
		temple_vassal_min_levy = 0.15
		
		vassal_limit = 2
		demesne_size = 3
	}
	
	crown_authority_4 = {
		show_as_title = yes
		group = crown_authority
		
		feudal_opinion = -15
		city_opinion = -15
		temple_opinion = -15

		potential = {
			holder_scope = {
				is_tribal = no
				is_nomadic = no
			}
		}		
		allow = {
			holder_scope = { 
				is_republic = no 
				custom_tooltip = {
					text = TT_NOT_UNREFORMED_PAGAN
					hidden_tooltip = {
						OR = {
							is_pagan_religion = no
							is_reformed_pagan_religion = yes
						}
					}
				}
			}

			NOT = {
				empire = {
					NOT = { title = PREV }
					holder_scope = {
						OR = {
							character = ROOT
							is_liege_of = ROOT
						}
					}
				}
			}
			has_law = crown_authority_3
			holder_scope = { prestige = 5000 }
			holder_scope = { NOT = { trait = uncrowned } }
			OR = {
				NOT = { title = e_byzantium }
				holder_scope = { trait = strong_basileus }
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				NOT = { has_law = crown_authority_3 }
			}
		}
		pass_effect = {
			hidden_tooltip = {
				if = { 
					limit = {
						has_law = crown_authority_3
						holder_scope = { NOT = { has_character_flag = centralize_without_penalties } }
						e_placeholder = { has_title_flag = startup }
					}
					any_de_jure_vassal = {
						limit = {
							OR = {
								religion = ROOT
								is_liege_or_above = ROOT
							}
						}
						opinion = {
							who = ROOT
							modifier = opinion_increased_authority
							months = 120
						}
					}
					holder_scope = { hidden_tooltip = { character_event = { id = PlusFaction.200 days = 1 } } }
				}
			}
		}
		effect = {
			hidden_tooltip = {
				revoke_law = crown_authority_0
				revoke_law = crown_authority_1
				revoke_law = crown_authority_2
				revoke_law = crown_authority_3
				revoke_law = crown_authority_4
			}
		}
		castle_vassal_max_levy = 0.2
		city_vassal_max_levy = 0.2
		temple_vassal_max_levy = 0.2

		castle_vassal_min_levy = 0.2
		city_vassal_min_levy = 0.2
		temple_vassal_min_levy = 0.2
		
		demesne_size = 4
	}

	
# INVESTITURE

	# Papal Investiture
	investiture_law_0 = {
		show_as_title = yes
		group = investiture_law
		default = yes

		potential = {
			holder_scope = {
				religion_head = {
					primary_title = {
						OR = {
							title = k_papal_state
							title = k_chalcedonian
							title = d_celtic_pagan_reformed
							title = d_pontifex_maximus
							title = d_cathar
							title = d_bogomilist
							title = d_manichean
							title = d_fraticelli
						}
					}
				}
			}
			is_tribal = no
			is_nomadic = no
		}
		allow = {
			has_law = investiture_law_1
			NOT = {
				empire = {
					NOT = { title = PREV }
					holder_scope = {
						OR = {
							character = ROOT
							is_liege_of = ROOT
						}
					}
				}
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				holder_scope = {
					OR = {
						trait = cynical
						trait = greedy
						trait = excommunicated
					}
				}
			}
		}
		effect = {
			revoke_law = investiture_law_1
			set_investiture = head
		}
	}
	
	# Free Investiture
	investiture_law_1 = {
		show_as_title = yes
		rel_head_opinion = -20
		free_invest_vassal_opinion = 5 # vassals with bishops will appreciate this law
		temple_all_opinion = 10 # Bishops will tend to be more loyal to the Crown
		group = investiture_law
		
		potential = {
			holder_scope = {
				religion_head = {
					primary_title = {
						OR = {
							title = k_papal_state
							title = k_chalcedonian
							title = d_celtic_pagan_reformed
							title = d_pontifex_maximus
							title = d_cathar
							title = d_bogomilist
							title = d_manichean
							title = d_fraticelli
						}
					}
				}
			}
			is_tribal = no
			is_nomadic = no
		}
		allow = {
			has_law = investiture_law_0
			holder_scope = {
				controls_religion = no
			}
			NOT = {
				empire = {
					NOT = { title = PREV }
					holder_scope = {
						OR = {
							character = ROOT
							is_liege_of = ROOT
						}
					}
				}
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.002 # Rare to do this
			}
			modifier = {
				factor = 0
				holder_scope = {
					NOR = {
						trait = cynical
						trait = greedy
						trait = excommunicated
					}
				}
			}
		}
		effect = {
			revoke_law = investiture_law_0
			set_investiture = any
		}
	}

	
# OUT OF REALM INHERITANCE

	out_of_realm_inheritance_law_0 = {
		group = out_of_realm_inheritance_law
		default = yes
		
		potential = {
			holder_scope = {
				is_tribal = no
				is_nomadic = no
				is_republic = no
			}
			
		}		
		allow = {
			has_law = out_of_realm_inheritance_law_1
		}		
		ai_will_do = {
			factor = 0
		}	
		effect = {
			hidden_tooltip = {
				revoke_law = out_of_realm_inheritance_law_1
			}
		}
	}

	out_of_realm_inheritance_law_1 = {
		group = out_of_realm_inheritance_law
		
		potential = {
			holder_scope = {
				is_tribal = no
				is_nomadic = no
				is_republic = no
			}
			
		}
		allow = {
			has_law = out_of_realm_inheritance_law_0
			OR = {
				has_law = crown_authority_2
				has_law = crown_authority_3
				has_law = crown_authority_4
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.05
				always = yes
			}
			modifier = {
				factor = 20
				holder_scope = {
					any_demesne_title = {
						current_heir = {
							NOT = { same_realm = PREVPREV }
						}
					}
				}
			}
		}
		effect = {
			hidden_tooltip = {
				revoke_law = out_of_realm_inheritance_law_0
			}
			set_protected_inheritance = yes
		}
	}

# KINGS PEACE

	kings_peace_0 = {
		group = kings_peace
		default = yes
		
		potential = {
			OR = {
				NOT = { has_dlc = "Zeus" }
				has_law = law_voting_power_0
			}
			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
			}
		}
		allow = {
			OR = {
				has_law = kings_peace_1
				has_law = kings_peace_2
				AND = {
					NOT = { has_law = kings_peace_0 }
					NOT = { has_law = kings_peace_1 }
					NOT = { has_law = kings_peace_2 }
				}
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.05
			}
		}
		pass_effect = {
			hidden_tooltip = {
				if = {
					limit = {
						OR = {
							has_law = kings_peace_1
							has_law = kings_peace_2
						}
						holder_scope = { NOT = { has_character_flag = centralize_without_penalties } }
						e_placeholder = { has_title_flag = startup }
					}
					any_de_jure_vassal = {
						limit = {
							OR = {
								religion = ROOT
								is_liege_or_above = ROOT
							}
						}
						opinion = {
							who = ROOT
							modifier = opinion_lowered_crown_authority
							months = 120
						}
					}
					holder_scope = { hidden_tooltip = { character_event = { id = PlusFaction.200 days = 1 } } }
				}
			}
		}
		effect = {
			hidden_tooltip = {
				revoke_law = kings_peace_1
				revoke_law = kings_peace_2
			}
			set_the_kings_peace = no
			set_the_kings_full_peace = no
		}
	}
	
	kings_peace_1 = {
		group = kings_peace
		potential = {
			OR = {
				NOT = { has_dlc = "Zeus" }
				has_law = law_voting_power_0
			}
			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
			}
		}
		allow = {
			OR = {
				has_law = kings_peace_2
				AND = {
					custom_tooltip = {
						text = ctt_no_conclave
						hidden_tooltip = {
							NOT = { has_dlc = "Zeus" }
						}
					}
					OR = {
						has_law = crown_authority_2
						has_law = crown_authority_3
						has_law = crown_authority_4
					}
				}
				AND = {
					custom_tooltip = {
						text = ctt_has_conclave
						hidden_tooltip = {
							has_dlc = "Zeus"
						}
					}
					has_law = kings_peace_0
					has_law = crown_authority_4
				}
			}
		}
		ai_will_do = {
			factor = 0
		}
		pass_effect = {
			hidden_tooltip = {
				if = { 
					limit = {
						has_law = kings_peace_0
						holder_scope = { NOT = { has_character_flag = centralize_without_penalties } }
						e_placeholder = { has_title_flag = startup }
					}
					any_de_jure_vassal = {
						limit = {
							OR = {
								religion = ROOT
								is_liege_or_above = ROOT
							}
						}
						opinion = {
							who = ROOT
							modifier = opinion_increased_authority
							months = 120
						}
					}
					holder_scope = { hidden_tooltip = { character_event = { id = PlusFaction.200 days = 1 } } }
				}
				if = {
					limit = {
						has_law = kings_peace_2
						holder_scope = { NOT = { has_character_flag = centralize_without_penalties } }
						e_placeholder = { has_title_flag = startup }
					}
					any_de_jure_vassal = {
						limit = {
							OR = {
								religion = ROOT
								is_liege_or_above = ROOT
							}
						}
						opinion = {
							who = ROOT
							modifier = opinion_lowered_crown_authority
							months = 120
						}
					}
					holder_scope = { hidden_tooltip = { character_event = { id = PlusFaction.200 days = 1 } } }
				}
			}
		}
		effect = {
			hidden_tooltip = {
				revoke_law = kings_peace_0
				revoke_law = kings_peace_2
			}
			set_the_kings_peace = yes
			set_the_kings_full_peace = no
		}
	}
	
	kings_peace_2 = {
		group = kings_peace
		potential = {
			OR = {
				NOT = { has_dlc = "Zeus" }
				has_law = law_voting_power_0
			}
			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
			}
		}
		allow = {
			has_law = crown_authority_4
			has_law = kings_peace_1
		}
		ai_will_do = {
			factor = 0
		}
		pass_effect = {
			hidden_tooltip = {
				if = { 
					limit = {
						has_law = kings_peace_1
						holder_scope = { NOT = { has_character_flag = centralize_without_penalties } }
						e_placeholder = { has_title_flag = startup }
					}
					any_de_jure_vassal = {
						limit = {
							OR = {
								religion = ROOT
								is_liege_or_above = ROOT
							}
						}
						opinion = {
							who = ROOT
							modifier = opinion_increased_authority
							months = 120
						}
					}
					holder_scope = { hidden_tooltip = { character_event = { id = PlusFaction.200 days = 1 } } }
				}
			}
		}
		effect = {
			hidden_tooltip = {
				revoke_law = kings_peace_1
			}
			set_the_kings_peace = yes
			set_the_kings_full_peace = yes
		}
	}
	
}