﻿### Hold a Triumph ###
hold_triumph_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/ep3_decision_hold_triumph.dds"
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 0
		empire = 60
		hegemony = 60
	}

	sort_order = 110

	desc = hold_triumph_decision_desc
	selection_tooltip = hold_triumph_decision_tooltip
	decision_group_type = roman

	is_shown = {
		has_ep3_dlc_trigger = yes
		is_roman_emperor_trigger = yes
		culture = { has_cultural_parameter = holds_triumphs }
	}

	is_valid = {
		is_at_war = no
		is_roman_emperor_trigger = yes
		culture = { has_cultural_parameter = holds_triumphs }
	}

	is_valid_showing_failures_only = {
		is_alive = yes
		is_available_healthy_adult = yes
		NOT = { exists = involved_activity }
		is_imprisoned = no
	}

	cost = {
		gold = {
			value = 0
			if = {
				limit = {
					NOR = { 
						has_treasury = yes
						has_character_flag = free_triumph_flag
					}
				}
				add = ep3_triumph_gold_cost
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					has_treasury = yes
					NOT = { has_character_flag = free_triumph_flag }
				}
				add = ep3_triumph_gold_cost
			}
		}
		influence = {
			value = 0
			if = {
				limit = {
					NOT = { has_character_flag = free_triumph_flag }
				}
				add = ep3_triumph_influence_cost
			}
		}
	}

	cooldown = { years = 10 }

	effect = {
		custom_tooltip = hold_triumph_decision_effects
		trigger_event = {
			id = ep3_decisions_event.0001
			days = 1
		}
		if = {
			limit = { has_character_flag = free_triumph_flag }
			remove_character_flag = free_triumph_flag
		}
	}

	ai_potential = {
		NOT = { has_trait = humble }
		has_variable = ep3_valid_triumph_victory
	}

	ai_will_do = {
		base = 30
		modifier = {
			has_trait = arrogant
			add = 30
		}
		modifier = {
			has_trait = ambitious
			add = 20
		}
	}
}

### Restore [ROOT.Char.GetPrimaryTitle.GetNameNoTierNoTooltip] ###
restore_backwater_counties_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/ep3_decision_estate.dds"
	}
	decision_group_type = major
	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 120
		kingdom = 120
		empire = 0
		hegemony = 0
	}

	sort_order = 70

	desc = restore_backwater_counties_decision_desc
	selection_tooltip = restore_backwater_counties_decision_tooltip
	decision_group_type = roman

	is_shown = {
		has_ep3_dlc_trigger = yes
		primary_title ?= {
			OR = {
				tier = tier_duchy
				tier = tier_kingdom
			}
		}
		any_sub_realm_county = {
			has_county_modifier = backwater_county_modifier
		}
	}

	is_valid = {
		is_at_war = no
		custom_tooltip = {
			text = backwater_county_eligible_modifier_removal_tt
			any_sub_realm_county = {
				count >= 1
				has_county_modifier = backwater_county_modifier
				development_level >= 50
			}
		}
	}

	is_valid_showing_failures_only = {
		is_alive = yes
		is_available = yes
		NOT = { exists = involved_activity }
		is_imprisoned = no
	}

	cost = {
		gold = {
			value = 0
			if = {
				limit = {
					has_treasury = no
				}
				add = medium_gold_value
				multiply = {
					value = 1
					every_sub_realm_county = {
						limit = {
							title_province = {
								geographical_region = greek_backwater_modifier_region
							}
							has_county_modifier = backwater_county_modifier
							development_level >= 50
						}
						add = 1
					}
				}
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					has_treasury = yes
				}
				add = medium_gold_value
				multiply = {
					value = 1
					every_sub_realm_county = {
						limit = {
							title_province = {
								geographical_region = greek_backwater_modifier_region
							}
							has_county_modifier = backwater_county_modifier
							development_level >= 50
						}
						add = 1
					}
				}
			}
		}
	}

	effect = {
		custom_tooltip = greek_backwater_modifier_removal_tt
		if = {
			limit = {
				NOT = {
					any_sub_realm_county = {
						title_province = {
							geographical_region = greek_backwater_modifier_region
						}
						has_county_modifier = backwater_county_modifier
						development_level >= 50
					}
				}
			}
			custom_tooltip = no_backwater_counties_meet_criteria_tt
		}
		else = {
			every_sub_realm_county = {
				limit = {
					title_province = {
						geographical_region = greek_backwater_modifier_region
					}
					has_county_modifier = backwater_county_modifier
					development_level >= 50
				}
				add_to_list = frontwater_counties
			}
		}
		primary_title = { save_scope_as = target_theme }
		# Toast for the Governor confirming which counties got the modifier removed
		send_interface_message = {
			type = event_generic_good
			title = ep3_theme_not_backwater.t
			left_icon = root
			right_icon = root.primary_title
			every_in_list = {
				list = frontwater_counties
				remove_county_modifier = backwater_county_modifier
			}
		}

		if = { # If we remove the modifier from the last county belonging to this governor, we fire a celebration event for some narrative flavor
			limit = {
				any_sub_realm_county = {
					count = 0 
					title_province = {
						geographical_region = greek_backwater_modifier_region
					}
					has_county_modifier = backwater_county_modifier
				}
			}
			# Event for the Governor if all counties are restored
			trigger_event = {
				id = ep3_decisions_event.3000
				days = 1
			}

			# Once all the counties have been brought up to speed, we notify the emperor
			liege = {
				send_interface_message = {
					type = event_generic_good_text
					title = ep3_theme_not_backwater.t
					desc = ep3_theme_not_backwater.desc
					left_icon = root
				}
				# Trigger the event for the emperor to see if all the counties have been cleared
				trigger_event = ep3_decisions_event.3001
			}
		}
	}
}

### Prepare Greek Fire Dromons ###
prepare_greek_fire_dromons_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_smith.dds"
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 120
		kingdom = 120
		empire = 120
		hegemony = 120
	}

	sort_order = 110

	desc = prepare_greek_fire_dromons_decision_desc
	selection_tooltip = prepare_greek_fire_dromons_decision_tooltip
	decision_group_type = roman

	is_shown = {
		has_ep3_dlc_trigger = yes
		has_multiple_players = no
		title:c_byzantion = {
			holder = root
		}
		culture = {
			OR = {
				this = culture:greek
				any_parent_culture_or_above = { this = culture:greek }
			}
		}
	}

	is_valid = {
		custom_tooltip = {
			text = prepare_greek_fire_dromons_constantinople_tt
			capital_county = title:c_byzantion
		}
		custom_tooltip = {
			text = prepare_greek_fire_dromons_capital_unoccupied_tt
			capital_province = {
				is_occupied = no
			}
		}
		custom_tooltip = {
			text = prepare_greek_fire_dromons_no_modifier_tt
			capital_county = {
				NOT = { has_county_modifier = defensive_fire_dromons_modifier }
			}
		}
		
		OR = {
			influence >= major_influence_value
			gold >= major_gold_value_static_max
		}
	}

	is_valid_showing_failures_only = {
		is_available = yes
		NOT = { exists = involved_activity }
	}

	cooldown = { years = 5 }

	effect = {
		custom_tooltip = defensive_fire_dromons_3_years_tooltip
		custom_tooltip = defensive_fire_dromons_custom_desc
		custom_tooltip = defensive_fire_dromons_buildings_desc
		trigger_event = ep3_decisions_event.3100
	}

	ai_potential = {
		NOT = { has_trait = compassionate }
		OR = {
			gold >= massive_gold_value
			influence >= massive_influence_value
		}
	}

	ai_will_do = {
		base = 20
		ai_value_modifier = {
			ai_compassion = -1
		}
		modifier = {
			OR = {
				has_trait = paranoid
				has_trait = craven
			}
			add = 30
		}
		modifier = {
			OR = {
				martial > high_skill_rating
				learning > high_skill_rating
			}
			add = 20
		}
		modifier = {
			OR = {
				has_trait = calm
				has_trait = content
			}
			add = -20
		}
	}
}

### Re-Establish the Theodosian Borders ###
retake_eastern_provinces_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/ep3_decision_roman_restoration.dds"
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 0
		empire = 120
		hegemony = 120
	}

	sort_order = 50

	desc = retake_eastern_provinces_decision_desc
	selection_tooltip = retake_eastern_provinces_decision_tooltip
	decision_group_type = roman

	is_shown = {
		has_ep3_dlc_trigger = yes
		has_title = title:e_byzantium
		NOT = {
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:retake_eastern_provinces_decision
			}
		}
	}

	is_valid = {
		government_has_flag = government_is_administrative
		completely_controls_region = custom_theodosian_ere
		custom_tooltip = {
			text = eastern_kingdoms_held_or_vassals_tt
			trigger_if = {
				limit = {
					exists = title:k_bulgaria.holder
				}
				title:k_bulgaria.holder = { liege = root }
			}
			trigger_if = {
				limit = {
					exists = title:k_epirus.holder
				}
				title:k_epirus.holder = { liege = root }
			}
			trigger_if = {
				limit = {
					exists = title:k_hellas.holder
				}
				title:k_hellas.holder = { liege = root }
			}
			trigger_if = {
				limit = {
					exists = title:k_thessalonika.holder
				}
				title:k_thessalonika.holder = { liege = root }
			}
			trigger_if = {
				limit = {
					exists = title:k_krete.holder
				}
				title:k_krete.holder = { liege = root }
			}
			trigger_if = {
				limit = {
					exists = title:k_cyprus.holder
				}
				title:k_cyprus.holder = { liege = root }
			}
			trigger_if = {
				limit = {
					exists = title:k_nikaea.holder
				}
				title:k_nikaea.holder = { liege = root }
			}
			trigger_if = {
				limit = {
					exists = title:k_anatolia.holder
				}
				title:k_anatolia.holder = { liege = root }
			}
			trigger_if = {
				limit = {
					exists = title:k_pontus.holder
				}
				title:k_pontus.holder = { liege = root }
			}
			trigger_if = {
				limit = {
					exists = title:k_syria.holder
				}
				title:k_syria.holder = { liege = root }
			}
			trigger_if = {
				limit = {
					exists = title:k_jerusalem.holder
				}
				title:k_jerusalem.holder = { liege = root }
			}
			trigger_if = {
				limit = {
					exists = title:k_egypt.holder
				}
				title:k_egypt.holder = { liege = root }
			}
		}
	}

	is_valid_showing_failures_only = {
		is_at_war = no
		NOT = { exists = involved_activity }
		is_imprisoned = no
		has_contagious_deadly_disease_trigger = no
	}

	cost = {
		prestige = {
			value = 1000		
		}
	}

	effect = {
		show_as_tooltip = {
			retake_eastern_provinces_decision_effect = yes
		}
		trigger_event = {
			id = ep3_decisions_event.4000
			days = 1
		}
		#Can only be done once
		add_to_global_variable_list = {
			name = unavailable_unique_decisions
			target = flag:retake_eastern_provinces_decision
		}
		if = {
			limit = {
				is_ai = no
				game_start_date >= 1178.10.1
			}
			add_achievement_global_variable_effect = {
				VARIABLE = achieved_against_the_odds_achievement
				VALUE = yes
			}
		}
	}

	ai_potential = {
		has_title = title:e_byzantium
		is_at_war = no
		NOT = { exists = involved_activity }
		is_imprisoned = no
		has_contagious_deadly_disease_trigger = no
	}

	ai_will_do = {
		base = 100
	}
}

