﻿#ideas:
#Every legend gives the ability to take a pilgrimage to Cyrus' Tomb once a life

darius = {
	color = { 243 25 240 }
	
	on_start = {
		legend_owner = {
			add_prestige = legend_prestige_gain
		}
		mark_historical_legend_as_done_achaemenid = yes
		if = {
			limit = {
				has_legend_chronicle = holy_warrior
				legend_protagonist = {
					is_landed = no
				}
			}
			set_legend_property = {
				name = ancestor
				target = legend_owner
			}
		}
	}
	
	is_valid_protagonist = {
		age >= 16
	}
	
	quality = {
		famed = {
			spread_chance = {
				if = {
					limit = {
						exists = scope:legend.legend_owner
					}
					value = spread_chance_legends_default_value
					multiply = spread_chance_legends_mult_value
				}
				else = {
					value = 0
				}
			}

			max_provinces = 100

			creation_cost = {
				gold = legend_base_cost
			}

			owner_cost = {
				round = no
				gold = famed_legend_owner_cost
			}
			
			promoter_cost = {
				round = no
				gold = famed_legend_promoter_cost
			}
			
			upgrade_cost = {
				gold = legend_upgrade_cost
				prestige = legend_prestige_cost
			}

			removal_duration = {
				years = { 25 35 }
			}

			impact = {
				province_modifier = {
					levy_size = 0.05
					tax_mult = 0.05
				}
				owner_modifier = {
					same_culture_opinion = 10
					same_heritage_county_advantage_add = 5
				}
				promoter_modifier = {
					levy_size = 0.2
					men_at_arms_recruitment_cost = -0.1
				}
				on_complete = {
					custom_tooltip = {
						text = darius_legend_complete_effect_famed_tooltip
						darius_legend_complete_effect_famed = yes
					}
					scope:protagonist = { save_scope_as = legend_protagonist }
					custom_tooltip = {
						text = reform_achaemenid_culture_tradition_tooltip
					#	add_character_flag = can_add_darius_tradition
					}
					legend_ending_rewards_heroic_effect = yes
					add_legitimacy = 100
					
					trigger_event = achaemenid_legend_event.0001
				}
			}
			ai_chance = {
				create = {
					value = heroic_legend_create_ai
				}
				promote = {
					value = base_legend_promote_ai
					if = {
						limit = {
							ai_has_warlike_personality = yes
						}
						multiply = 1.2
					}
				}
				take_unowned = 100
				upgrade = {
					value = 1000 # Always upgrade when you can
				}
				complete = {
					value = base_legend_complete_ai
				}
			}
		}
		illustrious = {
			spread_chance = {
				if = {
					limit = {
						exists = scope:legend.legend_owner
					}
					value = spread_chance_legends_default_value
					multiply = spread_chance_legends_mult_value
				}
				else = {
					value = 0
				}
			}

			max_provinces = 300
			
			creation_cost = {
				gold = {
					value = legend_base_cost
					multiply = 1.5
				}
			}

			owner_cost = {
				round = no
				gold = illustrious_legend_owner_cost
			}
			
			promoter_cost = {
				round = no
				gold = illustrious_legend_promoter_cost
			}
			
			upgrade_cost = {
				gold = legend_upgrade_cost
				prestige = legend_prestige_cost
			}

			removal_duration = {
				years = { 50 70 }
			}

			impact = {
				province_modifier = {
					levy_size = 0.15
					tax_mult = 0.10
				}
				owner_modifier = {
					same_culture_opinion = 20
					same_heritage_county_advantage_add = 10
				}
				promoter_modifier = {
					levy_size = 0.25
					men_at_arms_recruitment_cost = -0.15
				}
				on_complete = {
					custom_tooltip = {
						text = darius_legend_complete_effect_illustrious_tooltip
						darius_legend_complete_effect_illustrious = yes
					}
					scope:protagonist = { save_scope_as = legend_protagonist }
					custom_tooltip = {
						text = unlock_immortal_retinue_tooltip
						add_character_flag = immortal_retinue_unlock
					}
					custom_tooltip = {
						text = reform_achaemenid_culture_tradition_tooltip
					#	add_character_flag = can_add_darius_tradition
					}
					custom_tooltip = {
						text = unlock_unite_persia_cb_darius
						add_character_flag = can_unite_persia
					}
					legend_ending_rewards_heroic_effect = yes
					add_legitimacy = 200
					trigger_event = achaemenid_legend_event.0001
				}
			}
			ai_chance = {
				create = {
					value = heroic_legend_create_ai
					add = illustrious_legend_create_ai
				}
				promote = {
					value = base_legend_promote_ai
					if = {
						limit = {
							ai_has_warlike_personality = yes
						}
						multiply = 1.2
					}
				}
				take_unowned = 100
				upgrade = {
					value = 1000 # Always upgrade when you can
				}
				complete = {
					value = base_legend_complete_ai
				}
			}
		}
		mythical = {
			spread_chance = {
				if = {
					limit = {
						exists = scope:legend.legend_owner
					}
					value = spread_chance_legends_default_value
					multiply = spread_chance_legends_mult_value
				}
				else = {
					value = 0
				}
			}

			max_provinces = 500
			
			creation_cost = {
				gold = {
					value = legend_base_cost
					multiply = 2
				}
			}

			owner_cost = {
				round = no
				gold = mythical_legend_owner_cost
			}
			
			promoter_cost = {
				round = no
				gold = mythical_legend_promoter_cost
			}

			upgrade_cost = {
				gold = {
					value = {
						value = legend_upgrade_cost
						multiply = 2
					}
				}
				prestige = legend_prestige_cost
			}

			removal_duration = {
				years = { 75 100 }
			}

			impact = {
				province_modifier = {
					levy_size = 0.25
					tax_mult = 0.20
				}
				owner_modifier = {
					same_culture_opinion = 30
					same_heritage_county_advantage_add = 15
				}
				promoter_modifier = {
					levy_size = 0.33
					men_at_arms_recruitment_cost = -0.20
				}
				on_complete = {
					custom_tooltip = {
						text = darius_legend_complete_effect_mythical_tooltip
						darius_legend_complete_effect_mythical = yes
					}
					scope:protagonist = { save_scope_as = legend_protagonist }
					custom_tooltip = {
						text = unlock_immortal_retinue_tooltip
						add_character_flag = immortal_retinue_unlock
					}
					custom_tooltip = {
						text = mythical_achaemenid_legend_complete_tooltip
						add_character_flag = mythical_achaemenid_character
					}
					custom_tooltip = {
						text = reform_achaemenid_culture_tradition_tooltip
					#	add_character_flag = can_add_darius_tradition
					}
					custom_tooltip = {
						text = unlock_unite_persia_cb_darius
						add_character_flag = can_unite_persia
					}
					legend_ending_rewards_heroic_effect = yes
					add_legitimacy = 300
					trigger_event = achaemenid_legend_event.0001
				}
			}
			ai_chance = {
				create = {
					value = heroic_legend_create_ai
					add = mythical_legend_create_ai
				}
				promote = {
					value = base_legend_promote_ai
					if = {
						limit = {
							ai_has_warlike_personality = yes
						}
						multiply = 1.2
					}
				}
				take_unowned = 100
				upgrade = {
					value = 1000 # Always upgrade when you can
				}
				complete = {
					value = base_legend_complete_ai
				}
			}
		}
	}
	on_yearly = {
		scope:legend = { save_scope_as = promoted_legend }
		trigger_event = {
			on_action = legend_ongoing_events
		}
		trigger_event = {
			on_action = legend_changing_events
		}
	}
}

