﻿namespace = more_legends_decision_events

#Legend Book Commision
more_legends_decision_events.0001 = { #by Veronica Pazos
	type = character_event
	title = ce1_decision_events.0001.t
	desc = ce1_decision_events.0001.desc
	theme = legend
	override_background = { reference = study }
	left_portrait = {
		character = root
		animation = personality_honorable
	}
	right_portrait = {
		character = scope:chronicler
		animation = writing
	}
	artifact = {
		target = scope:newly_created_artifact
		position = lower_center_portrait
	}
	override_effect_2d = {
		reference = legend_glow
	}

	immediate = {
		play_music_cue = "mx_cue_positive_effect"
		hidden_effect_new_object = {
			if = {
				limit = {
					has_variable = finished_mythical_legend_var
				}
				if = {
					limit = {
						artifact_use_indian_building_visuals_trigger = yes
					}
					create_artifact = {
						name = legend_book
						type = chronicle
						creator = scope:chronicler
						description = legend_book_desc 
						visuals = indian_book
						modifier = artifact_diplomacy_3_modifier
						modifier = artifact_monthly_prestige_add_8_modifier
						save_scope_as = newly_created_artifact
						wealth = 400
						quality = 400
					}
				}
				else = {
					create_artifact = {
						name = legend_book
						type = chronicle
						creator = scope:chronicler
						description = legend_book_desc 
						visuals = chronicle
						modifier = artifact_diplomacy_3_modifier
						modifier = artifact_monthly_prestige_add_8_modifier
						save_scope_as = newly_created_artifact
						wealth = 400
						quality = 400
					}
				}
			}
			else_if = {
				limit = {
					has_variable = finished_illustrious_legend_var
				}
				if = {
					limit = {
						artifact_use_indian_building_visuals_trigger = yes
					}
					create_artifact = {
						name = legend_book
						type = chronicle
						creator = scope:chronicler
						description = legend_book_desc 
						visuals = indian_book
						modifier = artifact_diplomacy_2_modifier
						modifier = artifact_monthly_prestige_add_6_modifier
						save_scope_as = newly_created_artifact
						wealth = 200
						quality = 200
					}
				}
				else = {
					create_artifact = {
						name = legend_book
						type = chronicle
						creator = scope:chronicler
						description = legend_book_desc 
						visuals = chronicle
						modifier = artifact_diplomacy_2_modifier
						modifier = artifact_monthly_prestige_add_6_modifier
						save_scope_as = newly_created_artifact
						wealth = 200
						quality = 200
					}
				}
			}
			else = { #famed
				if = {
					limit = {
						artifact_use_indian_building_visuals_trigger = yes
					}
					create_artifact = {
						name = legend_book
						type = miscellaneous
						creator = scope:chronicler
						description = legend_book_desc 
						visuals = indian_book
						modifier = artifact_diplomacy_1_modifier
						modifier = artifact_monthly_prestige_add_4_modifier
						save_scope_as = newly_created_artifact
						wealth = 80
						quality = 80
					}
				}
				else = {
					create_artifact = {
						name = legend_book
						type = miscellaneous
						creator = scope:chronicler
						description = legend_book_desc 
						visuals = chronicle
						modifier = artifact_diplomacy_1_modifier
						modifier = artifact_monthly_prestige_add_4_modifier
						save_scope_as = newly_created_artifact
						wealth = 80
						quality = 80
					}
				}
			}
		}
		hidden_effect = {
			scope:newly_created_artifact = {
				if = {
					limit = {
						root = {
							has_variable = finished_terrorizing_legend_var
						}
					}
					if = {
						limit = {
							root = {
								has_variable = finished_mythical_legend_var
							}
						}
						add_artifact_modifier = more_legends_artifact_intrigue_3_modifier
					}
					else_if = {
						limit = {
							root = {
								has_variable = finished_illustrious_legend_var
							}
						}
						add_artifact_modifier = artifact_intrigue_2_modifier
						add_artifact_modifier = artifact_monthly_prestige_add_6_modifier
					}
					else = {
						add_artifact_modifier = artifact_intrigue_1_modifier
					}
				}
				else_if = {
					limit = {
						root = {
							has_variable = finished_cultural_legend_var
						}
					}
					if = {
						limit = {
							root = {
								has_variable = finished_mythical_legend_var
							}
						}
						add_artifact_modifier = artifact_learning_3_modifier
					}
					else_if = {
						limit = {
							root = {
								has_variable = finished_illustrious_legend_var
							}
						}
						add_artifact_modifier = artifact_learning_2_modifier
					}
					else = {
						add_artifact_modifier = artifact_learning_1_modifier
					}
				}
				else_if = {
					limit = {
						root = {
							has_variable = finished_enriching_legend_var
						}
					}
					if = {
						limit = {
							root = {
								has_variable = finished_mythical_legend_var
							}
						}
						add_artifact_modifier = artifact_stewardship_3_modifier
					}
					else_if = {
						limit = {
							root = {
								has_variable = finished_illustrious_legend_var
							}
						}
						add_artifact_modifier = artifact_stewardship_2_modifier
					}
					else = {
						add_artifact_modifier = artifact_stewardship_1_modifier
					}
				}
			}
		}
	}

	option = { #nice
		name = ce1_decision_events.0001.a
		show_as_tooltip = {
			scope:newly_created_artifact = { set_owner = root }
		}
	}
	
	after = {
		remove_variable ?= finished_legend_var
		remove_variable ?= finished_famed_legend_var
		remove_variable ?= finished_illustrious_legend_var
		remove_variable ?= finished_mythical_legend_var
		remove_variable ?= finished_heroic_legend_var
		remove_variable ?= finished_terrorizing_legend_var
		remove_variable ?= finished_cultural_legend_var
		remove_variable ?= finished_enriching_legend_var
		remove_variable ?= finished_holy_legend_var
		remove_variable ?= finished_legitimizing_legend_var
	}
}