### Refound the Pandidakterion ###
refound_pandidakterion_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_golden_age.dds"
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 0
		empire = 120
		hegemony = 120
	}

	sort_order = 110

	desc = refound_pandidakterion_decision_desc
	selection_tooltip = refound_pandidakterion_decision_tooltip
	decision_group_type = roman

	is_shown = {
		has_ep3_dlc_trigger = yes
		has_title = title:e_byzantium
		NOR = {
			# the pandidakterion was created by the player
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:refound_pandidakterion_decision
			}
			# the pandidakterion already existed at game start
			title:c_byzantion = { has_county_modifier = pandidakterion_university_modifier }
		}
	}

	is_valid = {
		government_has_flag = government_is_administrative
		custom_tooltip = {
			text = pandidakterion_tt
			any_sub_realm_county = {
				this = title:c_byzantion #owns Constantinople
			}
		}
	}

	is_valid_showing_failures_only = {
		is_at_war = no
		NOT = { exists = involved_activity }
		is_imprisoned = no
		has_contagious_deadly_disease_trigger = no
	}

	cost = {
		gold = {
			value = 0
			if = {
				limit = {
					has_treasury = no
				}
				add = 1000
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					has_treasury = yes
				}
				add = 1000
			}
		}
	}

	effect = {
		title:c_byzantion = { add_county_modifier = pandidakterion_university_modifier }
		found_university_decision_event_effect = yes
		#Can only be done once
		add_to_global_variable_list = {
			name = unavailable_unique_decisions
			target = flag:refound_pandidakterion_decision
		}
		create_character_memory = {
			type = refounded_pandidakterion_memory
		}
	}

	ai_potential = {
		has_title = title:e_byzantium
		gold > 1000
	}

	ai_will_do = {
		base = 100
	}
}

### Ask for Support ###
ask_western_help_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/ep3_cerimonial_decision.dds"
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 0
		empire = 80
		hegemony = 80
	}

	sort_order = 110

	desc = ask_western_help_decision_desc
	selection_tooltip = ask_western_help_decision_tooltip
	decision_group_type = roman

	is_shown = {
		has_ep3_dlc_trigger = yes
		# Byz emperor or governor
		has_title = title:e_byzantium
		# Christian without crusades (mainly Orthodox)
		OR = { religion = religion:eastern_orthodox_religion religion = religion:catholic_religion religion = religion:protestant_religion }
		faith = {
			NOT = { has_doctrine_parameter = great_holy_wars_active }
		}
		government_has_flag = government_is_administrative
	}

	is_valid = {
		is_at_war = yes
		custom_tooltip = {
			text = valid_primary_war_enemy_for_crusade
			any_primary_war_enemy = {
				NOT = { OR = { religion = religion:eastern_orthodox_religion religion = religion:catholic_religion religion = religion:protestant_religion } }
				OR = {
					highest_held_title_tier >= tier_kingdom
					liege = { highest_held_title_tier >= tier_kingdom }
				}
			}
		}
		custom_tooltip = {
			text = valid_realm_size_for_help
			top_liege = {
				realm_size < massive_realm_size
			}
		}
		custom_tooltip = {
			text = there_is_someone_to_ask_for_help
			OR = {
				any_ally = {
					OR = { religion = religion:eastern_orthodox_religion religion = religion:catholic_religion religion = religion:protestant_religion }
					faith = {
						has_doctrine_parameter = great_holy_wars_active
						exists = religious_head
					}
					trigger_if = {
						limit = {
							has_variable = asked_for_help_by
						}
						NOT = { var:asked_for_help_by = root }
					}
				}
				religion:christianity_religion = {
					any_faith = {
						has_doctrine_parameter = great_holy_wars_active
						religious_head ?= {
							trigger_if = {
								limit = {
									has_variable = asked_for_help_by
								}
								NOT = { var:asked_for_help_by = root }
							}
						}
					}
				}
			}
		}
	}

	is_valid_showing_failures_only = {
		is_at_war = yes
		NOT = { exists = involved_activity }
		custom_tooltip = {
			text = recently_asked_for_help
			NOT = {
				primary_title = { has_variable = recently_asked_western_help }
			}
		}
	}

	cost = {
		prestige = {
			value = 300
		}
		influence = {
			value = massive_influence_value
			multiply = 2
		}
	}

	effect = {
		custom_tooltip = ask_western_help_decision_effect_desc
		hidden_effect = {
			save_scope_as = caller
			# Cooldown on your main title
			primary_title = {
				set_variable = {
					name = recently_asked_western_help
					years = 20
				}
			}
			ordered_primary_war_enemy = {
				limit = {
					NOT = { OR = { religion = religion:eastern_orthodox_religion religion = religion:catholic_religion religion = religion:protestant_religion } }
					OR = {
						highest_held_title_tier >= tier_kingdom
						liege = { highest_held_title_tier >= tier_kingdom }
					}
				}
				order_by = max_military_strength
				save_scope_as = enemy
			}
			random_character_war = {
				limit = {
					is_war_leader = scope:enemy
				}
				save_scope_as = our_war
			}

			if = {
				limit = {
					any_ally = {
						OR = { religion = religion:eastern_orthodox_religion religion = religion:catholic_religion religion = religion:protestant_religion }
						faith = {
							has_doctrine_parameter = great_holy_wars_active
							exists = religious_head
						}
						trigger_if = {
							limit = {
								has_variable = asked_for_help_by
							}
							NOT = { var:asked_for_help_by = root }
						}
					}
				}
				ordered_ally = {
					limit = {
						OR = { religion = religion:eastern_orthodox_religion religion = religion:catholic_religion religion = religion:protestant_religion }
						faith = {
							has_doctrine_parameter = great_holy_wars_active
							exists = religious_head
						}
						trigger_if = {
							limit = {
								has_variable = asked_for_help_by
							}
							NOT = { var:asked_for_help_by = root }
						}
					}
					order_by = max_military_strength
					save_scope_as = called
					save_scope_as = called_1
					set_variable = {
						name = asked_for_help_by
						value = root
						years = 20
					}
				}
			}
			else = {
				religion:christianity_religion = {
					random_faith = {
						limit = {
							has_doctrine_parameter = great_holy_wars_active
							religious_head ?= {
								trigger_if = {
									limit = {
										has_variable = asked_for_help_by
									}
									NOT = { var:asked_for_help_by = root }
								}
							}
						}
						religious_head = {
							save_scope_as = called
							save_scope_as = called_2
							set_variable = {
								name = asked_for_help_by
								value = root
								years = 20
							}
						}
					}
				}
			}

			scope:called.faith = { save_scope_as = the_faith }
			# Prep for eventual crusade
			scope:enemy ?= {
				if = {
					limit = {
						highest_held_title_tier = tier_kingdom
					}
					primary_title = { save_scope_as = target_kingdom }
				}
				else_if = {
					limit = {
						liege ?= { highest_held_title_tier = tier_kingdom }
					}
					liege.primary_title = { save_scope_as = target_kingdom }
				}
				else_if = {
					limit = {
						highest_held_title_tier > tier_kingdom
					}
					ordered_realm_de_jure_kingdom = {
						order_by = great_holy_war_target_kingdom_weight_simplified	
						position = 1				
						save_scope_as = target_kingdom
					}
				}
				else = {
					liege ?= {
						ordered_realm_de_jure_kingdom = {
							order_by = great_holy_war_target_kingdom_weight_simplified		
							position = 1				
							save_scope_as = target_kingdom
						}
					}
				}
			}
			scope:called_1 ?= {
				trigger_event = {
					id = ep3_decisions_event.4010
					days = 3
				}
			}
			scope:called_2 ?= {
				trigger_event = {
					id = ep3_decisions_event.4011
					days = 3
				}
			}
		}
	}

	ai_potential = {
		has_title = title:e_byzantium
		realm_size < massive_realm_size
	}

	ai_will_do = {
		base = 50
	}
}