immortal = {
	color = { 243 230 15 }
	
	on_start = {
		legend_owner = {
			add_prestige = legend_prestige_gain
		}
		mark_historical_legend_as_done_achaemenid = yes
		if = {
			limit = {
				has_legend_chronicle = holy_warrior
				legend_protagonist = {
					is_landed = no
				}
			}
		}
	}
	
	is_valid_protagonist = {
		age >= 16
	}
	
	quality = {
		famed = {
			spread_chance = {
				if = {
					limit = {
						exists = scope:legend.legend_owner
					}
					value = spread_chance_legends_default_value
					multiply = spread_chance_legends_mult_value
				}
				else = {
					value = 0
				}
			}

			max_provinces = 100

			creation_cost = {
				gold = legend_base_cost
			}

			owner_cost = {
				round = no
				gold = famed_legend_owner_cost
			}
			
			promoter_cost = {
				round = no
				gold = famed_legend_promoter_cost
			}
			
			upgrade_cost = {
				gold = legend_upgrade_cost
				prestige = legend_prestige_cost
			}

			removal_duration = {
				years = { 25 35 }
			}

			impact = {
				province_modifier = {
					monthly_county_control_growth_add = 0.1
					stationed_maa_toughness_mult = 0.2
				}
				owner_modifier = {
					heavy_infantry_damage_mult = 0.15
					hard_casualty_modifier = -0.1
				}
				promoter_modifier = {
					hard_casualty_modifier = -0.05
					martial = 2
				}
				on_complete = {
					scope:protagonist = { save_scope_as = legend_protagonist }
					custom_tooltip = {
						text = immortal_legend_famed_scripted_effect_tooltip
						immortal_legend_famed_scripted_effect = yes
					}
					custom_tooltip = {
						text = reform_achaemenid_culture_tradition_tooltip
					#	add_character_flag = can_add_immortal_tradition
					}
					legend_ending_rewards_heroic_effect = yes
					add_legitimacy = 100
					trigger_event = achaemenid_legend_event.0002
				}
			}
			ai_chance = {
				create = {
					value = heroic_legend_create_ai
				}
				promote = {
					value = base_legend_promote_ai
					if = {
						limit = {
							ai_has_warlike_personality = yes
						}
						multiply = 1.2
					}
				}
				take_unowned = 100
				upgrade = {
					value = 1000 # Always upgrade when you can
				}
				complete = {
					value = base_legend_complete_ai
				}
			}
		}
		illustrious = {
			spread_chance = {
				if = {
					limit = {
						exists = scope:legend.legend_owner
					}
					value = spread_chance_legends_default_value
					multiply = spread_chance_legends_mult_value
				}
				else = {
					value = 0
				}
			}

			max_provinces = 300
			
			creation_cost = {
				gold = {
					value = legend_base_cost
					multiply = 1.5
				}
			}

			owner_cost = {
				round = no
				gold = illustrious_legend_owner_cost
			}
			
			promoter_cost = {
				round = no
				gold = illustrious_legend_promoter_cost
			}
			
			upgrade_cost = {
				gold = legend_upgrade_cost
				prestige = legend_prestige_cost
			}

			removal_duration = {
				years = { 50 70 }
			}

			impact = {
				province_modifier = {
					monthly_county_control_growth_add = 0.2
					stationed_maa_toughness_mult = 0.25
				}
				owner_modifier = {
					heavy_infantry_damage_mult = 0.25
					hard_casualty_modifier = -0.2
				}
				promoter_modifier = {
					hard_casualty_modifier = -0.1
					martial = 3
				}
				on_complete = {
					scope:protagonist = { save_scope_as = legend_protagonist }
					custom_tooltip = {
						text = immortal_legend_illustrious_scripted_effect_tooltip
						immortal_legend_illustrious_scripted_effect = yes
					}
					custom_tooltip = {
						text = immortals_legend_illustrious_decision_tooltip
						add_character_flag = can_take_illustrious_immortal_decision
					}
					custom_tooltip = {
						text = reform_achaemenid_culture_tradition_tooltip
					#	add_character_flag = can_add_immortal_tradition
					}
					legend_ending_rewards_heroic_effect = yes
					add_legitimacy = 200
					trigger_event = achaemenid_legend_event.0002
				}
			}
			ai_chance = {
				create = {
					value = heroic_legend_create_ai
					add = illustrious_legend_create_ai
				}
				promote = {
					value = base_legend_promote_ai
					if = {
						limit = {
							ai_has_warlike_personality = yes
						}
						multiply = 1.2
					}
				}
				take_unowned = 100
				upgrade = {
					value = 1000 # Always upgrade when you can
				}
				complete = {
					value = base_legend_complete_ai
				}
			}
		}
		mythical = {
			spread_chance = {
				if = {
					limit = {
						exists = scope:legend.legend_owner
					}
					value = spread_chance_legends_default_value
					multiply = spread_chance_legends_mult_value
				}
				else = {
					value = 0
				}
			}

			max_provinces = 500
			
			creation_cost = {
				gold = {
					value = legend_base_cost
					multiply = 2
				}
			}

			owner_cost = {
				round = no
				gold = mythical_legend_owner_cost
			}
			
			promoter_cost = {
				round = no
				gold = mythical_legend_promoter_cost
			}

			upgrade_cost = {
				gold = {
					value = {
						value = legend_upgrade_cost
						multiply = 2
					}
				}
				prestige = legend_prestige_cost
			}

			removal_duration = {
				years = { 75 100 }
			}

			impact = {
				province_modifier = {
					monthly_county_control_growth_add = 0.30
					stationed_maa_toughness_mult = 0.4
				}
				owner_modifier = {
					heavy_infantry_damage_mult = 0.4
					hard_casualty_modifier = -0.25
				}
				promoter_modifier = {
					hard_casualty_modifier = -0.15
					martial = 4
				}
				on_complete = {
					scope:protagonist = { save_scope_as = legend_protagonist }
					custom_tooltip = {
						text = immortal_legend_mythical_scripted_effect
						immortal_legend_mythical_scripted_effect = yes
					}
					custom_tooltip = {
						text = immortals_legend_illustrious_decision_tooltip
						add_character_flag = can_take_illustrious_immortal_decision
					}
					custom_tooltip = {
						text = immortals_legend_mythical_cb_tooltip
						root.dynasty = {
							add_dynasty_modifier = {
							modifier = can_declare_immortal_war
							}
						}
					}
					custom_tooltip = {
						text = reform_achaemenid_culture_tradition_tooltip
					#	add_character_flag = can_add_immortal_tradition
					}
					legend_ending_rewards_heroic_effect = yes
					add_legitimacy = 300
					trigger_event = achaemenid_legend_event.0002
				}
			}
			ai_chance = {
				create = {
					value = heroic_legend_create_ai
					add = mythical_legend_create_ai
				}
				promote = {
					value = base_legend_promote_ai
					if = {
						limit = {
							ai_has_warlike_personality = yes
						}
						multiply = 1.2
					}
				}
				take_unowned = 100
				upgrade = {
					value = 1000 # Always upgrade when you can
				}
				complete = {
					value = base_legend_complete_ai
				}
			}
		}
	}
	on_yearly = {
		scope:legend = { save_scope_as = promoted_legend }
		trigger_event = {
			on_action = legend_ongoing_events
		}
		trigger_event = {
			on_action = legend_changing_events
		}
	}
}

