﻿namespace = fp1_major_decisions

##################################################
# #Standard Events
# 0001 - 0010	Secure the High Kingdom of the North Sea - Bind England, Denmark, and Norway into one mighty de jure.
# 0011 - 0020	Found the Capital of the Rus' - Semi-dynamic founding of Kiev.
# 0021 - 0030	Elevate the Kingdom of the Isles - Make the Petty Kingdom of Mann & the Isles into the Perfectly Regular Kingdom of Mann & the Isles.
# 0031 - 0040	Forge the Jomsvikings - Sponsor the creation of a conservative Asatru holy fighting force.
#
#
# #Special Events
# 1001 - 1010	Canute-'em-Up
# 1011 - 1020	The True King of Norway - Harald Tanglehair earns his haircut.
##################################################





##################################################
# Securing the High Kingdom of the North Sea
# by Ewan Cowhig Croft
# 0001-0010
##################################################

#	Founder event
fp1_major_decisions.0001 = {
	type = character_event
	title = fp1_major_decisions.0001.t
	desc = fp1_major_decisions.0001.desc
	theme = realm
	left_portrait = {
		character = scope:founder
		animation = personality_honorable
	}
	override_background = { reference = fp1_ocean_norse }

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		#Apply decision effects.
		secure_high_kingdom_north_sea_scripted_effect = yes
		legend_seed_new_title_effect = yes
	}

	#I'm the besterest!
	option = {
		name = fp1_major_decisions.0001.a

		add_prestige_experience = 1000

		ai_chance = {
			#Only option.
			base = 100
		}
	}
}

#	Vassal notification event
fp1_major_decisions.0002 = {
	type = character_event
	title = fp1_major_decisions.0002.t
	desc = fp1_major_decisions.0002.desc
	theme = realm
	left_portrait = {
		character = scope:founder
		animation = personality_honorable
	}
	override_background = { reference = fp1_ocean_norse }

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		show_as_tooltip = { secure_high_kingdom_north_sea_scripted_effect = yes }
	}

	#Huzzah!
	option = {
		name = fp1_major_decisions.0002.a

		ai_chance = {
			#Doesn't especially matter.
			base = 100
		}
	}

	#This bodes ill...
	option = {
		name = fp1_major_decisions.0002.b

		ai_chance = {
			#Doesn't especially matter.
			base = 100
		}
	}
}

#	Distant players notification event
fp1_major_decisions.0003 = {
	type = character_event
	title = fp1_major_decisions.0003.t
	desc = fp1_major_decisions.0003.desc
	theme = realm
	left_portrait = {
		character = scope:founder
		animation = personality_honorable
	}
	override_background = { reference = fp1_ocean_norse }

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		show_as_tooltip = { secure_high_kingdom_north_sea_scripted_effect = yes }
	}

	#We're the best!
	option = {
		name = fp1_major_decisions.0003.a
		trigger = { faith = scope:founder.faith }

		ai_chance = {
			#Doesn't especially matter.
			base = 100
		}
	}

	#Foul Heathens/Christmen!
	option = {
		name = fp1_major_decisions.0003.b
		trigger = {
			faith != scope:founder.faith
		}

		ai_chance = {
			#Doesn't especially matter.
			base = 100
		}
	}

	#Emperors get antsy.
	option = {
		name = fp1_major_decisions.0003.c
		trigger = { highest_held_title_tier >= tier_empire }

		ai_chance = {
			#Doesn't especially matter.
			base = 100
		}
	}
}

##################################################
# Founding the Capital of the Rus'
# by Ewan Cowhig Croft
# 0011-0020
##################################################