### Evangelize the Pagans ###
evangelize_the_slavs_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_major_religion.dds"
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 0
		empire = 80
		hegemony = 80
	}

	sort_order = 120

	desc = evangelize_the_slavs_decision_desc
	selection_tooltip = evangelize_the_slavs_decision_tooltip
	decision_group_type = roman

	cooldown = { years = 10 }

	is_shown = {
		has_ep3_dlc_trigger = yes
		# Byz emperor or governor
		OR = {
			has_title = title:e_byzantium
			liege = { has_title = title:e_byzantium }
		}
		OR = { faith.religion = religion:eastern_orthodox_religion faith.religion = religion:catholic_religion faith.religion = religion:protestant_religion }
		# You border with pagans to convert
		trigger_if = {
			limit = {
				has_title = title:e_byzantium
			}
			any_neighboring_and_across_water_top_liege_realm_owner = {
				valid_for_pagan_conversion_trigger = yes
			}
		}
		trigger_else = {
			any_neighboring_and_across_water_realm_same_rank_owner = {
				valid_for_pagan_conversion_trigger = yes
			}
		}
	}

	is_valid = {
		government_has_flag = government_is_administrative
		trigger_if = {
			limit = {
				has_title = title:e_byzantium
			}
			custom_tooltip = {
				any_neighboring_and_across_water_top_liege_realm_owner = {
					valid_for_pagan_conversion_trigger = yes
				}
				text = valid_neighboring_and_across_water_top_liege
			}
		}
		trigger_else = {
			custom_tooltip = {
				any_neighboring_and_across_water_realm_same_rank_owner = {
					valid_for_pagan_conversion_trigger = yes
				}
				text = valid_neighboring_and_across_water_realm_same_rank
			}
		}
	}

	is_valid_showing_failures_only = {
		is_at_war = no
		NOT = { exists = involved_activity }
		is_imprisoned = no
		has_contagious_deadly_disease_trigger = no
	}

	cost = {
		piety = massive_piety_value
	}

	effect = {
		custom_tooltip = evangelize_the_slavs_decision_effect
		trigger_event = ep3_decisions_event.4020
	}

	ai_potential = {
		piety > massive_piety_value
		has_title = title:e_byzantium
	}

	ai_will_do = {
		base = 0
		ai_value_modifier = {
			ai_zeal = 1
		}
		modifier = {
			any_neighboring_and_across_water_top_liege_realm_owner = {
				valid_for_pagan_conversion_trigger = yes
				NOT = {
					capital_county.title_province = {
						geographical_region = world_europe_east
					}
				}
			}
			factor = 0.5
		}
	}
}

### Restore the Byzantine Empire ###
recreate_byzantine_empire_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/ep3_cerimonial_decision.dds"
	}
	decision_group_type = major

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 6
		empire = 6
		hegemony = 0
	}

	desc = recreate_byzantine_empire_decision_desc
	selection_tooltip = recreate_byzantine_empire_decision_tooltip
	decision_group_type = roman

	is_shown = {
		has_dlc_feature = roads_to_power
		NOR = {
			exists = title:e_byzantium.holder
			exists = title:h_roman_empire.holder
			exists = title:h_eastern_roman_empire.holder
		}
		title:e_byzantium = { is_titular = no }
		OR = {
			culture = {
				OR = {
					this = culture:greek
					any_parent_culture_or_above = { this = culture:greek }
				}
			}
			AND = {
				OR = {
					ep3_orthodox_faith_trigger = yes
					faith = faith:hellenic_pagan
				}
				primary_title = {
					tier <= tier_empire
					empire = title:e_latin_empire
				}
			}
			AND = {
				OR = {
					ep3_orthodox_faith_trigger = yes
					faith = faith:hellenic_pagan
				}
				primary_title = {
					tier <= tier_empire
					empire = title:e_byzantium
				}
			}
		}
	}

	is_valid = {
		custom_tooltip = {
			NOT = {
				exists = title:e_byzantium.holder
			}
			text = no_byz_emp_exists_tt
		}
		top_liege = this
		OR = {
			custom_tooltip = {
				culture = {
					this = culture:greek
				}
				text = is_greek_tt
			}
			custom_tooltip = {
				culture = {
					any_parent_culture_or_above = { this = culture:greek }
				}
				text = is_greek_descendent_tt
			}
			ep3_orthodox_faith_trigger = yes
			faith = faith:hellenic_pagan
		}
		highest_held_title_tier >= tier_kingdom
		
		realm_size >= 12
		custom_tooltip = {
			title:c_byzantion.holder = {
				exists = this
				OR = {
					this = root
					AND = {
						is_ai = yes
						top_liege = root
					}
				}
			}
			text = pandidakterion_tt
		}
		primary_title = {
			tier <= tier_empire
			OR = {
				empire = title:e_latin_empire
				empire = title:e_byzantium
			}
		}
		trigger_if = {
			limit = {
				is_ai = no
				has_legitimacy = yes
			}
			legitimacy_level >= 3
		}
		#A liiiiiittle easier for AI
		trigger_if = {
			limit = {
				is_ai = yes
				has_legitimacy = yes
			}
			legitimacy_level >= 1
		}
	}

	is_valid_showing_failures_only = {
		trigger_if = {
			limit = {
				is_ai = no
			}
			NOT = { exists = involved_activity }
			is_available = yes
		}
		trigger_else = {
			is_alive = yes
			is_imprisoned = no
			is_incapable = no
		}
	}

	cost = {
		prestige = {
			value = {
				add = 1000
				if = {
					limit = {
						any_held_title = {
							this = title:e_latin_empire
						}
					}
					add = 1000
				}
				if = {
					limit = {
						culture = {
							NOR = {
								this = culture:greek
								any_parent_culture_or_above = { this = culture:greek }
							}
						}
					}
					add = 500
				}
				#AI need to take this decision and aren't good at saving up for it
				if = {
					limit = {
						is_ai = yes
					}
					multiply = 0.5
				}
			}
		}
		piety = {
			value = {
				add = massive_piety_value
				if = {
					limit = {
						any_held_title = {
							this = title:e_latin_empire
						}
					}
					add = 500
				}
				if = {
					limit = {
						ep3_orthodox_faith_trigger = no
					}
					add = 500
				}
				if = {
					limit = {
						faith = faith:catholic
					}
					add = 500
				}
				#AI need to take this decision and aren't good at saving up for it
				if = {
					limit = {
						is_ai = yes
					}
					multiply = 0.5
				}
			}
		}
	}

	effect = {
		show_as_tooltip = {
			recreate_ere_decision_effect = yes
		}
		trigger_event = ep3_decisions_event.4030
	}

	ai_potential = {
		NOT = { exists = title:e_byzantium.holder }
		any_held_title = {
			title_tier = kingdom
			OR = {
				empire = title:e_latin_empire
				empire = title:e_byzantium
			}
		}
		OR = {
			culture = {
				OR = {
					this = culture:greek
					any_parent_culture_or_above = { this = culture:greek }
				}
			}
			ep3_orthodox_faith_trigger = yes
			primary_title = {
				tier <= tier_empire
				empire = title:e_latin_empire
			}
		}
	}

	ai_will_do = {
		base = 100
		modifier = {
			primary_title = {
				tier <= tier_empire
				empire = title:e_latin_empire
			}
			add = -60
		}
		modifier = {
			NAND = {
				culture = {
					OR = {
						this = culture:greek
						any_parent_culture_or_above = { this = culture:greek }
					}
				}
				OR = {
					ep3_orthodox_faith_trigger = yes
					faith = faith:hellenic_pagan
				}
			}
			add = -30
		}
	}
}

### Found the Varangian Guard ###
found_varangian_guard_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/ep3_decision_varangian_guard.dds"
	}
	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 0
		empire = 60
		hegemony = 60
	}

	sort_order = 100

	desc = found_varangian_guard_decision_desc
	selection_tooltip = found_varangian_guard_decision_tooltip
	decision_group_type = roman

	is_shown = {
		has_ep3_dlc_trigger = yes
		culture = { has_cultural_parameter = unlock_maa_varangian_guards }
		primary_title.tier >= tier_empire
		NOT = {
			# You have not already founded it for your current title
			primary_title = { has_variable = founded_varangian_guard }
		}
	}
	
	is_valid = {
		prestige_level >= 3
		OR = {
			any_realm_county = { culture = culture:norse }
			any_courtier = {
				count >= 5
				culture = culture:norse
			}
			any_ally = { culture = culture:norse }
		}
	}

	is_valid_showing_failures_only = {
		is_at_war = no
		NOT = { exists = involved_activity }
		is_imprisoned = no
	}

	cost = {
		prestige = 1000
	}

	effect = {
		primary_title = { set_variable = founded_varangian_guard }
		send_interface_toast = {
			title = unlocked_varangian_guard_desc_tt
			type = event_toast_effect_neutral
			left_icon = root
			custom_tooltip = unlocked_varangian_guard_desc
		}
		create_character_memory = {
			type = found_varangian_memory
		}
	}

	ai_potential = {
		has_title = title:e_byzantium
	}

	ai_will_do = {
		base = 100
	}
}

### Reinstate the Grain Dole ###
reinstitute_grain_dole_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/ep3_decision_hold_triumph.dds"
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 60
		empire = 60
		hegemony = 0
	}
	sort_order = 40

	desc = reinstitute_grain_dole_decision_desc
	selection_tooltip = reinstitute_grain_dole_decision_tooltip
	decision_group_type = roman

	is_shown = {
		has_ep3_dlc_trigger = yes
		is_roman_emperor_trigger = yes
		NOT = {
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:reinstitute_grain_dole_decision
			}
		}
	}

	is_valid = {
		government_has_flag = government_is_administrative
		OR = {
			capital_county = title:c_byzantion
			capital_county = title:c_roma
		}
		completely_controls_region = custom_roman_aegyptus
		custom_tooltip = {
			text = enough_granaries_in_egypt
			any_county_in_region = {
				region = custom_roman_aegyptus
				count >= 3
				any_county_province = {
					has_building_or_higher = cereal_fields_05
				}
			}
		}
	}

	is_valid_showing_failures_only = {
		is_at_war = no
		NOT = { exists = involved_activity }
		is_imprisoned = no
		custom_tooltip = {
			NOT = {
				title:c_byzantion = { has_county_modifier = panem_et_circenses_county_modifier }
			}
			text = grain_dole_already_active
		}
	}

	cost = {
		gold = {
			value = 0
			if = {
				limit = {
					has_treasury = no
				}
				add = grain_dole_cost
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					has_treasury = yes
				}
				add = grain_dole_cost
			}
		}
	}

	effect = {
		add_to_global_variable_list = {
			name = unavailable_unique_decisions
			target = flag:reinstitute_grain_dole_decision
		}
		trigger_event = ep3_decisions_event.4040
		reinstitute_grain_dole_decision_effect = yes
	}

	ai_potential = {
		is_roman_emperor_trigger = yes
	}

	ai_will_do = {
		base = 100
	}
}

