﻿
namespace = claim_throne_ongoing


# claim_throne_ongoing.0001 - Liege suffers ill omens


####################
# Liege suffers ill omens
# by Petter Vilberg
####################
claim_throne_ongoing.1001 = {
	type = character_event
	title = claim_throne_ongoing.1001.t
	desc = claim_throne_ongoing.1001.desc
	theme = claim_throne_scheme
	left_portrait = {
		character = root
		animation = personality_callous
	}
	right_portrait = {
		character = scope:target
		animation = worry
	}
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	
	trigger = {
		scope:scheme = {
			NOT = { has_variable = had_event_claim_throne_ongoing_1001 }
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		scope:scheme = {
			set_variable = {
				name = had_event_claim_throne_ongoing_1001
			}
		}	
		scope:target.primary_title = {
			save_scope_as = target_title # For loc purposes
		}
	}

	option = { # Emphasise the omens
		name = claim_throne_ongoing.1001.a
		add_piety = medium_piety_loss
		scope:scheme = {
			add_scheme_modifier = {
				type = claim_throne_liege_ill_omens_modifier
			}
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = -0.5
			}
		}
	}

	option = { # Only the clergy can interpret the will of heaven
		name = claim_throne_ongoing.1001.b
		add_piety = medium_piety_gain
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_zeal = 0.5
			}
		}
	}
}

####################
# Take on more responsibility
# by Petter Vilberg
####################
claim_throne_ongoing.1002 = {
	type = character_event
	title = claim_throne_ongoing.1002.t
	desc = claim_throne_ongoing.1002.desc
	theme = claim_throne_scheme
	left_portrait = {
		character = root
		animation = personality_callous
	}
	right_portrait = {
		character = scope:target
		animation = personality_rational
	}
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	
	trigger = {
		scope:scheme = {
			NOT = { has_variable = had_event_claim_throne_ongoing_1002 }
			scheme_agent_charges >= 1
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 2
			is_councillor_of = scope:target
		}
	}

	immediate = {
		scope:scheme = {
			set_variable = {
				name = had_event_claim_throne_ongoing_1002
			}
		}		
		scope:target.primary_title = {
			save_scope_as = target_title # For loc purposes
		}
	}

	option = { # Take on more responsibility
		name = claim_throne_ongoing.1002.a
		stress_impact = {
			base = medium_stress_gain
			lazy = medium_stress_impact_gain
		}
		scope:scheme = {
			add_scheme_modifier = {
				type = claim_throne_increased_responsibility
			}
			change_opportunities = -1
		}
		if = {
			limit = { scope:target = { is_ai = no } }
			scope:target = {
				add_opinion = {
					target = scope:owner
					modifier = claim_throne_aiding_liege_opinion
					years = 10
				}
			}
		}
		ai_chance = {
			base = 100
			compare_modifier = {
				value = stress
				multiplier = -0.5
			}
			ai_value_modifier = {
				ai_energy = 1
			}
		}
	}

	option = { # Relax instead
		name = claim_throne_ongoing.1002.b
		stress_impact = {
			base = medium_stress_loss
		}
		ai_chance = {
			base = 100
		}
	}
}

####################
# Buy Support from Fellow Vassals
# by Petter Vilberg
####################
claim_throne_ongoing.1003 = {
	type = character_event
	title = claim_throne_ongoing.1003.t
	desc = claim_throne_ongoing.1003.desc
	theme = claim_throne_scheme
	left_portrait = {
		character = root
		animation = personality_callous
	}
	right_portrait = {
		character = scope:target
		animation = personality_dishonorable
	}
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	
	trigger = {
		scope:scheme = {
			NOT = { has_variable = had_event_claim_throne_ongoing_1003 }
		}
		short_term_gold > medium_gold_value
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		scope:scheme = {
			set_variable = {
				name = had_event_claim_throne_ongoing_1003
			}
		}			
		scope:target.primary_title = {
			save_scope_as = target_title # For loc purposes
		}
	}

	option = { # Of course!
		name = claim_throne_ongoing.1003.a
		remove_short_term_gold = major_gold_value
		liege = {
			every_vassal = {
				limit = { this != root }
				add_opinion = { # Opinion rather than a fellow_vassal modifier in order to sustain it even if you become their ruler
					target = root
					modifier = claim_throne_bought_support_opinion
					years = 10
				}
			}
		}
		scope:scheme = {
			add_scheme_modifier = {
				type = claim_throne_bought_support_modifier
			}
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = -0.5
			}
		}
	}

	option = { # I will need the gold for other things
		name = claim_throne_ongoing.1003.b
		add_character_modifier = {
			modifier = claim_throne_preparing_for_struggle_modifier
			years = 10
		}
		ai_chance = {
			base = 100
		}
	}
}

