﻿#EK NOTE: changed government triggers
#############################################
# Hire Agents								#
# by Emil Tisander							#
#############################################

estate_hire_agents_decisions = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_misc.dds"
	}
	sort_order = 105
	ai_check_interval = 120

	desc = estate_hire_agents_decisions_desc
	selection_tooltip = estate_hire_agents_decisions_tooltip
	decision_group_type = admin
	
	cooldown = { years = 15 }
	
	is_shown = {
		has_ep3_dlc_trigger = yes
		domicile ?= {
			has_domicile_parameter = estate_unlock_hire_agents_decision
		}
	}

	is_valid = {
	}

	is_valid_showing_failures_only = {
		is_available_adult = yes # Skulduggery isn't for children
	}

	effect = {
		add_character_modifier = {
			modifier = ep3_estate_hired_agents_modifier
			years = 15
		}
	}
	
	cost = {
		influence = major_influence_value
	}

	ai_potential = {
		is_governor = yes
	}

	ai_will_do = {
		base = 20
		modifier = {
			add = 20
			has_trait = deceitful
		}
		modifier = {
			add = 20
			has_trait = vengeful
		}
		modifier = {
			add = 20
			has_trait = paranoid
		}
		modifier = {
			add = 10
			has_trait = ambitious
		}
		modifier = {
			add = -20
			has_trait = content
		}
		modifier = {
			add = -20
			has_trait = compassionate
		}
	}
}

#############################################
# Bolster Security							#
# by Emil Tisander							#
#############################################

estate_bolster_security_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_invite_knights.dds"
	}
	sort_order = 105
	ai_check_interval = 120

	desc = estate_bolster_security_decision_desc
	selection_tooltip = estate_bolster_security_decision_tooltip
	decision_group_type = admin
	
	cooldown = { years = 15 }
	
	is_shown = {
		has_ep3_dlc_trigger = yes
		domicile ?= {
			has_domicile_parameter = estate_unlock_bolster_security_decision
		}
	}

	is_valid = {
	}

	is_valid_showing_failures_only = {
		is_available_adult = yes
	}

	effect = {
		add_character_modifier = {
			modifier = ep3_estate_bolster_security_modifier
			years = 15
		}
	}
	
	cost = {
		influence = major_influence_value
	}

	ai_potential = {
		is_governor = yes
		NOR = {
			has_trait = trusting
			has_trait = gregarious
		}
	}

	ai_will_do = {
		base = 20
		modifier = {
			add = 50
			has_trait = paranoid
		}
		modifier = {
			add = 10
			has_trait = deceitful
		}
		modifier = {
			add = 10
			has_trait = craven
		}
		modifier = {
			add = 10
			dread >= 50
		}
	}
}

#############################################
# Patrol Governorship						#
# by Emil Tisander							#
#############################################

estate_governor_patrols_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/fp2_decision_struggle_opening.dds"
	}
	sort_order = 105
	ai_check_interval = 120

	desc = estate_governor_patrols_decision_desc
	selection_tooltip = estate_governor_patrols_decision_tooltip
	decision_group_type = admin
	
	cooldown = { years = 15 }
	
	is_shown = {
		has_ep3_dlc_trigger = yes
		domicile ?= {
			has_domicile_parameter = estate_unlock_patrol_decision
		}
	}

	is_valid = {
	}

	is_valid_showing_failures_only = {
		is_governor = yes
	}

	effect = {
		every_held_title = {
			limit = {
				tier = tier_county
			}
			add_to_list = counties_in_governorship
		}
		every_vassal = {
			limit = {
				any_held_title = { tier = tier_county }
			}
			every_held_title = {
				limit = {
					tier = tier_county
				}
				add_to_list = counties_in_governorship
			}
		}
		every_in_list = {
			list = counties_in_governorship
			add_county_modifier = {
				modifier = ep3_estate_governor_patrols_modifier
				years = 15
			}
		}
		increase_governance_effect = { VALUE = 6 }
	}
	
	cost = {
		gold = medium_gold_value
	}
	
	ai_potential = {
		is_governor = yes
	}
	
	ai_will_do = {
		base = 20
		modifier = {
			add = 50
			influence > monumental_influence_value
		}
		modifier = {
			add = 10
			has_trait = just
		}
		modifier = {
			add = 10
			has_trait = loyal
		}
		modifier = {
			add = 10
			has_trait = diligent
		}
		modifier = {
			add = -25
			has_trait = lazy
		}
		modifier = {
			add = -20
			opinion = {
				target = liege
				value < -20
			}
		}
	}
}