### Reconfirm the Grain Dole ###
reconfirm_grain_dole_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_spend_money.dds"
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 60
		empire = 60
		hegemony = 0
	}
	sort_order = 90

	desc = reconfirm_grain_dole_decision_desc
	selection_tooltip = reconfirm_grain_dole_decision_tooltip
	decision_group_type = roman

	is_shown = {
		has_ep3_dlc_trigger = yes
		is_roman_emperor_trigger = yes
		is_target_in_global_variable_list = {
			name = unavailable_unique_decisions
			target = flag:reinstitute_grain_dole_decision
		}
	}

	is_valid = {
		government_has_flag = government_is_administrative
		OR = {
			capital_county = title:c_byzantion
			capital_county = title:c_roma
		}
		completely_controls_region = custom_roman_aegyptus
		custom_tooltip = {
			text = enough_granaries_in_egypt
			any_county_in_region = {
				region = custom_roman_aegyptus
				count >= 3
				any_county_province = {
					has_building_or_higher = cereal_fields_05
				}
			}
		}
	}

	is_valid_showing_failures_only = {
		is_at_war = no
		NOT = { exists = involved_activity }
		is_imprisoned = no
		custom_tooltip = {
			NOT = {
				capital_county = { has_county_modifier = panem_et_circenses_county_modifier }
			}
			text = grain_dole_already_active
		}
	}

	cost = {
		gold = {
			value = 0
			if = {
				limit = {
					has_treasury = no
				}
				add = grain_dole_cost
				multiply = {
					value = 0.5
					desc = unlocked_grain_dole
				}
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					has_treasury = yes
				}
				add = grain_dole_cost
				multiply = {
					value = 0.5
					desc = unlocked_grain_dole
				}
			}
		}
	}

	effect = {
		send_interface_message = {
			type = event_title_good
			title = reconfirm_grain_dole_decision_tt
			right_icon = root
			reinstitute_grain_dole_decision_effect = yes
		}
	}

	ai_potential = {
		is_roman_emperor_trigger = yes
		capital_county = { has_variable = unlocked_grain_dole }
	}

	ai_will_do = {
		base = 100
	}
}

#mass_arrests_decision = {
#	picture = {
#		reference = "gfx/interface/illustrations/decisions/decision_prison.dds"
#	}
#	sort_order = 115
#
#	desc = mass_arrests_decision_desc
#	selection_tooltip = mass_arrests_decision_tooltip
#	decision_group_type = admin
#
#	is_shown = {
#		has_ep3_dlc_trigger = yes
#		government_allows = administrative
#		primary_title.tier ?= tier_empire
#		dynasty ?= { has_dynasty_perk = ep3_administrative_legacy_5 }
#	}
#
#	is_valid = {
#		government_has_flag = government_is_administrative
#		primary_title.tier ?= tier_empire
#		dynasty ?= { has_dynasty_perk = ep3_administrative_legacy_5 }
#	}
#
#	is_valid_showing_failures_only = {
#		NOT = { exists = involved_activity }
#		is_imprisoned = no
#		any_powerful_family = { }
#	}
#
#	cost = {
#		influence = monumental_influence_value
#	}
#
#	cooldown = { years = 20 }
#
#	effect = {
#		show_as_tooltip = {
#			add_tyranny = massive_tyranny_gain
#			add_legitimacy = medium_legitimacy_loss
#
#			custom_tooltip = house_loses_power_rating
#			random_powerful_family = {
#				every_house_member = {
#					custom = choose_a_powerful_family
#					change_influence = major_influence_loss
#					custom_tooltip = imprisoned_by_you
#					add_opinion = {
#						modifier = imprisoned_me
#						years = 10
#						target = root
#					}
#				}
#			}
#		}
#
#		trigger_event = ep3_decisions_event.3200
#	}
#
#	ai_potential = {
#		always = no
#	}
#
#	ai_check_interval = 0
#
#	ai_will_do = {
#		base = 0
#	}
#}

change_state_faith = {
	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
						is_roman_emperor_primary_title_trigger = yes
					}
				}
			}
		}
		reference = "gfx/interface/illustrations/decisions/ep3_cerimonial_decision.dds"
	}
	picture = {
		trigger = {
			faith.religion = religion:islam_religion 
		}
		reference = "gfx/interface/illustrations/activity_header_backgrounds/activity_pilgrimage.dds"
	}
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_major_religion.dds"
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 60
		empire = 60
		hegemony = 0
	}
	sort_order = 110
	decision_group_type = admin

	desc = change_state_faith_decision_desc
	selection_tooltip = change_state_faith_decision_selection_tooltip

	is_shown = {
		has_ep3_dlc_trigger = yes
		government_allows = state_faith
		exists = primary_title.state_faith
		faith != primary_title.state_faith
	}

	is_valid = {
		government_allows = state_faith
		NOT = { faith ?= top_liege.primary_title.state_faith }
	}

	is_valid_showing_failures_only = {
		NOT = { exists = involved_activity }
		is_imprisoned = no
	}

	cost = {
		influence = {
			value = 5000
			if = {
				limit = {
					has_character_flag = ep3_hof_state_faith_discount
				}
				multiply = {
					value = 0.7
					desc = hof_state_faith_discount
				}
			}
			if = {
				limit = {
					domicile ?= { has_domicile_parameter = reduce_state_faith_cost }
				}
				multiply = {
					value = 0.9
					desc = domicile_large_temple
				}
			}
			if = {
				limit = {
					has_perk = prophet_perk
				}
				multiply = {
					value = 1
					subtract = admin_state_faith_cost_perk_value
					desc = "[GetPerk('prophet_perk').GetName(GetPlayer)]"
				}
			}
		}
		piety = {
			value = 5000
			if = {
				limit = {
					has_character_flag = ep3_hof_state_faith_discount
				}
				multiply = {
					value = 0.7
					desc = hof_state_faith_discount
				}
			}
			if = {
				limit = {
					domicile ?= { has_domicile_parameter = reduce_state_faith_cost }
				}
				multiply = {
					value = 0.9
					desc = domicile_large_temple
				}
			}
			if = {
				limit = {
					has_perk = prophet_perk
				}
				multiply = {
					value = 1
					subtract = admin_state_faith_cost_perk_value
					desc = "[GetPerk('prophet_perk').GetName(GetPlayer)]"
				}
			}
		}
	}

	effect = {
		hidden_effect = {
			primary_title.state_faith = { save_scope_as = old_faith }
			root.faith = { save_scope_as = new_faith }
			create_character_memory = { type = changed_state_faith_memory }
			scope:new_memory = {
				set_variable = {
					name = old_faith
					value = scope:old_faith
				}
				set_variable = {
					name = new_faith
					value = scope:new_faith
				}
				set_variable = {
					name = title
					value = root.primary_title
				}
			}
		}

		primary_title = { set_state_faith = root.faith }
		capital_county = { set_county_faith = root.faith }

		# Some vassals who like you the most will convert
		every_vassal = {
			custom = vassals_change_state_faith
			limit = {
				opinion = {
					target = root
					value >= 30
				}
				faith != root.faith
				NOT = { has_vassal_stance = zealot }
				is_ai = yes
			}

			hidden_effect = {
				faith = { save_scope_as = old_faith }
				root.faith = { save_scope_as = new_faith }
				create_character_memory = { type = adopted_state_faith_memory }
				scope:new_memory = {
					set_variable = {
						name = old_faith
						value = scope:old_faith
					}
					set_variable = {
						name = new_faith
						value = scope:new_faith
					}
					set_variable = {
						name = title
						value = root.primary_title
					}
				}
			}

			set_character_faith = root.faith
		}

		# Opinion malus with Zealot vassals
		save_scope_as = root_scope
		every_vassal = {
			vassal_stance = zealot
			limit = {
				faith != root.faith
			}
			custom = every_zealot_vassal
			add_opinion = {
				target = root
				modifier = changed_state_faith_opinion
				opinion = -30
			}
		}

		# Notify and let the players choose
		every_vassal = {
			limit = {
				is_ai = no
			}
			trigger_event = {
				id = ep3_emperor_yearly.2300
				days = 1
			}
		}
	}

	ai_potential = {
		government_has_flag = government_is_administrative
		primary_title.tier >= tier_empire
		faith != primary_title.state_faith
	}

	ai_will_do = {
		base = 50
		modifier = {
			has_trait = ambitious
			add = 30
		}
		modifier = {
			has_trait = arbitrary
			add = 30
		}
		modifier = {
			has_trait = arrogant
			add = 25
		}
		modifier = {
			has_trait = lazy
			add = -20
		}
		modifier = {
			has_trait = content
			add = -50
		}
		modifier = {
			has_trait = cynical
			add = -50
		}
		modifier = {
			has_trait = zealous
			factor = 2
		}
	}
}

