meritocratic_obligations = {
	obligation_levels = {
		default = {
			levies = {
				value = 0.3
			}

			tax = {
				value = 0.75
			}
		}
	}
}

### brief: administrative_themes
# This is referenced in code. 
#
meritocratic_provinces = {
	display_mode = radiobutton
	is_shown = {
		scope:subject.primary_title.tier >= tier_duchy
	}
	obligation_levels = {
		meritocratic_province_standard = {
			default = yes
			position = { 0 0 }
			icon = "gfx/interface/icons/celestial_administration_types/icon_standard_administration.dds"
			gui_tags = { civilian }
			
			ai_liege_desire = {
				value = 0
				if = {
					limit = {
						scope:subject = {
							is_ai = yes
						}
					}
					add = 1
					
					# Cautious AI should tend to have a minor bias towards the default
					if = {
						limit = {
							scope:liege = {
								ai_has_cautious_personality = yes
							}
						}
						add = 1
					}
				}
			}
			ai_subject_desire = 0
			
			score = 0
			color = { 0.7 0.7 0.7 1.0 }
			
			enable_title_maa = no
			
			subject_modifier = {
				monthly_merit_per_liege_tax = 0.8
			}
			
			flag = meritocratic_province_standard
			flag = meritocratic_civil_appointment
			appointment_trait_flag = civilian_province
		}
		meritocratic_province_industrial = {
			position = { 1 0 }
			icon = "gfx/interface/icons/celestial_administration_types/icon_industrial_administration.dds"
			gui_tags = { civilian }
			
			ai_liege_desire = {
				value = 0
				if = {
					limit = {
						scope:subject = {
							is_ai = yes
							OR = {
								has_trait = education_stewardship
								stewardship >= very_high_skill_rating
							}
							# Avoid replacing any military types if they have title troops already
							primary_title = {
								any_owned_title_maa_regiment = { count < 1 }
							}
						}
					}
					add = 2
					
					# Economical AI wants more of civic vassals
					if = {
						limit = {
							scope:liege = { ai_has_builder_or_pious_builder_personality = yes }
						}
						add = 1
					}
				}
			}
			ai_subject_desire = 0
			
			score = 0
			color = { 0.2 0.2 0.7 1.0 }
			
			is_valid = {
				# Only for direct vassals of the top liege or sub-vassals of a civilian province
				custom_tooltip = {
					text = liege_is_not_civilian_desc
					scope:liege = {
						trigger_if = {
							limit = {
								this != top_liege
							}
							vassal_contract_has_flag = meritocratic_civil_appointment
						}
					}
				}
				# There can only be a limited number of industries at a time
				custom_tooltip = {
					text = meritocratic_province_industrial_amount_desc
					OR = {
						scope:liege = {
							any_vassal = {
								count < meritocratic_province_industrial_max_value
								vassal_contract_has_flag = meritocratic_province_industrial
							}
						}
						scope:subject = { vassal_contract_has_flag = meritocratic_province_industrial }
					}
				}
			}

			tax_factor = 0.25
			enable_title_maa = no

			subject_modifier = {
				development_growth_factor = 0.15
				build_gold_cost = -0.1
				build_speed = -0.2
				monthly_merit_per_liege_tax = 1.2
			}
			
			flag = admin_ai_is_builder
			flag = meritocratic_province_industrial
			flag = meritocratic_civil_appointment
			flag = obligation_high_taxes
			appointment_trait_flag = civilian_province
		}
		meritocratic_province_military = {
			position = { 0 1 }
			icon = "gfx/interface/icons/celestial_administration_types/icon_military_administration.dds"
			gui_tags = { military }
			
			ai_liege_desire = {
				value = 0
				if = {
					limit = {
						scope:subject = {
							is_ai = yes
							OR = {
								has_trait = education_martial
								martial >= very_high_skill_rating
								primary_title = { any_owned_title_maa_regiment = { count >= 3 } }
								any_sub_realm_county = { # Is a border province
									any_neighboring_county = {
										holder = {
											top_liege != scope:subject.top_liege
										}
									}
								}
							}
						}
					}
					add = 2
					
					# Preference for vassals along the border
					if = {
						limit = {
							scope:subject = {
								any_sub_realm_county = {
									any_neighboring_county = {
										holder = {
											top_liege != scope:subject.top_liege
										}
									}
								}
							}
						}
						add = 3
					}
					
					# Warlike AI wants more military vassals
					if = {
						limit = {
							scope:liege = {
								ai_has_warlike_personality = yes
							}
						}
						add = 1
					}
				}
			}
			ai_subject_desire = 0
			
			score = 0
			color = { 0.7 0.2 0.2 1.0 }
			
			is_valid = {
				# Vassal has to be landed and direct vassal of the top liege, or a vassal of another military governor
				custom_tooltip = {
					text = liege_is_not_military_desc
					scope:liege = {
						trigger_if = {
							limit = {
								this != top_liege
							}
							vassal_contract_has_flag = meritocratic_military_appointment
						}
					}
				}
				# There can only be a limited number of militaries at a time
				custom_tooltip = {
					text = meritocratic_province_military_amount_desc
					OR = {
						scope:liege = {
							any_vassal = {
								count < meritocratic_province_military_max_value
								vassal_contract_has_flag = meritocratic_province_military
							}
						}
						scope:subject = { vassal_contract_has_flag = meritocratic_province_military }
					}
				}
			}

			levies_factor = 0.5
			
			subject_modifier = {
				development_growth_factor = -0.2
				monthly_county_control_growth_factor = 0.1
				additional_fort_level = 2
				defender_advantage = 4
				monthly_merit_per_title_maa_value = 0.024
				domain_tax_mult = -0.3

				monthly_treasury_from_military_budget_base = 1.0
			}
			
			flag = meritocratic_province_military
			flag = meritocratic_military_appointment
			flag = obligation_high_levies
			appointment_trait_flag = military_province
		}
	}
}

