﻿namespace = major_decisions

#Decisions:
# form_dai_viet_empire_decision, by Ali Kara
# 4000 - The decision is made, choose a reward.
# 4001 - Inform any players.

# form_majapahit_empire_decision, by Ali Kara
# 5000 - The decision is made, choose a reward.
# 5001 - Inform any players.

# form_ryukyu_empire_decision, by Ali Kara
# 6000 - The decision is made, choose an artifact to be crafted.
# 6001 - The chosen shaku artifact has been crafted
# 6002 - The chosen crown artifact has been crafted
# 6003 - Inform any players.

# form_siam_kingdom_decision, by Ali Kara
# 7000 - The decision is made, choose a reward.
# 7001 - Inform any players.

#form_dai_viet_empire_decision
#The decision is made, choose a reward.
major_decisions.4000 = { #by Ali Kara
	type = character_event
	title = major_decisions.4000.t
	desc = major_decisions.4000.desc
	window = big_event_window
	theme = realm
	override_effect_2d = { reference = legend_glow }
	right_portrait = {
		character = scope:founder
		animation = personality_bold
		camera = camera_event_right_to_the_right
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		form_dai_viet_empire_decision_scripted_effect = yes
		legend_seed_new_title_effect = yes
		primary_title = { save_scope_as = new_primary_title }
		save_scope_as = flavor
		create_character_memory = {
			type = ascended_throne_memory

			participants = {
				flavor_character = scope:flavor
			}	
		}
		scope:new_memory = {
			set_variable = {
				name = landed_title
				value = scope:new_primary_title
			}
		}
	}

	#More house Godliness
	option = {
		name = major_decisions.4000.a
		root.house = {
			add_house_modifier = dai_viet_empire_house_modifier
		}
		if = {
			limit = {
				exists = cp:councillor_court_chaplain
			}
			cp:councillor_court_chaplain = {
				add_opinion = {
					modifier = pious_opinion
					target = root
					opinion = 40
				}
			}
		}
	}
	#Subject opinion boost
	option = {
		trigger = {
			any_vassal_or_below = {
				count > 0
				primary_title.tier >= tier_county
			}
		}
		name = major_decisions.4000.b
		every_vassal_or_below = {
			limit = {
				primary_title.tier >= tier_county
			}
			add_opinion = {
				modifier = respect_opinion
				opinion = 15
				target = root
			}
		}
	}
	#Personal credit
	option = {
		name = major_decisions.4000.c
		give_nickname = nick_the_great
		add_prestige_experience = massive_fame_gain
		stress_impact = {
			humble = medium_stress_impact_gain
		}
	}
}

#Inform any players.
major_decisions.4001 = { #by Ali Kara
	type = character_event
	title = major_decisions.4001.t
	desc = major_decisions.4001.desc
	theme = realm
	override_effect_2d = { reference = legend_glow }
	right_portrait = {
		character = scope:founder
		animation = personality_bold
		camera = camera_body_left_slight
	}

	immediate = {
		if = {
			limit = { highest_held_title_tier >= tier_empire }
			play_music_cue = "mx_cue_combat_2"
		}
	}

	option = {
		name = {
			trigger = {
				highest_held_title_tier < tier_empire
			}
			text = major_decisions.4001.a
		}
		name = { #Empires are less than impressed.
			trigger = {
				NOT = {
					highest_held_title_tier >= tier_empire
				}
			}
			text = major_decisions.4001.b
		}
	}
}

scripted_effect majapahit_reward_island_title_claims_list_effect = {
	title:d_BOR_tanjungpura = { add_to_list = island_titles }
	title:d_BOR_nan_sarunai = { add_to_list = island_titles }
	title:d_BOR_kutai = { add_to_list = island_titles }
	title:d_SUM_jambi = { add_to_list = island_titles }
	title:d_SUM_minangkabau = { add_to_list = island_titles }
	title:d_SUM_riau = { add_to_list = island_titles }
	title:d_SUM_aceh = { add_to_list = island_titles }
	title:d_SuMa_luwu = { add_to_list = island_titles }
	title:d_SuMa_tompotika = { add_to_list = island_titles }
	title:d_SuMa_konawe = { add_to_list = island_titles }
	random_in_list = {
		list = island_titles
		limit = {
			is_title_created = yes
			holder = {
				this != root
				NOT = {
					is_vassal_of = root
					is_tributary_of = root
				}
				is_within_diplo_range = { CHARACTER = root }
			}
			root = {
				NOT = {
					has_claim_on = prev
				}
			}
		}
		save_scope_as = chosen_island_title_scope
	}
}