adopt_state_faith = {
	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
						is_roman_emperor_primary_title_trigger = yes
					}
				}
			}
		}
		reference = "gfx/interface/illustrations/decisions/ep3_cerimonial_decision.dds"
	}
	picture = {
		trigger = {
			top_liege.primary_title.state_faith.religion = religion:islam_religion 
		}
		reference = "gfx/interface/illustrations/activity_header_backgrounds/activity_pilgrimage.dds"
	}
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_major_religion.dds"
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 60
		duchy = 60
		kingdom = 60
		empire = 60
		hegemony = 0
	}
	sort_order = 110
	decision_group_type = admin

	desc = adopt_state_faith_decision_desc
	selection_tooltip = adopt_state_faith_decision_selection_tooltip

	is_shown = {
		has_ep3_dlc_trigger = yes
		top_liege = { government_allows = state_faith }
		exists = top_liege.primary_title.state_faith
		NOT = { faith ?= top_liege.primary_title.state_faith }
	}

	is_valid = {
		top_liege = { government_allows = state_faith }
		NOT = { faith ?= top_liege.primary_title.state_faith }
	}

	is_valid_showing_failures_only = {
		NOT = {
			custom_description = {
				text = "is_in_an_activity"
				exists = involved_activity
			}
		}
		is_imprisoned = no
		NOT = { faith.religious_head ?= root }
	}

	cost = {}

	effect = {
		hidden_effect = {
			faith = { save_scope_as = old_faith }
			top_liege.faith = { save_scope_as = new_faith }
			create_character_memory = { type = adopted_state_faith_memory }
			scope:new_memory = {
				set_variable = {
					name = old_faith
					value = scope:old_faith
				}
				set_variable = {
					name = new_faith
					value = scope:new_faith
				}
				set_variable = {
					name = title
					value = root.top_liege.primary_title
				}
			}
		}

		set_character_faith = top_liege.primary_title.state_faith

		if = {
			limit = { NOT = { has_character_flag = adopted_state_faith } }
			if = {
				limit = { government_allows = administrative }
				change_influence = monumental_influence_gain
			}
			add_piety = massive_piety_gain
			top_liege = {
				if = {
					limit = { faith = primary_title.state_faith }
					add_opinion = {
						target = root
						modifier = converted_to_state_faith_opinion
						opinion = 30
					}
				}
				every_vassal = {
					custom = every_governor_of_state_faith
					limit = {
						faith = top_liege.primary_title.state_faith
						this != root
					}
					add_opinion = {
						target = root
						modifier = converted_to_state_faith_opinion
						opinion = 30
					}
				}
			}
			add_character_flag = adopted_state_faith
		}
	}

	ai_potential = {
		government_has_flag = government_is_administrative
		NOT = { has_trait = zealous } # A zealous vassal would presumably not want to change their faith
		exists = top_liege.primary_title.state_faith
		faith != top_liege.primary_title.state_faith
	}

	ai_will_do = {
		base = 20
		modifier = {
			is_governor = yes
			add = 40
		}
		
		# Personality
		modifier = {
			is_governor = yes
			has_trait = ambitious
			add = 20
		}
		modifier = {
			has_trait = fickle
			add = 30
		}
		modifier = {
			has_trait = arbitrary
			add = 10
		}
		modifier = {
			has_trait = ambitious
			add = -15
		}
		modifier = {
			has_trait = arrogant
			add = -15
		}
		modifier = {
			has_trait = content
			add = -20
		}
		modifier = {
			has_trait = cynical
			add = -30
		}
		modifier = {
			has_trait = stubborn
			add = -50
		}
		
		# Faith
		modifier = { # More likely to switch away from an unreformed faith
			faith ?= { has_doctrine_parameter = unreformed }
			add = 20
		}
		modifier = { # Communal Identity make it more likely to adopt faith if they share same culture with the top liege
			faith ?= { has_doctrine_parameter = same_culture_conversion_bonus_active }
			culture ?= top_liege.culture
			add = 10
		}
		modifier = { # Some faith are more likely to be abandoned
			faith ?= { has_doctrine_parameter = unattractive_for_character_conversions }
			add = 10
		}
		modifier = { # Don't adopt the state faith if you have the same faith as the top liege (if the emperor can have this faith, so can we!)
			faith = top_liege.faith
			top_liege != this
			factor = 0
		}
		
		# Other
		modifier = {
			has_vassal_stance = zealot
			factor = 0.3
		}
		
		# Non-admin vassals only consider converting if their faith hostility is low enough
		modifier = {
			NOT = { government_has_flag = government_is_administrative }
			faith ?= {
				faith_hostility_level = {
					target = root.top_liege.primary_title.state_faith
					value >= faith_hostile_level
				}
			}
			factor = 0
		}
	}
}

### Found Salon ###
found_salon_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_golden_age.dds"
	}
	sort_order = 120

	desc = found_salon_decision_desc
	selection_tooltip = found_salon_decision_tooltip
	decision_group_type = adventurer

	is_shown = {
		has_ep3_dlc_trigger = yes
		has_trait = violet_poet
		NOT = {	#You can only do it once.
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:flag_founded_salon
			}
		}
	}

	is_valid = {
		has_trait = violet_poet
		custom_tooltip = {
			text = found_salon_decision_trigger_tt
			any_courtier = {
				has_trait = lifestyle_poet
				count > 4
			}
		}
	}

	cost = {
		gold = {
			value = 0
			if = {
				limit = {
					has_treasury = no
				}
				add = 350
				if = {
					limit = {
						has_character_modifier = ep3_power_couple_modifier
					}
					subtract = 125
				}
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					has_treasury = yes
				}
				add = 350
				if = {
					limit = {
						has_character_modifier = ep3_power_couple_modifier
					}
					subtract = 125
				}
			}
		}
	}

	effect = {
		root.location = {
			save_scope_as = location
		}
		show_as_tooltip = {
			if = {
				limit = {
					exists = dynasty
				}
				dynasty = {
					add_dynasty_prestige = medium_dynasty_prestige_gain
				}
			}
			add_prestige = major_prestige_gain
			scope:location = {
				add_province_modifier = {
					modifier = ep3_poets_salon_modifier
					years = 250
				}
			}
			add_character_modifier = {
				modifier = ep3_founded_salon_modifier
			}
		}

		hidden_effect = {
			add_to_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:flag_founded_salon
			}
		}

		trigger_event = ep3_decisions_event.4080
	}

	ai_potential = {
		always = no
	}

	ai_check_interval = 0

	ai_will_do = {
		base = 0
	}
}

### Cleave the Empire ###
split_roman_empire_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/ep3_decision_hold_triumph.dds"
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 0
		empire = 0
		hegemony = 360
	}
	sort_order = 110

	desc = split_roman_empire_decision_desc
	selection_tooltip = split_roman_empire_decision_selection_tooltip
	decision_group_type = roman

	is_shown = {
		has_ep3_dlc_trigger = yes
		primary_title = title:h_roman_empire
		NOT = { exists = title:h_eastern_roman_empire.holder }
	}

	is_valid = {
		realm_size >= 150
		capital_county = title:c_roma
		has_title = title:c_byzantion
	}

	is_valid_showing_failures_only = {
		NOT = { exists = involved_activity }
		is_imprisoned = no
	}

	cost = {}

	effect = {
		if = {
			limit = {
				has_active_diarchy = yes
				has_diarchy_type = co_emperorship
			}
			diarch = { save_scope_as = new_holder }
		}
		if = {
			limit = {
				any_powerful_family = {
					this != root.house
					count >= 1
					exists = house_head
				}
			}
			ordered_powerful_family = {
				limit = { this != root.house }
				order_by = house_power_score
				house_head = { save_scope_as = new_holder }
			}
		}
		else = {
			ordered_powerful_vassal = {
				order_by = max_military_strength
				save_scope_as = new_holder
			}
		}
		custom_tooltip = {
			text = form_eastern_roman_empire_tt
			create_eastern_roman_empire_scripted_effect = yes
		}
		title:h_roman_empire = {
			set_title_name = h_roman_empire_western
		}

		# Add truce with new Byzantine Emperor
		add_truce_both_ways = {
			character = scope:new_holder
			years = 10
			name = TRUCE_COLLABORATION
		}

		# Some additional bonuses
		change_influence = {
			value = monumental_influence_gain
			multiply = 2
		}

		if = {
			limit = {
				any_owned_story = { 
					type = ep3_story_cycle_restoring_rome 
					has_variable = roman_empire_hard_mode
				}
			}
			custom_tooltip = {
				text = ending_of_restore_rome_trials_tt
				random_owned_story = {
					limit = { story_type = ep3_story_cycle_restoring_rome }
					remove_variable = roman_empire_hard_mode
				}
			}
		}
	}

	ai_potential = {
		primary_title = title:h_roman_empire
	}

	ai_will_do = {
		base = 50
	}
}