#	Founder event
fp1_major_decisions.0011 = {
	type = character_event
	title = fp1_major_decisions.0011.t
	desc = fp1_major_decisions.0011.desc
	theme = realm
	left_portrait = {
		character = scope:founder
		animation = personality_honorable
	}
	override_background = { reference = fp1_runestone }

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
	}

	#Kiev shall be my capital.
	option = {
		name = fp1_major_decisions.0011.a

		trigger = {
			#Must have title:c_kiev in order to make it your capital.
			any_sub_realm_county = { this = title:c_kiev }
			#And Kiev cannot be held by a player who has _only_ title:c_kiev, unless that player is you.
			title:c_kiev.holder = {
				OR = {
					is_ai = yes
					any_held_title = {
						count >= 1
						title_tier = county
						NOT = { this = title:c_kiev }
					}
					this = scope:founder
				}
			}
		}

		#Organise the usurpation/capital move of title:c_kiev if appropriate.
		if = {
			limit = {
				NOT = { title:c_kiev.holder = scope:founder }
			}
			create_title_and_vassal_change = {
				type = usurped
				save_scope_as = change
				add_claim_on_loss = yes
			}
			title:c_kiev = {
				change_title_holder = {
					holder = root
					change = scope:change
				}
			}
			resolve_title_and_vassal_change = scope:change
		}
		set_realm_capital = title:c_kiev
		#Otherwise, set title:c_kiev to be scope:new_rus_capital & go through with the effect.
		title:c_kiev = {
			save_scope_as = new_rus_capital
			found_capital_of_rus_scripted_effect = yes
		}

		ai_chance = {
			#AI should always take this option if it's available.
			base = 100
		}
	}

	#My current capital shall be my capital!
	option = {
		name = fp1_major_decisions.0011.b

		#Not generally necessary, but just to stop some weird loc eventualities.
		trigger = {
			NOT = { capital_county = title:c_kiev }
		}

		#We try to use the player's current capital, but if they've moved it outside of e_russia, then we go with the default set in the standard decision entry.
		if = {
			limit = { capital_county.empire = title:e_russia }
			#Formatted a little inefficiently for readability.
			capital_county = { save_scope_as = new_rus_capital }
		}
		#Then enact the actual effects.
		found_capital_of_rus_scripted_effect = yes

		ai_chance = {
			#AI will only take this option if they have no other choice (i.e., can't get Kiev).
			base = 0
		}
	}

	after = {
		#Take care of notification events.
		every_player = {
			limit = {
				capital_province = {
					OR = {
						geographical_region = world_europe_east
						geographical_region = world_europe_north
					}
				}
				#Obviously, we exempt scope:founder themselves.
				this != scope:founder
			}
			#Vassal players get a separate event.
			if = {
				limit = {
					any_liege_or_above = { this = scope:founder }
				}
				trigger_event = fp1_major_decisions.0012
			}
			#Everyone else within range gets a less personal version.
			else = { trigger_event = fp1_major_decisions.0013 }
		}
	}
}

#	Vassal notification event
fp1_major_decisions.0012 = {
	type = character_event
	title = fp1_major_decisions.0012.t
	desc = fp1_major_decisions.0012.desc
	theme = realm
	left_portrait = {
		character = scope:founder
		animation = personality_honorable
	}
	override_background = { reference = fp1_runestone }

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		show_as_tooltip = { found_capital_of_rus_scripted_effect = yes }
	}

	#A worthy capital!
	option = {
		name = fp1_major_decisions.0012.a

		ai_chance = {
			#Doesn't especially matter.
			base = 100
		}
	}

	#Bah, ain't no city of mine.
	option = {
		name = fp1_major_decisions.0012.b

		ai_chance = {
			#Doesn't especially matter.
			base = 100
		}
	}
}

#	Distant players notification event
fp1_major_decisions.0013 = {
	type = character_event
	title = fp1_major_decisions.0013.t
	desc = fp1_major_decisions.0013.desc
	theme = realm
	left_portrait = {
		character = scope:founder
		animation = personality_honorable
	}
	override_background = { reference = fp1_runestone }

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		show_as_tooltip = { found_capital_of_rus_scripted_effect = yes }
	}

	#This scope:new_rus_capital sounds intriguingly rich...
	option = {
		name = fp1_major_decisions.0013.a
		trigger = {
			OR = {
				culture = { has_cultural_pillar = heritage_north_germanic }
				culture = { has_cultural_pillar = heritage_east_slavic }
			}
		}

		ai_chance = {
			#Doesn't especially matter.
			base = 100
		}
	}

	#They're still just backwards foreigners.
	option = {
		name = fp1_major_decisions.0013.b
		trigger = {
			NOR = {
				culture = { has_cultural_pillar = heritage_north_germanic }
				culture = { has_cultural_pillar = heritage_east_slavic }
			}
		}

		ai_chance = {
			#Doesn't especially matter.
			base = 100
		}
	}

	#I don't really see how this concerns me?
	option = {
		name = fp1_major_decisions.0013.c

		ai_chance = {
			#Doesn't especially matter.
			base = 100
		}
	}
}

