﻿@crown_authority_cooldown_years = 20

eranshar_authority = {
	default = eranshar_authority_1
	cumulative = yes
	flag = realm_law
	
	eranshar_authority_0 = {
		modifier = { 
			direct_vassal_opinion = 10 
			vassal_limit = 10
			vassal_tax_mult = -0.1
			vassal_levy_contribution_mult = -0.1
			domain_limit = -1
		}

		can_keep = { 
			realm_law_use_eranshar_authority = yes
			realm_law_use_nomadic_authority = no
			realm_law_use_gupta_authority = no
		}
	}
	
	eranshar_authority_1 = {
		modifier = { 
			direct_vassal_opinion = -15
			vassal_limit = -15
			vassal_tax_mult = 0.15
			vassal_levy_contribution_mult = 0.15
			domain_limit = 3
		}
		flag = title_revocation_allowed
		flag = can_change_succession_laws

		can_keep = { 
			realm_law_use_eranshar_authority = yes
			realm_law_use_nomadic_authority = no
			realm_law_use_gupta_authority = no
		}

		can_pass = {
			trigger_if = {
				limit = { has_realm_law = eranshar_authority_0 }
				custom_description = {
					subject = root
					text = "has_crown_authority_cooldown"
					NAND = {
						has_variable = crown_authority_cooldown
						NOT = {
							culture = { has_innovation = innovation_all_things }
						}
					}
				}
			}
		}
		
		pass_cost = {
			prestige = {
				if = {
					limit = {
						NOR = {
							has_realm_law = eranshar_authority_2
							has_realm_law = eranshar_authority_3
						}
					}
					add = increase_crown_authority_prestige_cost
				}
			}
		}
		
		on_pass = {
			# Increment cooldown breaker tally, if appropriate.
			calculate_authority_cooldown_break_effect = yes
			# Set regular cooldown.
			set_variable = {
				name = crown_authority_cooldown
				years = @crown_authority_cooldown_years
			}
		}

		ai_will_do = {
			if = {
				limit = { has_realm_law = eranshar_authority_0 }
				value = 1
			}
		}
	}
	
	eranshar_authority_2 = {
		modifier = { 
			direct_vassal_opinion = -15
			vassal_limit = -10
			vassal_tax_mult = 0.2
			vassal_levy_contribution_mult = 0.2
			domain_limit = 4
		}
		flag = vassal_retraction_allowed
		
		can_keep = { 
			realm_law_use_eranshar_authority = yes
			realm_law_use_nomadic_authority = no
			realm_law_use_gupta_authority = no 
		}
		
		can_pass = {
			trigger_if = {
				limit = {
					NOT = { has_realm_law = eranshar_authority_3 }
				}
				has_realm_law = eranshar_authority_1
				custom_description = {
					subject = root
					text = "has_crown_authority_cooldown"
					NAND = {
						has_variable = crown_authority_cooldown
						NOT = {
							culture = { has_innovation = innovation_all_things }
						}
					}
				}
			}
		}

		pass_cost = {
			prestige = {
				if = {
					limit = {
						NOT = { has_realm_law = eranshar_authority_3 }
					}
					add = increase_crown_authority_prestige_cost
				}
			}
		}
		
		on_pass = {
			# Increment cooldown breaker tally, if appropriate.
			calculate_authority_cooldown_break_effect = yes
			# Set regular cooldown.
			set_variable = {
				name = crown_authority_cooldown
				years = @crown_authority_cooldown_years
			}
		}

		ai_will_do = {
			if = {
				limit = { has_realm_law = eranshar_authority_1 }
				value = 1
			}
		}
	}
	
	eranshar_authority_3 = {
		modifier = { 
			direct_vassal_opinion = -30
			vassal_limit = -15
			vassal_tax_mult = 0.35
			vassal_levy_contribution_mult = 0.35
			domain_limit = 6
		}
		
		can_keep = { 
			realm_law_use_eranshar_authority = yes 
			realm_law_use_nomadic_authority = no
			realm_law_use_gupta_authority = no
		}
		
		can_pass = {
			has_realm_law = eranshar_authority_2
			custom_description = {
				subject = root
				text = "has_crown_authority_cooldown"
				NAND = {
						has_variable = crown_authority_cooldown
						NOT = {
							culture = { has_innovation = innovation_all_things }
						}
					}
			}
		}
		
		pass_cost = { prestige = increase_crown_authority_prestige_cost }
		
		on_pass = {
			# Increment cooldown breaker tally, if appropriate.
			calculate_authority_cooldown_break_effect = yes
			# Set regular cooldown.
			set_variable = {
				name = crown_authority_cooldown
				years = @crown_authority_cooldown_years
			}
		}

		ai_will_do = {
			if = {
				limit = { has_realm_law = eranshar_authority_2 }
				value = 1
			}
		}
	}
}
