﻿# latin
vlaanderen_crush_nikaea_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_dynasty_house.dds"
	}
	decision_group_type = major

	ai_check_interval = 36

	desc = vlaanderen_crush_nikaea_decision_desc
	selection_tooltip = vlaanderen_crush_nikaea_decision_tooltip

	is_shown = {
		is_ruler = yes
		is_landed = yes
		exists = dynasty
		exists = title:e_vlaanderen
		has_title = title:e_vlaanderen
		NOR = { # only once
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:vlaanderen_crush_nikaea_decision
			}
			has_title = title:e_byzantium
		}
	}

	is_valid = {
		has_primary_title = title:e_vlaanderen
		trigger_if = {
			limit = { is_ai = no }
			has_title = title:c_byzantion
		}
		completely_controls_region = special_vlaanderen_restore_byzantium_region
		religion = religion:christianity_religion
		custom_tooltip = {
			text = religious_head_catholic_pope
			faith.religious_head = faith:catholic.religious_head
		}
	}

	is_valid_showing_failures_only = {
		is_imprisoned = no
		is_available = yes
		is_at_war = no
	}

	cost = {
		gold = 250
		prestige = 750
		piety = 150
	}

	effect = {
		vlaanderen_crush_nikaea_decision_effect = yes
		# legend
		gain_heroic_legend_seed_tooltip_effect = yes
		hidden_effect = { legend_seed_new_title_effect = yes }
	}

	ai_potential = {
		primary_title.tier = tier_empire
		has_primary_title = title:e_vlaanderen
	}

	ai_will_do = { base = 100 }
}

# greek
vlaanderen_restore_byzantium_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_dynasty_house.dds"
	}
	decision_group_type = major

	ai_check_interval = 36

	desc = vlaanderen_restore_byzantium_decision_desc
	selection_tooltip = vlaanderen_restore_byzantium_decision_tooltip

	is_shown = {
		is_ruler = yes
		is_landed = yes
		exists = dynasty
		exists = title:e_nikaea
		has_title = title:e_nikaea
		NOR = { # only once
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:vlaanderen_restore_byzantium_decision
			}
			has_title = title:e_byzantium
		}
	}

	is_valid = {
		has_primary_title = title:e_nikaea
		trigger_if = {
			limit = { is_ai = no }
			has_title = title:c_byzantion
		}
		completely_controls_region = special_vlaanderen_restore_byzantium_region
		OR = {
			religion = religion:christianity_religion
			religion = religion:hellenism_religion
		}
		custom_tooltip = {
			text = religious_head_not_catholic_pope
			NOT = { faith.religious_head = faith:catholic.religious_head }
		}
	}

	is_valid_showing_failures_only = {
		is_imprisoned = no
		is_available = yes
		is_at_war = no
	}

	cost = {
		gold = 250
		prestige = 750
		piety = 150
	}

	effect = {
		vlaanderen_restore_byzantium_decision_effect = yes
		# legend
		gain_heroic_legend_seed_tooltip_effect = yes
		hidden_effect = { legend_seed_new_title_effect = yes }
	}

	ai_potential = {
		primary_title.tier = tier_empire
		has_primary_title = title:e_nikaea
	}

	ai_will_do = { base = 100 }
}

### restore byzantine empire prior to the 4th crusade
vlaanderen_reclaim_byzantine_empire_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_dynasty_house.dds"
	}
	decision_group_type = major

	ai_check_interval = 36

	desc = vlaanderen_reclaim_byzantine_empire_decision_desc
	selection_tooltip = vlaanderen_reclaim_byzantine_empire_decision_tooltip

	is_shown = {
		is_ruler = yes
		is_landed = yes
		exists = dynasty
		exists = title:e_byzantium
		title:e_byzantium = {
			is_title_created = no
			is_titular = no
		}
		# only show within relevant region
		OR = {
			capital_province = { geographical_region = world_europe_south_east }
			capital_province = { geographical_region = world_asia_minor }
		}
	}

	is_valid = {
		# Byzantine Empire is not created
		custom_tooltip = {
			text = e_byzantium_not_created
			title:e_byzantium = { is_title_created = no }
		}
		# you control N percent of the de jure territory of the ERE
		# weird structure - I know - but this makes it very pretty to look at in the decision window! :)
		title:e_byzantium = {
			custom_tooltip = {
				text = vlaanderen_reclaim_byzantine_empire_decision_hold_percent
				any_in_de_jure_hierarchy = {
					filter = { tier = tier_county }
					continue = { tier > tier_county }
					OR = {
						holder = root
						holder = { target_is_liege_or_above = ROOT }
					}
					percent >= 0.3
				}
			}
			any_in_de_jure_hierarchy = {
				filter = { tier = tier_county }
				continue = { tier > tier_county }
				OR = {
					holder = root
					holder = { target_is_liege_or_above = ROOT }
				}
				percent >= 0.3
			}			
		}
		# you or your vassal controls constantinople
		OR = {
			custom_tooltip = {
				text = your_vassal_controls_c_byzantion
				title:c_byzantion.holder = { any_liege_or_above = { this = root } }
			}
			custom_tooltip = {
				text = you_control_c_byzantion
				title:c_byzantion.holder = { this = root }
			}
		}
		# AI needs to be christian
		trigger_if = {
			limit = { is_ai = yes }
			religion = religion:christianity_religion
		}
		# don't allow Alexander to reform the empire
		trigger_if = {
			limit = {
				has_character_modifier = first_argead_modifier
			}
			NOT = { has_character_modifier = first_argead_modifier }
		}
	}

	is_valid_showing_failures_only = {
		is_imprisoned = no
		is_available = yes
		is_at_war = no
	}

	cost = { # lower cost for AI
		gold = {
			value = 250
			if = {
				limit = { is_ai = no }
				add = 500
			}
		}
		prestige = {
			value = 150
			if = {
				limit = { is_ai = no }
				add = 2350
			}
		}
		piety = {
			value = 50
			if = {
				limit = { is_ai = no }
				add = 450
			}
		}
	}

	effect = {
		# grant title
		create_title_and_vassal_change = {
			type = created
			save_scope_as = title_change
			add_claim_on_loss = no
		}
		title:e_byzantium = {
			change_title_holder = {
				holder = root
				change = scope:title_change
			}
		}
		resolve_title_and_vassal_change = scope:title_change
		set_primary_title_to = title:e_byzantium

		# other bonuses
		add_trait = augustus
		give_nickname = nick_hi_restorer
		add_prestige = 2500
		dynasty = { add_dynasty_prestige = 250 }
	}

	ai_potential = { primary_title.tier >= tier_kingdom }

	ai_will_do = { base = 100 }
}