##################################################
# Elevating the Kingdom of the Isles
# by Ewan Cowhig Croft
# 0021 - 0030
##################################################

#	Founder event
fp1_major_decisions.0021 = {
	type = character_event
	title = fp1_major_decisions.0021.t
	desc = fp1_major_decisions.0021.desc
	theme = war
	left_portrait = {
		character = root
		animation = personality_honorable
	}
	override_background = { reference = fp1_beached_longships }

	trigger = {
		# DLC check.
		has_fp1_dlc_trigger = yes
	}

	immediate = {
		play_music_cue = "mx_cue_war_declared"
		# Apply effects
		elevate_mann_and_the_isles_scripted_effect = yes
		legend_seed_new_title_effect = yes
	}

	# I am the Lady/Lord of Blood and Gold!
	option = {
		name = fp1_major_decisions.0021.a

		# Add a unique nickname.
		give_nickname = nick_the_great_and_terrible

		# No stress impact necessary.
		ai_chance = {
			# AI should always choose this option.
			base = 100
		}
	}
	
	# At last my dream is achieved...
	option = {
		name = fp1_major_decisions.0021.b

		# Minor stress loss for turning down the nickname.
		add_stress = minor_stress_loss

		# No stress impact necessary.
		ai_chance = {
			# AI should, if it somehow makes it here, never opt out of the nickname.
			base = 0
		}
	}
}

#	Vassal notification event
fp1_major_decisions.0022 = {
	type = character_event
	title = fp1_major_decisions.0022.t
	desc = fp1_major_decisions.0022.desc
	theme = war
	left_portrait = {
		character = scope:founder
		animation = personality_honorable
	}
	override_background = { reference = fp1_beached_longships }

	immediate = {
		play_music_cue = "mx_cue_war_declared"
		# Apply effects
		scope:founder = {
			show_as_tooltip = { elevate_mann_and_the_isles_scripted_effect = yes }
		}
	}

	# Just think of all the gold we're going to make!
	option = {
		name = fp1_major_decisions.0022.a

		ai_chance = {
			#Doesn't especially matter.
			base = 100
		}
	}

	# A _queen/king_? They're little better than a robber baron!
	option = {
		name = fp1_major_decisions.0022.b

		ai_chance = {
			#Doesn't especially matter.
			base = 100
		}
	}
}

#	Distant players notification event
fp1_major_decisions.0023 = {
	type = character_event
	title = fp1_major_decisions.0023.t
	desc = fp1_major_decisions.0023.desc
	theme = war
	left_portrait = {
		character = scope:founder
		animation = personality_honorable
	}
	override_background = { reference = fp1_beached_longships }

	immediate = {
		play_music_cue = "mx_cue_war_declared"
		# Apply effects
		scope:founder = {
			show_as_tooltip = { elevate_mann_and_the_isles_scripted_effect = yes }
		}
	}

	# They're not going to raid *us*, right?
	option = {
		name = fp1_major_decisions.0023.a

		ai_chance = {
			#Doesn't especially matter.
			base = 100
		}
	}

	# No more than a Queen/King of Thieves!
	option = {
		name = fp1_major_decisions.0023.b

		ai_chance = {
			#Doesn't especially matter.
			base = 100
		}
	}
}

##################################################
# Forge the Jomsvikings
# by Ewan Cowhig Croft
# 0031-0041
##################################################