zoroaster = {
	color = { 100 100 125 }

	on_start = {
		legend_owner = {
			add_piety = legend_piety_gain
		}
		mark_historical_legend_as_done_achaemenid = yes
	}
	
	is_valid_protagonist = {
		age >= 16
	}

	ai_protagonist_weight = {
		value = 0
		if = {
			limit = {
				this = scope:creator
				piety_level < 3
			}
			add = 6
		}
		else_if = {
			limit = {
				this = scope:creator
				piety_level >= 3
			}
			add = 10
		}
		if = {
			limit = {
				is_parent_of = scope:creator
				is_alive = no
			}
			add = 8
		}
		if = {
			limit = {
				is_primary_heir_of = scope:creator
			}
			add = 5
		}
		if = {
			limit = {
				is_spouse_of = scope:creator
				has_relation_soulmate = scope:creator
			}
			add = 5
		}
		if = {
			limit = {
				is_close_family_of = scope:creator
				has_any_good_relationship_with_root_trigger = yes
			}
			add = 1
		}
		if = {
			limit = {
				has_trait = zealous
			}
			add = 1
		}
		if = { # If they already have the trait it makes no sense that they will get it again
			limit = {
				has_trait = saint
			}
			add = -10
		}
	}

	quality = {
		famed = {
			spread_chance = {
				if = {
					limit = {
						exists = scope:legend.legend_owner
					}
					value = spread_chance_legends_default_value
					multiply = spread_chance_legends_mult_value
				}
				else = {
					value = 0
				}
			}

			max_provinces = 100

			creation_cost = {
				gold = legend_base_cost
			}

			owner_cost = {
				round = no
				gold = famed_legend_owner_cost
			}
			
			promoter_cost = {
				round = no
				gold = famed_legend_promoter_cost
			}
			
			upgrade_cost = {
				gold = legend_upgrade_cost
				prestige = legend_piety_cost
			}

			removal_duration = {
				years = { 25 35 }
			}

			impact = {
				province_modifier = {
					church_holding_build_gold_cost = -0.2
					development_growth = 0.2
				}
				owner_modifier = {
					zoroastrianism_religion_opinion = 10
					faith_conversion_piety_cost_mult = -0.25
				}
				promoter_modifier = {
					faith_conversion_piety_cost_mult = -0.10
					learning = 1
				}
				on_complete = {
					scope:protagonist = { save_scope_as = legend_protagonist }
					custom_tooltip = {
						text = zoroaster_legend_complete_effect_famed_tooltip
						zoroaster_legend_complete_effect_famed = yes
					}
					custom_tooltip = {
						text = zoroaster_legend_complete_mystic_trait_add_tooltip
						zoroaster_legend_complete_mystic_trait_add = yes
					}
					custom_tooltip = {
						text = reform_achaemenid_culture_tradition_tooltip
					#	add_character_flag = can_add_zoroaster_tradition
					}
					legend_ending_rewards_holy_effect = yes
					add_legitimacy = 100
					trigger_event = achaemenid_legend_event.0003
				}		
			}
			ai_chance = {
				# root = character with the legend seed
				create = {
					value = holy_legend_create_ai
				}

				# root = character who can promote
				# scope:legend = the legend to promote
				promote = {
					value = base_legend_promote_ai
					if = {
						limit = {
							ai_has_economical_boom_personality = yes
						}
						multiply = 1.2
					}
				}
				
				# root = character who can take a legend
				# scope:legend = the legend to take ownership
				take_unowned = 100

				# root = legend owner
				# scope:legend = the legend
				upgrade = {
					value = 1000 # Always upgrade when you can
				}

				# root = legend owner
				# scope:legend = the legend
				complete = {
					value = base_legend_complete_ai
				}
			}
		}
		
		illustrious = {
			spread_chance = {
				if = {
					limit = {
						exists = scope:legend.legend_owner
					}
					value = spread_chance_legends_default_value
					multiply = spread_chance_legends_mult_value
				}
				else = {
					value = 0
				}
			}

			max_provinces = 300
			
			creation_cost = {
				gold = {
					value = legend_base_cost
					multiply = 1.5
				}
			}

			owner_cost = {
				round = no
				gold = illustrious_legend_owner_cost
			}
			
			promoter_cost = {
				round = no
				gold = illustrious_legend_promoter_cost
			}
			
			upgrade_cost = {
				gold = legend_upgrade_cost
				prestige = legend_piety_cost
			}

			removal_duration = {
				years = { 50 70 }
			}

			impact = {
				province_modifier = {
					church_holding_build_gold_cost = -0.4
					development_growth = 0.3
				}
				owner_modifier = {
					zoroastrianism_religion_opinion = 20
					faith_conversion_piety_cost_mult = -0.4
				}
				promoter_modifier = {
					faith_conversion_piety_cost_mult = -0.15
					learning = 2
				}
				on_complete = {
					scope:protagonist = { save_scope_as = legend_protagonist }
					custom_tooltip = {
						text = zoroaster_legend_complete_effect_illustrious_tooltip
						zoroaster_legend_complete_effect_illustrious = yes
					}
					custom_tooltip = {
						text = zoroaster_legend_complete_mystic_trait_add_illustrious_tooltip
						zoroaster_legend_complete_mystic_trait_add_illustrious = yes
					}
					custom_tooltip = {
						text = zoroaster_legend_complete_can_summon_scholar_tooltip
						add_character_flag = can_summon_zoroastrian_scholar
					}
					custom_tooltip = {
						text = reform_achaemenid_culture_tradition_tooltip
					#	add_character_flag = can_add_zoroaster_tradition
					}
					legend_ending_rewards_holy_effect = yes
					add_legitimacy = 200
					trigger_event = achaemenid_legend_event.0003
				}
			}
			ai_chance = {
				# root = character with the legend seed
				create = {
					value = holy_legend_create_ai
					add = illustrious_legend_create_ai
				}

				# root = character who can promote
				# scope:legend = the legend to promote
				promote = {
					value = base_legend_promote_ai
					if = {
						limit = {
							ai_has_economical_boom_personality = yes
						}
						multiply = 1.2
					}
				}
				
				# root = character who can take a legend
				# scope:legend = the legend to take ownership
				take_unowned = 100

				# root = legend owner
				# scope:legend = the legend
				upgrade = {
					value = 1000 # Always upgrade when you can
				}

				# root = legend owner
				# scope:legend = the legend
				complete = {
					value = base_legend_complete_ai
				}
			}
		}
		
		mythical = {
			spread_chance = {
				if = {
					limit = {
						exists = scope:legend.legend_owner
					}
					value = spread_chance_legends_default_value
					multiply = spread_chance_legends_mult_value
				}
				else = {
					value = 0
				}
			}

			max_provinces = 500
			
			creation_cost = {
				gold = {
					value = legend_base_cost
					multiply = 2
				}
			}

			owner_cost = {
				round = no
				gold = mythical_legend_owner_cost
			}
			
			promoter_cost = {
				round = no
				gold = mythical_legend_promoter_cost
			}

			upgrade_cost = {
				gold = {
					value = {
						value = legend_upgrade_cost
						multiply = 2
					}
				}
				prestige = legend_piety_cost
			}

			removal_duration = {
				years = { 75 100 }
			}

			impact = {
				province_modifier = {
					church_holding_build_gold_cost = -0.60
					development_growth = 0.5
				}
				owner_modifier = {
					zoroastrianism_religion_opinion = 40
					faith_conversion_piety_cost_mult = -0.6
				}
				promoter_modifier = {
					faith_conversion_piety_cost_mult = -0.30
					learning = 4
				}
				on_complete = {
					scope:protagonist = { save_scope_as = legend_protagonist }
					custom_tooltip = {
						text = zoroaster_legend_complete_effect_mythical_tooltip
						zoroaster_legend_complete_effect_mythical = yes
					}
					custom_tooltip = {
						text = zoroaster_legend_complete_mystic_trait_add_mythical_tooltip
						zoroaster_legend_complete_mystic_trait_add_mythical = yes
					}
					custom_tooltip = {
						text = zoroaster_legend_complete_can_summon_scholar_tooltip
						add_character_flag = can_summon_zoroastrian_scholar
					}
					custom_tooltip = {
						text = zoroaster_legend_complete_pure_blooded_add_effect_mythical_tooltip
						zoroaster_legend_complete_pure_blooded_add_effect_mythical = yes
					}
					custom_tooltip = {
						text = reform_achaemenid_culture_tradition_tooltip
					#	add_character_flag = can_add_zoroaster_tradition
					}
					legend_ending_rewards_holy_effect = yes
					add_legitimacy = 300
					trigger_event = achaemenid_legend_event.0003
				}
			}
			ai_chance = {
				# root = character with the legend seed
				create = {
					value = holy_legend_create_ai
					add = mythical_legend_create_ai
				}

				# root = character who can promote
				# scope:legend = the legend to promote
				promote = {
					value = base_legend_promote_ai
					if = {
						limit = {
							ai_has_economical_boom_personality = yes
						}
						multiply = 1.2
					}
				}
				
				# root = character who can take a legend
				# scope:legend = the legend to take ownership
				take_unowned = 100

				# root = legend owner
				# scope:legend = the legend
				upgrade = {
					value = 1000 # Always upgrade when you can
				}

				# root = legend owner
				# scope:legend = the legend
				complete = {
					value = base_legend_complete_ai
				}
			}
		}
	}
	
	on_yearly = {
		scope:legend = { save_scope_as = promoted_legend }
		trigger_event = {
			on_action = legend_ongoing_events
		}
		trigger_event = {
			on_action = legend_changing_events
		}
	}
}