#form_majapahit_empire_decision
#The decision is made, choose a reward.
major_decisions.5000 = { #by Ali Kara
	type = character_event
	title = major_decisions.5000.t
	desc = major_decisions.5000.desc
	window = big_event_window
	theme = faith
	right_portrait = {
		character = scope:founder
		animation = personality_bold
		camera = camera_event_very_right
	}
	left_portrait = {
		character = scope:ritual_guide
		animation = storyteller
		camera = camera_event_very_left
	}


	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		form_majapahit_empire_decision_scripted_effect = yes
		majapahit_reward_island_title_claims_list_effect = yes
		legend_seed_new_title_effect = yes
		if = {
			limit = {
				exists = root.cp:councillor_court_chaplain
			}
			cp:councillor_court_chaplain = {
				save_scope_as = ritual_guide
			}
		}
		else = {
			faith = {
				ordered_faith_character = {
					order_by = learning
					limit = {
						culture = root.culture
						top_liege = root
					}
					position = 0
					save_scope_as = ritual_guide
				}
			}
		}
		primary_title = { save_scope_as = new_primary_title }
		save_scope_as = flavor
		create_character_memory = {
			type = ascended_throne_memory

			participants = {
				flavor_character = scope:flavor
			}	
		}
		scope:new_memory = {
			set_variable = {
				name = landed_title
				value = scope:new_primary_title
			}
		}
	}

	# (War/Aggression) Get a random island duchy claim & modifiers
	option = {
		name = major_decisions.5000.a
		add_character_modifier = {
			modifier = majapahit_empire_knight_modifier
			years = 15
		}
		if = {
			limit = {
				list_size = {
					name = island_titles
					value > 0
				}
			}
			add_unpressed_claim = scope:chosen_island_title_scope
		}
		give_nickname = nick_the_brave
	}
	# (Peace/Development) build speed & cost
	option = {
		name = major_decisions.5000.b
		add_character_modifier = {
			modifier = majapahit_empire_build_discount_modifier
			years = 15
		}
		give_nickname = nick_the_meticulous
	}
}

#Inform any players.
major_decisions.5001 = { #by Ali Kara
	type = character_event
	title = major_decisions.5001.t
	desc = major_decisions.5001.desc
	theme = realm
	override_effect_2d = { reference = legend_glow }
	right_portrait = {
		character = scope:founder
		animation = personality_bold
		camera = camera_body_left_slight
	}

	immediate = {
		if = {
			limit = { highest_held_title_tier >= tier_empire }
			play_music_cue = "mx_cue_combat_2"
		}
	}

	option = {
		name = {
			trigger = {
				highest_held_title_tier > tier_empire
			}
			text = major_decisions.5001.a
		}
		name = { #Empires are less than impressed.
			trigger = {
				NOT = {
					highest_held_title_tier >= tier_empire
				}
			}
			text = major_decisions.5001.b
		}
	}
}