#############################################
# Manipulate Grain Market					#
# by Emil Tisander							#
#############################################

estate_granary_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_spend_money.dds"
	}
	sort_order = 105
	ai_check_interval = 120

	desc = estate_granary_decision_desc
	selection_tooltip = estate_granary_decision_tooltip
	decision_group_type = admin
	
	cooldown = { years = 20 }
	
	is_shown = {
		has_ep3_dlc_trigger = yes
		domicile ?= {
			has_domicile_parameter = estate_unlock_granary_decision
		}
	}

	is_valid = {
	}

	is_valid_showing_failures_only = {
	}

	effect = {
		add_character_modifier = {
			modifier = ep3_estate_granary_modifier
			years = 10
		}
		
		# Descriptions - Make sure the triggers below matches the ones in the granary_modifier_scaling_value scripted value
		save_scope_as = domicile_owner # We save it for the descriptions
		custom_description_no_bullet = { text = estate_unlock_granary_decision_factors_tt }
		if = {
			limit = {
				domicile ?= { has_domicile_building_or_higher = grain_field_01 }
			}
			custom_tooltip = estate_unlock_granary_decision_grain_building_tt
		}
		if = {
			limit = {
				domicile ?= {
					domicile_location = {
						this = root.top_liege.capital_province
					}
				}
			}
			custom_tooltip = estate_unlock_granary_decision_capital_tt
		}
		if = {
			limit = {
				domicile ?= {
					domicile_location = {
						OR = {
							terrain = farmlands
							terrain = floodplains
						}
					}
				}
			}
			custom_tooltip = estate_unlock_granary_decision_terrain_tt
		}
		if = {
			limit = {
				domicile ?= {
					domicile_location.county = {
						county_control < 100
					}
				}
			}
			custom_tooltip = estate_unlock_granary_decision_control_tt
		}
		if = {
			limit = {
				domicile ?= {
					domicile_location.county = {
						development_level >= estate_granary_development_bonus_2_value
					}
				}
			}
			custom_tooltip = estate_unlock_granary_decision_development_2_tt
		}
		else_if = {
			limit = {
				domicile ?= {
					domicile_location.county = {
						development_level >= estate_granary_development_bonus_1_value
					}
				}
			}
			custom_tooltip = estate_unlock_granary_decision_development_1_tt
		}
		if = {
			limit = {
				domicile ?= {
					domicile_location = {
						any_province_epidemic = { count >= 1 }
					}
				}
			}
			custom_tooltip = estate_unlock_granary_decision_epidemic_tt
		}
		if = {
			limit = {
				granary_modifier_scaling_value <= 1
			}
			custom_tooltip = estate_unlock_granary_decision_no_factors_tt
		}
	}
	
	cost = {
		prestige = major_prestige_value
	}
	
	ai_potential = {
		is_governor = yes
	}
	
	ai_will_do = {
		base = 20
		modifier = {
			add = 30
			prestige > massive_prestige_value
		}
		modifier = {
			add = 20
			has_trait = greedy
		}
		modifier = {
			add = 10
			has_trait = deceitful
		}
		modifier = {
			add = 10
			has_trait = arbitrary
		}
		modifier = {
			add = 10
			has_trait = callous
		}
		modifier = {
			add = 10
			domicile ?= { has_domicile_building_or_higher = grain_field_01 }
		}
		modifier = {
			add = -10
			has_trait = generous
		}
		modifier = {
			add = -20
			has_trait = compassionate
		}
		modifier = {
			add = -25
			has_trait = just
		}
	}
}

#############################################
# Governorship Confirmation					#
# by Joe Parkin								#
#############################################