#	Founder event
fp1_major_decisions.0031 = {
	type = character_event
	title = fp1_major_decisions.0031.t
	desc = fp1_major_decisions.0031.desc
	theme = faith
	left_portrait = {
		character = scope:founder
		animation = personality_honorable
	}
	right_portrait = {
		character = scope:leader
		animation = personality_zealous
	}

	trigger = {
		# DLC check.
		has_fp1_dlc_trigger = yes
	}

	immediate = {
		play_music_cue = "mx_cue_crusade_starts"
		# Found the Jomsvikings.
		forge_the_jomsvikings_scripted_effect = yes
		#Notify other players.
		every_player = {
			limit = {
				OR = {
					religion = religion:germanic_religion
					save_temporary_scope_as = neighbouring_players
					scope:founder = {
						any_neighboring_and_across_water_top_liege_realm_owner = { this = scope:neighbouring_players }
					}
				}
				#Obviously, we exempt scope:founder themselves.
				this != scope:founder
			}
			#Vassal players get a separate event.
			if = {
				limit = {
					any_liege_or_above = { this = scope:founder }
				}
				trigger_event = fp1_major_decisions.0032
			}
			#Everyone else within range gets a less personal version.
			else = { trigger_event = fp1_major_decisions.0033 }
		}
	}

	# For our ancestors!
	option = {
		name = {
			trigger = { has_trait = cynical }
			text = fp1_major_decisions.0031.a.cynical
		}
		name = {
			trigger = {
				NOT = { has_trait = cynical }
			}
			text = fp1_major_decisions.0031.a.fallback
		}

		# Get your bonus troops.
		forge_the_jomsvikings_maa_reward_effect = yes

		stress_impact = {
			# Usually bad form to give stress impact on single event options, but if you're cynical and taking this option, you *know* you're doing it for purely cynical reasons.
			zealous = massive_stress_impact_loss
			cynical = medium_stress_impact_gain
		}
		ai_chance = {
			# Single option event doesn't need ai_chance sorted.
			base = 100
		}
	}
}

#	Vassal notification event
fp1_major_decisions.0032 = {
	type = character_event
	title = fp1_major_decisions.0032.t
	desc = fp1_major_decisions.0032.desc
	theme = faith
	left_portrait = {
		character = scope:founder
		animation = personality_honorable
	}
	right_portrait = {
		character = scope:leader
		# Same-faith characters see them as zealous.
		triggered_animation = {
			trigger = { faith = scope:leader.faith }
			animation = personality_zealous
		}
		# Everyone else sees them as pirates.
		triggered_animation = {
			trigger = {
				faith != scope:leader.faith
			}
			animation = schadenfreude
		}
	}

	trigger = {
		# DLC check.
		has_fp1_dlc_trigger = yes
	}

	immediate = {
		play_music_cue = "mx_cue_crusade_starts"
		# Jomsvikings founded.
		scope:founder = {
			show_as_tooltip = { forge_the_jomsvikings_scripted_effect = yes }
		}
	}

	# Huzzah!
	option = {
		name = fp1_major_decisions.0032.a
		trigger = { faith = scope:founder.faith }

		# Scope:founder gets a boost.
		scope:founder = {
			show_as_tooltip = { forge_the_jomsvikings_maa_reward_effect = yes }
		}

		# No stress impact for notification event.
		ai_chance = {
			# Player-only, AI choice irrelevant.
			base = 100
		}
	}

	# So, they're pirates?
	option = {
		name = fp1_major_decisions.0032.b

		# Scope:founder gets a boost.
		scope:founder = {
			show_as_tooltip = { forge_the_jomsvikings_maa_reward_effect = yes }
		}

		# No stress impact for notification event.
		ai_chance = {
			# Player-only, AI choice irrelevant.
			base = 100
		}
	}
}

#	Distant players notification event
fp1_major_decisions.0033 = {
	type = character_event
	title = fp1_major_decisions.0033.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { exists = scope:jomsvikings_autofounded }
				desc = fp1_major_decisions.0033.desc.autofounded
			}
			desc = fp1_major_decisions.0033.desc.decision_founded
		}
		desc = fp1_major_decisions.0033.desc.outro
	}
	theme = faith
	left_portrait = {
		character = scope:founder
		animation = personality_bold
	}
	right_portrait = {
		character = scope:leader
		# Same-faith characters see them as zealous.
		triggered_animation = {
			trigger = { faith = scope:leader.faith }
			animation = personality_zealous
		}
		# Everyone else sees them as pirates.
		triggered_animation = {
			trigger = {
				faith != scope:leader.faith
			}
			animation = schadenfreude
		}
	}
	lower_center_portrait = scope:victim

	trigger = {
		# DLC check.
		has_fp1_dlc_trigger = yes
	}

	immediate = {
		play_music_cue = "mx_cue_crusade_starts"
		# Jomsvikings founded.
		custom_tooltip = fp1_founder_founded_the_jomsviking_tt
		show_as_tooltip = {
			scope:founder.faith = {
				change_fervor = {
					value = 10
					desc = fervor_gain_holy_order_founded
				}
			}
		}
	}

	# Wonderous news!
	option = {
		name = fp1_major_decisions.0033.a
		trigger = { faith = scope:founder.faith }

		# Scope:founder gets a boost.
		scope:founder = {
			show_as_tooltip = { forge_the_jomsvikings_maa_reward_effect = yes }
		}

		# No stress impact for notification event.
		ai_chance = {
			# Player-only, AI choice irrelevant.
			base = 100
		}
	}

	# Just another band of raiders.
	option = {
		name = {
			trigger = {
				religion = { is_in_family = rf_pagan }
			}
			text = fp1_major_decisions.0033.b.competition
		}
		name = {
			trigger = {
				NOT = {
					religion = { is_in_family = rf_pagan }
				}
			}
			text = fp1_major_decisions.0033.b.heathens
		}

		# Scope:founder gets a boost.
		scope:founder = {
			show_as_tooltip = { forge_the_jomsvikings_maa_reward_effect = yes }
		}

		# No stress impact for notification event.
		ai_chance = {
			# Player-only, AI choice irrelevant.
			base = 100
		}
	}
}