meritocratic_treasury = {
	display_mode = tree
	is_shown = {
		scope:subject.primary_title.tier >= tier_duchy
	}
	obligation_levels = {
		treasury_very_low = {
			position = { 0 0 }

			subject_modifier = {
				monthly_treasury_from_liege_mult = -0.10
			}

			ai_liege_desire = 1
			ai_subject_desire = 5

			subject_opinion = -25

			score = -2
		}
		treasury_low = {
			parent = treasury_very_low
			position = { 1 0 }

			subject_modifier = {
				monthly_treasury_from_liege_mult = -0.05
			}

			ai_liege_desire = 2
			ai_subject_desire = 4

			subject_opinion = -15

			score = -1
		}
		treasury_medium = {
			parent = treasury_low
			default = yes
			position = { 2 0 }

			ai_liege_desire = 3
			ai_subject_desire = 3

			score = 0
		}
		treasury_high = {
			parent = treasury_medium
			position = { 3 0 }

			subject_modifier = {
				monthly_treasury_from_liege_mult = 0.05
			}

			ai_liege_desire = 4
			ai_subject_desire = 2

			subject_opinion = 5

			score = 1
		}
		treasury_very_high = {
			parent = treasury_high
			position = { 4 0 }

			subject_modifier = {
				monthly_treasury_from_liege_mult = 0.10
			}

			ai_liege_desire = 5
			ai_subject_desire = 1

			subject_opinion = 10

			score = 2
		}
	}
}

meritocratic_salary = {
	display_mode = tree
	is_shown = {
		scope:subject.primary_title.tier >= tier_duchy
	}
	obligation_levels = {
		salary_very_low = {
			position = { 0 0 }

			subject_modifier = {
				monthly_treasury_from_salary_budget_mult = -0.5
			}

			ai_liege_desire = 1
			ai_subject_desire = 5

			subject_opinion = -25

			score = -2
		}
		salary_low = {
			parent = salary_very_low
			position = { 1 0 }

			subject_modifier = {
				monthly_treasury_from_salary_budget_mult = -0.25
			}

			ai_liege_desire = 2
			ai_subject_desire = 4

			subject_opinion = -15

			score = 1
		}
		salary_medium = {
			parent = salary_low
			default = yes
			position = { 2 0 }

			subject_modifier = {
			}

			ai_liege_desire = 3
			ai_subject_desire = 3

			score = 0
		}
		salary_high = {
			parent = salary_medium
			position = { 3 0 }

			subject_modifier = {
				monthly_treasury_from_salary_budget_mult = 0.25
			}

			ai_liege_desire = 4
			ai_subject_desire = 2

			subject_opinion = 5

			score = 1
		}
		salary_very_high = {
			parent = salary_high
			position = { 4 0 }

			subject_modifier = {
				monthly_treasury_from_salary_budget_mult = 0.5
			}

			ai_liege_desire = 5
			ai_subject_desire = 1

			subject_opinion = 10

			score = 2
		}
	}
}