admin_confirmation_decision = {
	ai_check_interval = 45
	sort_order = 1000
	#EK DISABLED: byzantium
	#picture = {
	#	trigger = {
	#		NOR = {
	#			government_has_flag = government_is_tribal
	#			government_has_flag = government_is_theocracy
	#			top_liege ?= { government_has_flag = government_is_tribal }
	#			top_liege ?= { government_has_flag = government_is_theocracy }
	#		}
	#		OR = {
	#			culture = { has_cultural_pillar = heritage_byzantine }
	#			top_liege ?= {
	#				OR = {
	#					culture = { has_cultural_pillar = heritage_byzantine }
	#					capital_barony ?= title:b_constantinople
	#					primary_title ?= title:e_byzantium
	#					primary_title ?= title:e_roman_empire
	#				}
	#			}
	#		}
	#	}
	#	reference = "gfx/interface/illustrations/decisions/ep3_cerimonial_decision.dds"
	#}
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_knight_kneeling.dds"
	}
	decision_group_type = admin

	cost = {
		prestige = standard_activity_cost
	}

	is_shown = {
		has_ep3_dlc_trigger = yes
		is_playable_character = yes
		is_governor = yes
		liege ?= top_liege
	}

	is_valid = {
		custom_tooltip = {
			text = admin_confirmation_rank_tt
			primary_title.tier >= tier_duchy # Governs a Province
		}
		custom_tooltip = {
			text = admin_confirmation_liege_tt
			is_independent_ruler = no
			liege ?= top_liege
		}
		custom_tooltip = {
			text = admin_confirmation_time_tt
			primary_title ?= {
				title_held_years >= 1
			}
		}
		custom_tooltip = {
			text = admin_confirmation_grace_valid_tt
			NOR = {
				has_variable = confirmation_grace
				has_variable = confirmation_cooldown_vassal
			}
		}
	}

	is_valid_showing_failures_only = {
		is_available_adult = yes
		liege ?= { is_available_adult = yes }
		is_at_war_with_liege = no
		trigger_if = {
			limit = {
				is_ai = no
				has_royal_court = yes
			}
			has_spawned_court_events = no # should only be used for human players
		}
		trigger_if = {
			limit = { is_ai = yes }
			NOT = {
				liege = { has_variable = confirmation_cooldown }
			}
		}
	}

	effect = {
		set_variable = {
			name = confirmation_liege_scope
			value = liege
		}
		custom_tooltip = admin_confirmation_decision_effects
		show_as_tooltip = {
			stress_impact = {
				shy = medium_stress_impact_gain
				humble = medium_stress_impact_gain
			}
			custom_description_no_bullet = {
				text = admin_confirmation_decision_tt_if_accepted
				subject = root
			}
			admin_confirmation_vassal_reward_guts_effect = yes
		}
		save_scope_as = confirmation_vassal
		liege ?= { save_scope_as = confirmation_liege }
		start_travel_plan = {
			destination = liege.capital_province
			on_start_on_action = admin_confirmation_start
			on_travel_planner_cancel_on_action = admin_confirmation_travel_planner_exit
			on_arrival_event = ep3_decisions_event.2090
			on_arrival_destinations = all_but_last
		}
	}
	
	ai_potential = {
		is_at_war = no
	}

	ai_will_do = {
		base = 0
		modifier = {
			add = 50
			prestige > standard_activity_cost
		}
		modifier = {
			add = -50
			has_relation_rival = liege
		}
		modifier = {
			add = -25
			opinion = {
				target = liege
				value < 0
			}
		}
		modifier = { # Kings should be more weighted
			add = 25
			primary_title.tier >= tier_kingdom
		}
	}
}

#############################################
# Consolidate Rule							#
#############################################

consolidate_rule_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_family_tree.dds"
	}
	sort_order = 105
	ai_check_interval = 120

	desc = consolidate_rule_decision_desc
	selection_tooltip = consolidate_rule_decision_tooltip
	decision_group_type = admin
	
	cooldown = { years = 15 }
	
	is_shown = {
		has_ep3_dlc_trigger = yes
		highest_held_title_tier = tier_empire # Only for Emperors
		culture = { # Byzantium and others
			has_cultural_tradition = tradition_religious_patronage
		}
		faith = { # You cannot consolidate yourself... kinda
			exists = religious_head
			religious_head = {
				NOT = { this = root }
			}
		}
	}

	is_valid = {
		government_allows = administrative
	}

	is_valid_showing_failures_only = {
		culture = {
			has_cultural_parameter = consolidate_rule_decision
		}
		any_held_title = { is_head_of_faith = no }
	}

	effect = {
		custom_tooltip = consolidate_rule_decision_effect_tt
		trigger_event = ep3_decisions_event.4050
	}
	
	cost = {
		influence = medium_influence_value
		piety = medium_piety_value
	}

	ai_potential = {
		highest_held_title_tier = tier_empire # Only for Emperors
		culture = { # Byzantium and others
			has_cultural_tradition = tradition_religious_patronage
		}
		faith = { # You cannot consolidate yourself... kinda
			exists = religious_head
			religious_head = {
				NOT = { this = root }
			}
		}
	}

	ai_will_do = {
		base = 20
		modifier = {
			add = 20
			legitimacy_level <= 2
		}
		modifier = {
			add = 20
			legitimacy_level <= 1
		}
		modifier = {
			add = 20
			legitimacy_level = 0
		}
	}
}