# #Legendary Kingdom Integration
# #by James Beaumont
# scripted_effect ce1_dec_1000_integrate = {
# 	# Empires are simple, just de-jure shift the kingdom
# 	if = {
# 		limit = {
# 			root.primary_title.tier = tier_empire
# 		}
# 		$KINGDOM$ = {
# 			set_de_jure_liege_title = root.primary_title
# 		}
# 	}
# 	# Kingdoms, de jure shift all duchies into your kingdom
# 	else = {
# 		$KINGDOM$ = {
# 			every_in_de_jure_hierarchy = {
# 				limit = { tier = tier_duchy }
# 				set_de_jure_liege_title = root.primary_title
# 			}
# 		}
# 	}
# }
# scripted_effect ce1_dec_1010_integrate = {
# 	# Kingdoms are simple, just de-jure shift the duchy
# 	if = {
# 		limit = {
# 			root.primary_title.tier = tier_kingdom
# 		}
# 		$DUCHY$ = {
# 			set_de_jure_liege_title = root.primary_title
# 		}
# 	}
# 	# Empires suck, find a kingdom within your empire that borders the duchy
# 	else_if = {
# 		limit = {
# 			root.primary_title = {
# 				any_in_de_jure_hierarchy = {
# 					tier = tier_kingdom
# 					any_title_to_title_neighboring_and_across_water_duchy = {
# 						this = $DUCHY$
# 					}
# 				}
# 			}
# 		}
# 		root.primary_title = {
# 			random_in_de_jure_hierarchy = {
# 				limit = {
# 					tier = tier_kingdom
# 					any_title_to_title_neighboring_and_across_water_duchy = {
# 						this = $DUCHY$
# 					}
# 				}
# 				$DUCHY$ = {
# 					set_de_jure_liege_title = prev
# 				}
# 			}
# 		}
# 	}
# 	# Empires suck, de-jure shift to your capital's kingdom
# 	else = {
# 		$DUCHY$ = {
# 			set_de_jure_liege_title = root.capital_county.kingdom
# 		}
# 	}
# }
# ce1_decision_events.1000 = {
# 	type = character_event
# 	title = ce1_decision_events.1000.t
# 	desc = ce1_decision_events.1000.desc
# 	theme = martial
# 	left_portrait = {
# 		character = root
# 		animation = personality_honorable
# 	}