##################################################
# Canute-'em-Up
# by Ewan Cowhig Croft
# 1001-1010
##################################################

scripted_trigger fp1_major_decisions_1001_valid_sycophant_trigger = {
	# Has to be around.
	is_available_ai_adult = yes
	# And have an outrageously positive opinion of root...
	opinion = {
		target = root
		value >= very_high_positive_opinion
	}
	# _Without_ actually having any good reason to.
	has_any_good_relationship_with_root_trigger = no
	# Plus gotta filter out some general traits.
	NOR = {
		has_trait = honest
		has_trait = brave
		has_trait = shy
		has_trait = content
		has_trait = just
		has_trait = zealous
		has_trait = trusting
	}
}

#	So you think you're _truly_ the High King of the North Sea, eh?
##	Ok, so this probably didn't *actually* happen, but we can't have a North Sea title without the myth, right?
fp1_major_decisions.1001 = {
	type = character_event
	title = fp1_major_decisions.1001.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:type = flag:canute_dumb }
				desc = fp1_major_decisions.1001.desc.dumb
			}
			desc = fp1_major_decisions.1001.desc.smart
		}
	}
	theme = crown
	left_portrait = {
		character = root
		# Smart Canute.
		triggered_animation = {
			trigger = { scope:type = flag:canute_smart }
			animation = disapproval
		}
		# And, tragically, dumb-Canute.
		triggered_animation = {
			trigger = { scope:type = flag:canute_dumb }
			animation = personality_bold
		}
	}
	right_portrait = {
		character = scope:sycophant
		animation = admiration
	}

	trigger = {
		# DLC check.
		has_fp1_dlc_trigger = yes
		# Since this is a once-only event for e_north_sea, we can early-out by checking if we're even looking at them.
		has_title = title:e_north_sea
		# And that this even has never happened before.
		NOT = { exists = global_var:had_event_fp1_major_decisions_1001 }
		# Then, that we're within -ish the legendary frame.
		current_date <= 1050.1.1
		# And might actually have a problem with all this deceit.
		NOR = {
			has_trait = arrogant
			has_trait = trusting
			has_trait = deceitful
		}
		# Finally (for once), standard checks.
		is_available_at_peace_adult = yes
		# And at least one sycophantic courtier.
		any_courtier_or_guest = { fp1_major_decisions_1001_valid_sycophant_trigger = yes }
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		set_global_variable = {
			name = had_event_fp1_major_decisions_1001
			value = yes
		}
		# Are we dealing with an idiotic Canute?
		if = {
			limit = {
				OR = {
					learning <= low_skill_rating
					has_trait = intellect_bad
					has_trait = dull
				}
			}
			save_scope_value_as = {
				name = type
				value = flag:canute_dumb
			}
		}
		# If not, assume they're smart.
		else = {
			save_scope_value_as = {
				name = type
				value = flag:canute_smart
			}
		}
		# And grab a chief sycophant.
		random_courtier_or_guest = {
			limit = { fp1_major_decisions_1001_valid_sycophant_trigger = yes }
			save_scope_as = sycophant
		}
	}

	# To the beach!
	option = {
		name = fp1_major_decisions.1001.a

		# Onwards!
		custom_tooltip = fp1_major_decisions.1001.a.tt
		trigger_event = fp1_major_decisions.1002

		stress_impact = {
			humble = major_stress_impact_loss
			paranoid = major_stress_impact_loss
			honest = major_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = 0.5
				ai_vengefulness = 0.25
			}
			modifier = {	# Weight up for stress.
				add = 30
				has_trait = humble
			}
			modifier = {	# Weight up for stress.
				add = 30
				has_trait = paranoid
			}
			modifier = {	# Weight up for stress.
				add = 30
				has_trait = honest
			}
		}
	}
	
	# They're probably correct, right?
	option = {
		name = fp1_major_decisions.1001.b

		# Gain some very minor stress loss for opting out.
		## Stress loss handled in stress_impact.

		stress_impact = {
			base = minor_stress_loss
			vengeful = minor_stress_impact_gain
			impatient = minor_stress_impact_gain
			humble = medium_stress_impact_gain
			cynical = medium_stress_impact_gain
			zealous = medium_stress_impact_gain
			paranoid = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_vengefulness = -0.25
				ai_boldness = -0.5
			}
			modifier = {	# Weight down for stress.
				add = -10
				has_trait = vengeful
			}
			modifier = {	# Weight down for stress.
				add = -10
				has_trait = impatient
			}
			modifier = {	# Weight down for stress.
				add = -20
				has_trait = humble
			}
			modifier = {	# Weight down for stress.
				add = -20
				has_trait = cynical
			}
			modifier = {	# Weight down for stress.
				add = -20
				has_trait = zealous
			}
			modifier = {	# Weight down for stress.
				add = -30
				has_trait = paranoid
			}
		}
	}
}