###################################
# Convert Realm to Administrative #
###################################

convert_to_administrative_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/ep3_cerimonial_decision.dds"
	}
	decision_group_type = major
	desc = convert_to_administrative_decision_desc

	ai_check_interval = 36

	is_shown = {
		has_ep3_dlc_trigger = yes
		has_feudal_like_succession = yes #EK EDIT: succession instead of government because it doesn't include hierocracy 
		trigger_if = {
			limit = { is_independent_ruler = no }
			liege = { government_allows = administrative }
		}
		trigger_else = {
			is_independent_ruler = yes
		}
	}

	is_valid = {
		has_ep3_dlc_trigger = yes
		has_feudal_like_succession = yes #EK EDIT: succession instead of government because it doesn't include hierocracy 
		trigger_if = {
			limit = { is_independent_ruler = no }
			liege = { government_allows = administrative }
		}
		trigger_else = {
			trigger_if = {
				limit = {
					culture = { has_cultural_parameter = can_adopt_administrative_government_as_kingdom_tier }
				}
				custom_tooltip = {
					text = king_tier_tt
					primary_title.tier >= tier_kingdom
				}
			}
			trigger_else = {
				custom_tooltip = {
					text = empire_tier_tt
					primary_title.tier = tier_empire
				}
				root = { save_temporary_scope_as = root_scope }
				custom_tooltip = {
					text = small_realm_size_tt
					realm_size >= small_empire_size_value
				}
			}
		}
		trigger_if = {
			limit = {
				is_independent_ruler = yes
				is_ai = no
			}
			prestige_level >= 3
		}
		trigger_if = {
			limit = {
				is_independent_ruler = yes
				is_ai = no
			}
			custom_tooltip = {
				text = all_powerful_vassals_required_tt
				any_powerful_vassal = {
					count = all
					opinion = {
						target = root
						value >= 50
					}
				}
			}
		}
		trigger_if = {
			limit = { is_ai = yes }
			calc_true_if = {
				amount >= 2
				culture = { has_cultural_pillar = ethos_bureaucratic }
				culture = { has_cultural_pillar = ethos_courtly }
				culture = { has_cultural_pillar = ethos_egalitarian }
				culture = { has_cultural_tradition = tradition_legalistic }
				has_realm_law = crown_authority_3
				capital_county = {
					development_level > medium_development_level
				}
				faith = { has_doctrine = tenet_legalism }
				dynasty = {
					has_dynasty_perk = erudition_legacy_5
				}
				dynasty = {
					has_dynasty_perk = law_legacy_5
				}
				#EK ADDITION: our cultures that like administrative
				culture = { has_cultural_tradition = tradition_imperial_legacy }
				culture = { has_cultural_tradition = tradition_ceremoniarchy }
				culture = { has_cultural_tradition = tradition_crown_core }
				culture = { has_cultural_tradition = tradition_pursuit_of_wealth }
				#EK TODO: enable when MW is on develop
				#culture = { has_cultural_tradition = tradition_garden_of_veloth }
			}
		}
	}
	
	is_valid_showing_failures_only = {
		is_at_war = no
	}

	cost = {
		prestige = {
			value = 1000
			if = {
				limit = {
					is_ai = no
					primary_title.tier = tier_kingdom
				}
				multiply = 1.5
			}
			if = { # Much cheaper for vassals wanting to adopt their admin liege's government
				limit = {
					is_independent_ruler = no
				}
				multiply = 0.1
			}
		}
		gold = {
			value = 800
			if = {
				limit = { is_ai = no }
				#Realm size
				if = {
					limit = { root.realm_size >= 300 }
					multiply = 3.5
				}
				else_if = {
					limit = { root.realm_size >= 250 }
					multiply = 3
				}
				else_if = {
					limit = { root.realm_size >= 200 }
					multiply = 2.5
				}
				else_if = {
					limit = { root.realm_size >= 150 }
					multiply = 2
				}
				else_if = {
					limit = { root.realm_size >= 100 }
					multiply = 1.5
				}
			}
			#Era
			culture = {
				if = {
					limit = { has_cultural_era_or_later = culture_era_late_medieval }
					multiply = 1.75
				}
				else_if = {
					limit = { has_cultural_era_or_later = culture_era_high_medieval }
					multiply = 1.25
				}
				else_if = {
					limit = { has_cultural_era_or_later = culture_era_early_medieval }
					multiply = 1
				}
				else = {
					multiply = 0.75
				}
			}
			#Income
			if = {
				limit = { root.monthly_character_income >= 100 }
				multiply = 3
			}
			else_if = {
				limit = { root.monthly_character_income >= 80 }
				multiply = 2.5
			}
			else_if = {
				limit = { root.monthly_character_income >= 60 }
				multiply = 2
			}
			else_if = {
				limit = { root.monthly_character_income >= 40 }
				multiply = 1.5
			}
			else_if = {
				limit = { root.monthly_character_income >= 20 }
				multiply = 1.1
			}

			max = 3000
			
			if = { # Much cheaper for vassals wanting to adopt their admin liege's government
				limit = {
					is_independent_ruler = no
				}
				multiply = 0.1
			}
		}
	}

	effect = {
		save_scope_as = actor
		convert_to_administrative_from_feudalism_effect = yes
		if = {
			limit = {
				is_independent_ruler = yes
			}
			add_legitimacy_effect = { LEGITIMACY = admin_convert_legitimacy_value } #One Time Legitimacy Boost
		}
		trigger_event = ep3_decisions_event.4060 #Also sends information event to human vassals
		#Letter event for the vassals
		hidden_effect = {
			if = {
				limit = {
					is_ai = no
				}
				add_achievement_global_variable_effect = {
					VARIABLE = achieved_epic_paperwork_achievement
					VALUE = yes
				}
			}
			#EK DISABLED: vanilla achievement
			#if = {
			#	limit = {
			#		is_ai = no
			#		religion = religion:islam_religion
			#		has_title = title:k_rum
			#		OR = {
			#			has_title = title:c_byzantion
			#			any_sub_realm_title = {
			#				this = title:c_byzantion
			#			}
			#		}
			#	}
			#	add_achievement_global_variable_effect = {
			#		VARIABLE = finished_new_management_achievement
			#		VALUE = yes
			#	}
			#}
		}
	}

	ai_potential = {
		has_feudal_like_succession = yes #EK EDIT: succession instead of government because it doesn't include hierocracy 
		is_independent_ruler = yes
	}

	ai_will_do = {
		base = 0
		#EK DISABLED
		#modifier = {
		#	OR = {
		#		primary_title = title:e_byzantium
		#		primary_title = title:e_roman_empire
		#	}
		#	add = 100
		#}
		modifier = {
			culture = {
				OR = {
					has_cultural_pillar = ethos_bureaucratic 
					has_cultural_pillar = ethos_courtly 
					has_cultural_pillar = ethos_egalitarian 
				}
			}
			add = 50
		}
		modifier = {
			culture = {
				has_cultural_tradition = tradition_legalistic
			}
			add = 50
		}
		modifier = {
			culture = {
				OR = {
					has_cultural_tradition = tradition_fp3_enlightened_magnates 
					has_cultural_tradition = tradition_loyal_soldiers 
				}
			}
			add = 20
		}
		modifier = {
			culture = {
				OR = {
					has_cultural_tradition = tradition_staunch_traditionalists
					has_cultural_tradition = tradition_ep3_audacious_cadets
				}
			}
			add = -20
		}
		modifier = {
			culture = {
				has_cultural_tradition = tradition_hereditary_hierarchy
			}
			add = -20
		}
		modifier = {
			culture = {
				OR = {
					has_cultural_tradition = tradition_ep3_indomitable_azatani
					has_cultural_tradition = tradition_quarrelsome
					has_cultural_tradition = tradition_warrior_culture
					has_cultural_tradition = tradition_fp3_fierce_independence
				}
			}
			add = -50
		}
		modifier = {
			culture = {
				OR = {
					has_cultural_pillar = ethos_stoic
					has_cultural_pillar = ethos_bellicose 
					has_cultural_pillar = ethos_communal 
				}
			}
			add = -50
		}
		#EK DISABLED
		#modifier = {
		#	culture = {
		#		any_parent_culture_or_above = {
		#			OR = {
		#				this = culture:han
		#				this = culture:greek
		#			}
		#		}
		#	}
		#	add = 100
		#}
		#EK ADDITION: our titles that like administrative
		modifier = {
			OR = {
				primary_title = title:e_cyrodiil
				primary_title = title:e_cyrodiilic_potentate
				primary_title = title:e_tamriel
				primary_title = title:e_summerset
				primary_title = title:k_indoril
				primary_title = title:k_hlaalu
				primary_title = title:e_hammerfell
				#EK TODO: enable when e_crown is on develop
				#primary_title = title:e_crown
			}
			add = 100
		}
		#EK ADDITION: our traditions that like administrative
		modifier = {
			culture = {
				OR = {
					has_cultural_tradition = tradition_ceremoniarchy
					has_cultural_tradition = tradition_imperial_legacy
					has_cultural_tradition = tradition_crown_core
					has_cultural_tradition = tradition_pursuit_of_wealth
					#EK TODO: enable when MW is on develop
					#has_cultural_tradition = tradition_garden_of_veloth
				}
			}
			add = 50
		}
		#EK ADDITION: our heritages and cultures that like administrtive
		modifier = {
			culture = {
				OR = {
					has_cultural_pillar = heritage_cyrodiilic
					has_cultural_pillar = heritage_aldmeri
					any_parent_culture_or_above = {
						OR = {
							this = culture:chuzei
							this = culture:armun_an
							this = culture:crown_culture
						}
					}
				}
			}
			add = 100
		}
	}
}