### Commission Icon ###
commission_icon_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_smith.dds"
	}
	cooldown = { days = standard_commission_artifact_cooldown_time }
	sort_order = 150
	decision_group_type = admin
	
	is_shown = {
		has_dlc_feature = roads_to_power
		is_landed_or_landless_administrative = yes
		OR = {
			faith = faith:orthodox
			faiths_are_in_orthodox_christianity_group = { FAITH_1 = faith:orthodox FAITH_2 = root.faith }
		}
		faith_is_aniconic_trigger = no
	}
	
	is_valid_showing_failures_only = {
		trigger_if = {
			limit = {
				government_allows = administrative
			}
			domicile ?= {
				has_domicile_building_or_higher = temple_monastery_04
			}
		}
		trigger_else = { always = yes }
	}

	minimum_cost = {
		# Matches the cost defined in 00_inspirations.txt
		gold = {
			value = basic_fund_inspiration_cost
			if = {
				limit = { # Estate discount bonus
					domicile ?= { has_domicile_parameter = estate_reduce_commission_artifact_cost }
				}
				multiply = estate_reduce_commission_artifact_cost_value
			}
		}
	}
	widget = {
    	gui = "decision_view_widget_commission_artifact"
		controller = decision_option_list_controller
		decision_to_second_step_button = "COMMISSION_ARTIFACT_DECISION_NEXT_STEP_BUTTON" 

		# Personal Artifacts are always valid to commission
		item = {
			value = commission_trinket_icon
			current_description = {
				desc = commission_artifact_decision_option_trinket_icon_desc
			}
			localization  = {
				desc = commission_artifact_decision_option_trinket_icon
			}
			icon = "gfx/interface/icons/artifact/artifact_icon_byz.dds"

			ai_chance = {
				value = 10
				if = {
					limit = {
						has_royal_court = yes
					}
					multiply = 0
				}
			}
		}
		# Court Artifacts only appear if you have the Royal Court DLC, and are only valid if you have an active Royal Court
		item = {
			value = commission_court_icon_large
			is_shown = { has_dlc_feature = royal_court }
			is_valid = { has_royal_court = yes }
			current_description = {
				desc = commission_artifact_decision_option_tapestry_desc
			}

			localization = {
				desc = commission_artifact_decision_option_court_icon_large
			}
			icon = "gfx/interface/icons/artifact/artifact_icon_byz.dds"

			ai_chance = {
				value = 20
				if = {
					limit = {
						has_royal_court = yes
						# Only make this choice if we don't already have an artifact of this type.
						NOT = {
							any_character_artifact = {
								artifact_slot_type = wall_big
							}
						}
					}
					add = 100
				}
			}
		}
		item = {
			value = commission_court_icon_small
			is_shown = { has_dlc_feature = royal_court }
			is_valid = { has_royal_court = yes }
			current_description = {
				desc = commission_artifact_decision_option_court_icon_small_desc
			}

			localization = {
				desc = commission_artifact_decision_option_court_icon_small
			}
			icon = "gfx/interface/icons/artifact/artifact_icon_byz.dds"

			ai_chance = {
				value = 20
				if = {
					limit = {
						has_royal_court = yes
						# Only make this choice if we don't already have an artifact of this type.
						NOT = {
							any_character_artifact = {
								artifact_slot_type = wall_small
							}
						}
					}
					add = 100
				}
			}
		}
	}
	effect = {
		if = {
			limit = {
				any_court_position_holder = {
					type = antiquarian_court_position
				}
			}
			random_court_position_holder = {
				type = antiquarian_court_position
				save_scope_as = antiquarian
			}
		}
		# Explanatory Tooltips
		custom_tooltip = commission_icon_decision_effect
		if = {
			limit = {
				any_pool_character = {
					province = root.capital_province
					has_no_particular_noble_roots_trigger = yes
					is_available_healthy_ai_adult = yes
					NOR = {
						exists = inspiration
						has_trait = peasant_leader
					}
				}
			}
			random_pool_character = {
				province = root.capital_province
				limit = {
					has_no_particular_noble_roots_trigger = yes
					is_available_healthy_ai_adult = yes
					NOR = {
						exists = inspiration
						has_trait = peasant_leader
					}
				}
				save_scope_as = local_artisan
			}
		}
		else_if = {
			limit = {
				is_ai = yes
				any_courtier_or_guest = {
					is_available_healthy_ai_adult = yes
				}
			}
			random_courtier_or_guest = {
				limit = {
					is_available_healthy_ai_adult = yes
				}
				save_scope_as = local_artisan
			}
		}
		else = {
			# Artisan Generation
			hidden_effect = {
				create_character = {
					template = local_artisan_template
					location = root.capital_province
					gender_female_chance = root_faith_dominant_gender_adjusted_female_chance
					save_scope_as = local_artisan
				}
			}
		}

		hidden_effect = {
			if = {
				# Conditional exists to avoid false-positives during tooltip generation, but 'local_artisan' should always exist on execution!
				limit = { exists = scope:local_artisan }
				root = { add_courtier = scope:local_artisan	}
				scope:local_artisan = {
					add_trait = devoted
				}
			}
			trigger_event = ep3_decisions_event.5000
		}
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 36
		kingdom = 36
		empire = 36
		hegemony = 36
	}
	
	ai_potential = {
		is_at_war = no
		ai_greed < medium_positive_ai_value
		short_term_gold > ai_war_chest_desired_gold_value
		war_chest_gold >= halved_ai_war_chest_gold_maximum
		NOT = { has_variable = conqueror }
		ai_should_focus_on_building_in_their_capital = no
	}

	ai_will_do = {
		base = 75

		ai_value_modifier = {
			ai_zeal = 1
		}
	}
}

### Embrace Heresy ###
embrace_heresy_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_major_religion.dds"
	}
	sort_order = 120

	desc = embrace_heresy_decision_desc
	selection_tooltip = embrace_heresy_decision_tooltip
	decision_group_type = admin

	is_shown = {
		government_allows = state_faith
		is_adult = yes
		top_liege != this
		top_liege ?= { is_ai = yes }
		top_liege.primary_title.state_faith ?= {
			OR = {
				NOT = { has_doctrine = eastern_hostility_doctrine }
				has_doctrine = heresy_hostility_doctrine #Zoroastrians also get heresies, despite being Eastern.
			}
		}
		this != top_liege.primary_title.state_faith.religious_head
	}

	is_valid = {
		has_lifestyle = learning_lifestyle
		custom_tooltip = {
			text = heresy_in_empire_or_bordering_tt
			top_liege ?= {
				any_realm_county = {
					OR = {
						faith = {
							faith_is_interesting_heresy_to_state_faith_trigger = yes
						}
						any_neighboring_county = {
							holder.top_liege ?= {
								this != root.top_liege
							}
							faith = {
								faith_is_interesting_heresy_to_state_faith_trigger = yes
							}
						}
					}
				}
			}
		}
	}

	is_valid_showing_failures_only = {
		NOT = { exists = involved_activity }
		is_imprisoned = no
		is_available = yes
	}

	cost = {
		prestige = major_influence_loss
		piety = massive_piety_loss
	}

	cooldown = { years = 50 }

	effect = {
		custom_tooltip = embrace_heresy_tt
		custom_tooltip = leverage_position_tt
		custom_tooltip = unlocks_demand_state_faith_decision
		trigger_event = ep3_decisions_event.5020
	}

	ai_potential = {
		always = no
	}

	ai_check_interval = 0

	ai_will_do = {
		base = 0
	}
}

push_heresy_as_state_faith = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_major_religion.dds"
	}
	sort_order = 150

	desc = push_heresy_as_state_faith_desc
	selection_tooltip = push_heresy_as_state_faith_tooltip
	decision_group_type = admin

	is_shown = {
		government_allows = state_faith
		is_adult = yes
		top_liege != this
		top_liege ?= { is_ai = yes }
		top_liege.primary_title.state_faith ?= {
			OR = {
				NOT = { has_doctrine = eastern_hostility_doctrine }
				has_doctrine = heresy_hostility_doctrine #Zoroastrians also get heresies, despite being Eastern.
			}
		}
		NOR = {
			this = top_liege.primary_title.state_faith.religious_head
			faith = top_liege.primary_title.state_faith
		}
		has_variable = heresy_embraced
	}

	is_valid = {
		custom_tooltip = {
			text = has_embraced_heresy_tt
			has_variable = heresy_embraced
			faith = var:heresy_embraced
		}
	}

	is_valid_showing_failures_only = {
		NOT = { exists = involved_activity }
		is_imprisoned = no
		is_available = yes
	}

	cost = {
		influence = major_influence_loss
	}

	cooldown = { years = 10 }

	effect = {
		custom_tooltip = try_to_push_faith_with_emperor_tt
		save_scope_as = heretic
		scope:heretic.faith = { save_scope_as = heresy }
		top_liege = {
			trigger_event = {
				id = ep3_decisions_event.5021 
				days = 1
			}
		}
	}

	ai_potential = {
		always = no
	}

	ai_check_interval = 0

	ai_will_do = {
		base = 0
	}
}

### Establish Silk Production ###
establish_silk_production_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/ep3_decision_estate.dds"
	}
	sort_order = 120

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { top_liege = this }
				desc = establish_silk_production_decision_desc.emperor
			}
			desc = establish_silk_production_decision_desc
		}
	}
	selection_tooltip = establish_silk_production_decision_tooltip
	decision_group_type = admin

	is_shown = {
		has_ep3_dlc_trigger = yes
		government_allows = administrative
		OR = {
			this = house.house_head
			AND = {
				is_ai = no
				house.house_head = top_liege
			}
		}
		domicile ?= {
			is_domicile_type = estate
		}
		top_liege ?= {
			is_roman_emperor_primary_title_trigger = yes
		}
		NOT = {
			house = {
				has_house_modifier = ep3_unlocked_silk
			}
		}
	}

	is_valid = {
		trigger_if = {
			limit = { top_liege = this }
			is_roman_emperor_trigger = yes
			OR = {
				has_realm_law = imperial_bureaucracy_2
				has_realm_law = imperial_bureaucracy_3
			}
		}
		trigger_else = {
			influence_level >= 3
			OR = {
				has_weak_hook = top_liege
				has_strong_usable_hook = top_liege
				AND = {
					exists = house
					top_liege.house ?= house
				}
			}
		}
	}

	cost = {
		gold = {
			value = {
				value = massive_gold_value
				multiply = 2
			}
		}
	}

	effect = {
		custom_tooltip = {
			text = unlocked_estate_silk_buildings
			house = { add_house_modifier = ep3_unlocked_silk }
		}
		send_interface_toast = {
			type = msg_domicile_building_unlocked
			title = unlocked_estate_silk_buildings_t
		}
		if = {
			limit = {
				top_liege != this
				NOT = {
					exists = house
					top_liege.house ?= house
				}
			}
			use_hook = top_liege
		}
	}

	ai_potential = {
		domicile ?= {
			is_domicile_type = estate
		}
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 120
		kingdom = 120
		empire = 120
		hegemony = 120
	}

	ai_will_do = {
		base = 50
		modifier = {
			has_trait = arrogant
			add = 15
		}
		modifier = {
			has_trait = ambitious
			add = 25
		}
	}
}