meritocratic_salary_rank = {
	display_mode = hidden

	defaults_to_highest_valid_level = yes

	can_be_changed = {
		always = no
	}

	obligation_levels = {
		meritocratic_salary_rank_none = {
			position = { 0 0 }
			default = yes

			ai_liege_desire = 0
			ai_subject_desire = 0
		}
		meritocratic_salary_rank_county = {
			position = { 1 0 }

			parent = meritocratic_salary_rank_none
			is_valid = {
				scope:subject = {
					highest_held_title_tier = tier_county
					primary_title = {
						is_noble_family_title = no
					}
				}
			}

			ai_liege_desire = 2
			ai_subject_desire = 2

			subject_modifier = {
				monthly_treasury_from_salary_budget_base = 0.3
			}
		}
		meritocratic_salary_rank_duchy = {
			position = { 2 0 }

			parent = meritocratic_salary_rank_county
			is_valid = {
				scope:subject = {
					highest_held_title_tier = tier_duchy
				}
			}

			ai_liege_desire = 3
			ai_subject_desire = 3

			subject_modifier = {
				monthly_treasury_from_salary_budget_base = 0.75
			}
		}
		meritocratic_salary_rank_kingdom = {
			position = { 3 0 }

			parent = meritocratic_salary_rank_duchy
			is_valid = {
				scope:subject = {
					highest_held_title_tier = tier_kingdom
				}
			}

			ai_liege_desire = 4
			ai_subject_desire = 4

			subject_modifier = {
				monthly_treasury_from_salary_budget_base = 1.0
			}
		}
		meritocratic_salary_rank_empire = {
			position = { 4 0 }

			parent = meritocratic_salary_rank_kingdom

			ai_liege_desire = 5
			ai_subject_desire = 5

			is_valid = {
				scope:subject = {
					highest_held_title_tier = tier_empire
					is_landless_ruler = no
				}
			}
			subject_modifier = {
				monthly_treasury_from_salary_budget_base = 2.0
			}
		}
	}
}

meritocratic_tribute_gold = {
	display_mode = tree
	icon = gold_icon
	obligation_levels = {
		meritocratic_tributary_tax_none = {
			position = { 0 0 }

			tax = 0
			subject_opinion = 5

			subject_modifier = {
				monthly_legitimacy_add = 0.1
			}

			ai_liege_desire = 1
			ai_subject_desire = 4
			score = -2
		}
		meritocratic_tributary_tax_low = {
			default = yes
			parent = meritocratic_tributary_tax_none
			position = { 1 0 }

			tax = low_meritocratic_tributary_tax
			subject_opinion = -5

			subject_modifier = {
				monthly_legitimacy_add = 0.2
			}

			ai_liege_desire = 2
			ai_subject_desire = 3
			score = -1
		}
		meritocratic_tributary_tax_normal = {
			parent = meritocratic_tributary_tax_low
			position = { 2 0 }

			tax = normal_meritocratic_tributary_tax
			subject_opinion = -10

			subject_modifier = {
				monthly_legitimacy_add = 0.3
			}

			ai_liege_desire = 3
			ai_subject_desire = 2
			score = 0
		}
		meritocratic_tributary_tax_high = {
			parent = meritocratic_tributary_tax_normal
			position = { 3 0 }

			tax = high_meritocratic_tributary_tax
			subject_opinion = -25

			subject_modifier = {
				monthly_legitimacy_add = 0.5
			}

			ai_liege_desire = 4
			ai_subject_desire = 1
			score = 1
		}
	}
}

meritocratic_tribute_prestige = {
	display_mode = tree
	icon = prestige_icon
	obligation_levels = {
		meritocratic_prestige_transfer_none = {
			position = { 0 1 }

			prestige = 0
			subject_opinion = 5

			subject_modifier = {
				monthly_legitimacy_add = 0.1
			}

			ai_liege_desire = 1
			ai_subject_desire = 4
			score = -2
		}
		meritocratic_prestige_transfer_low = {
			default = yes
			parent = meritocratic_prestige_transfer_none
			position = { 1 1 }

			prestige = low_meritocratic_prestige_transfer
			subject_opinion = -5

			subject_modifier = {
				monthly_legitimacy_add = 0.2
			}

			ai_liege_desire = 2
			ai_subject_desire = 3
			score = -1
		}
		meritocratic_prestige_transfer_normal = {
			default = yes
			parent = meritocratic_prestige_transfer_low
			position = { 2 1 }

			prestige = normal_meritocratic_prestige_transfer
			subject_opinion = -10

			subject_modifier = {
				monthly_legitimacy_add = 0.3
			}

			ai_liege_desire = 3
			ai_subject_desire = 2
			score = 0
		}
		meritocratic_prestige_transfer_high = {
			parent = meritocratic_prestige_transfer_normal
			position = { 3 1 }

			prestige = high_meritocratic_prestige_transfer
			subject_opinion = -25

			subject_modifier = {
				monthly_legitimacy_add = 0.5
			}

			ai_liege_desire = 4
			ai_subject_desire = 1
			score = 1
		}
	}
}