#form_ryukyu_empire_decision
#The decision is made, choose an artifact to be crafted.
major_decisions.6000 = { #by Ali Kara
	type = character_event
	title = major_decisions.6000.t
	desc = major_decisions.6000.desc
	window = big_event_window
	theme = realm
	right_portrait = {
		character = scope:founder
		animation = personality_bold
		camera = camera_event_center_pointing_slighty_left
	}
	left_portrait = {
		character = scope:antiquarian
		animation = storyteller
		camera = camera_event_left_away_3_4
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		form_ryukyu_empire_decision_scripted_effect = yes
		legend_seed_new_title_effect = yes
		primary_title = { save_scope_as = new_primary_title }
		save_scope_as = flavor
		create_character_memory = {
			type = ascended_throne_memory

			participants = {
				flavor_character = scope:flavor
			}	
		}
		scope:new_memory = {
			set_variable = {
				name = landed_title
				value = scope:new_primary_title
			}
		}
		if = {
			limit = {
				employs_court_position = antiquarian_court_position
				any_court_position_holder = {
					type = antiquarian_court_position
				}
				is_healthy = yes
				NOR = {
					has_trait = ill
					has_trait = leper
					has_trait = cancer
				}
			}
			random_court_position_holder = {
				type = antiquarian_court_position
				save_scope_as = antiquarian
			}
		}
		else = {
			ordered_courtier = {
				limiT = {
					is_healthy = yes
					NOR = {
						has_trait = ill
						has_trait = leper
						has_trait = cancer
					}
				}
			 	order_by = learning
			 	position = 0
			 	save_scope_as = antiquarian
			 }
		}
	}

	# Taller
	option = {
		name = major_decisions.6000.a
		custom_tooltip = ryukyu_artifact_regalia_craft_tt
		trigger_event = {
			id = major_decisions.6001
			days = 180
		}
	}
	# Wider
	option = {
		name = major_decisions.6000.b
		custom_tooltip = ryukyu_artifact_crown_craft_tt
		trigger_event = {
			id = major_decisions.6002
			days = 180
		}
	}
}

#The chosen shaku artifact has been crafted
major_decisions.6001 = { #by Ali Kara
	type = character_event
	title = major_decisions.6001.t
	desc = major_decisions.6001.desc
	theme = realm
	override_effect_2d = { reference = legend_glow }
	right_portrait = {
		character = root
		animation = personality_bold
		camera = camera_event_right_crowner_crowning
	}
	left_portrait = {
		character = scope:antiquarian
		animation = gongshou_with_hu
		camera = camera_event_left_crowning_observation
	}
	artifact = {
		target = scope:ryukyu_shaku_artifact
		position = lower_right_portrait
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		if = {
			limit = {
				employs_court_position = antiquarian_court_position
				any_court_position_holder = {
					type = antiquarian_court_position
				}
				is_healthy = yes
				NOR = {
					has_trait = ill
					has_trait = leper
					has_trait = cancer
				}
			}
			random_court_position_holder = {
				type = antiquarian_court_position
				save_scope_as = antiquarian
			}
		}
		else = {
			ordered_courtier = {
				limit = {
					is_healthy = yes
					NOR = {
						has_trait = ill
						has_trait = leper
						has_trait = cancer
					}
				}
			 	order_by = learning
			 	position = 0
			 	save_scope_as = antiquarian
			 }
		}
		set_artifact_rarity_illustrious = yes
		create_artifact = {	
			name = ryukyu_shaku_name
			description = ryukyu_shaku_description
			template = ryukyu_shaku_template
			type = regalia
			visuals = ryukyuan_regalia
			wealth = scope:wealth
			quality = scope:quality
			modifier = ryukyu_empire_shaku_modifier
			save_scope_as = ryukyu_shaku_artifact
			decaying = no
		}
	}

	option = {
		name = major_decisions.6001.a
		add_piety_experience = medium_piety_value
		add_prestige_experience = medium_fame_gain
	}
}

#The chosen crown artifact has been crafted
major_decisions.6002 = { #by Ali Kara
	type = character_event
	title = major_decisions.6002.t
	desc = major_decisions.6002.desc
	theme = realm
	override_effect_2d = { reference = legend_glow }
	right_portrait = {
		character = root
		animation = personality_bold
		camera = camera_event_right_crowner_crowning
	}
	left_portrait = {
		character = scope:antiquarian
		animation = crowning
		camera = camera_event_left_crowning_observation
	}
	artifact = {
		target = scope:ryukyu_crown_artifact
		position = lower_right_portrait
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		if = {
			limit = {
				employs_court_position = antiquarian_court_position
				any_court_position_holder = {
					type = antiquarian_court_position
				}
				is_healthy = yes
				NOR = {
					has_trait = ill
					has_trait = leper
					has_trait = cancer
				}
			}
			random_court_position_holder = {
				type = antiquarian_court_position
				save_scope_as = antiquarian
			}
		}
		else = {
			ordered_courtier = {
				limit = {
					is_healthy = yes
					NOR = {
						has_trait = ill
						has_trait = leper
						has_trait = cancer
					}
				}
			 	order_by = learning
			 	position = 0
			 	save_scope_as = antiquarian
			 }
		}
		set_artifact_rarity_illustrious = yes
		create_artifact = {	
			name = ryukyu_crown_name
			description = ryukyu_crown_description
			template = ryukyu_crown_template
			type = helmet
			visuals = ryukyuan_crown
			wealth = scope:wealth
			quality = scope:quality
			modifier = ryukyu_empire_crown_modifier
			save_scope_as = ryukyu_crown_artifact
			decaying = no
		}
	}

	option = {
		name = major_decisions.6002.a
		add_prestige_experience = major_fame_gain
	}
}