### Commission Silk Regalia ###
commission_silk_regalia_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_smith.dds"
	}
	cooldown = { days = standard_commission_artifact_cooldown_time }
	sort_order = 120

	desc = commission_silk_regalia_decision_desc
	selection_tooltip = commission_silk_regalia_decision_tooltip
	decision_group_type = admin
	
	is_shown = {
		has_dlc_feature = roads_to_power
		government_allows = administrative
		this = house.house_head
		domicile ?= {
			has_domicile_parameter = estate_unlock_silk_regalia_decision
		}
	}

	is_valid = {
	}

	minimum_cost = {
		# Matches the cost defined in 00_inspirations.txt
		gold = {
			value = basic_fund_inspiration_cost
			if = {
				limit = { # Estate discount bonus
					domicile ?= { has_domicile_parameter = estate_reduce_commission_artifact_cost }
				}
				multiply = estate_reduce_commission_artifact_cost_value
			}
		}
	}
	effect = {
	# Explanatory Tooltips
		custom_tooltip = commission_silk_regalia_decision_effect
		if = {
			limit = {
				any_pool_character = {
					province = root.capital_province
					has_no_particular_noble_roots_trigger = yes
					is_available_healthy_ai_adult = yes
					NOR = {
						exists = inspiration
						has_trait = peasant_leader
					}
				}
			}
			random_pool_character = {
				province = root.capital_province
				limit = {
					has_no_particular_noble_roots_trigger = yes
					is_available_healthy_ai_adult = yes
					NOR = {
						exists = inspiration
						has_trait = peasant_leader
					}
				}
				save_scope_as = local_artisan
				hidden_effect = {
					add_character_modifier = local_artisan_modifier
				}
			}
		}
		else = {
			# Artisan Generation
			hidden_effect = {
				create_character = {
					template = local_artisan_template
					location = root.capital_province
					gender_female_chance = root_faith_dominant_gender_adjusted_female_chance
					save_scope_as = local_artisan
				}
				scope:local_artisan = {
					hidden_effect = {
						add_character_modifier = local_artisan_modifier
					}
				}
			}
		}
		hidden_effect = {
			if = {
				# Conditional exists to avoid false-positives during tooltip generation, but 'local_artisan' should always exist on execution!
				limit = { exists = scope:local_artisan }
				root = { add_courtier = scope:local_artisan	}
				scope:local_artisan = {
					add_character_flag = local_artisan
				}
			}
			trigger_event = ep3_decisions_event.5030
		}
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 60
		duchy = 60
		kingdom = 60
		empire = 60
		hegemony = 60
	}
	
	ai_potential = {
		is_at_war = no
		ai_greed < medium_positive_ai_value
		short_term_gold > ai_war_chest_desired_gold_value
		war_chest_gold >= halved_ai_war_chest_gold_maximum
		NOT = { has_variable = conqueror }
		ai_should_focus_on_building_in_their_capital = no
	}

	ai_will_do = {
		base = 75

		ai_value_modifier = {
			ai_boldness = 0.5
		}
	}
}

### Foster Integration ###
foster_integration_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_legitimacy.dds"
	}
	cooldown = { years = 20 }
	sort_order = 120

	desc = foster_integration_decision_desc
	selection_tooltip = foster_integration_decision_tooltip
	decision_group_type = admin
	
	is_shown = {
		has_dlc_feature = roads_to_power
		is_adult = yes
		this = house.house_head
		government_allows = administrative
		domicile ?= {
			is_domicile_type = estate
		}
		exists = top_liege
		root.top_liege != root
		OR = {
			top_liege.primary_title = {
				NOT = { is_de_jure_liege_or_above_target = root.domicile.domicile_location.county }
			}
			domicile.domicile_location.county.culture != root.top_liege.culture
		}
	}

	is_valid = {
		OR = {
			domicile.domicile_location.county = { de_jure_drifting_towards = root.top_liege.primary_title }
			domicile.domicile_location.county.culture = {
				cultural_acceptance = {
					target = root.top_liege.culture
					value <= 75
				}
			}
		}
	}

	is_valid_showing_failures_only = {
		NOT = { exists = involved_activity }
		is_imprisoned = no
		is_available = yes
		is_at_war = no
	}

	cost = {
		influence = {
			value = {
				add = major_influence_value
				multiply = 2
			}
		}
	}

	effect = {
		domicile.domicile_location.county = { save_scope_as = target_county }
		add_character_modifier = {
			modifier = ep3_integration_promoter_modifier
			years = 15
		}
		set_variable = {
			name = integration_promoted_in
			value = scope:target_county
			years = 15
		}
		if = {
			limit = {
				scope:target_county = { de_jure_drifting_towards = root.top_liege.primary_title }
			}
			scope:target_county = {
				add_county_modifier = {
					modifier = improve_de_jure_integration_modifier
					years = 10
				}
			}
		}
		if = {
			limit = {
				scope:target_county.culture != root.top_liege.culture
				scope:target_county.culture = {
					cultural_acceptance = {
						target = root.top_liege.culture
						value <= 75
					}
				}
			}
			scope:target_county = {
				add_county_modifier = {
					modifier = improve_promote_culture_modifier
					years = 10
				}
			}
		}
		if = {
			limit = {
				top_liege = { is_ai = yes }
			}
			top_liege = {
				add_opinion = {
					target = root
					modifier = grateful_opinion
					opinion = 25
				}
			}
		}
		else = {
			if = {
				limit = {
					scope:target_county = { has_county_modifier = improve_promote_culture_modifier }
				}
				top_liege = {
					send_interface_message = {
						type = msg_vassal_decision_good
						title = improve_promote_culture_modifier
						desc = improve_promote_culture_modifier_tt
						left_icon = root
						right_icon = scope:target_county
					}
				}
			}
			else = {
				top_liege = {
					send_interface_message = {
						type = msg_vassal_decision_good
						title = improve_de_jure_integration_modifier
						desc = improve_de_jure_integration_modifier_tt
						left_icon = root
						right_icon = scope:target_county
					}
				}
			}
		}
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 36
		duchy = 36
		kingdom = 36
		empire = 36
		hegemony = 0
	}
	
	ai_potential = {
		government_allows = administrative
		exists = top_liege
		root.top_liege != root
	}

	ai_will_do = {
		base = 75
		modifier = {
			culture = top_liege.culture
			add = 25
		}
		modifier = {
			has_trait = loyal
			add = 20
		}
		modifier = {
			has_trait = disloyal
			add = -20
		}
	}
}

### Gather Faction Support ###
gather_faction_support_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_recruitment.dds"
	}
	cooldown = { years = 25 }
	sort_order = 120

	desc = gather_faction_support_decision_desc
	selection_tooltip = gather_faction_support_decision_tooltip
	decision_group_type = admin
	
	is_shown = {
		has_dlc_feature = roads_to_power
		government_allows = administrative
		exists = top_liege
		top_liege != root
		is_adult = yes
		this = house.house_head
		domicile ?= {
			is_domicile_type = estate
		}
	}

	is_valid = {
		custom_tooltip = {
			text = belong_to_claimant_liberty_faction_tt
			joined_faction ?= {
				OR = {
					faction_is_type = claimant_faction
					faction_is_type = liberty_faction
				}
			}
		}
	}

	is_valid_showing_failures_only = {
		NOT = { exists = involved_activity }
		is_imprisoned = no
		is_available = yes
		is_at_war = no
	}

	cost = {
		influence = {
			value = {
				add = massive_influence_value
				multiply = 2
			}
		}
	}

	effect = {
		joined_faction = { save_scope_as = the_faction }
		add_joined_faction_discontent = 20
		custom_tooltip = gathered_support_for_faction_get_army_tt
		set_variable = {
			name = gathered_support_for_faction
			value = scope:the_faction
			years = 5
		}
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 60
		duchy = 60
		kingdom = 60
		empire = 60
		hegemony = 0
	}
	
	ai_potential = {
		government_allows = administrative
		exists = top_liege
		top_liege != root
	}

	ai_will_do = {
		base = 50
		modifier = {
			has_trait = loyal
			add = -30
		}
		modifier = {
			has_trait = disloyal
			add = 30
		}
		modifier = {
			has_trait = ambitious
			add = 50
		}
	}
}

#The latin emperor switching byz kingdoms to his de jure
### Legitimize Latin Dominion ###
legitimize_latin_dominion_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/ep3_decision_hold_triumph.dds"
	}
	decision_group_type = major

	desc = legitimize_latin_dominion_decision_desc
	selection_tooltip = legitimize_latin_dominion_decision_tooltip
	# Yeah it's in the Roman category: what're you gonna do about it, _Greek_?
	decision_group_type = roman

	cooldown = { days = 60 }
	
	is_shown = {
		has_dlc_feature = roads_to_power
		primary_title = title:e_latin_empire
		title:e_byzantium = {
			any_de_jure_county = { }
		}
	}

	is_valid = {
		custom_tooltip = {
			text = is_latin_emperor_tt
			primary_title = title:e_latin_empire
		}
		OR = {
			custom_tooltip = {
				text = control_byzantine_kingdom_tt
				title:e_byzantium = {
					any_in_de_jure_hierarchy = {
						tier = tier_kingdom
						NOT = { this = title:e_byzantium }
						any_de_jure_county = {
							percent >= 0.8
							holder.top_liege = {
								this = root
							}
						}
					}
				}
			}
			custom_tooltip = {
				text = latin_capital_byzantine_kingdom_tt
				title:e_byzantium = {
					any_in_de_jure_hierarchy = {
						tier = tier_kingdom
						NOT = { this = title:e_byzantium }
						any_de_jure_county = {
							this = root.capital_county
						}
					}
				}
			}
		}
		custom_tooltip = {
			text = hold_byz_kingdom_title_tt
			title:e_byzantium = {
				any_in_de_jure_hierarchy = {
					tier = tier_kingdom
					NOT = { this = title:e_byzantium }
					holder ?= {
						OR = {
							this = root
							top_liege = root
						}
					}
					OR = {
						any_de_jure_county = {
							this = root.capital_county
						}
						any_de_jure_county = {
							percent >= 0.8
							holder.top_liege = {
								this = root
							}
						}
					}
				}
			}
		}
		trigger_if = {
			limit = {
				is_ai = no
				has_legitimacy = yes
			}
			legitimacy_level >= 3
		}
		#A liiiiiittle easier for AI
		trigger_if = {
			limit = {
				has_legitimacy = yes
				is_ai = yes
			}
			legitimacy_level >= 2
		}
	}

	is_valid_showing_failures_only = {
		trigger_if = {
			limit = {
				is_ai = no
			}
			NOT = { exists = involved_activity }
			is_available = yes
		}
		trigger_else = {
			is_alive = yes
			is_imprisoned = no
			is_incapable = no
		}
	}

	cost = {
		prestige = {
			value = {
				add = massive_prestige_value
				#AI suck
				if = {
					limit = {
						is_ai = yes
					}
					multiply = 0.75
				}
			}
		}
		piety = {
			value = {
				add = massive_piety_value
			}
			if = {
				limit = {
					is_ai = yes
				}
				multiply = 0.1
			}
		}
	}

	effect = {
		custom_tooltip = gain_byz_kingdom_de_jure_tt
		custom_tooltip = legitimize_latin_control_tt
		custom_tooltip = legitimize_latin_cultural_acceptance_tt
		show_as_tooltip = {
			if = {
				limit = {
					government_allows = administrative
				}
				custom_tooltip = legitimize_latin_holder_influence_tt
			}
			else = {
				custom_tooltip = legitimize_latin_holder_legitimacy_tt
			}
		}
		custom_tooltip = latin_de_jure_lost_on_title_loss_tt
		custom_tooltip = byzantines_threaten_latin_titles_tt
		
		
		trigger_event = ep3_frankokratia_events.0080
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 0
		empire = 6
		hegemony = 0
	}
	
	ai_potential = {
		primary_title ?= {
			this = title:e_latin_empire
		}
		title:e_byzantium = {
			any_in_de_jure_hierarchy = {
				tier = tier_kingdom
				exists = holder
				holder.top_liege = {
					this = root
				}
			}
		}
		NOT = {
			any_held_title = {
				this = title:e_byzantium
			}
		}
	}

	ai_will_do = {
		base = 100
	}
}