##################################################
# Convert Realm to Feudalism from Administrative #
##################################################

convert_to_feudalism_from_administrative_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_realm.dds"
	}
	decision_group_type = major
	desc = convert_to_feudalism_from_administrative_decision_desc

	ai_check_interval = 36

	is_shown = {
		has_ep3_dlc_trigger = yes
		government_has_flag = government_is_administrative
	}

	is_valid = {
		trigger_if = {
			limit = {
				is_independent_ruler = no
			}
			top_liege ?= { has_realm_law = imperial_bureaucracy_0 }
			is_landed = yes
			custom_tooltip = {
				text = governorship_is_on_the_border_tt
				any_sub_realm_county = {
					any_neighboring_county = {
						holder.top_liege != root.top_liege
					}
				}
			}
			custom_tooltip = {
				text = you_have_governorship_rights_tt
				primary_title.var:petition_house_rights ?= house
			}
			prestige_level >= 3
			influence_level >= 3
		}
		trigger_else = {
			prestige_level >= { # Depends on tier
				value = 2
				if = {
					limit = {
						primary_title.tier >= tier_empire
					}
					add = 1
				}
			}
			has_realm_law = imperial_bureaucracy_3
		}
	}

	cost = {
		prestige = 1000
		gold = {
			value = 1000 #Them pens be expensive
			#Realm size
			if = {
				limit = { root.realm_size >= 300 }
				multiply = 3.5
			}
			else_if = {
				limit = { root.realm_size >= 250 }
				multiply = 3
			}
			else_if = {
				limit = { root.realm_size >= 200 }
				multiply = 2.5
			}
			else_if = {
				limit = { root.realm_size >= 150 }
				multiply = 2
			}
			else_if = {
				limit = { root.realm_size >= 100 }
				multiply = 1.5
			}
			#Era
			culture = {
				if = {
					limit = { has_cultural_era_or_later = culture_era_late_medieval }
					multiply = 1.75
				}
				else_if = {
					limit = { has_cultural_era_or_later = culture_era_high_medieval }
					multiply = 1.25
				}
				else_if = {
					limit = { has_cultural_era_or_later = culture_era_early_medieval }
					multiply = 1
				}
				else = {
					multiply = 0.75
				}
			}
			#Income
			if = {
				limit = { root.monthly_character_income >= 100 }
				multiply = 3
			}
			else_if = {
				limit = { root.monthly_character_income >= 80 }
				multiply = 2.5
			}
			else_if = {
				limit = { root.monthly_character_income >= 60 }
				multiply = 2
			}
			else_if = {
				limit = { root.monthly_character_income >= 40 }
				multiply = 1.5
			}
			else_if = {
				limit = { root.monthly_character_income >= 20 }
				multiply = 1.1
			}
			
			# Vassals has a slightly reduced cost
			if = {
				limit = {
					is_independent_ruler = no
				}
				multiply = 0.7
			}
		}
	}

	effect = {
		convert_to_feudalism_from_administrative_effect = yes
		save_scope_as = actor
		trigger_event = ep3_decisions_event.4070
		hidden_effect = {
			every_vassal = {
				trigger_event = {
					id = ep3_decisions_event.4075
					days = 3
				}
			}
		}
	}

	ai_potential = {
		always = no
	}
}

