﻿#valid_holdings = { city_holding}
#feudal, theocracy, clan, nomad, mandala
### Brief: feudal_government
#
### Brief: feudal_government
#
# This is referenced in code
#
feudal_government = {
	government_rules = {
		create_cadet_branches = yes
		rulers_should_have_dynasty = yes
		dynasty_named_realms = yes
		legitimacy = yes
		allow_accolades = yes
	}

	royal_court = any

	fallback = 1

	primary_holding = castle_holding
	valid_holdings = { temple_citadel_holding city_holding }
	required_county_holdings = { castle_holding city_holding church_holding }

	vassal_contract_group = feudal_vassal

	ai = {
		use_legends = yes
	}

	# Use flags instead of has_government for moddability if possible (i.e., wherever not visible to the player).
	flags = {
		government_is_feudal
		government_is_settled
		may_elevate_co_monarch
		government_uses_crown_authority
		government_uses_domain_limit
	}

	mechanic_type = feudal
	is_mechanic_type_default = yes

	color = hsv{ 0.67 1.00 0.78 }
	realm_mask_offset = { 0.0 0.01 }
	realm_mask_scale = { 1 1 }
}

### Brief: theocracy_government
# Head of faith will always get this if possible
#
# This is referenced in code
#
theocracy_government = {
	government_rules = {
		religious = yes
		inherit_from_dynastic_government = no
	}

	primary_holding = church_holding
	valid_holdings = { castle_holding city_holding tribal_holding nomad_holding herder_holding temple_citadel_holding }
	required_county_holdings = { church_holding castle_holding city_holding }

	ai = {
		use_legends = no
	}

	can_get_government = {
		NOT = {
			faith = { has_doctrine = doctrine_theocracy_lay_clergy }
		}
		#The LAAMP Construct Holding decision
		trigger_if = {
			limit = {
				OR = {
					has_variable = city_construction_is_temple_citadel
					has_variable = city_construction_is_castle
				}
			}
			always = no
		}
	}

	vassal_contract_group = theocracy_vassal

	# Use flags instead of has_government for moddability if possible (i.e., wherever not visible to the player).
	flags = {
		government_is_theocracy
		government_is_settled
		government_uses_domain_limit
	}

	mechanic_type = theocracy
	is_mechanic_type_default = yes

	color = hsv{ 0.00 0.00 0.78 }
	realm_mask_offset = { 0.0 0.02 }
	realm_mask_scale = { 0.95 0.95 }
}

### Brief: clan_government
clan_government = {
	government_rules = {
		create_cadet_branches = yes
		rulers_should_have_dynasty = yes
		legitimacy = yes
		dynasty_named_realms = yes
		always_use_patronym = yes
		allow_accolades = yes
	}

	royal_court = any

	primary_holding = castle_holding
	primary_heritages = { heritage_arabic heritage_iranian heritage_turkic }

	fallback = 2

	preferred_religions = { islam_religion }

	valid_holdings = { temple_citadel_holding city_holding }
	required_county_holdings = { castle_holding city_holding church_holding }

	house_unity = clan_house_unity
	tax_slot_type = clan_tax_slot

	vassal_contract_group = clan_vassal

	ai = {
		use_legends = yes
	}

	opinion_of_liege = {
		scope:vassal = {
			if = {
				limit = {
					is_powerful_vassal = yes
					NOT = {
						is_allied_to = scope:liege
					}
				}
				value = clan_powerful_vassal_no_alliance_opinion_penalty_value
			}
		}
	}
	opinion_of_liege_desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:vassal = {
						NOT = {
							is_allied_to = scope:liege
						}
						is_powerful_vassal = yes
					}
				}
				desc = "GOVERNMENT_CLAN_NOT_ALLIED_POWERFUL"
			}
		}
	}

	# Use flags instead of has_government for moddability if possible (i.e., wherever not visible to the player).
	flags = {
		government_is_clan
		may_appoint_viziers
		government_is_settled
		government_uses_crown_authority
		government_uses_domain_limit
	}

	mechanic_type = clan
	is_mechanic_type_default = yes

	color = hsv{ 0.39 0.93 0.54 }
	realm_mask_offset = { 0.0 0.03 }
	realm_mask_scale = { 1 1 }
}