####################
# Lunatic takes it by confidence alone
# by Petter Vilberg
####################
claim_throne_ongoing.1004 = {
	type = character_event
	title = claim_throne_ongoing.1004.t
	desc = claim_throne_ongoing.1004.desc
	theme = claim_throne_scheme
	left_portrait = {
		character = root
		animation = eccentric
	}
	right_portrait = {
		character = scope:target
		animation = boredom
	}
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	
	trigger = {
		has_trait = lunatic
		scope:scheme = {
			NOT = { has_variable = had_event_claim_throne_ongoing_1004 }
			scheme_agent_charges >= 1
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		scope:scheme = {
			set_variable = {
				name = had_event_claim_throne_ongoing_1004
			}
		}			
		scope:target.primary_title = {
			save_scope_as = target_title # For loc purposes
		}
	}

	option = { # Of course!
		name = claim_throne_ongoing.1004.a
		trait = lunatic_1
		trait = lunatic_genetic
		scope:target = {
			add_opinion = {
				target = root
				modifier = claim_throne_self_declared_opinion
				years = 10
			}
		}
		scope:scheme = {
			add_scheme_modifier = {
				type = claim_throne_self_declared_modifier
			}
			change_opportunities = -1
		}
		ai_chance = {
			base = 100
		}
	}

	option = { # Why only the kingdom??
		name = claim_throne_ongoing.1004.b
		flavor = claim_throne_ongoing.1004.b_flavor
		trait = lunatic_1
		trait = lunatic_genetic
		add_character_modifier = {
			modifier = claim_throne_claimed_world_modifier
			years = 10
		}
		ai_chance = {
			base = 30
		}
	}

	after = {
		random = {
			chance = 75
			trigger_event = {
				id = claim_throne_ongoing.1005
				days = { 300 400 }
			}
		}
	}
}

# Lunatic follow-up
claim_throne_ongoing.1005 = {
	type = character_event
	title = claim_throne_ongoing.1005.t
	desc = claim_throne_ongoing.1005.desc
	theme = claim_throne_scheme
	left_portrait = {
		character = root
		animation = worry
	}
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	
	trigger = {
		OR = { # Check that the character still has the relevant modifier
			AND = {
				exists = scope:scheme
				scope:scheme = {
					has_scheme_modifier = claim_throne_self_declared_modifier
				}
			}
			any_scheme = {
				has_scheme_modifier = claim_throne_self_declared_modifier
			}
			has_character_modifier = claim_throne_claimed_world_modifier
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		if = {
			limit = {
				NOT = { exists = scope:scheme }
				any_scheme = {
					has_scheme_modifier = claim_throne_self_declared_modifier
				}
			}
			random_scheme = {
				limit = {
					has_scheme_modifier = claim_throne_self_declared_modifier
				}
				save_scope_as = scheme
			}
		}
	}

	option = { # What have I been doing?
		name = claim_throne_ongoing.1005.a
		if = {
			limit = {
				has_character_modifier = claim_throne_claimed_world_modifier
			}
			remove_character_modifier = claim_throne_claimed_world_modifier
		}
		if = {
			limit = {
				exists = scope:scheme
				scope:scheme = {
					has_scheme_modifier = claim_throne_self_declared_modifier
				}
			}
			scope:scheme = {
				remove_scheme_modifier = claim_throne_self_declared_modifier
			}
		}
		stress_impact = {
			arrogant = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = 1
			}
		}
	}

	option = { # No, I never make mistakes...
		name = claim_throne_ongoing.1005.b
		stress_impact = {
			base = medium_stress_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				add = 50
				has_trait = arrogant
			}
		}
	}
}


####################
# A Friend swears they will support your claim
# by Petter Vilberg
####################
scripted_trigger claim_throne_ongoing_1006_friend_trigger = {
	this != scope:target
	top_liege = root.top_liege # Is in the same realm
	NOT = { has_relation_friend = scope:target }
}