#############################################
# Renounce Governorship						#
#############################################

renounce_governorship_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_dynasty_house.dds"
	}
	sort_order = 85
	ai_check_interval = 120

	desc = renounce_governorship_decision_desc
	selection_tooltip = renounce_governorship_decision_tooltip
	decision_group_type = admin

	is_shown = {
		has_ep3_dlc_trigger = yes
		is_playable_character = yes
		is_governor = yes
		liege ?= top_liege
		any_held_title = { # To avoid accidentally game-overing yourself
			is_noble_family_title = yes
		}
	}

	is_valid = {
		custom_tooltip = { # You have a Theme
			text = admin_confirmation_rank_tt
			primary_title.tier >= tier_duchy
		}
		custom_tooltip = { # The Emperor is your liege
			text = admin_confirmation_liege_tt
			top_liege ?= { highest_held_title_tier >= tier_kingdom }
			liege ?= top_liege
		}
	}

	is_valid_showing_failures_only = {
		is_available_adult = yes
		is_at_war_with_liege = no
	}

	effect = {
		custom_tooltip = renounce_governorship_decision_effect_tt
		show_as_tooltip = {
			add_gold = massive_gold_value
			add_character_modifier = {
				modifier = ep3_renounced_governorship
				years = 15
			}
		}
		trigger_event = ep3_decisions_event.4090
		close_view = {
			view = decisions
			player = root
		}
	}
	
	cost = {
		influence = minor_influence_value
	}

	ai_potential = {
		is_at_war = no
		# Don't step down freely if you don't have any other house members holding a governorship or inherit any held governorship
		OR = {
			house ?= {
				any_house_member = {
					is_governor = yes
					top_liege = root.top_liege
				}
			}
			any_held_title = {
				tier >= tier_duchy
				is_noble_family_title = no
				current_heir.house = root.house
			}
		}
	}

	ai_will_do = {
		base = 0
		modifier = {
			add = 5
			has_trait = lazy
		}
		modifier = {
			add = 10
			has_trait = humble
		}
		modifier = {
			add = 15
			has_trait = content
		}
		modifier = {
			add = 100
			NOR = {
				has_trait = ambitious
				has_trait = greedy
				has_trait = arrogant
			}
			debt_level >= 1
		}
	}
}