### Brief: nomad_government
# Default nomad government, used for the Steppe Region
#
# This is referenced in code
#
nomad_government = {
	government_rules = {
		obedience = yes
		create_cadet_branches = yes
		rulers_should_have_dynasty = yes
		dynasty_named_realms = no
		landless_playable = yes
		legitimacy = yes
		use_as_base_on_rank_up = yes
		use_as_base_on_landed = yes
		conditional_maa_refill = yes
		uses_county_fertility = yes
		uses_culture_and_house_head_named_realms = yes
		sticky_government = yes
		subject_men_at_arms = yes
		no_capital_movement_cooldown = yes
		affected_by_development = no
		buildings = no
		allow_accolades = yes
	}

	royal_court = any

	domicile_type = yurt

	primary_holding = nomad_holding
	valid_holdings = { castle_holding city_holding tribal_holding temple_citadel_holding }
	required_county_holdings = { nomad_holding }

	generated_character_template = nomadic_chieftain_character

	max_dread = 150

	vassal_contract_group = nomad_vassal

	can_get_government = {
		has_mpo_dlc_trigger = yes
	}

	character_modifier = {
		steppe_travel_danger = steppe_high_danger_reduction
		plains_travel_danger = steppe_high_danger_reduction
		drylands_travel_danger = drylands_medium_danger_reduction
		mountains_travel_danger = mountains_medium_danger_reduction
		steppe_cancel_negative_supply = yes
		ignore_negative_opinion_of_culture = yes
		county_fertility_decline_add = -15
		movement_speed = 0.1
		movement_speed_land_raiding = 0.1
		the_great_steppe_supply_limit_add = 10000
		game_rule_extra_nomads_arabs_supply_limit_add = 10000
		game_rule_extra_nomads_horn_supply_limit_add = 10000
		game_rule_extra_nomads_sahel_supply_limit_add = 10000
		game_rule_extra_nomads_sami_supply_limit_add = 10000
		game_rule_extra_nomads_tibet_supply_limit_add = 10000
		domain_limit = -1
		ai_war_cooldown = -0.5
		ai_war_chance = 2
		men_at_arms_maintenance = -0.5
		supply_duration = 1
		county_opinion_add = 25
		title_creation_cost_mult = -0.5
	}

	# Use flags instead of has_government for moddability if possible (i.e., wherever not visible to the player).
	flags = {
		government_is_nomadic
		government_has_herd
		government_can_raid_rule
		government_can_use_tributary_men_at_arms
		can_start_war_with_raised_troops
		ignores_faith_marriage_penalties
		no_hostile_attrition_in_steppe # Done in code, here for loc
		movement_speed_from_government
		land_raiding_movement_speed_from_government
		can_raze_holdings
		government_uses_domicile_but_not_adventurer
	}

	mechanic_type = nomad
	is_mechanic_type_default = yes

	# These flags only exist for loc and in-game descriptions
	color = { 255 127 80 }
	realm_mask_offset = { 0.0 0.12 }
	realm_mask_scale = { 0.8 0.8 }
}