scripted_effect fp1_major_decisions_1002_courtiers_terrified_effect = {
	every_courtier_or_guest = {
		custom = custom.every_courtier_and_guest
		add_opinion = {
			target = root
			modifier = respect_opinion
			opinion = -30
		}
	}
}

fp1_major_decisions.1002 = {
	type = character_event
	title = fp1_major_decisions.1002.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:type = flag:canute_dumb }
				desc = fp1_major_decisions.1002.desc.dumb
			}
			desc = fp1_major_decisions.1002.desc.smart
		}
	}
	theme = crown
	left_portrait = {
		character = root
		# Smart Canute.
		triggered_animation = {
			trigger = { scope:type = flag:canute_smart }
			animation = disapproval
		}
		# And, tragically, dumb-Canute.
		triggered_animation = {
			trigger = { scope:type = flag:canute_dumb }
			animation = shock
		}
	}
	right_portrait = {
		character = scope:sycophant
		# Reacting to smart Canute.
		triggered_animation = {
			trigger = { scope:type = flag:canute_smart }
			animation = shame
		}
		# And, tragically, reacting to dumb-Canute.
		triggered_animation = {
			trigger = { scope:type = flag:canute_dumb }
			animation = fear
		}
	}
	override_background = { reference = docks }

	# Smart: shame the simpering courtiers.
	option = {
		name = fp1_major_decisions.1002.a
		trigger = { scope:type = flag:canute_smart }

		# Gain a colossal amount of opinion with your court.
		every_courtier_or_guest = {
			custom = custom.every_courtier_and_guest
			add_opinion = {
				target = root
				modifier = respect_opinion
				opinion = 75
			}
		}

		stress_impact = {
			cynical = medium_stress_impact_loss
			humble = major_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = 0.5
				ai_sociability = 0.5
			}
			modifier = {	# Weight up for stress.
				add = 20
				has_trait = cynical
			}
			modifier = {	# Weight up for stress.
				add = 30
				has_trait = humble
			}
		}
	}
	
	# Smart: abase yourself before HighGod.
	option = {
		name = fp1_major_decisions.1002.b
		trigger = { scope:type = flag:canute_smart }

		# Gain a modifier trading piety for prestige.
		add_character_modifier = { modifier = fp1_abased_before_highgod_modifier }
		# And also a fairly-substantial amount of opinion with your court.
		every_courtier_or_guest = {
			custom = custom.every_courtier_and_guest
			add_opinion = {
				target = root
				modifier = respect_opinion
				opinion = 50
			}
		}

		stress_impact = {
			humble = major_stress_impact_loss
			zealous = massive_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = 0.5
				ai_sociability = 0.5
			}
			modifier = {	# Weight up for stress.
				add = 30
				has_trait = humble
			}
			modifier = {	# Weight up for stress.
				add = 40
				has_trait = zealous
			}
		}
	}
	
	# Dumb: develop crippling thalassaphobia.
	option = {
		name = fp1_major_decisions.1002.c
		trigger = { scope:type = flag:canute_dumb }

		# Gain stress.
		## More stress if you have neither modifier to lose.
		if = {
			limit = {
				NOR = {
					has_character_modifier = high_king_of_the_seas_fp1_modifier
					has_character_modifier = high_queen_of_the_seas_fp1_modifier
				}
			}
			stress_impact = {
				base = massive_stress_gain
				paranoid = major_stress_impact_loss
				honest = major_stress_impact_gain
			}
		}
		## Ordinary stress otherwise.
		else = {
			stress_impact = {
				paranoid = major_stress_impact_loss
				honest = major_stress_impact_gain
			}
		}
		# If you've got one, lose your beneficial modifier.
		if = {
			limit = {
				OR = {
					has_character_modifier = high_king_of_the_seas_fp1_modifier
					has_character_modifier = high_queen_of_the_seas_fp1_modifier
				}
			}
			remove_character_modifier = high_king_of_the_seas_fp1_modifier
			remove_character_modifier = high_queen_of_the_seas_fp1_modifier
		}
		# The court is confused and afraid.
		fp1_major_decisions_1002_courtiers_terrified_effect = yes

		# Stress impact handled above due to variability.
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = -0.25
				ai_rationality = -0.75
			}
			modifier = {	# Weight up for stress.
				add = 30
				has_trait = paranoid
			}
			modifier = {	# Weight down for stress.
				add = -30
				has_trait = honest
			}
		}
	}

	# Dumb: have the ocean whipped. No shade, Xerxes.
	option = {
		name = fp1_major_decisions.1002.d
		trigger = {
			scope:type = flag:canute_dumb
			NOT = { has_trait = lunatic }
		}

		# Welp, you're having a bit of a time.
		custom_tooltip = fp1_major_decisions.1002.d.tt
		add_trait = lunatic_1
		# The court is confused and afraid.
		fp1_major_decisions_1002_courtiers_terrified_effect = yes

		stress_impact = {
			vengeful = major_stress_impact_loss
			forgiving = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = 0.5
				ai_rationality = -0.75
			}
			modifier = {	# Weight up for stress.
				add = 30
				has_trait = vengeful
			}
			modifier = {	# Weight down for stress.
				add = -10
				has_trait = forgiving
			}
		}
	}

	# Dumb: dedicate yourself to learning spellcraft.
	option = {
		name = fp1_major_decisions.1002.e
		trigger = {
			scope:type = flag:canute_dumb
			is_witch_trigger = no
		}

		# Become a witch.
		give_witch_secret_or_trait_effect = yes
		# The court is confused and afraid.
		fp1_major_decisions_1002_courtiers_terrified_effect = yes

		stress_impact = {
			cynical = medium_stress_impact_loss
			craven = medium_stress_impact_gain
			zealous = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = 0.25
				ai_sociability = -0.5
			}
			modifier = {	# Weight up for stress.
				add = 20
				has_trait = cynical
			}
			modifier = {	# Weight down for stress.
				add = -20
				has_trait = craven
			}
			modifier = {	# Weight down for stress.
				add = -20
				has_trait = zealous
			}
		}
	}
}

