﻿##################################################
######################HEROIC######################
##################################################

###########################
# Demand fealty
# By James Beaumont
###########################
legend_demand_fealty = {
#	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 = {
		reference = "gfx/interface/illustrations/decisions/decision_knight_kneeling.dds"
	}
	decision_group_type = major

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

	is_shown = {
		has_character_flag = legend_demand_fealty
		has_dlc_feature = legends
	}

	is_valid = {
		is_landless_adventurer = no
	}

	effect = {
		custom_tooltip = {
			text = fifteen_year_vassalization_tt
			remove_character_flag = legend_demand_fealty
		}
		add_character_modifier = {
			modifier = fealty_demanded
			years = 15
		}
	}
	

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}
###########################
# Become an adventurer
# By James Beaumont
###########################

launch_a_legendary_adventure = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_tale.dds"
	}
	decision_group_type = major

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

	is_shown = {
		has_character_flag = launch_a_legendary_adventure
		has_dlc_feature = legends
	}

	is_valid = {
		is_landless_adventurer = no
	}

	effect = {
		custom_tooltip = {
			text = launch_a_legendary_adventure_tt
			remove_character_flag = launch_a_legendary_adventure
			if = {
				limit = {
					NOT = { exists = var:legendary_adventure_cb }
				}
				set_variable = {
					name = legendary_adventure_cb
					value = 1
				}
			}
			else = {
				change_variable = {
					name = legendary_adventure_cb
					add = 1
				}
			}
		}
		add_character_modifier = {
			modifier = legendary_adventurer
			years = 5
		}
	}
	

	ai_potential = {
		always = no # I don't know that we want to see AI kings hopping around the world all the time
	}

	ai_will_do = {
		base = 100
	}
}

##################################################
###################LEGITIMIZING###################
##################################################
###########################
# Legendary Integration
# By James Beaumont
###########################

legendary_integration_e = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_family_tree.dds"
	}
	decision_group_type = major

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

	is_shown = {
		has_character_flag = legendary_integration_e
		has_dlc_feature = legends
	}

	is_valid = {
		custom_tooltip = {
			text = any_drifting_empire_tt
			OR = {
				any_held_title = { # Check held empires first, any_empire is unoptimal and should only be checked if any_held_title fails
					title_tier = empire
					this != root.primary_title
					valid_for_legendary_integration_e = yes
				}
				any_realm_de_jure_empire = {
					this != root.primary_title
					valid_for_legendary_integration_e = yes
				}
			}
		}
		is_landless_adventurer = no
	}

	effect = {
		custom_tooltip = {
			text = select_empire_to_drift_tt
			remove_character_flag = legendary_integration_e
			trigger_event = ce1_decision_events.1015
		}
	}
	

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}

legendary_integration_k = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_family_tree.dds"
	}
	decision_group_type = major

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

	is_shown = {
		has_character_flag = legendary_integration_k
		has_dlc_feature = legends
	}

	is_valid = {
		custom_tooltip = {
			text = any_drifting_kingdom_tt
			OR = {
				any_held_title = { # Check held kingdoms first, any_kingdom is unoptimal and should only be checked if any_held_title fails
					title_tier = kingdom
					this != root.primary_title
					valid_for_legendary_integration_k = yes
				}
				any_realm_de_jure_kingdom = {
					this != root.primary_title
					valid_for_legendary_integration_k = yes
				}
			}
		}
		is_landless_adventurer = no
	}

	effect = {
		custom_tooltip = {
			text = select_kingdom_to_drift_tt
			remove_character_flag = legendary_integration_k
			trigger_event = ce1_decision_events.1000
		}
	}
	

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}

legendary_integration_d = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_family_tree.dds"
	}
	decision_group_type = major

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

	is_shown = {
		has_character_flag = legendary_integration_d
		has_dlc_feature = legends
	}

	is_valid = {
		custom_tooltip = {
			text = any_drifting_duchy_tt
			any_realm_de_jure_duchy = {
				valid_for_legendary_integration_d = yes
			}
		}
		is_landless_adventurer = no
	}

	effect = {
		custom_tooltip = {
			text = select_duchy_to_drift_tt
			remove_character_flag = legendary_integration_d
			trigger_event = ce1_decision_events.1010
		}
	}
	

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}
##################################################
#######################HOLY#######################
##################################################
###########################
# Reassert the War
# By James Beaumont
###########################

legendary_holy_war = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_legend.dds"
	}
	decision_group_type = major

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

	is_shown = {
		has_character_flag = legendary_holy_war
		has_dlc_feature = legends
	}

	is_valid = {
		is_landless_adventurer = no
	}

	effect = {
		custom_tooltip = {
			text = bonus_holy_war_tt
			add_character_flag = bonus_major_holy_war
			remove_character_flag = legendary_holy_war
		}
	}
	

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}

legendary_pacifism_spread = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_tale.dds"
	}
	decision_group_type = major

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

	is_shown = {
		has_character_flag = legendary_pacifism_spread
		has_dlc_feature = legends
	}

	is_valid = {
		custom_tooltip = {
			text = non_true_faith_neighbour
			any_neighboring_and_across_water_top_liege_realm_owner = {
				faith != root.faith
				NOT = {
					any_held_title = { is_head_of_faith = yes }
				}
			}
		}
		is_landless_adventurer = no
	}

	effect = {
		custom_tooltip = {
			text = legendary_pacifism_spread_tt
			remove_character_flag = legendary_pacifism_spread
			save_scope_as = legendary_character
			if = {
				limit = {
					any_neighboring_and_across_water_top_liege_realm_owner = {
						faith != root.faith
						NOT = {
							any_held_title = { is_head_of_faith = yes }
						}
						is_ai = yes
					}
				}
				random_neighboring_and_across_water_top_liege_realm_owner = {
					limit = {
						faith != root.faith
						NOT = {
							any_held_title = { is_head_of_faith = yes }
						}
						is_ai = yes
					}
					add_character_flag = guarantee_conversion # Freebie, ensures the AI accepts the conversion demand
				}
			}
			every_neighboring_and_across_water_top_liege_realm_owner = {
				limit = {
					faith != root.faith
					NOT = {
						any_held_title = { is_head_of_faith = yes }
					}
				}
				trigger_event = ce1_decision_events.1020
			}
		}
	}
	

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}

legendary_conversion = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_legend.dds"
	}
	decision_group_type = major

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

	is_shown = {
		OR = {
			AND = {
				has_character_flag = legendary_conversion
				has_dlc_feature = legends
			}
			has_character_flag = major_religious_inspiration
		}
	}

	is_valid = {
		custom_tooltip = {
			text = leg_conv_valid_county
			any_sub_realm_county = {
				faith != root.faith
			}
		}
		is_landless_adventurer = no
	}

	effect = {
		custom_tooltip = {
			text = legendary_conversion_tt
			remove_character_flag = legendary_conversion
			remove_character_flag = major_religious_inspiration
			random_sub_realm_county = { # Give em a freebie
				set_county_faith = root.faith
			}
			every_sub_realm_county = {
				random = {
					chance = 50
					set_county_faith = root.faith
				}
			}
		}
	}
	

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}