mandala_government = {
	government_rules = {
		create_cadet_branches = yes

		rulers_should_have_dynasty = yes
		dynasty_named_realms = yes

		legitimacy = yes
		use_as_base_on_landed = yes
		use_as_base_on_rank_up = yes
		house_aspirations = yes
		considers_piety_for_title_creation = yes
		ask_for_tribute = yes

		deny_powerful_vassal = yes #LET HAVOC ENSUE!

		count_tributaries_for_title_requirements = yes
		radiance = yes
		allow_accolades = yes
	}

	royal_court = any

	primary_holding = temple_citadel_holding
	valid_holdings = { church_holding city_holding castle_holding }
	required_county_holdings = { temple_citadel_holding city_holding }

	can_get_government = {
		has_tgp_dlc_trigger = yes
		OR = {
			liege ?= { has_government = mandala_government }
			is_independent_ruler = yes
		}
		#The LAAMP Construct Holding decision
		trigger_if = {
			limit = {
				OR = {
					has_variable = city_construction_is_temple_citadel
					has_variable = city_construction_is_castle
				}
			}
			capital_province = { has_holding_type = temple_citadel_holding }
		}
	}

	vassal_contract_group = mandala_vassal

	opinion_of_liege = {
		scope:liege = {
			if = {
				limit = { piety_level = max_piety_level_plus_3 }
				scope:vassal = { value = mandala_vassal_opinion_bonus_piety_8_value }
			}
			else_if = {
				limit = { piety_level = max_piety_level_plus_2 }
				scope:vassal = { value = mandala_vassal_opinion_bonus_piety_7_value }
			}
			else_if = {
				limit = { piety_level = max_piety_level_plus_1 }
				scope:vassal = { value = mandala_vassal_opinion_bonus_piety_6_value }
			}
			else_if = {
				limit = { piety_level = max_piety_level }
				scope:vassal = { value = mandala_vassal_opinion_bonus_piety_5_value }
			}
			else_if = {
				limit = { piety_level = very_high_piety_level }
				scope:vassal = { value = mandala_vassal_opinion_bonus_piety_4_value }
			}
			else_if = {
				limit = { piety_level = high_piety_level }
				scope:vassal = { value = mandala_vassal_opinion_bonus_piety_3_value }
			}
			else_if = {
				limit = { piety_level = medium_piety_level }
				scope:vassal = { value = mandala_vassal_opinion_bonus_piety_2_value }
			}
			else_if = {
				limit = { piety_level = low_piety_level }
				scope:vassal = { value = mandala_vassal_opinion_bonus_piety_1_value }
			}
			else_if = {
				limit = { piety_level = low_negative_piety_level }
				scope:vassal = { value = mandala_vassal_opinion_bonus_piety_0_value }
			}
		}
	}
	opinion_of_liege_desc = { desc = liege_piety_level_desc }

	opinion_of_suzerain = {
		scope:suzerain = {
			if = {
				limit = { piety_level = max_piety_level_plus_3 }
				scope:tributary = { value = mandala_tributary_opinion_bonus_piety_8_value }
			}
			else_if = {
				limit = { piety_level = max_piety_level_plus_2 }
				scope:tributary = { value = mandala_tributary_opinion_bonus_piety_7_value }
			}
			else_if = {
				limit = { piety_level = max_piety_level_plus_1 }
				scope:tributary = { value = mandala_tributary_opinion_bonus_piety_6_value }
			}
			else_if = {
				limit = { piety_level = max_piety_level }
				scope:tributary = { value = mandala_tributary_opinion_bonus_piety_5_value }
			}
			else_if = {
				limit = { piety_level = very_high_piety_level }
				scope:tributary = { value = mandala_tributary_opinion_bonus_piety_4_value }
			}
			else_if = {
				limit = { piety_level = high_piety_level }
				scope:tributary = { value = mandala_tributary_opinion_bonus_piety_3_value }
			}
			else_if = {
				limit = { piety_level = medium_piety_level }
				scope:tributary = { value = mandala_tributary_opinion_bonus_piety_2_value }
			}
			else_if = {
				limit = { piety_level = low_piety_level }
				scope:tributary = { value = mandala_tributary_opinion_bonus_piety_1_value }
			}
			else_if = {
				limit = { piety_level = low_negative_piety_level }
				scope:tributary = { value = mandala_tributary_opinion_bonus_piety_0_value }
			}
		}
	}
	opinion_of_suzerain_desc = { desc = suzerain_piety_level_desc }

	character_modifier = {
		clergy_opinion = 5
		zealot_opinion = 5
		domain_limit_max = 2

		#Vassal Limit Max:
		#Base:
		vassal_limit_max = 2
		#Increased with Mandala Temple Complex up to 30
		#Further 35 possible from Piety Levels 6-8 for a total of 65
		zealot_tax_contribution_mult = 0.05
		zealot_levy_contribution_mult = 0.05
		monthly_piety_gain_mult = 0.15
	}

	# Use flags instead of has_government for moddability if possible (i.e., wherever not visible to the player).
	flags = {
		uses_mandala_aspects
		uses_mandala_decrees
		government_is_mandala
		has_coerce_tributary_scheme
		additional_piety_from_religious_buildings
		can_perform_ritual_contracts
		subjects_gain_piety_based_on_overlord_piety_level
		has_special_house_aspirations
		government_is_settled
		has_unique_government_perks
		no_powerful_vassals
	}

	# These flags only exist for loc and in-game descriptions

	currency_levels_cap = {
		piety = 8
	}

	mechanic_type = mandala
	is_mechanic_type_default = yes

	color = { 42 56 100 }
	realm_mask_offset = { 0.0 0.05 }
	realm_mask_scale = { 0.92 0.92 }
}