# 	immediate = {
# 		play_music_cue = "mx_cue_positive_effect"
# 		random_kingdom = {
# 			limit = {
# 				valid_for_legendary_integration_k = yes
# 				NOT = { this = root.primary_title }
# 			}
# 			save_scope_as = kingdom_01
# 		}
# 		random_kingdom = {
# 			limit = {
# 				valid_for_legendary_integration_k = yes
# 				NOT = {
# 					this = root.primary_title
# 					this = scope:kingdom_01
# 				}
# 			}
# 			save_scope_as = kingdom_02
# 		}
# 		random_kingdom = {
# 			limit = {
# 				valid_for_legendary_integration_k = yes
# 				NOT = {
# 					this = root.primary_title
# 					this = scope:kingdom_01
# 					this = scope:kingdom_02
# 				}
# 			}
# 			save_scope_as = kingdom_03
# 		}
# 		random_kingdom = {
# 			limit = {
# 				valid_for_legendary_integration_k = yes
# 				NOT = {
# 					this = root.primary_title
# 					this = scope:kingdom_01
# 					this = scope:kingdom_02
# 					this = scope:kingdom_03
# 				}
# 			}
# 			save_scope_as = kingdom_04
# 		}
# 		random_kingdom = {
# 			limit = {
# 				valid_for_legendary_integration_k = yes
# 				NOT = {
# 					this = root.primary_title
# 					this = scope:kingdom_01
# 					this = scope:kingdom_02
# 					this = scope:kingdom_03
# 					this = scope:kingdom_04
# 				}
# 			}
# 			save_scope_as = kingdom_05
# 		}
# 		random_kingdom = {
# 			limit = {
# 				valid_for_legendary_integration_k = yes
# 				NOT = {
# 					this = root.primary_title
# 					this = scope:kingdom_01
# 					this = scope:kingdom_02
# 					this = scope:kingdom_03
# 					this = scope:kingdom_04
# 					this = scope:kingdom_05
# 				}
# 			}
# 			save_scope_as = kingdom_06
# 		}
# 	}

# 	option = { #Kingdom 1 please
# 		name = {
# 			text = {
# 				first_valid = {
# 					triggered_desc = {
# 						trigger = {
# 							primary_title.tier = tier_empire
# 						}
# 						desc = ce1_decision_events.1000.a.empire
# 					}
# 					desc = ce1_decision_events.1000.a.kingdom
# 				}
# 			}
# 		}
# 		trigger = {
# 			exists = scope:kingdom_01
# 		}
# 		ce1_dec_1000_integrate = {
# 			KINGDOM = scope:kingdom_01
# 		}
# 		ai_chance = {
# 			base = 10
# 		}
# 	}

# 	option = { #Kingdom 2 please
# 		name = {
# 			text = {
# 				first_valid = {
# 					triggered_desc = {
# 						trigger = {
# 							primary_title.tier = tier_empire
# 						}
# 						desc = ce1_decision_events.1000.b.empire
# 					}
# 					desc = ce1_decision_events.1000.b.kingdom
# 				}
# 			}
# 		}
# 		trigger = {
# 			exists = scope:kingdom_02
# 		}
# 		ce1_dec_1000_integrate = {
# 			KINGDOM = scope:kingdom_02
# 		}
# 		ai_chance = {
# 			base = 10
# 		}
# 	}

# 	option = { #Kingdom 3 please
# 		name = {
# 			text = {
# 				first_valid = {
# 					triggered_desc = {
# 						trigger = {
# 							primary_title.tier = tier_empire
# 						}
# 						desc = ce1_decision_events.1000.c.empire
# 					}
# 					desc = ce1_decision_events.1000.c.kingdom
# 				}
# 			}
# 		}
# 		trigger = {
# 			exists = scope:kingdom_03
# 		}
# 		ce1_dec_1000_integrate = {
# 			KINGDOM = scope:kingdom_03
# 		}
# 		ai_chance = {
# 			base = 10
# 		}
# 	}

# 	option = { #Kingdom 4 please
# 		name = ce1_decision_events.1000.d
# 		trigger = {
# 			exists = scope:kingdom_04
# 		}
# 		ce1_dec_1000_integrate = {
# 			KINGDOM = scope:kingdom_04
# 		}
# 		ai_chance = {
# 			base = 10
# 		}
# 	}

# 	option = { #Kingdom 5 please
# 		name = ce1_decision_events.1000.e
# 		trigger = {
# 			exists = scope:kingdom_05
# 		}
# 		ce1_dec_1000_integrate = {
# 			KINGDOM = scope:kingdom_05
# 		}
# 		ai_chance = {
# 			base = 10
# 		}
# 	}