amastris = {
	color = { 225 190 20 }

	on_start = {
		legend_owner = {
			add_piety = legend_prestige_gain
		}
		mark_historical_legend_as_done_achaemenid = yes
	}
	
	is_valid_protagonist = {
		age >= 16
	}

	ai_protagonist_weight = {
		value = 0
		if = {
			limit = {
				this = scope:creator
				piety_level < 3
			}
			add = 6
		}
		else_if = {
			limit = {
				this = scope:creator
				piety_level >= 3
			}
			add = 10
		}
		if = {
			limit = {
				is_parent_of = scope:creator
				is_alive = no
			}
			add = 8
		}
		if = {
			limit = {
				is_primary_heir_of = scope:creator
			}
			add = 5
		}
		if = {
			limit = {
				is_spouse_of = scope:creator
				has_relation_soulmate = scope:creator
			}
			add = 5
		}
		if = {
			limit = {
				is_close_family_of = scope:creator
				has_any_good_relationship_with_root_trigger = yes
			}
			add = 1
		}
		if = {
			limit = {
				has_trait = zealous
			}
			add = 1
		}
		if = { # If they already have the trait it makes no sense that they will get it again
			limit = {
				has_trait = saint
			}
			add = -10
		}
	}

	quality = {
		famed = {
			spread_chance = {
				if = {
					limit = {
						exists = scope:legend.legend_owner
					}
					value = spread_chance_legends_default_value
					multiply = spread_chance_legends_mult_value
				}
				else = {
					value = 0
				}
			}

			max_provinces = 100

			creation_cost = {
				gold = legend_base_cost
			}

			owner_cost = {
				round = no
				gold = famed_legend_owner_cost
			}
			
			promoter_cost = {
				round = no
				gold = famed_legend_promoter_cost
			}
			
			upgrade_cost = {
				gold = legend_upgrade_cost
				prestige = legend_piety_cost
			}

			removal_duration = {
				years = { 25 35 }
			}

			impact = {
				province_modifier = {
					county_opinion_add = 10
					supply_limit_mult = 0.25
				}
				owner_modifier = {
					dread_per_tyranny_add = 0.3
					monthly_lifestyle_xp_gain_mult = 0.05
				}
				promoter_modifier = {
					monthly_tyranny = -2
					dread_decay_mult = -0.2
				}
				on_complete = {
					scope:protagonist = { save_scope_as = legend_protagonist }
					custom_tooltip = {
						text = amastris_legend_complete_famed_reward_tooltip
						amastris_legend_complete_famed_reward = yes
					}
					custom_tooltip = {
						text = amastris_legend_complete_add_trait_effect_reward_tooltip
						amastris_legend_complete_add_trait_effect_reward = yes
					}
					custom_tooltip = {
						text = reform_achaemenid_culture_tradition_tooltip
					#	add_character_flag = can_add_amastris_tradition
					}
					legend_ending_rewards_legitimizing_effect = yes
					add_legitimacy = 100
					trigger_event = achaemenid_legend_event.0004
				}		
			}
			ai_chance = {
				# root = character with the legend seed
				create = {
					value = holy_legend_create_ai
				}

				# root = character who can promote
				# scope:legend = the legend to promote
				promote = {
					value = base_legend_promote_ai
					if = {
						limit = {
							ai_has_economical_boom_personality = yes
						}
						multiply = 1.2
					}
				}
				
				# root = character who can take a legend
				# scope:legend = the legend to take ownership
				take_unowned = 100

				# root = legend owner
				# scope:legend = the legend
				upgrade = {
					value = 1000 # Always upgrade when you can
				}

				# root = legend owner
				# scope:legend = the legend
				complete = {
					value = base_legend_complete_ai
				}
			}
		}
		
		illustrious = {
			spread_chance = {
				if = {
					limit = {
						exists = scope:legend.legend_owner
					}
					value = spread_chance_legends_default_value
					multiply = spread_chance_legends_mult_value
				}
				else = {
					value = 0
				}
			}

			max_provinces = 300
			
			creation_cost = {
				gold = {
					value = legend_base_cost
					multiply = 1.5
				}
			}

			owner_cost = {
				round = no
				gold = illustrious_legend_owner_cost
			}
			
			promoter_cost = {
				round = no
				gold = illustrious_legend_promoter_cost
			}
			
			upgrade_cost = {
				gold = legend_upgrade_cost
				prestige = legend_piety_cost
			}

			removal_duration = {
				years = { 50 70 }
			}

			impact = {
				province_modifier = {
					county_opinion_add = 15
					supply_limit_mult = 0.5
				}
				owner_modifier = {
					dread_per_tyranny_add = 0.5
					monthly_lifestyle_xp_gain_mult = 0.15
				}
				promoter_modifier = {
					monthly_tyranny = -3
					dread_decay_mult = -0.4
				}
				on_complete = {
					scope:protagonist = { save_scope_as = legend_protagonist }
					custom_tooltip = {
						text = amastris_legend_complete_illustrious_reward_tooltip
						amastris_legend_complete_illustrious_reward = yes
					}
					custom_tooltip = {
						text = amastris_legend_complete_add_trait_effect_reward_tooltip
						amastris_legend_complete_add_trait_effect_reward = yes
					}
					custom_tooltip = {
						text = amastris_legend_complete_illustrious_reward_decision_tooltip
						amastris_legend_complete_illustrious_reward_decision = yes
					}
					custom_tooltip = {
						text = reform_achaemenid_culture_tradition_tooltip
					#	add_character_flag = can_add_amastris_tradition
					}
					legend_ending_rewards_legitimizing_effect = yes
					add_legitimacy = 200
					trigger_event = achaemenid_legend_event.0004
				}
			}
			ai_chance = {
				# root = character with the legend seed
				create = {
					value = holy_legend_create_ai
					add = illustrious_legend_create_ai
				}

				# root = character who can promote
				# scope:legend = the legend to promote
				promote = {
					value = base_legend_promote_ai
					if = {
						limit = {
							ai_has_economical_boom_personality = yes
						}
						multiply = 1.2
					}
				}
				
				# root = character who can take a legend
				# scope:legend = the legend to take ownership
				take_unowned = 100

				# root = legend owner
				# scope:legend = the legend
				upgrade = {
					value = 1000 # Always upgrade when you can
				}

				# root = legend owner
				# scope:legend = the legend
				complete = {
					value = base_legend_complete_ai
				}
			}
		}
		
		mythical = {
			spread_chance = {
				if = {
					limit = {
						exists = scope:legend.legend_owner
					}
					value = spread_chance_legends_default_value
					multiply = spread_chance_legends_mult_value
				}
				else = {
					value = 0
				}
			}

			max_provinces = 500
			
			creation_cost = {
				gold = {
					value = legend_base_cost
					multiply = 2
				}
			}

			owner_cost = {
				round = no
				gold = mythical_legend_owner_cost
			}
			
			promoter_cost = {
				round = no
				gold = mythical_legend_promoter_cost
			}

			upgrade_cost = {
				gold = {
					value = {
						value = legend_upgrade_cost
						multiply = 2
					}
				}
				prestige = legend_piety_cost
			}

			removal_duration = {
				years = { 75 100 }
			}

			impact = {
				province_modifier = {
					county_opinion_add = 25
					supply_limit_mult = 1
				}
				owner_modifier = {
					dread_per_tyranny_add = 0.8
					monthly_lifestyle_xp_gain_mult = 0.25
				}
				promoter_modifier = {
					monthly_tyranny = -5
					dread_decay_mult = -0.6
				}
				on_complete = {
					scope:protagonist = { save_scope_as = legend_protagonist }
					custom_tooltip = {
						text = amastris_legend_complete_mythical_reward_tooltip
						amastris_legend_complete_mythical_reward = yes
					}
					custom_tooltip = {
						text = amastris_legend_complete_add_trait_effect_reward_mythical_tooltip
						amastris_legend_complete_add_trait_effect_reward_mythical = yes
					}
					custom_tooltip = {
						text = amastris_legend_complete_illustrious_reward_decision_tooltip
						amastris_legend_complete_illustrious_reward_decision = yes
					}
					custom_tooltip = {
						text = amastris_legend_complete_mythical_reward_iranian_assimilation_tooltip
						amastris_legend_complete_mythical_reward_iranian_assimilation = yes
					}
					custom_tooltip = {
						text = reform_achaemenid_culture_tradition_tooltip
					#	add_character_flag = can_add_amastris_tradition
					}
					legend_ending_rewards_legitimizing_effect = yes
					add_legitimacy = 300
					trigger_event = achaemenid_legend_event.0004
				}
			}
			ai_chance = {
				# root = character with the legend seed
				create = {
					value = holy_legend_create_ai
					add = mythical_legend_create_ai
				}

				# root = character who can promote
				# scope:legend = the legend to promote
				promote = {
					value = base_legend_promote_ai
					if = {
						limit = {
							ai_has_economical_boom_personality = yes
						}
						multiply = 1.2
					}
				}
				
				# root = character who can take a legend
				# scope:legend = the legend to take ownership
				take_unowned = 100

				# root = legend owner
				# scope:legend = the legend
				upgrade = {
					value = 1000 # Always upgrade when you can
				}

				# root = legend owner
				# scope:legend = the legend
				complete = {
					value = base_legend_complete_ai
				}
			}
		}
	}
	
	on_yearly = {
		scope:legend = { save_scope_as = promoted_legend }
		trigger_event = {
			on_action = legend_ongoing_events
		}
		trigger_event = {
			on_action = legend_changing_events
		}
	}
}