##################################################
# The True King of Norway
# by Ewan Cowhig Croft
# 1011-1020
##################################################

scripted_effect fp1_1011_gib_pretty_hair_effect = {
	# Gain the famous nickname.
	give_nickname = nick_fairhair
	# And a bit of diplomacy for your long vow.
	add_diplomacy_skill = 2
	# Plus that haircut.
	remove_character_modifier = harald_tanglehairs_vow_modifier
}

#	Tanglehair becomes Fairhair.
fp1_major_decisions.1011 = {
	type = character_event
	title = fp1_major_decisions.1011.t
	desc = {
		desc = fp1_major_decisions.1011.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = { exists = scope:gyda }
				desc = fp1_major_decisions.1011.desc.gyda
			}
			desc = fp1_major_decisions.1011.desc.oath
		}
		desc = fp1_major_decisions.1011.desc.outro
	}
	theme = crown
	left_portrait = {
		character = root
		animation = personality_honorable
	}
	right_portrait = {
		character = scope:gyda
		animation = admiration
	}
	override_background = { reference = fp1_ocean_norse }

	trigger = {
		# This character is Harald Fairhair.
		exists = character:144000
		this = character:144000
		# The title they've acquired is Norway.
		scope:title = title:k_norway
		# Norway has been created by them.
		scope:transfer_type = flag:created
		# Norway has not been created previously.
		NOT = { exists = global_var:norway_created }
	}

	immediate = {
		play_music_cue = "mx_cue_succession"
		# Check to see if Gyda is still around and kicking, and if so, treat this as a romance.
		character:166044 = {
			if = {
				limit = {
					is_alive = yes
					can_marry_character_trigger = { CHARACTER = root }
					has_any_bad_relationship_with_root_trigger = no
					is_ai = yes
				}
				save_scope_as = gyda
			}
		}
	}

	# My vow fulfilled!
	option = {
		name = fp1_major_decisions.1011.a

		# Apply standard haircut effects.
		fp1_1011_gib_pretty_hair_effect = yes

		ai_chance = {
			# AI should only default to this if Gyda is unavailable.
			base = 0
		}
	}
	
	# Gyda, my love!
	option = {
		name = fp1_major_decisions.1011.b
		trigger = {
			# Gyda must have been valid.
			exists = scope:gyda
			# And, for MP, remain valid.
			can_marry_character_trigger = { CHARACTER = scope:gyda }
		}

		# Apply standard haircut effects.
		fp1_1011_gib_pretty_hair_effect = yes
		# Harald & Gyda are wed.
		if = {
			limit = {
				has_ep2_dlc_trigger = yes
			}
			create_grand_wedding_betrothal = {
				SPOUSE_1 = root
				SPOUSE_2 = scope:gyda
				HOST = root
				PROMISEE = scope:gyda
			}
		}
		else = { marry = scope:gyda }
		# And rather happy about it.
		add_opinion = {
			target = scope:gyda
			modifier = love_opinion
			opinion = 50
		}
		reverse_add_opinion = {
			target = scope:gyda
			modifier = love_opinion
			opinion = 50
		}

		ai_chance = {
			# AI should always select this option if it's present.
			base = 100
		}
	}
	
	# Leave it; it is a mark of the struggles I have been through.
	option = {
		name = fp1_major_decisions.1011.c
		trigger = { is_ai = no }

		# Harald Tanglehair keeps his wild locks.
		custom_tooltip = fp1_major_decisions.1011.c.tt
		## We swap the modifiers out so the copy responds correctly.
		hidden_effect = {
			remove_character_modifier = harald_tanglehairs_vow_modifier
			add_character_modifier = harald_tanglehairs_reminder_modifier
		}
		# And a bit of learning for the lessons you've endured.
		add_learning_skill = 2

		ai_chance = {
			# Option here for player choice.
			base = 0
		}
	}
}

# Check Norway's creation status.
fp1_major_decisions.1012 = {
	hidden = yes

	# If Norway has just been created for the first time...
	trigger = {
		scope:title = title:k_norway
		scope:transfer_type = flag:created
		NOT = { exists = global_var:norway_created }
	}

	# ... flag that.
	immediate = {
		set_global_variable = {
			name = norway_created
			value = yes
		}
		# And if it's not Harald Fairhair who did it, shame him.
		if = {
			limit = {
				exists = character:144000
				NOT = { this = character:144000 }
				character:144000 = { is_alive = yes }
			}
			hidden_effect = {
				# Save the current King of Norway.
				save_scope_as = king_of_norway
				# And message Harald with the bad news.
				character:144000 = {
					send_interface_toast = {	
						title = fp1_major_decisions.1012.t
						left_icon = scope:king_of_norway
						hidden_effect = { remove_character_modifier = harald_tanglehairs_vow_modifier }
						add_character_modifier = harald_tanglehairs_vow_broken_modifier
					}
				}
			}
		}
	}
}