#############################################
# Change Imperial Aspirations				#
#############################################
change_imperial_aspirations_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/ep3_cerimonial_decision.dds"
	}
	sort_order = 80
	ai_check_interval = 120

	desc = change_imperial_aspirations_decision_desc
	selection_tooltip = change_imperial_aspirations_decision_tooltip
	decision_group_type = admin

	is_shown = {
		has_ep3_dlc_trigger = yes
		is_playable_character = yes
		government_has_flag = government_is_administrative
		liege ?= {
			has_realm_law = acclamation_succession_law
		}
	}

	is_valid = {
		custom_tooltip = {
			text = has_admin_government
			government_has_flag = government_is_administrative
		}
		trigger_if = { # Unavailable if you are the top liege - Unless you have either modifier, so you may remove it.
			limit = {
				is_independent_ruler = yes
			}
			OR = {
				has_character_modifier = ep3_admin_renounce_throne_personal
				house ?= { has_house_modifier = ep3_admin_renounce_throne_house }
			}
		}
		trigger_else = {
			custom_tooltip = { # The Emperor is your liege
				text = admin_confirmation_liege_tt
				top_liege ?= { highest_held_title_tier >= tier_kingdom }
				liege ?= top_liege
				liege != root
			}
		}
		liege ?= {
			has_realm_law = acclamation_succession_law
		}
	}

	is_valid_showing_failures_only = {
		is_available_adult = yes
		is_at_war_with_liege = no
		NOT = { top_liege ?= root }
	}
	
	widget = {
		gui = "decision_view_widget_generic_multichoice_with_effects"
		controller = decision_option_list_controller
		decision_to_second_step_button = "SELECT_ACTION"
		#show_from_start = yes

		### Remove yourself from competing for the throne
		item = {
			value = admin_renounce_throne_personal
			is_valid = {
				NOR = {
					has_character_modifier = ep3_admin_renounce_throne_personal
					house ?= { has_house_modifier = ep3_admin_renounce_throne_house }
				}
				NOT = { top_liege ?= root }
				is_diarch = no
			}
			current_description = admin_renounce_throne_personal_desc
			localization = admin_renounce_throne_personal_name
			icon = "gfx/interface/icons/character_interactions/icon_liege.dds"
			ai_chance = {
				value = 0
				if = {
					limit = {
						has_trait = content
					}
					add = 100
				}
			}
		}
		### Make yourself available to compete for the throne
		item = {
			value = admin_desire_throne_personal
			is_valid = {
				has_character_modifier = ep3_admin_renounce_throne_personal
			}
			current_description = admin_desire_throne_personal_desc
			localization = admin_desire_throne_personal_name
			icon = "gfx/interface/icons/character_interactions/icon_liege.dds"
			ai_chance = {
				value = 0
				if = {
					limit = {
						has_character_modifier = ep3_admin_renounce_throne_personal
						NOT = { has_trait = content }
					}
					add = 100
				}
			}
		}
		### Remove your house from competing for the throne
		item = {
			value = admin_renounce_throne_house
			is_valid = {
				house ?= {
					custom_tooltip = {
						text = HOF_INTERACTION_IS_HOUSE_HEAD
						house_head ?= root
					}
					NOT = { has_house_modifier = ep3_admin_renounce_throne_house }
				}
				NOT = { top_liege.house ?= root.house }
			}
			current_description = admin_renounce_throne_house_desc
			localization = admin_renounce_throne_house_name
			icon = "gfx/interface/icons/character_interactions/icon_dynasty.dds"
			ai_chance = {
				value = 0
			}
		}
		### Make your house available to compete for the throne
		item = {
			value = admin_desire_throne_house
			is_valid = {
				house ?= {
					custom_tooltip = {
						text = HOF_INTERACTION_IS_HOUSE_HEAD
						house_head ?= root
					}
					has_house_modifier = ep3_admin_renounce_throne_house
				}
			}
			current_description = admin_desire_throne_house_desc
			localization = admin_desire_throne_house_name
			icon = "gfx/interface/icons/character_interactions/icon_dynasty.dds"
			ai_chance = {
				value = 0
				if = {
					limit = {
						house ?= { has_house_modifier = ep3_admin_renounce_throne_house }
					}
					add = 100
				}
			}
		}
	}

	effect = {
		if = {
			limit = {
				scope:admin_renounce_throne_personal = yes
			}
			add_character_modifier = {
				modifier = ep3_admin_renounce_throne_personal
			}
		}
		else_if = {
			limit = {
				scope:admin_desire_throne_personal = yes
			}
			remove_character_modifier = ep3_admin_renounce_throne_personal
		}
		else_if = {
			limit = {
				scope:admin_renounce_throne_house = yes
			}
			house ?= {
				add_house_modifier = ep3_admin_renounce_throne_house
			}
		}
		else_if = {
			limit = {
				scope:admin_desire_throne_house = yes
			}
			house ?= {
				remove_house_modifier = ep3_admin_renounce_throne_house
			}
		}
	}

	ai_potential = {
		OR = {
			has_character_modifier = ep3_admin_renounce_throne_personal
			house ?= { has_house_modifier = ep3_admin_renounce_throne_house }
			has_trait = content
		}
	}

	ai_will_do = {
		base = 20
		modifier = {
			add = 80
			OR = {
				has_character_modifier = ep3_admin_renounce_throne_personal
				house ?= { has_house_modifier = ep3_admin_renounce_throne_house }
			}
			NOT = { has_trait = content }
		}
	}
}