#Inform any players.
major_decisions.6003 = { #by Ali Kara
	type = character_event
	title = major_decisions.6003.t
	desc = major_decisions.6003.desc
	theme = realm
	override_effect_2d = { reference = legend_glow }
	right_portrait = {
		character = scope:founder
		animation = personality_bold
		camera = camera_body_left_slight
	}

	immediate = {
		if = {
			limit = { highest_held_title_tier >= tier_empire }
			play_music_cue = "mx_cue_combat_2"
		}
	}

	option = {
		name = {
			trigger = {
				highest_held_title_tier < tier_empire
			}
			text = major_decisions.6003.a
		}
		name = { #Empires are less than impressed.
			trigger = {
				highest_held_title_tier >= tier_empire
			}
			text = major_decisions.6003.b
		}
	}
}

#form_siam_kingdom_decision
#The decision is made, choose an artifact to be crafted.
major_decisions.7000 = { #by Ali Kara
	type = character_event
	title = major_decisions.7000.t
	desc = major_decisions.7000.desc
	window = big_event_window
	theme = realm
	right_portrait = {
		character = scope:founder
		animation = personality_rational
		camera = camera_legend_chronicle
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		form_siam_kingdom_decision_scripted_effect = yes
		legend_seed_new_title_effect = yes
		primary_title = { save_scope_as = new_primary_title }
		save_scope_as = flavor
		create_character_memory = {
			type = ascended_throne_memory

			participants = {
				flavor_character = scope:flavor
			}	
		}
		scope:new_memory = {
			set_variable = {
				name = landed_title
				value = scope:new_primary_title
			}
		}
		capital_county = {
			save_scope_as = kingdom_capital
		}
	}

	# Invest in development
	option = {
		name = major_decisions.7000.a
		scope:kingdom_capital = {
			add_county_modifier = {
				modifier = siam_kingdom_sangkhalok_workshops_county_modifier
				years = 20
			}
		}
		capital_county = {
			every_county_province = {
				add_province_modifier = {
					modifier = siam_kingdom_sangkhalok_workshops_province_modifier
					years = 20
				}
			}
		}
	}
	# Invest in military
	option = {
		name = major_decisions.7000.b
		capital_county = {
			every_county_province = {
				add_province_modifier = {
					modifier = siam_kingdom_military_modifier
					years = 20
				}
			}
		}
	}
	# Invest in culture
	option = {
		name = major_decisions.7000.c
		add_character_modifier = {
			modifier = siam_kingdom_culture_modifier
			years = 20
		}
	}
}

#Inform any players.
major_decisions.7001 = { #by Ali Kara
	type = character_event
	title = major_decisions.7001.t
	desc = major_decisions.7001.desc
	theme = realm
	override_effect_2d = { reference = legend_glow }
	right_portrait = {
		character = scope:founder
		animation = personality_bold
		camera = camera_body_left_slight
	}

	immediate = {
		if = {
			limit = { highest_held_title_tier >= tier_kingdom }
			play_music_cue = "mx_cue_combat_2"
		}
	}

	option = {
		name = {
			trigger = {
				highest_held_title_tier < tier_kingdom
			}
			text = major_decisions.7001.a
		}
		name = { #Kingdoms are less than impressed.
			trigger = {
				highest_held_title_tier >= tier_kingdom
			}
			text = major_decisions.7001.b
		}
	}
}