# latin
vlaanderen_set_capital_constantinople_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_destiny_goal.dds"
	}

	desc = vlaanderen_set_capital_constantinople_decision_desc
	selection_tooltip = vlaanderen_set_capital_constantinople_decision_tooltip
	decision_group_type = major

	ai_check_interval = 12

	is_shown = {
		is_ruler = yes
		is_landed = yes
		exists = dynasty
		exists = title:e_vlaanderen
		has_title = title:e_vlaanderen
		NOT = { capital_county = { this = title:c_byzantion } }
		OR = {
			title:c_byzantion.holder = { any_liege_or_above = { this = root } }
			title:c_byzantion.holder = { this = root }
		}
	}

	is_valid_showing_failures_only = {
		NOT = { has_trait = incapable }
		is_imprisoned = no
		is_independent_ruler = yes
	}

	effect = {
		if = { #Usurp if not held personally.
			limit = {
				NOT = { title:c_byzantion.holder = { this = root } }
			}
			title:c_byzantion.holder = { save_scope_as = target_for_denunciation }
			create_title_and_vassal_change = {
				type = returned
				save_scope_as = change
				add_claim_on_loss = no
			}
			title:c_byzantion = {
				change_title_holder = {
					holder = root
					change = scope:change
				}
			}
			resolve_title_and_vassal_change = scope:change
		}
		set_realm_capital = title:c_byzantion
		if = {
			limit = {
				exists = scope:target_for_denunciation
			}
			scope:target_for_denunciation = {
				trigger_event = {
					id = vlaanderen_invasion.1201
				}
			}
		}
	}
	ai_potential = {
		primary_title.tier = tier_empire
		has_primary_title = title:e_vlaanderen
	}

	ai_will_do = { #Do it always, for coherence.
		base = 100
		modifier = {
			title:c_byzantion.holder = {
				is_ai = no
				any_realm_county = {
					count < 2
					holder = title:c_byzantion.holder
				}
			}
			factor = 0
		}
	}
}

# greek
nicene_empire_set_capital_nikaea_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_destiny_goal.dds"
	}

	desc = nicene_empire_set_capital_nikaea_decision_desc
	selection_tooltip = nicene_empire_set_capital_nikaea_decision_tooltip
	decision_group_type = major

	ai_check_interval = 12

	is_shown = {
		is_ruler = yes
		is_landed = yes
		exists = dynasty
		exists = title:e_nikaea
		has_title = title:e_nikaea
		NOT = { capital_county = { this = title:c_nikaea } }
		OR = {
			title:c_nikaea.holder = { any_liege_or_above = { this = root } }
			title:c_nikaea.holder = { this = root }
		}
	}

	is_valid_showing_failures_only = {
		NOT = { has_trait = incapable }
		is_imprisoned = no
		is_independent_ruler = yes
	}

	effect = {
		if = { #Usurp if not held personally.
			limit = {
				NOT = { title:c_nikaea.holder = { this = root } }
			}
			title:c_nikaea.holder = { save_scope_as = target_for_denunciation }
			create_title_and_vassal_change = {
				type = returned
				save_scope_as = change
				add_claim_on_loss = no
			}
			title:c_nikaea = {
				change_title_holder = {
					holder = root
					change = scope:change
				}
			}
			resolve_title_and_vassal_change = scope:change

		}
		set_realm_capital = title:c_nikaea
		if = {
			limit = {
				exists = scope:target_for_denunciation
			}
			scope:target_for_denunciation = {
				trigger_event = {
					id = vlaanderen_invasion.1202
				}
			}
		}
	}
	ai_potential = {
		primary_title.tier = tier_empire
		has_primary_title = title:e_nikaea
	}

	ai_will_do = { #Do it always, for coherence.
		base = 100
		modifier = {
			title:c_nikaea.holder = {
				is_ai = no
				any_realm_county = {
					count < 2
					holder = title:c_nikaea.holder
				}
			}
			factor = 0
		}
	}
}