# 	option = { #Kingdom 6 please
# 		name = ce1_decision_events.1000.f
# 		trigger = {
# 			exists = scope:kingdom_06
# 		}
# 		ce1_dec_1000_integrate = {
# 			KINGDOM = scope:kingdom_06
# 		}
# 		ai_chance = {
# 			base = 10
# 		}
# 	}
# }

# ce1_decision_events.1010 = {
# 	type = character_event
# 	title = ce1_decision_events.1010.t
# 	desc = ce1_decision_events.1010.desc
# 	theme = martial
# 	left_portrait = {
# 		character = root
# 		animation = personality_honorable
# 	}

# 	immediate = {
# 		play_music_cue = "mx_cue_positive_effect"
# 		random_duchy = {
# 			limit = {
# 				valid_for_legendary_integration_d = yes
# 			}
# 			save_scope_as = duchy_01
# 		}
# 		random_duchy = {
# 			limit = {
# 				valid_for_legendary_integration_d = yes
# 				NOT = {
# 					this = scope:duchy_01
# 				}
# 			}
# 			save_scope_as = duchy_02
# 		}
# 		random_duchy = {
# 			limit = {
# 				valid_for_legendary_integration_d = yes
# 				NOT = {
# 					this = scope:duchy_01
# 					this = scope:duchy_02
# 				}
# 			}
# 			save_scope_as = duchy_03
# 		}
# 		random_duchy = {
# 			limit = {
# 				valid_for_legendary_integration_d = yes
# 				NOT = {
# 					this = scope:duchy_01
# 					this = scope:duchy_02
# 					this = scope:duchy_03
# 				}
# 			}
# 			save_scope_as = duchy_04
# 		}
# 		random_duchy = {
# 			limit = {
# 				valid_for_legendary_integration_d = yes
# 				NOT = {
# 					this = scope:duchy_01
# 					this = scope:duchy_02
# 					this = scope:duchy_03
# 					this = scope:duchy_04
# 				}
# 			}
# 			save_scope_as = duchy_05
# 		}
# 		random_duchy = {
# 			limit = {
# 				valid_for_legendary_integration_d = yes
# 				NOT = {
# 					this = scope:duchy_01
# 					this = scope:duchy_02
# 					this = scope:duchy_03
# 					this = scope:duchy_04
# 					this = scope:duchy_05
# 				}
# 			}
# 			save_scope_as = duchy_06
# 		}
# 	}

# 	option = { #Duchy 1 please
# 		name = ce1_decision_events.1010.a
# 		trigger = {
# 			exists = scope:duchy_01
# 		}
# 		ce1_dec_1010_integrate = {
# 			DUCHY = scope:duchy_01
# 		}
# 		ai_chance = {
# 			base = 10
# 		}
# 	}

# 	option = { #Duchy 2 please
# 		name = ce1_decision_events.1010.b
# 		trigger = {
# 			exists = scope:duchy_02
# 		}
# 		ce1_dec_1010_integrate = {
# 			DUCHY = scope:duchy_02
# 		}
# 		ai_chance = {
# 			base = 10
# 		}
# 	}

# 	option = { #Duchy 3 please
# 		name = ce1_decision_events.1010.c
# 		trigger = {
# 			exists = scope:duchy_03
# 		}
# 		ce1_dec_1010_integrate = {
# 			DUCHY = scope:duchy_03
# 		}
# 		ai_chance = {
# 			base = 10
# 		}
# 	}

# 	option = { #Duchy 4 please
# 		name = ce1_decision_events.1010.d
# 		trigger = {
# 			exists = scope:duchy_04
# 		}
# 		ce1_dec_1010_integrate = {
# 			DUCHY = scope:duchy_04
# 		}
# 		ai_chance = {
# 			base = 10
# 		}
# 	}

# 	option = { #Duchy 5 please
# 		name = ce1_decision_events.1010.e
# 		trigger = {
# 			exists = scope:duchy_05
# 		}
# 		ce1_dec_1010_integrate = {
# 			DUCHY = scope:duchy_05
# 		}
# 		ai_chance = {
# 			base = 10
# 		}
# 	}