claim_throne_ongoing.1006 = {
	type = character_event
	title = claim_throne_ongoing.1006.t
	desc = claim_throne_ongoing.1006.desc
	theme = claim_throne_scheme
	left_portrait = {
		character = root
		animation = personality_callous
	}
	right_portrait = {
		character = scope:friend
		animation = personality_bold
	}
	lower_right_portrait = scope:target
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	
	trigger = {
		scope:scheme = {
			NOT = { has_variable = had_event_claim_throne_ongoing_1006 }
			scheme_agent_charges >= 1
		}
		any_relation = {
			type = friend
			claim_throne_ongoing_1006_friend_trigger = yes
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		scope:scheme = {
			set_variable = {
				name = had_event_claim_throne_ongoing_1006
			}
		}	
		random_relation = {
			type = friend
			limit = {
				claim_throne_ongoing_1006_friend_trigger = yes
			}
			save_scope_as = friend
		}			
		scope:target.primary_title = {
			save_scope_as = target_title # For loc purposes
		}
	}

	option = { # Of course!
		name = claim_throne_ongoing.1006.a
		scope:scheme = {
			add_scheme_modifier = {
				type = claim_throne_friend_support_modifier
			}
			change_opportunities = -1
		}
		ai_chance = {
			base = 100
		}
	}

	option = { # Don't support my claim, but rather my character
		name = claim_throne_ongoing.1006.b
		add_prestige = medium_prestige_gain
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_rationality = 0.5
			}
		}
	}
}

####################
# Get a Knight on Your Side
# by David Johansson
####################

scripted_trigger claim_throne_ongoing_1007_knight_trigger = {
	is_ai = yes
	this != root
	scope:scheme = {
		NOT = { scheme_is_character_agent = prev }
	}
	char_can_fit_into_scheme_trigger = { SCHEME = scope:scheme }
	opinion = {
		target = liege
		value <= 0
	}
	NOT = {
		has_friendly_relationship_trigger = {
			CHARACTER = scope:target
		}
	}
}

claim_throne_ongoing.1007 = {
	type = character_event
	title = claim_throne_ongoing.1007.t
	desc = claim_throne_ongoing.1007.desc
	theme = claim_throne_scheme

	left_portrait = {
		character = root
		animation = personality_callous
	}
	right_portrait = {
		character = scope:scheming_knight
		animation = personality_bold
	}
	lower_right_portrait = scope:target
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	
	trigger = {
		scope:scheme = {
			NOT = { has_variable = had_event_claim_throne_ongoing_1007 }
		}
		scope:target = {
			any_knight = { claim_throne_ongoing_1007_knight_trigger = yes }
		}
		short_term_gold > medium_gold_value
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		scope:scheme = {
			set_variable = {
				name = had_event_claim_throne_ongoing_1007
			}
		}
		scope:target = { # scope to schemed-against liege
			primary_title = { save_scope_as = target_title } # For loc purposes
			random_knight = { # one of their knights
				limit = { claim_throne_ongoing_1007_knight_trigger = yes }
				save_scope_as = scheming_knight
			}
		}
	}

	option = { # Turn the Knights against their liege
		name = claim_throne_ongoing.1007.a
		add_prestige = minor_prestige_loss
		scope:scheme = {
			add_scheme_modifier = {
				type = claim_throne_rule_sword_modifier
			}
		}
		if = {
			limit = {
				scope:scheming_knight = { claim_throne_ongoing_1007_knight_trigger = yes }
			}
			remove_short_term_gold = medium_gold_value
			try_to_force_assign_character_to_random_agent_slot_effect = {
				SCHEME = scope:scheme
				CHAR = scope:scheming_knight
				YEARS = 5
			}
		}
		stress_impact = {
			greedy = miniscule_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = -0.5
			}
		}
	}

	option = { # This isn't right. 
		name = claim_throne_ongoing.1007.b
		add_prestige = medium_prestige_gain
		stress_impact = {
			arrogant = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 1
			}
		}
	}
}