#A Byzantine switches it back
### Expunge Latin Dominion ###
expunge_latin_dominion_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/ep3_decision_hold_triumph.dds"
	}
	decision_group_type = major

	desc = expunge_latin_dominion_decision_desc
	selection_tooltip = expunge_latin_dominion_decision_tooltip
	decision_group_type = roman

	cooldown = { days = 60 }
	
	is_shown = {
		has_dlc_feature = roads_to_power
		#Latin land needs to exist
		title:e_latin_empire = {
			any_in_de_jure_hierarchy = {
				tier <= tier_kingdom
			}
		}
		#Must be a Greek or Greekoid
		OR = {
			culture = culture:greek
			culture = culture:roman
			culture = {
				any_parent_culture_or_above = {
					this = culture:greek
				}
			}
			ep3_orthodox_faith_trigger = yes
			faith = faith:hellenic_pagan
			AND = {
				exists = title:e_byzantium.holder
				this = title:e_byzantium.holder
			}
			AND = {
				exists = title:h_roman_empire.holder
				this = title:h_roman_empire.holder
			}
			AND = {
				exists = title:h_eastern_roman_empire.holder
				this = title:h_eastern_roman_empire.holder
			}
		}
		OR = {
			capital_province = {
				OR = {
					geographical_region = world_asia_minor
					geographical_region = world_europe_south
					geographical_region = world_middle_east
					geographical_region = world_europe_east
					geographical_region = world_steppe_west
				}
			}
			AND = {
				exists = title:e_byzantium.holder
				this = title:e_byzantium.holder
			}
			AND = {
				exists = title:h_roman_empire.holder
				this = title:h_roman_empire.holder
			}
			AND = {
				exists = title:h_eastern_roman_empire.holder
				this = title:h_eastern_roman_empire.holder
			}
		}
	}

	is_valid = {
		trigger_if = {
			limit = {
				top_liege != this
			}
			custom_tooltip = {
				text = liege_isnt_latin_emp_tt
				NOT = {
					top_liege = {
						primary_title = title:e_latin_empire
					}
				}
			}
		}
		trigger_else = {
			OR = {
				highest_held_title_tier <= tier_kingdom
				custom_tooltip = {
					exists = title:e_byzantium.holder
					this = title:e_byzantium.holder
					text = holds_byz_emp_tt
				}
				custom_tooltip = {
					exists = title:h_roman_empire.holder
					this = title:h_roman_empire.holder
					text = holds_roman_emp_tt
				}
				custom_tooltip = {
					exists = title:h_eastern_roman_empire.holder
					this = title:h_eastern_roman_empire.holder
					text = holds_roman_emp_tt
				}
			}
		}
		#Must be a Greek or Greekoid
		OR = {
			culture = culture:greek
			culture = culture:roman
			custom_tooltip = {
				culture = {
					any_parent_culture_or_above = { this = culture:greek }
				}
				text = is_greek_descendent_tt
			}
			ep3_orthodox_faith_trigger = yes
			faith = faith:hellenic_pagan
			custom_tooltip = {
				exists = title:e_byzantium.holder
				this = title:e_byzantium.holder
				text = holds_byz_emp_tt
			}
			custom_tooltip = {
				exists = title:h_roman_empire.holder
				this = title:h_roman_empire.holder
				text = holds_roman_emp_tt
			}
			custom_tooltip = {
				exists = title:h_eastern_roman_empire.holder
				this = title:h_eastern_roman_empire.holder
				text = holds_roman_emp_tt
			}
		}
		OR = {
			#Controls entire kingdom
			custom_tooltip = {
				text = control_latin_kingdom_tt
				title:e_latin_empire = {
					any_in_de_jure_hierarchy = {
						tier = tier_kingdom
						NOT = { this = title:e_latin_empire }
						any_de_jure_county = {
							percent >= 1
							holder.top_liege = {
								this = root
							}
						}
					}
				}
			}
			#Controls half and has de jure title
			custom_tooltip = {
				text = has_latin_kingdom_title_tt
				title:e_latin_empire = {
					any_in_de_jure_hierarchy = {
						tier = tier_kingdom
						NOT = { this = title:e_latin_empire }
						holder ?= {
							OR = {
								this = root
								top_liege = root
							}
						}
						OR = {
							any_de_jure_county = {
								this = root.capital_county
							}
							any_de_jure_county = {
								percent >= 0.5
								holder.top_liege = {
									this = root
								}
							}
						}
					}
				}
			}
		}
		trigger_if = {
			limit = {
				has_legitimacy = yes
				is_ai = no
			}
			legitimacy_level >= 2
		}
		#A liiiiiittle easier for AI
		trigger_if = {
			limit = {
				has_legitimacy = yes
				is_ai = yes
			}
			legitimacy_level >= 1
		}
	}

	is_valid_showing_failures_only = {
		trigger_if = {
			limit = {
				is_ai = no
			}
			NOT = { exists = involved_activity }
			is_available = yes
		}
		trigger_else = {
			is_alive = yes
			is_imprisoned = no
			is_incapable = no
		}
		is_at_war = no
	}

	cost = {
		prestige = {
			value = {
				add = major_prestige_value
				#AI should definitely take this
				if = {
					limit = {
						is_ai = yes
					}
					multiply = 0.5
				}
			}
		}
		piety = {
			value = {
				add = major_piety_value
				if = {
					limit = {
						is_ai = yes
					}
					multiply = 0.5
				}
			}
		}
	}

	effect = {
		custom_tooltip = remove_latin_kingdom_de_jure_tt
		custom_tooltip = legitimize_byz_control_tt
		custom_tooltip = legitimize_byz_claim_tt
		show_as_tooltip = {
			expunge_latin_dominion_effect = yes
		}
		trigger_event = ep3_frankokratia_events.0090
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 12
		kingdom = 9
		empire = 9
		hegemony = 9
	}
	
	ai_potential = {
		is_available = yes
		OR = {
			highest_held_title_tier >= tier_kingdom
			realm_size >= 10
		}
		#Must be a Greek or Greekoid
		OR = {
			culture = culture:greek
			culture = culture:roman
			culture = {
				any_parent_culture_or_above = {
					this = culture:greek
				}
			}
			ep3_orthodox_faith_trigger = yes
			faith = faith:hellenic_pagan
			primary_title = title:e_byzantium
		}
		OR = {
			#Controls entire kingdom
			title:e_latin_empire = {
				any_in_de_jure_hierarchy = {
					tier = tier_kingdom
					NOT = { this = title:e_latin_empire }
					any_de_jure_county = {
						percent >= 1
						holder.top_liege = {
							this = root
						}
					}
				}
			}
			#Controls half and has de jure title
			title:e_latin_empire = {
				any_in_de_jure_hierarchy = {
					tier = tier_kingdom
					NOT = { this = title:e_latin_empire }
					holder ?= {
						OR = {
							this = root
							top_liege = root
						}
					}
					OR = {
						any_de_jure_county = {
							this = root.capital_county
						}
						any_de_jure_county = {
							percent >= 0.5
							holder.top_liege = {
								this = root
							}
						}
					}
				}
			}
		}
	}

	ai_will_do = {
		base = 75
		modifier = {
			add = 25
			primary_title = title:e_byzantium
		}
		modifier = {
			add = -50
			any_held_title = {
				this = title:e_latin_empire
			}
		}
	}
}

### Go Fishing ###
go_fishing_decision = {
	picture = { reference = "gfx/interface/illustrations/event_scenes/bp1_docks_tribal.dds" }
	desc = go_fishing_decision_desc
	selection_tooltip = go_fishing_decision_tooltip

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 24
		kingdom = 0
		empire = 0
		hegemony = 0
	}
	cooldown = { years = 2 }
	decision_group_type = adventurer_minor

	is_shown = {
		#DLC check.
		has_ep3_dlc_trigger = yes
		OR = { has_government = landless_adventurer_government has_government = landless_minority_government   }
	}

	is_valid_showing_failures_only = {
		is_available = yes
		custom_tooltip = {
			text = go_fishing_decision_unlock_tt
			location = {
				OR = {
					is_coastal = yes
					is_riverside_province = yes
				}
			}
		}
	}

	effect = {
		custom_tooltip = {
			text = go_fishing_decision_effect_tt
			trigger_event = ep3_decisions_event.9001
		}
		close_view = {
			view = decisions
			player = root
		}
	}

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}
