# p5 headgear
5 = {
	# Imperial crown/Caliph turban
	0 = {
		factor = 100
		hide_layers = { 31 = { } } #Prevent hedge-incompatibilities with Ducal French Overlayers.
		hide_layers = { 32 = { } } #Prevent hedge-incompatibilities with Ducal French Overlayers.
		trigger = {
			OR = {
				real_tier = emperor
				spouse = { real_tier = emperor }
				is_or_was_offmap_power_ruler = yes
			}
		}
		modifier = {
			factor = 0
			OR = {
				trait = peasant_leader
				trait = heresiarch
				trait = saint
				is_offmap_governor = yes
				song_dynasty_futou_trigger = yes
				check_variable = { which = ca_headgear value = 2 }
			}
		}
		modifier = {
			factor = 0
			is_nomadic = yes
			NOT = {
				population = 10000
			}
		}
		modifier = { #Nomads marrying lowly pagans should not give them Imperial crowns, unless the spouse has enough population to warrant it.
			factor = 0
			spouse = {
				is_nomadic = yes
				real_tier = EMPEROR
				NOT = {
					population = 10000
				}
			}
			is_ruler = yes
			lower_tier_than = EMPEROR
		}
		modifier = {
			factor = 0
			in_command = yes
			has_game_rule = {
				name = martial_headgear
				value = on
			}
		}
		modifier = { #If you are a living Emperor and are not crowned, you don't wear a crown.
			factor = 0
			has_dlc = "Holy Fury" #Ignore Coronation triggers if Holy Fury is disabled.
			real_tier = EMPEROR
			is_feudal = yes
			is_landed = yes
			OR = {
				religion = catholic
				religion = fraticelli
			}
			OR = {
				is_alive = yes
				trait = uncrowned
			}
			OR = {
				has_game_started = yes
				is_save_game = yes
			}
			NOR = {
				trait = crowned_by_priest
				trait = crowned_by_bishop
				trait = crowned_by_pope
				trait = crowned_by_myself
			}
		}
		modifier = {
			factor = 0
			has_dlc = "Holy Fury" #Ignore Coronation triggers if Holy Fury is disabled.
			NOT = { real_tier = EMPEROR }
			OR = {
				has_game_started = yes
				is_save_game = yes
			}
			spouse = {
				real_tier = EMPEROR
				is_feudal = yes
				is_landed = yes
				OR = {
					religion = catholic
					religion = fraticelli
				}
				OR = {
					is_alive = yes
					trait = uncrowned
				}
				NOR = {
					trait = crowned_by_priest
					trait = crowned_by_bishop
					trait = crowned_by_pope
					trait = crowned_by_myself
				}
			}
		}
		modifier = {
			factor = 0
			is_republic = yes
			is_or_was_offmap_power_ruler = no
		}
		modifier = {
			factor = 0
			spouse = { is_republic = yes } #Dead wives of Patricians are nogovernment, thus they would wear crowns for being married to a King-tier.
			is_alive = no
			is_landed = no
			is_or_was_offmap_power_ruler = no
		}
	}

	# Royal crown/turban 1
	1 = {
		factor = 1
		hide_layers = { 31 = { } } #Prevent hedge-incompatibilities with Ducal French Overlayers.
		hide_layers = { 32 = { } } #Prevent hedge-incompatibilities with Ducal French Overlayers.
		trigger = {
			OR = {
				higher_real_tier_than = duke
				spouse = {  higher_real_tier_than = duke }
				has_minor_title = title_despot
				has_minor_title = title_augusta
				is_or_was_offmap_power_ruler = yes
			}
		}
		modifier = {
			factor = 0
			OR = {
				has_portrait_property = { layer = 5 index = 2 }
				has_portrait_property = { layer = 5 index = 3 }
			}
			NOT = { is_variable_equal = { which = ca_headgear value = 2 } }
		}
		modifier = {
			factor = 0
			is_nomadic = yes
			NOT = {
				population = 5000
			}
		}
		modifier = { #Nomads marrying lowly pagans should not give them Imperial crowns unless proper population is met.
			factor = 0
			spouse = {
				is_nomadic = yes
				real_tier = KING
				NOT = {
					population = 5000
				}
			}
			is_ruler = yes
			lower_tier_than = KING
		}
		modifier = { #If you are a king and are not crowned, you don't wear a crown.
			factor = 0
			has_dlc = "Holy Fury" #Ignore Coronation triggers if Holy Fury is disabled.
			higher_real_tier_than = duke
			is_feudal = yes
			is_landed = yes
			OR = {
				religion = catholic
				religion = fraticelli
			}
			OR = {
				is_alive = yes
				trait = uncrowned
			}
			OR = {
				has_game_started = yes
				is_save_game = yes
			}
			NOR = {
				trait = crowned_by_priest
				trait = crowned_by_bishop
				trait = crowned_by_pope
				trait = crowned_by_myself
				primary_title = { is_vice_royalty = yes }
			}
		}
		modifier = {
			factor = 0
			has_dlc = "Holy Fury"
			NOT = { higher_real_tier_than = duke }
			OR = {
				has_game_started = yes
				is_save_game = yes
			}
			spouse = {
				higher_real_tier_than = duke
				is_feudal = yes
				is_landed = yes
				OR = {
					religion = catholic
					religion = fraticelli
				}
				OR = {
					is_alive = yes
					trait = uncrowned
				}
				NOR = {
					trait = crowned_by_priest
					trait = crowned_by_bishop
					trait = crowned_by_pope
					trait = crowned_by_myself
					primary_title = { is_vice_royalty = yes }
				}
			}
		}
		modifier = {
			factor = 0
			OR = {
				trait = peasant_leader
				trait = heresiarch
			}
		}
		modifier = {
			factor = 0
			is_republic = yes
			is_or_was_offmap_power_ruler = no
		}
		modifier = {
			factor = 0
			spouse = { is_republic = yes }
			is_alive = no
			is_landed = no
			is_or_was_offmap_power_ruler = no
		}
		modifier = {
			factor = 100
			is_variable_equal = { which = ca_headgear value = 2 }
		}
	}

	# Royal crown/turban 2
	2 = {
		factor = 1
		hide_layers = { 31 = { } } #Prevent hedge-incompatibilities with Ducal French Overlayers.
		hide_layers = { 32 = { } } #Prevent hedge-incompatibilities with Ducal French Overlayers.
		trigger = {
			OR = {
				higher_real_tier_than = duke
				spouse = {  higher_real_tier_than = duke }
				has_minor_title = title_despot
				has_minor_title = title_augusta
				is_or_was_offmap_power_ruler = yes
			}
		}
		modifier = {
			factor = 0
			OR = {
				has_portrait_property = { layer = 5 index = 1 }
				has_portrait_property = { layer = 5 index = 3 }
			}
			NOT = { is_variable_equal = { which = ca_headgear value = 3 } }
		}
		modifier = {
			factor = 0
			is_nomadic = yes
			NOT = {
				population = 5000
			}
		}
		modifier = { #Nomads marrying lowly pagans should not give them Imperial crowns unless proper population is met.
			factor = 0
			spouse = {
				is_nomadic = yes
				real_tier = KING
				NOT = {
					population = 5000
				}
			}
			is_ruler = yes
			lower_tier_than = KING
		}
		modifier = { #If you are a king and are not crowned, you don't wear a crown.
			factor = 0
			has_dlc = "Holy Fury" #Ignore Coronation triggers if Holy Fury is disabled.
			higher_real_tier_than = duke
			is_feudal = yes
			is_landed = yes
			OR = {
				religion = catholic
				religion = fraticelli
			}
			OR = {
				is_alive = yes
				trait = uncrowned
			}
			OR = {
				has_game_started = yes
				is_save_game = yes
			}
			NOR = {
				trait = crowned_by_priest
				trait = crowned_by_bishop
				trait = crowned_by_pope
				trait = crowned_by_myself
				primary_title = { is_vice_royalty = yes }
			}
		}
		modifier = {
			factor = 0
			has_dlc = "Holy Fury"
			NOT = { higher_real_tier_than = duke }
			OR = {
				has_game_started = yes
				is_save_game = yes
			}
			spouse = {
				higher_real_tier_than = duke
				is_feudal = yes
				is_landed = yes
				OR = {
					religion = catholic
					religion = fraticelli
				}
				OR = {
					is_alive = yes
					trait = uncrowned
				}
				NOR = {
					trait = crowned_by_priest
					trait = crowned_by_bishop
					trait = crowned_by_pope
					trait = crowned_by_myself
					primary_title = { is_vice_royalty = yes }
				}
			}
		}
		modifier = {
			factor = 0
			OR = {
				trait = peasant_leader
				trait = heresiarch
			}
		}
		modifier = {
			factor = 0
			is_republic = yes
			is_or_was_offmap_power_ruler = no
		}
		modifier = {
			factor = 0
			spouse = { is_republic = yes }
			is_alive = no
			is_landed = no
			is_or_was_offmap_power_ruler = no
		}
		modifier = {
			factor = 100
			is_variable_equal = { which = ca_headgear value = 3 }
		}
	}

	# Royal crown/turban 3
	3 = {
		factor = 1
		hide_layers = { 31 = { } } #Prevent hedge-incompatibilities with Ducal French Overlayers.
		hide_layers = { 32 = { } } #Prevent hedge-incompatibilities with Ducal French Overlayers.
		trigger = {
			OR = {
				higher_real_tier_than = duke
				spouse = {  higher_real_tier_than = duke }
				has_minor_title = title_despot
				has_minor_title = title_augusta
				is_or_was_offmap_power_ruler = yes
			}
		}
		modifier = {
			factor = 0
			OR = {
				has_portrait_property = { layer = 5 index = 1 }
				has_portrait_property = { layer = 5 index = 2 }
			}
			NOT = { is_variable_equal = { which = ca_headgear value = 4 } }
		}
		modifier = {
			factor = 0
			is_nomadic = yes
			NOT = {
				population = 5000
			}
		}
		modifier = { #Nomads marrying lowly pagans should not give them Imperial crowns unless proper population is met.
			factor = 0
			spouse = {
				is_nomadic = yes
				real_tier = KING
				NOT = {
					population = 5000
				}
			}
			is_ruler = yes
			lower_tier_than = KING
		}

		modifier = {
			factor = 0
			is_republic = yes
			is_alive = no
		}
		modifier = {
			factor = 0
			spouse = { is_republic = yes } #Dead wives of Patricians are nogovernment, thus they would wear crowns for being married to a King-tier.
			is_alive = no
			is_ruler = no
		}
		modifier = { #If you are a king and are not crowned, you don't wear a crown.
			factor = 0
			has_dlc = "Holy Fury" #Ignore Coronation triggers if Holy Fury is disabled.
			higher_real_tier_than = duke
			is_feudal = yes
			is_landed = yes
			OR = {
				religion = catholic
				religion = fraticelli
			}
			OR = {
				is_alive = yes
				trait = uncrowned
			}
			OR = {
				has_game_started = yes
				is_save_game = yes
			}
			NOR = {
				trait = crowned_by_priest
				trait = crowned_by_bishop
				trait = crowned_by_pope
				trait = crowned_by_myself
				primary_title = { is_vice_royalty = yes }
			}
		}
		modifier = {
			factor = 0
			has_dlc = "Holy Fury"
			NOT = { higher_real_tier_than = duke }
			OR = {
				has_game_started = yes
				is_save_game = yes
			}
			spouse = {
				higher_real_tier_than = duke
				is_feudal = yes
				is_landed = yes
				OR = {
					religion = catholic
					religion = fraticelli
				}
				OR = {
					is_alive = yes
					trait = uncrowned
				}
				NOR = {
					trait = crowned_by_priest
					trait = crowned_by_bishop
					trait = crowned_by_pope
					trait = crowned_by_myself
					primary_title = { is_vice_royalty = yes }
				}
			}
		}
		modifier = {
			factor = 0
			OR = {
				trait = peasant_leader
				trait = heresiarch
			}
		}
		modifier = {
			factor = 0
			is_republic = yes
			is_or_was_offmap_power_ruler = no
		}
		modifier = {
			factor = 0
			spouse = { is_republic = yes }
			is_alive = no
			is_landed = no
			is_or_was_offmap_power_ruler = no
		}
		modifier = {
			factor = 100
			is_variable_equal = { which = ca_headgear value = 4 }
		}
		modifier = {
			factor = 100
			song_dynasty_futou_trigger = yes
		}
	}

	# Simple golden band/turban
	4 = {
		factor = 4
		trigger = {
			OR = {
				higher_real_tier_than = count
				spouse = { higher_real_tier_than = count }
				has_minor_title = title_prince
				has_minor_title = title_queen_mother
				AND = { #French Counts also wear the golden band.
					has_dlc = "Holy Fury"
					OR = {
						culture = frankish
						culture = occitan
					}
					OR = {
						real_tier = count
						spouse = { real_tier = count }
					}
				}
			}
		}
		modifier = {
			factor = 0
			has_dlc = "Holy Fury" #Ignore Coronation triggers if Holy Fury is disabled.
			OR = {
				AND = {
					higher_real_tier_than = DUKE
					is_feudal = yes
					OR = {
						religion = catholic
						religion = fraticelli
					}
					OR = {
						trait = crowned_by_priest
						trait = crowned_by_bishop
						trait = crowned_by_pope
						trait = crowned_by_myself
						AND = {
							is_alive = no
							NOT = { trait = uncrowned }
						}
						AND = {
							has_game_started = no
							is_save_game = no
							is_alive = yes
						}
						is_vice_royalty = yes
					}
				}
				spouse = {
					higher_real_tier_than = DUKE
					is_feudal = yes
					OR = {
						religion = catholic
						religion = fraticelli
					}
					OR = {
						trait = crowned_by_priest
						trait = crowned_by_bishop
						trait = crowned_by_pope
						trait = crowned_by_myself
						AND = {
							is_alive = no
							NOT = { trait = uncrowned }
						}
						AND = {
							has_game_started = no
							is_save_game = no
							is_alive = yes
						}
						is_vice_royalty = yes
					}
				}
			}
			NOT = { is_variable_equal = { which = ca_headgear value = 5 } }
		}
		modifier = {
			factor = 0
			in_command = yes
			has_game_rule = {
				name = martial_headgear
				value = on
			}
		}
		modifier = {
			factor = 0
			NOT = { has_dlc = "Holy Fury" }
			higher_real_tier_than = DUKE
		}
		modifier = {
			factor = 0
			NOT = { has_dlc = "Holy Fury" }
			spouse = { higher_real_tier_than = DUKE }
		}
		modifier = {
			factor = 0
			is_ruler = yes
			NOT = { trait = uncrowned }
			NOT = { religion = catholic }
			NOT = { religion = fraticelli }
			higher_real_tier_than = DUKE
			OR = {
				is_nomadic = no
				population = 5000
			}
		}
		modifier = {
			factor = 0 #Dead Doges should not wear crowns.
			is_republic = yes
			is_alive = no
		}
		modifier = {
			factor = 0
			NOT = { real_tier = count }
			NOT = { real_tier = duke }
			NOT = { real_tier = king }
			NOT = { real_tier = emperor }
			NOT = { has_minor_title = title_prince }
			NOT = { spouse = { real_tier = emperor } }
			NOT = { spouse = { real_tier = king } }
			NOT = { spouse = { real_tier = duke } }
			NOT = { spouse = { real_tier = count } }
		}
		modifier = {
			factor = 0
			OR = {
				trait = peasant_leader
				trait = heresiarch
			}
		}
		modifier = {
			factor = 100
			is_variable_equal = { which = ca_headgear value = 5 }
		}
	}

	# Common headgear 1 - hood
	5 = {
		factor = 1
		modifier = {
			factor = 0
			OR = {
				higher_real_tier_than = count
				spouse = { higher_real_tier_than = count }
				has_minor_title = title_prince
				has_minor_title = title_queen_mother
				has_minor_title = title_despot
				has_minor_title = title_augusta
				is_or_was_offmap_power_ruler = yes
			}
			NOR = {
				employer = { government = order_government }
				employer = { mercenary = yes }
				trait = peasant_leader
				trait = heresiarch
				is_variable_equal = { which = ca_headgear value = 6 }
			}
		}
		modifier = {
			factor = 2
			is_female = yes
			is_married = no
			is_consort = no
			OR = {
				culture_group = west_slavic
				culture_group = south_slavic
				culture_group = magyar
			}
		}
		modifier = { # Specific rules for frankish / Occitanian layering
			factor = 0
			has_dlc = "Holy Fury"
			is_female = yes
			OR = {
				culture = frankish
				culture = occitan
			}
			NOR = {
				french_courtier_overlayer_trigger = yes
				is_variable_equal = { which = ca_headgear value = 6 }
			}
		}
		modifier = {
			factor = 100
			is_variable_equal = { which = ca_headgear value = 6 }
		}
	}

	# Common headgear 2 - hood
	6 = {
		factor = 1
		modifier = {
			factor = 0
			OR = {
				higher_real_tier_than = count
				spouse = { higher_real_tier_than = count }
				has_minor_title = title_prince
				has_minor_title = title_queen_mother
				has_minor_title = title_despot
				has_minor_title = title_augusta
				is_or_was_offmap_power_ruler = yes
			}
			NOR = {
				employer = { government = order_government }
				employer = { mercenary = yes }
				trait = peasant_leader
				trait = heresiarch
				is_variable_equal = { which = ca_headgear value = 7 }
			}
		}
		modifier = { # Specific rules for frankish / Occitanian layering
			factor = 0
			has_dlc = "Holy Fury"
			is_female = yes
			OR = {
				culture = frankish
				culture = occitan
			}
			OR = {
				is_ruler = yes
				spouse = { is_ruler = yes }
			}
			OR = {
				is_married = no
				NOT = { age = 40 }
			}
		}
		modifier = { # Specific rules for frankish / Occitanian layering
			factor = 0
			has_dlc = "Holy Fury"
			is_female = yes
			OR = {
				culture = frankish
				culture = occitan
			}
			NOR = {
				french_courtier_overlayer_trigger = yes
				is_variable_equal = { which = ca_headgear value = 7 }
			}
		}
		modifier = {
			factor = 100
			is_variable_equal = { which = ca_headgear value = 7 }
		}
	}

	# Common headgear 3 - Red hat
	7 = {
		factor = 1
		modifier = {
			factor = 0
			OR = {
				higher_real_tier_than = count
				spouse = { higher_real_tier_than = count }
				has_minor_title = title_prince
				has_minor_title = title_queen_mother
				has_minor_title = title_despot
				has_minor_title = title_augusta
				is_or_was_offmap_power_ruler = yes
			}
			NOR = {
				employer = { government = order_government }
				employer = { mercenary = yes }
				trait = peasant_leader
				trait = heresiarch
				is_variable_equal = { which = ca_headgear value = 8 }
			}
		}
		modifier = { # Specific rules for frankish / Occitanian layering
			factor = 0
			has_dlc = "Holy Fury"
			is_female = yes
			OR = {
				culture = frankish
				culture = occitan
			}
			OR = {
				is_ruler = yes
				spouse = { is_ruler = yes }
			}
			OR = {
				is_married = no
				NOT = { age = 40 }
			}
		}
		modifier = { # Specific rules for frankish / Occitanian layering
			factor = 0
			has_dlc = "Holy Fury"
			is_female = yes
			OR = {
				culture = frankish
				culture = occitan
			}
			NOR = {
				french_courtier_overlayer_trigger = yes
				is_variable_equal = { which = ca_headgear value = 8 }
			}
		}
		modifier = {
			factor = 100
			is_variable_equal = { which = ca_headgear value = 8 }
		}
	}

	# Common headgear 4 - hood
	8 = {
		factor = 1
		modifier = {
			factor = 0
			OR = {
				higher_real_tier_than = count
				spouse = { higher_real_tier_than = count }
				has_minor_title = title_prince
				has_minor_title = title_queen_mother
				has_minor_title = title_despot
				has_minor_title = title_augusta
				is_or_was_offmap_power_ruler = yes
			}
			NOR = {
				employer = { government = order_government }
				employer = { mercenary = yes }
				trait = peasant_leader
				trait = heresiarch
				is_variable_equal = { which = ca_headgear value = 9 }
			}
		}
		modifier = {
			factor = 0
			is_female = yes
			OR = {
				is_married = yes
				is_consort = yes
			}
			OR = {
				culture_group = west_slavic
				culture_group = south_slavic
				culture_group = magyar
			}
		}
		modifier = {
			factor = 2
			is_female = yes
			is_married = no
			is_consort = no
			OR = {
				culture_group = west_slavic
				culture_group = south_slavic
				culture_group = magyar
			}
		}
		modifier = { # Specific rules for frankish / Occitanian layering
			factor = 0
			has_dlc = "Holy Fury"
			is_female = yes
			OR = {
				culture = frankish
				culture = occitan
			}
			OR = {
				is_ruler = yes
				spouse = { is_ruler = yes }
			}
			OR = {
				is_married = no
				NOT = { age = 40 }
			}
		}
		modifier = { # Specific rules for frankish / Occitanian layering
			factor = 0
			has_dlc = "Holy Fury"
			is_female = yes
			OR = {
				culture = frankish
				culture = occitan
			}
			NOR = {
				french_courtier_overlayer_trigger = yes
				is_variable_equal = { which = ca_headgear value = 9 }
			}
		}
		modifier = {
			factor = 100
			is_variable_equal = { which = ca_headgear value = 9 }
		}
	}

	# Shady headgear
	9 = {
		hide_layers = { 31 = { } } #Veil overload.
		hide_layers = { 32 = { } }
		hide_layers = { 33 = { } }
		factor = 3
		trigger = {
			OR = {
				has_job_title = job_spymaster
				AND = {
					intrigue = 10
					lower_real_tier_than = duke
				}
				is_variable_equal = { which = ca_headgear value = 10 }
			}
		}
		modifier = {
			factor = 0
			OR = {
				higher_real_tier_than = duke
				spouse = { higher_real_tier_than = duke }
			}
			NOT = { is_variable_equal = { which = ca_headgear value = 10 } }
		}
		modifier = {
			factor = 100
			is_variable_equal = { which = ca_headgear value = 10 }
		}
	}

	# Martial headgear
	10 = {
		factor = 100
		trigger = {
			OR = {
				has_portrait_property = { layer = 3 index = 10 }
				is_variable_equal = { which = ca_headgear value = 11 }
			}
		}
		modifier = {
			factor = 0
			trait = saint
		}
		modifier = {
			factor = 0
			OR = {
				trait = shieldmaiden
				primary_title = { #Holy Orders in peace time should wear martial clothes, but not the helmet.
					OR = {
						title = d_knights_hospitaler
						title = d_knights_templar
						title = d_teutonic_order
						title = k_teutonic_state
						title = d_livonian_order
						title = e_china_west_governor
					}
				}
			}
			NAND = {
				in_command = yes
				has_game_rule = {
					name = martial_headgear
					value = on
				}
			}
		}
	}

	# Blank
	11 = {
		factor = 3
		modifier = {
			factor = 0
			OR = {
				higher_real_tier_than = count
				spouse = { higher_real_tier_than = count }
				has_minor_title = title_prince
				has_minor_title = title_queen_mother
				has_minor_title = title_despot
				has_minor_title = title_augusta
				is_or_was_offmap_power_ruler = yes
			}
			NOR = {
				prisoner = yes
				employer = { government = order_government }
				employer = { mercenary = yes }
				trait = peasant_leader
				trait = heresiarch
				trait = saint
				is_variable_equal = { which = ca_headgear value = 12 }
			}
		}
		modifier = {
			factor = 20000
			OR = {
				prisoner = yes
				trait = saint
				trait = shieldmaiden
				government = order_government
				primary_title = { #Holy Orders in peace time should wear martial clothes, but not the helmet.
					OR = {
						title = d_knights_hospitaler
						title = d_knights_templar
						title = d_teutonic_order
						title = k_teutonic_state
						title = d_livonian_order
					}
				}
			}
		}
		modifier = {
			factor = 4
			is_female = yes
			OR = {
				culture_group = west_slavic
				culture_group = south_slavic
				culture_group = magyar
			}
			is_married = no
		}
		modifier = {
			factor = 100
			is_variable_equal = { which = ca_headgear value = 12 }
		}
	}

	# Chinese Martial Extension 1
	12 = {
		factor = 100
		trigger = {
			OR = {
				has_portrait_property = { layer = 3 index = 12 }
				is_variable_equal = { which = ca_headgear value = 13 }
			}
		}
	}

	# Chinese Martial Extension 2
	13 = {
		factor = 100
		trigger = {
			OR = {
				has_portrait_property = { layer = 3 index = 13 }
				is_variable_equal = { which = ca_headgear value = 14 }
			}
		}
	}

	# Chinese Martial Extension 3
	14 = {
		factor = 100
		trigger = {
			OR = {
				has_portrait_property = { layer = 3 index = 14 }
				is_variable_equal = { which = ca_headgear value = 15 }
			}
		}
	}
}