####################
# Claim the throne using trickery
# by David Johansson
####################
claim_throne_ongoing.1008 = {
	type = character_event
	title = claim_throne_ongoing.1008.t
	desc = claim_throne_ongoing.1008.desc
	theme = claim_throne_scheme
	left_portrait = {
		character = root
		animation = writing
	}
	right_portrait = {
		character = scope:target
		animation = boredom
	}
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	
	trigger = {
		has_trait_rank = {
			trait = education_intrigue
			rank >= 1
		}
		scope:scheme = {
			NOT = { has_variable = had_event_claim_throne_ongoing_1008 }
			scheme_agent_charges >= 1
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		scope:scheme = {
			set_variable = {
				name = had_event_claim_throne_ongoing_1008
			}
		}			
		scope:target.primary_title = {
			save_scope_as = target_title # For loc purposes
		}
	}

	option = { # Fool the peasants
		name = claim_throne_ongoing.1008.a
		scope:target = {
			add_opinion = {
				target = root
				modifier = claim_throne_tricked_peasants_opinion
			}
		}
		scope:scheme = {
			add_scheme_modifier = {
				type = claim_throne_tricked_peasants_modifier
			}
			change_opportunities = -1
		}

		stress_impact = {
			honest = minor_stress_impact_gain
			just = minor_stress_impact_gain
		}

		ai_chance = {
			base = 30
		}
	}

	option = { # Fool the nobles
		name = claim_throne_ongoing.1008.b
		trigger_event = {
			id = claim_throne_ongoing.1009
			days = { 50 100 }
		}
		scope:scheme = {
			add_scheme_modifier = {
				type = claim_throne_tricked_nobles_modifier
			}
			change_opportunities = -1
		}

		stress_impact = {
			honest = minor_stress_impact_gain
			just = minor_stress_impact_gain
		}
		
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_boldness = 1
			}
		}
	}

	option = { #Stay out of it
		name = claim_throne_ongoing.1008.c
		flavor = claim_throne_ongoing.1008.c.tt
		add_learning_skill = 1
		stress_impact = {
			ambitious  = minor_stress_impact_gain
			impatient = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 1
			}
		}
	}
}

# Trickery follow-up. Someone is onto you. 
claim_throne_ongoing.1009 = {
	type = character_event
	title = claim_throne_ongoing.1009.t
	desc = claim_throne_ongoing.1009.desc
	theme = claim_throne_scheme
	left_portrait = {
		character = root
		animation = worry
	}
	right_portrait = {
		character = scope:fraud_catcher
		animation = anger
	}
	lower_right_portrait = scope:target
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	
	trigger = {
		exists = scope:scheme
		scope:target = {
			is_ai = yes
			any_courtier_or_guest = {
				learning >= good_skill_level
				save_temporary_scope_as = potential_snitch
			}
 		}
		scope:scheme = {
			has_scheme_modifier = claim_throne_tricked_nobles_modifier
			NOT = { any_scheme_agent_character = { this = scope:potential_snitch } }
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		scope:target = {
			random_courtier_or_guest = {
				limit = {
					learning >= good_skill_level
					save_temporary_scope_as = potential_snitch
					scope:scheme = {
						NOT = { any_scheme_agent_character = { this = scope:potential_snitch } }
					}
				}
				save_scope_as = fraud_catcher
			}
		}
	}

	option = { # You're right, I was just kidding. 
		name = claim_throne_ongoing.1009.a
		if = {
			limit = {
				exists = scope:scheme
				scope:scheme = {
					has_scheme_modifier = claim_throne_tricked_nobles_modifier
				}
			}
			scope:scheme = {
				remove_scheme_modifier = claim_throne_tricked_nobles_modifier
			}
		}
		scope:target = {
			add_opinion = {
				target = root
				modifier = claim_throne_forged_letter_opinion
			}
		}
		stress_impact = {
			arrogant = minor_stress_impact_gain
			honest = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = 1
			}
		}
	}

	option = { # Double Down
		name = claim_throne_ongoing.1009.b
		duel = {
			skill = learning
			target = scope:fraud_catcher
			10 = {
				desc = claim_throne_ongoing.1009.b.duel_success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 1
				}
				modifier = {
					add = 5
					has_trait = education_intrigue_2
				}
				send_interface_toast = {
					left_icon = root
					title = tooltip.claim_throne_ongoing.1009.b.duel_success
					scope:scheme = {
						add_scheme_modifier = {
							type = claim_throne_fooled_them_all_modifier
						}
					}
				}
			}
			5 = {
				desc = claim_throne_ongoing.1009.b.duel_failure 
				modifier = {
					add = 5
					has_trait = honest
				}
				send_interface_toast = {
					left_icon = root
					title = tooltip.claim_throne_ongoing.1009.b.duel_failure
					add_prestige = medium_prestige_loss
					scope:scheme = {
						remove_scheme_modifier = claim_throne_tricked_nobles_modifier
					}
				}
			}
		}

		ai_chance = {
			base = 50
			modifier = {
				add = 50
				has_trait = stubborn
			}
		}
	}
}