# 	option = { #Duchy 6 please
# 		name = ce1_decision_events.1010.f
# 		trigger = {
# 			exists = scope:duchy_06
# 		}
# 		ce1_dec_1010_integrate = {
# 			DUCHY = scope:duchy_06
# 		}
# 		ai_chance = {
# 			base = 10
# 		}
# 	}
# }

# # Pacifist conversion
# ce1_decision_events.1020 = {
# 	type = character_event
# 	title = ce1_decision_events.1020.t
# 	desc = ce1_decision_events.1020.desc
# 	theme = learning
# 	left_portrait = {
# 		character = root
# 		animation = personality_honorable
# 	}
# 	right_portrait = {
# 		character = scope:legendary_character
# 		animation = personality_zealous
# 	}

# 	immediate = {
# 		scope:legendary_character.faith = { save_scope_as = leg_faith }
# 		save_scope_as = liege_convert
# 	}

# 	option = { # Convert I shall!
# 		name = ce1_decision_events.1020.a
# 		every_vassal_or_below = {
# 			custom = every_same_faith_vassal
# 			limit = {
# 				faith = root.faith
# 				NOT = { any_held_title = { is_head_of_faith = yes } }
# 			}
# 			if = {
# 				limit = {
# 					is_ai = yes
# 				}
# 				set_character_faith = scope:leg_faith
# 			}
# 			else = {
# 				trigger_event = ce1_decision_events.1021 # Give players a choice
# 			}
# 		}
# 		every_sub_realm_county = {
# 			custom = every_same_faith_county_in_realm
# 			limit = {
# 				faith = root.faith
# 			}
# 			random = {
# 				chance = 25
# 				set_county_faith = scope:leg_faith
# 			}
# 		}
# 		scope:legendary_character = {
# 			send_interface_toast = {
# 				title = ce1_decision_events.1020.conversion
# 				left_icon = scope:legendary_character
# 				right_icon = scope:liege_convert
# 				scope:liege_convert = {
# 					set_character_faith = scope:leg_faith
# 				}
# 			}
# 		}
# 		ai_chance = {
# 			base = 350 # Should be high, this is a reward for a massive investment
# 			ai_value_modifier = {
# 				ai_zeal = -2
# 				ai_honor = 0.5
# 				ai_compassion = 2 # Pacifism is epic
# 				ai_vengefulness = -0.5
# 				ai_rationality = -0.75
# 			}
# 			opinion_modifier = {
# 				opinion_target = root
# 				multiplier = 1
# 			}
# 		}
# 	}

# 	option = { # Pacifism is cringe
# 		name = ce1_decision_events.1020.b
# 		trigger = {
# 			NOT = {
# 				has_character_flag = guarantee_conversion
# 			}
# 		}
# 		ai_chance = {
# 			base = 100
# 			ai_value_modifier = {
# 				ai_zeal = 2
# 				ai_honor = -0.5
# 				ai_compassion = -2
# 				ai_vengefulness = 0.5
# 				ai_rationality = 0.75
# 			}
# 		}
# 	}

# 	after = {
# 		if = {
# 			limit = {
# 				has_character_flag = guarantee_conversion
# 			}
# 			remove_character_flag = guarantee_conversion
# 		}
# 	}
# }
# ce1_decision_events.1021 = {
# 	type = character_event
# 	title = ce1_decision_events.1021.t
# 	desc = ce1_decision_events.1021.desc
# 	theme = learning
# 	left_portrait = {
# 		character = root
# 		animation = personality_honorable
# 	}
# 	right_portrait = {
# 		character = scope:legendary_character
# 		animation = personality_zealous
# 	}

# 	option = { # Convert I shall!
# 		name = ce1_decision_events.1021.a
# 		set_character_faith = scope:leg_faith
# 		ai_chance = {
# 			base = 100
# 			ai_value_modifier = {
# 				ai_zeal = -2
# 				ai_honor = 0.5
# 				ai_compassion = 2 # Pacifism is epic
# 				ai_vengefulness = -0.5
# 				ai_rationality = -0.75
# 			}
# 		}
# 	}

# 	option = { # Pacifism is cringe
# 		name = ce1_decision_events.1021.b
# 		ai_chance = {
# 			base = 100
# 			ai_value_modifier = {
# 				ai_zeal = 2
# 				ai_honor = -0.5
# 				ai_compassion = -2
# 				ai_vengefulness = 0.5
# 				ai_rationality = 0.75
# 			}
# 		}
# 	}
# }