cyrus = {
	color = { 243 25 240 }
	
	on_start = {
		legend_owner = {
			add_prestige = legend_prestige_gain
		}
		mark_historical_legend_as_done_achaemenid = yes
	}
	
	is_valid_protagonist = {
		age >= 16
	}
	
	quality = {
		famed = {
			spread_chance = {
				if = {
					limit = {
						exists = scope:legend.legend_owner
					}
					value = spread_chance_legends_default_value
					multiply = spread_chance_legends_mult_value
				}
				else = {
					value = 0
				}
			}

			max_provinces = 100

			creation_cost = {
				gold = legend_base_cost
			}

			owner_cost = {
				round = no
				gold = famed_legend_owner_cost
			}
			
			promoter_cost = {
				round = no
				gold = famed_legend_promoter_cost
			}
			
			upgrade_cost = {
				gold = legend_upgrade_cost
				prestige = legend_prestige_cost
			}

			removal_duration = {
				years = { 25 35 }
			}

			impact = {
				province_modifier = {
					development_growth_factor = 0.2
					tax_mult = 0.10
				}
				owner_modifier = {
					domain_tax_mult = 0.15
					vassal_tax_mult = 0.3
				}
				promoter_modifier = {
					domain_limit = 1
					title_creation_cost_mult = -0.25
				}
				on_complete = {
					scope:protagonist = { save_scope_as = legend_protagonist }
					custom_tooltip = {
						text = cyrus_legend_complete_effect_famed_tooltip
						cyrus_legend_complete_effect_famed = yes
					}
					custom_tooltip = {
						text = reform_achaemenid_culture_tradition_tooltip
					#	add_character_flag = can_add_cyrus_tradition
					}
					legend_ending_rewards_heroic_effect = yes
					add_legitimacy = 100
					
					trigger_event = achaemenid_legend_event.0005
				}
			}
			ai_chance = {
				create = {
					value = heroic_legend_create_ai
				}
				promote = {
					value = base_legend_promote_ai
					if = {
						limit = {
							ai_has_warlike_personality = yes
						}
						multiply = 1.2
					}
				}
				take_unowned = 100
				upgrade = {
					value = 1000 # Always upgrade when you can
				}
				complete = {
					value = base_legend_complete_ai
				}
			}
		}
		illustrious = {
			spread_chance = {
				if = {
					limit = {
						exists = scope:legend.legend_owner
					}
					value = spread_chance_legends_default_value
					multiply = spread_chance_legends_mult_value
				}
				else = {
					value = 0
				}
			}

			max_provinces = 300
			
			creation_cost = {
				gold = {
					value = legend_base_cost
					multiply = 1.5
				}
			}

			owner_cost = {
				round = no
				gold = illustrious_legend_owner_cost
			}
			
			promoter_cost = {
				round = no
				gold = illustrious_legend_promoter_cost
			}
			
			upgrade_cost = {
				gold = legend_upgrade_cost
				prestige = legend_prestige_cost
			}

			removal_duration = {
				years = { 50 70 }
			}

			impact = {
				province_modifier = {
					development_growth_factor = 0.3
					tax_mult = 0.2
				}
				owner_modifier = {
					domain_tax_mult = 0.25
					vassal_tax_mult = 0.4
				}
				promoter_modifier = {
					domain_limit = 1
					title_creation_cost_mult = -0.40
				}
				on_complete = {
					scope:protagonist = { save_scope_as = legend_protagonist }
					custom_tooltip = {
						text = cyrus_legend_complete_effect_illustrious_tooltip
						cyrus_legend_complete_effect_illustrious = yes
					}
					custom_tooltip = {
						text = cyrus_legend_complete_illustrious_trait_reward_tooltip
						cyrus_legend_complete_illustrious_trait_reward = yes
					}
					custom_tooltip = {
						text = reform_achaemenid_culture_tradition_tooltip
					#	add_character_flag = can_add_cyrus_tradition
					}
					legend_ending_rewards_heroic_effect = yes
					add_legitimacy = 200
					
					trigger_event = achaemenid_legend_event.0005
				}
			}
			ai_chance = {
				create = {
					value = heroic_legend_create_ai
					add = illustrious_legend_create_ai
				}
				promote = {
					value = base_legend_promote_ai
					if = {
						limit = {
							ai_has_warlike_personality = yes
						}
						multiply = 1.2
					}
				}
				take_unowned = 100
				upgrade = {
					value = 1000 # Always upgrade when you can
				}
				complete = {
					value = base_legend_complete_ai
				}
			}
		}
		mythical = {
			spread_chance = {
				if = {
					limit = {
						exists = scope:legend.legend_owner
					}
					value = spread_chance_legends_default_value
					multiply = spread_chance_legends_mult_value
				}
				else = {
					value = 0
				}
			}

			max_provinces = 500
			
			creation_cost = {
				gold = {
					value = legend_base_cost
					multiply = 2
				}
			}

			owner_cost = {
				round = no
				gold = mythical_legend_owner_cost
			}
			
			promoter_cost = {
				round = no
				gold = mythical_legend_promoter_cost
			}

			upgrade_cost = {
				gold = {
					value = {
						value = legend_upgrade_cost
						multiply = 2
					}
				}
				prestige = legend_prestige_cost
			}

			removal_duration = {
				years = { 75 100 }
			}

			impact = {
				province_modifier = {
					development_growth_factor = 0.5
					tax_mult = 0.33
				}
				owner_modifier = {
					domain_tax_mult = 0.4
					vassal_tax_mult = 0.5
				}
				promoter_modifier = {
					domain_limit = 2
					title_creation_cost_mult = -0.50
				}
				on_complete = {
					scope:protagonist = { save_scope_as = legend_protagonist }
					custom_tooltip = {
						text = cyrus_legend_complete_effect_mythical_tooltip
						cyrus_legend_complete_effect_mythical = yes
					}
					custom_tooltip = {
						text = cyrus_legend_complete_illustrious_trait_reward_tooltip
						cyrus_legend_complete_illustrious_trait_reward = yes
					}
					custom_tooltip = {
						text = cyrus_legend_mythical_vassal_trait_reward_tooltip
						cyrus_legend_mythical_vassal_trait_reward = yes
					}
					custom_tooltip = {
						text = reform_achaemenid_culture_tradition_tooltip
					#	add_character_flag = can_add_cyrus_tradition
					}
					legend_ending_rewards_heroic_effect = yes
					add_legitimacy = 300
					
					trigger_event = achaemenid_legend_event.0005
				}
			}
		}
	}
	on_yearly = {
		scope:legend = { save_scope_as = promoted_legend }
		trigger_event = {
			on_action = legend_ongoing_events
		}
		trigger_event = {
			on_action = legend_changing_events
		}
	}
}


	