﻿namespace = agot_hf_revealbastard_events


# EVENT START
agot_hf_revealbastard_events.0001 = {
	type = character_event
	title = agot_hf_revealbastard_events.0001.t
	desc = agot_hf_revealbastard_events.0001.desc

	theme = court

	override_background = {
		reference = courtyard
	}

	right_portrait = {
		character = scope:bastard_character
		animation = idle
	}

	immediate = {
		# add liege to the list of possible fathers
		if = {
			limit = {
				exists = scope:bastard_character.liege
				scope:bastard_character.liege = {
					is_adult = yes
					is_male = yes
				}
			}
			scope:story = {
				add_to_variable_list = {
					name = agot_hf_possible_father
					target = scope:bastard_character.liege
				}
			}
		}
		# add top liege to the list of possible fathers
		if = {
			limit = {
				exists = scope:bastard_character.top_liege
				scope:bastard_character.top_liege = {
					is_adult = yes
					is_male = yes
				}
				NOT = { scope:bastard_character.liege = scope:bastard_character.top_liege }
			}
			scope:story = {
				add_to_variable_list = {
					name = agot_hf_possible_father
					target = scope:bastard_character.top_liege
				}
			}
		}
		# add the real father to the list of possible fathers
		if = {
			limit = {
				NOT = { scope:bastard_character.real_father = scope:bastard_character.liege }
				NOT = { scope:bastard_character.real_father = scope:bastard_character.top_liege }
			}
			scope:story = {
				add_to_variable_list = {
					name = agot_hf_possible_father
					target = scope:bastard_character.real_father
				}
			}
		}
		# add random courtier to the list of possible fathers
		if = {
			limit = {
				exists = scope:bastard_character.liege
				scope:bastard_character.liege = {
					any_courtier = {
						count >= 1
						is_adult = yes
						is_male = yes
						NOT = { this = scope:bastard_character.liege }
						NOT = { this = scope:bastard_character.top_liege }
						NOT = { this = scope:bastard_character.real_father }
						NOT = { house = scope:bastard_character.mother.house }
						NOT = { house = scope:bastard_character.real_father.house }
						NOT = { house = scope:bastard_character.liege.house }
					}
				}
			}
			scope:bastard_character.liege = {
				random_courtier = {
					limit = {
						is_adult = yes
						is_male = yes
						NOT = { this = scope:bastard_character.liege }
						NOT = { this = scope:bastard_character.top_liege }
						NOT = { this = scope:bastard_character.real_father }
						NOT = { house = scope:bastard_character.mother.house }
						NOT = { house = scope:bastard_character.real_father.house }
						NOT = { house = scope:bastard_character.liege.house }
					}
					scope:story = {
						add_to_variable_list = {
							name = agot_hf_possible_father
							target = prev
						}
					}
				}
			}
		}
		# add random house member of the mother to the list of possible fathers
		if = {
			limit = {
				exists = scope:bastard_character.mother.house
				scope:bastard_character.mother.house = {
					any_house_member = {
						count >= 1
						is_adult = yes
						is_male = yes
						NOT = { this = scope:bastard_character.liege }
						NOT = { this = scope:bastard_character.top_liege }
						NOT = { this = scope:bastard_character.real_father }
						NOT = { house = scope:bastard_character.real_father.house }
						NOT = { house = scope:bastard_character.liege.house }
					}
				}
			}
			scope:bastard_character.mother.house = {
				random_house_member = {
					limit = {
						is_adult = yes
						is_male = yes
						NOT = { this = scope:bastard_character.liege }
						NOT = { this = scope:bastard_character.top_liege }
						NOT = { this = scope:bastard_character.real_father }
						NOT = { house = scope:bastard_character.real_father.house }
						NOT = { house = scope:bastard_character.liege.house }
					}
					scope:story = {
						add_to_variable_list = {
							name = agot_hf_possible_father
							target = prev
						}
					}
				}
			}
		}
		# add random house member of the real father to the list of possible fathers
		if = {
			limit = {
				exists = scope:bastard_character.real_father.house
				scope:bastard_character.real_father.house = {
					any_house_member = {
						count >= 1
						is_adult = yes
						is_male = yes
						NOT = { this = scope:bastard_character.liege }
						NOT = { this = scope:bastard_character.top_liege }
						NOT = { this = scope:bastard_character.real_father }
						NOT = { house = scope:bastard_character.mother.house }
						NOT = { house = scope:bastard_character.liege.house }
					}
				}
			}
			scope:bastard_character.real_father.house = {
				random_house_member = {
					limit = {
						is_adult = yes
						is_male = yes
						NOT = { this = scope:bastard_character.liege }
						NOT = { this = scope:bastard_character.top_liege }
						NOT = { this = scope:bastard_character.real_father }
						NOT = { house = scope:bastard_character.mother.house }
						NOT = { house = scope:bastard_character.liege.house }
					}
					scope:story = {
						add_to_variable_list = {
							name = agot_hf_possible_father
							target = prev
						}
					}
				}
			}
		}
		# add random house member of the liege to the list of possible fathers
		if = {
			limit = {
				exists = scope:bastard_character.liege.house
				scope:bastard_character.liege.house = {
					any_house_member = {
						count >= 1
						is_adult = yes
						is_male = yes
						NOT = { this = scope:bastard_character.liege }
						NOT = { this = scope:bastard_character.top_liege }
						NOT = { this = scope:bastard_character.real_father }
						NOT = { house = scope:bastard_character.mother.house }
						NOT = { house = scope:bastard_character.real_father.house }
					}
				}
			}
			scope:bastard_character.liege.house = {
				random_house_member = {
					limit = {
						is_adult = yes
						is_male = yes
						NOT = { this = scope:bastard_character.liege }
						NOT = { this = scope:bastard_character.top_liege }
						NOT = { this = scope:bastard_character.real_father }
						NOT = { house = scope:bastard_character.mother.house }
						NOT = { house = scope:bastard_character.real_father.house }
					}
					scope:story = {
						add_to_variable_list = {
							name = agot_hf_possible_father
							target = prev
						}
					}
				}
			}
		}
	}

	option = {
		name = agot_hf_revealbastard_events.0001.a
	}
}

# BASTARD DIED
agot_hf_revealbastard_events.0002 = {
	type = character_event
	title = agot_hf_revealbastard_events.0002.t
	desc = agot_hf_revealbastard_events.0002.desc

	theme = bastardy

	override_background = {
		reference = courtyard
	}

	right_portrait = {
		character = scope:bastard_character
		animation = idle
	}

	immediate = { agot_hf_revealbastard_story_end_effect = yes }

	option = {
		name = agot_hf_revealbastard_events.0002.a
	}
}

# BASTARD DIED, OR IS IT?
agot_hf_revealbastard_events.0003 = {
	type = character_event
	title = agot_hf_revealbastard_events.0003.t
	desc = agot_hf_revealbastard_events.0003.desc

	theme = bastardy

	override_background = {
		reference = courtyard
	}

	right_portrait = {
		character = scope:the_dupe
		animation = idle
	}

	immediate = {
		scope:bastard_character.var:secret_identity_character = { save_scope_as = the_dupe }
		agot_hf_revealbastard_story_end_effect = yes
	}

	option = {
		name = agot_hf_revealbastard_events.0003.a
	}
}

# BASTARD ALREADY REVEALED
agot_hf_revealbastard_events.0004 = {
	type = character_event
	title = agot_hf_revealbastard_events.0004.t
	desc = agot_hf_revealbastard_events.0004.desc

	theme = bastardy

	override_background = {
		reference = courtyard
	}

	right_portrait = {
		character = scope:bastard_character
		animation = idle
	}

	immediate = { agot_hf_revealbastard_story_end_effect = yes }

	trigger = { NOT = { has_variable = agot_hf_revealbastard_completed } }

	option = {
		name = agot_hf_revealbastard_events.0004.a
	}
}

# INVESTIGATION STAGE 1
agot_hf_revealbastard_events.0005 = {
	type = character_event
	title = agot_hf_revealbastard_events.0005.t
	desc = agot_hf_revealbastard_events.0005.desc

	theme = bastardy

	override_background = {
		reference = courtyard
	}

	right_portrait = {
		character = scope:bastard_character
		animation = idle
	}

	lower_left_portrait = {
		character = scope:suspect_a
	}

	immediate = {
		agot_hf_revealbastard_liege_finder = yes
		scope:story = {
			random_in_list = {
				variable = agot_hf_possible_father
				save_scope_as = suspect_a
			}
		}
	}

	option = {
		name = agot_hf_revealbastard_events.0005.a
	}

	option = {
		name = agot_hf_revealbastard_events.0005.b
		trigger = { is_ai = no }
		custom_tooltip = agot_hf_revealbastard_investigation_cancel

		agot_hf_revealbastard_story_end_effect = yes
	}
}

# INVESTIGATION STAGE 2
agot_hf_revealbastard_events.0006 = {
	type = character_event
	title = agot_hf_revealbastard_events.0006.t
	desc = agot_hf_revealbastard_events.0006.desc

	theme = bastardy

	override_background = {
		reference = courtyard
	}

	right_portrait = {
		character = scope:bastard_character
		animation = idle
	}

	lower_left_portrait = {
		character = scope:suspect_a
	}

	immediate = {
		agot_hf_revealbastard_liege_finder = yes
		scope:story = {
			random_in_list = {
				variable = agot_hf_possible_father
				save_scope_as = suspect_a
			}
		}
		agot_hf_revealbastard_busted_effect = yes
	}

	option = {
		name = agot_hf_revealbastard_events.0006.a
	}

	option = {
		name = agot_hf_revealbastard_events.0006.b
		trigger = { is_ai = no }
		custom_tooltip = agot_hf_revealbastard_investigation_cancel

		agot_hf_revealbastard_story_end_effect = yes
	}
}

# INVESTIGATION STAGE 3
agot_hf_revealbastard_events.0007 = {
	type = character_event
	title = agot_hf_revealbastard_events.0007.t
	desc = agot_hf_revealbastard_events.0007.desc

	theme = bastardy

	override_background = {
		reference = courtyard
	}

	right_portrait = {
		character = scope:bastard_character
		animation = idle
	}

	lower_left_portrait = {
		character = scope:suspect_a
	}

	lower_center_portrait = {
		character = scope:suspect_b
	}

	immediate = {
		agot_hf_revealbastard_liege_finder = yes
		scope:story = {
			random_in_list = {
				variable = agot_hf_possible_father
				save_scope_as = suspect_a
			}
			random_in_list = {
				variable = agot_hf_possible_father
				limit = { NOT = { this = scope:suspect_a } }
				save_scope_as = suspect_b
			}
		}
	}

	option = {
		name = agot_hf_revealbastard_events.0007.a
	}

	option = {
		name = agot_hf_revealbastard_events.0007.b
		trigger = { is_ai = no }
		custom_tooltip = agot_hf_revealbastard_investigation_cancel

		agot_hf_revealbastard_story_end_effect = yes
	}
}

# INVESTIGATION STAGE 4
agot_hf_revealbastard_events.0008 = {
	type = character_event
	title = agot_hf_revealbastard_events.0008.t
	desc = agot_hf_revealbastard_events.0008.desc

	theme = bastardy

	override_background = {
		reference = courtyard
	}

	right_portrait = {
		character = scope:bastard_character
		animation = idle
	}

	lower_left_portrait = {
		character = scope:suspect_a
	}

	immediate = {
		agot_hf_revealbastard_liege_finder = yes
		random_list = {
			10 = {
				scope:story = {
					random_in_list = {
						variable = agot_hf_possible_father
						limit = { NOT = { this = scope:bastard_character.real_father } }
						save_scope_as = suspect_a
					}
				}
				add_character_flag = agot_hf_witness_was_wrong
			}
			10 = {
				scope:bastard_character.real_father = { save_scope_as = suspect_a }
				add_character_flag = agot_hf_witness_was_right
			}
		}
	}

	option = {
		name = agot_hf_revealbastard_events.0008.a

		ai_chance = {
			base = 50
		}
	}

	option = {
		trigger = { scope:bastard_character = { NOT = { has_character_flag = agot_hf_royal_bastard } } }
		name = agot_hf_revealbastard_events.0008.b
		custom_tooltip = agot_hf_revealbastard_events.0008.b.tt

		if = {
			limit = { NOT = { scope:suspect_a = scope:bastard_character.real_father } }
			trigger_event = {
				id = agot_hf_revealbastard_events.0013
				days = 1
			}
		}
		else = {
			trigger_event = agot_hf_revealbastard_events.0010
		}

		ai_chance = {
			base = 1

			ai_value_modifier = {
				ai_rationality = -1
			}
		}
	}
}

# INVESTIGATION FINAL
agot_hf_revealbastard_events.0009 = {
	type = character_event
	title = agot_hf_revealbastard_events.0009.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { has_character_flag = agot_hf_witness_was_wrong }
				desc = agot_hf_revealbastard_events.0009.desc.untrue
			}
			triggered_desc = {
				trigger = { has_character_flag = agot_hf_witness_was_right }
				desc = agot_hf_revealbastard_events.0009.desc.true
			}
		}
	}

	theme = bastardy

	override_background = {
		reference = courtyard
	}

	right_portrait = {
		character = scope:bastard_character
		animation = idle
	}

	lower_left_portrait = {
		character = scope:true_father
	}

	immediate = {
		agot_hf_revealbastard_liege_finder = yes
		scope:bastard_character.real_father = { save_scope_as = true_father }
	}

	option = {
		trigger = { scope:bastard_character = { NOT = { has_character_flag = agot_hf_royal_bastard } } }
		name = agot_hf_revealbastard_events.0009.a

		trigger_event = agot_hf_revealbastard_events.0010

		ai_chance = {
			base = 75
		}
	}

	option = {
		name = agot_hf_revealbastard_events.0009.b

		agot_hf_revealbastard_story_end_effect = yes

		ai_chance = {
			base = 1

			ai_value_modifier = {
				ai_boldness = -1
			}
		}
	}

	option = {
		trigger = { scope:bastard_character = { has_character_flag = agot_hf_royal_bastard } }
		name = agot_hf_revealbastard_events.0009.c
		custom_tooltip = agot_hf_revealbastard_events.0009.c.tt

		add_secret = {
			type = secret_agot_disputed_heritage
			target = scope:bastard_character
		}

		agot_hf_revealbastard_story_end_effect = yes

		ai_chance = {
			base = 100
		}
	}

	after = {
		if = {
			limit = { has_character_flag = agot_hf_witness_was_wrong }
			remove_character_flag = agot_hf_witness_was_wrong
		}
		if = {
			limit = { has_character_flag = agot_hf_witness_was_right }
			remove_character_flag = agot_hf_witness_was_right
		}
	}
}

#THE TRUTH
agot_hf_revealbastard_events.0010 = {
	type = character_event
	hidden = yes

	immediate = {
		save_scope_as = i_am_the_exposer
		agot_hf_revealbastard_liege_finder = yes
		agot_hf_revealbastard_final_effect = yes
		agot_hf_revealbastard_set_claims_and_events_effect = yes
	}
}

#IS A BASTARD!
agot_hf_revealbastard_events.0011 = {
	type = character_event
	title = agot_hf_revealbastard_events.0011.t
	theme = bastardy

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:the_legit_bastard
					scope:agot_hf_is_bastard = scope:the_legit_bastard
					NOT = { scope:bastard_character = scope:bastard_character.top_liege }
				}
				desc = agot_hf_revealbastard_events.0011.normal.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:the_legit_bastard
					scope:agot_hf_is_bastard = scope:the_legit_bastard
					scope:bastard_character = scope:bastard_character.top_liege
				}
				desc = agot_hf_revealbastard_events.0011.top_liege.desc
			}
			desc = agot_hf_revealbastard_events.0011.base.desc
		}
	}

	override_background = {
		reference = bedchamber
	}

	left_portrait = {
		character = scope:bastard_character
		animation = worry
	}
	right_portrait = scope:bastard_character.real_father
	lower_right_portrait = scope:bastard_revealer

	immediate = {
		scope:bastard_character = {
			if = {
				limit = {
					any_sibling = {
						is_alive = yes
						has_trait = disputed_heritage
						exists = real_father
						real_father = scope:bastard_character.real_father
						mother = scope:bastard_character.mother
					}
				}
				every_sibling = {
					limit = {
						is_alive = yes
						has_trait = disputed_heritage
						exists = real_father
						real_father = scope:bastard_character.real_father
						mother = scope:bastard_character.mother
					}
					add_character_flag = {
						flag = agot_hf_bastard_sibling
						days = 40
					}
				}
				trigger_event = agot_hf_revealbastard_events.0022
			}
		}
	}

	option = {
		name = agot_hf_revealbastard_events.0011.a
		trigger = {
			NOT = { this = scope:bastard_revealer }
			NOT = { this = scope:bastard_character.real_father }
			NOT = { this = scope:bastard_character }
		}

		hidden_effect = {
			if = {
				limit = { scope:bastard_character = { is_playable_character = yes } }
				add_opinion = {
					target = scope:bastard_character
					opinion = -45
					modifier = agot_hf_revealbastard_illegitimate_ruler_opinion
				}
			}
		}

		ai_chance = {
			base = 75
			modifier = {
				add = 100
				has_trait = honest
			}
		}
	}

	option = {
		name = agot_hf_revealbastard_events.0011.b
		trigger = {
			NOT = { this = scope:bastard_revealer }
			NOT = { this = scope:bastard_character.real_father }
		}

		hidden_effect = {
			if = {
				limit = { scope:bastard_character = { is_playable_character = yes } }
				add_opinion = {
					target = scope:bastard_character
					opinion = -65
					modifier = agot_hf_revealbastard_illegitimate_ruler_opinion
				}
			}
		}

		ai_chance = {
			base = 25
			modifier = {
				add = 50
				has_trait = deceitful
			}
			modifier = {
				add = 50
				has_trait = humble
			}
		}
	}

	option = {
		name = agot_hf_revealbastard_events.0011.c
		trigger = { this = scope:bastard_revealer }
		ai_chance = {
			base = 1
		}
	}

	option = {
		name = agot_hf_revealbastard_events.0011.d
		trigger = {
			this = scope:bastard_character.real_father
			NOT = { this = scope:bastard_revealer }
		}

		add_opinion = {
			target = scope:bastard_revealer
			opinion = -45
			modifier = agot_hf_revealbastard_revealed_the_truth_bad
		}

		if = {
			limit = {
				is_landed = yes
				highest_held_title_tier > tier_barony
				scope:bastard_revealer = { NOT = { is_imprisoned = yes } }
				OR = {
					this = scope:bastard_revealer.liege
					this = scope:bastard_revealer.top_liege
				}
			}
			hard_imprison_character_effect = {
				TARGET = scope:bastard_revealer
				IMPRISONER = scope:suspect_a
			}
		}

		ai_chance = {
			base = 1

			ai_value_modifier = {
				ai_vengefulness = 1
			}
		}
	}

	option = {
		name = agot_hf_revealbastard_events.0011.e
		trigger = { this = scope:bastard_character.real_father }

		add_opinion = {
			target = scope:bastard_revealer
			opinion = -45
			modifier = agot_hf_revealbastard_revealed_the_truth_bad
		}

		ai_chance = {
			base = 50
		}
	}

	option = {
		name = agot_hf_revealbastard_events.0011.d
		trigger = {
			this = scope:bastard_character
			is_landed = yes
			trigger_if = {
				limit = { scope:bastard_character.real_father = { is_alive = yes } }
				scope:bastard_character.real_father = { NOT = { is_landed = yes } }
			}
		}

		add_opinion = {
			target = scope:bastard_revealer
			opinion = -45
			modifier = agot_hf_revealbastard_revealed_the_truth_bad
		}

		if = {
			limit = {
				is_landed = yes
				highest_held_title_tier > tier_barony
				scope:bastard_revealer = { NOT = { is_imprisoned = yes } }
				OR = {
					this = scope:bastard_revealer.liege
					this = scope:bastard_revealer.top_liege
				}
			}
			hard_imprison_character_effect = {
				TARGET = scope:bastard_revealer
				IMPRISONER = scope:suspect_a
			}
		}

		ai_chance = {
			base = 1

			ai_value_modifier = {
				ai_vengefulness = 1
			}
		}
	}

	option = {
		name = agot_hf_revealbastard_events.0011.e
		trigger = { this = scope:bastard_character }

		add_opinion = {
			target = scope:bastard_revealer
			opinion = -45
			modifier = agot_hf_revealbastard_revealed_the_truth_bad
		}

		ai_chance = {
			base = 50
		}
	}

	after = {
		scope:bastard_character = {
			if = {
				limit = {
					is_playable_character = no
					agot_can_be_ruler = yes
					is_adult = yes
				}
				random = {
					chance = {
						value = ai_boldness
						divide = 2
					}
					create_landless_adventurer_title_effect = {
						REASON = flag:voluntary
						FLAVOR_CHAR = scope:bastard_character
					}
					scope:bastard_character = { save_scope_as = my_bastard_child }
					if = {
						limit = {
							real_father = {
								is_alive = yes
								is_landed = yes
								highest_held_title_tier > tier_barony
							}
						}
						real_father = { trigger_event = agot_hf_revealbastard_events.0015 }
					}
				}
			}
		}
	}
}

#IS NOT A BASTARD!
agot_hf_revealbastard_events.0012 = {
	type = character_event
	title = agot_hf_revealbastard_events.0012.t

	theme = court

	desc = {
		desc = agot_hf_revealbastard_events.0012.desc
	}

	override_background = {
		reference = relaxing_room
	}

	left_portrait = {
		character = scope:bastard_character
		animation = thinking
	}
	right_portrait = scope:bastard_character.real_father
	lower_right_portrait = scope:bastard_revealer

	option = {
		name = agot_hf_revealbastard_events.0012.a
		trigger = { NOT = { this = scope:bastard_revealer } }

		ai_chance = {
			base = 1
		}
	}

	option = {
		name = agot_hf_revealbastard_events.0011.c
		trigger = { this = scope:bastard_revealer }

		ai_chance = {
			base = 1
		}
	}
}

#FALSE ACCUSATION
agot_hf_revealbastard_events.0013 = {
	type = character_event
	title = agot_hf_revealbastard_events.0013.t
	desc = agot_hf_revealbastard_events.0013.desc

	theme = court

	override_background = {
		reference = courtyard
	}

	right_portrait = {
		character = scope:suspect_a
		animation = anger
	}

	lower_left_portrait = {
		character = scope:bastard_character
	}

	immediate = {
		agot_hf_revealbastard_liege_finder = yes
		agot_hf_revealbastard_story_end_effect = yes
	}

	option = {
		name = agot_hf_revealbastard_events.0013.a

		if = {
			limit = {
				scope:suspect_a = {
					is_landed = yes
					highest_held_title_tier > tier_barony
				}
			}
			scope:suspect_a = { trigger_event = agot_hf_revealbastard_events.0014 }
		}

		show_as_tooltip = {
			scope:suspect_a = {
				add_opinion = {
					target = scope:bastard_revealer
					opinion = -90
					modifier = insult_opinion
				}
			}
		}
	}
}

#REACTION TO FALSE ACCUSATION
agot_hf_revealbastard_events.0014 = {
	type = character_event
	title = agot_hf_revealbastard_events.0014.t
	desc = agot_hf_revealbastard_events.0014.desc

	theme = court

	override_background = {
		reference = courtyard
	}

	right_portrait = {
		character = scope:bastard_revealer
		animation = scheme
	}

	lower_left_portrait = {
		character = scope:bastard_character
	}

	immediate = {
		agot_hf_revealbastard_liege_finder = yes
		scope:suspect_a = {
			add_opinion = {
				target = scope:bastard_revealer
				opinion = -90
				modifier = insult_opinion
			}
		}
	}

	option = {
		name = agot_hf_revealbastard_events.0014.a

		if = {
			limit = {
				is_landed = yes
				highest_held_title_tier > tier_barony
				OR = {
					this = scope:bastard_revealer.liege
					this = scope:bastard_revealer.top_liege
				}
			}
			hard_imprison_character_effect = {
				TARGET = scope:bastard_revealer
				IMPRISONER = scope:suspect_a
			}
		}

		ai_chance = {
			base = 1

			ai_value_modifier = {
				ai_vengefulness = 1
			}
		}
	}

	option = {
		name = agot_hf_revealbastard_events.0014.b

		ai_chance = {
			base = 1
		}
	}
}

#BASTARD BECAME LAAMP
agot_hf_revealbastard_events.0015 = {
	type = character_event
	title = agot_hf_revealbastard_events.0015.t
	desc = agot_hf_revealbastard_events.0015.desc

	theme = court

	override_background = {
		reference = courtyard
	}

	right_portrait = {
		character = scope:my_bastard_child
		animation = war_defender
	}

	immediate = {
		agot_hf_revealbastard_liege_finder = yes
	}

	option = {
		name = agot_hf_revealbastard_events.0015.a
	}
}

#YOINK EVENT
agot_hf_revealbastard_events.0016 = {
	type = character_event
	title = agot_hf_revealbastard_events.0016.t
	desc = agot_hf_revealbastard_events.0016.desc

	theme = court

	override_background = {
		reference = courtyard
	}

	right_portrait = {
		character = scope:bastard_character
		animation = idle
	}

	trigger = {
		scope:bastard_character.mother = { is_alive = yes }
		scope:bastard_character = {
			is_alive = yes
			is_playable_character = no
			is_adult = no
			is_married = no
			is_concubine = no
			NOT = {
				any_relation = {
					type = agot_dragon
				}
			}
			is_human = yes
		}
	}

	immediate = {
		scope:bastard_character = {
			add_character_flag = {
				flag = agot_hf_revealbastard_busted
				years = 3
			}
		}
		add_opinion = {
			target = scope:bastard_revealer
			opinion = -90
			modifier = insult_opinion
		}

		save_scope_as = bastard_parent
	}

	#Flee
	option = {
		name = agot_hf_revealbastard_events.0016.a
		trigger = { scope:bastard_character = { agot_hf_special_secret_character_eligible = yes } }

		hidden_effect = {
			scope:bastard_character = {
				set_variable = {
					name = agot_hf_the_real_real_father
					value = scope:bastard_character.real_father
				}
				agot_start_secret_identity_effect = yes
			}
		}
		add_stress = major_stress_gain

		if = {
			limit = {
				exists = scope:bastard_character.father
				scope:bastard_character.father = {
					is_alive = yes
					is_playable_character = yes
				}
			}
			scope:bastard_character.father = {
				trigger_event = agot_hf_revealbastard_events.0017
			}
		}
		if = {
			limit = {
				exists = scope:bastard_character.mother
				scope:bastard_character.mother = {
					is_alive = yes
					is_playable_character = yes
				}
				NOT = { this = scope:bastard_character.mother }
			}
			scope:bastard_character.mother = {
				trigger_event = agot_hf_revealbastard_events.0017
			}
		}

		ai_chance = {
			base = 1

			ai_value_modifier = {
				ai_rationality = 1
				ai_boldness = 1
			}
		}
	}

	#Accident
	option = {
		name = agot_hf_revealbastard_events.0016.b

		scope:bastard_character = {
			death = { death_reason = death_accident }
		}
		add_stress = monumental_stress_gain

		ai_chance = {
			base = 1

			ai_value_modifier = {
				ai_honor = -1
				ai_compassion = -1
			}
		}
	}

	#Nothing
	option = {
		name = agot_hf_revealbastard_events.0016.c

		add_stress = minor_stress_gain

		ai_chance = {
			base = 1

			ai_value_modifier = {
				ai_boldness = -2
			}
		}
	}

	#Imprison
	option = {
		name = agot_hf_revealbastard_events.0016.d
		trigger = {
			is_landed = yes
			highest_held_title_tier > tier_barony
			OR = {
				this = scope:bastard_revealer.liege
				this = scope:bastard_revealer.top_liege
			}
		}

		show_as_tooltip = {
			hard_imprison_character_effect = {
				TARGET = scope:bastard_revealer
				IMPRISONER = this
			}
		}
		scope:bastard_revealer = {
			trigger_event = agot_hf_revealbastard_events.0019
		}

		ai_chance = {
			base = 1

			ai_value_modifier = {
				ai_vengefulness = 1
				ai_rationality = -1
			}
		}
	}

	#Bribe
	option = {
		name = agot_hf_revealbastard_events.0016.e
		trigger = { gold >= 300 }

		show_as_tooltip = { pay_short_term_gold = { target = scope:bastard_revealer gold = 300 } }
		scope:bastard_revealer = {
			trigger_event = agot_hf_revealbastard_events.0018
		}

		ai_chance = {
			base = 1

			ai_value_modifier = {
				ai_greed = -1
				ai_boldness = 1
			}
		}
	}
}

#Non-Real father learns the child went missing
agot_hf_revealbastard_events.0017 = {
	type = character_event
	title = agot_hf_revealbastard_events.0017.t
	desc = agot_hf_revealbastard_events.0017.desc

	theme = court

	override_background = {
		reference = courtyard
	}

	right_portrait = {
		character = scope:the_dupe
		animation = idle
	}

	immediate = {
		agot_hf_revealbastard_liege_finder = yes
		scope:bastard_character.var:secret_identity_character = { save_scope_as = the_dupe }
	}

	option = {
		name = agot_hf_revealbastard_events.0017.a
	}
}

#Bribe the Revealer
agot_hf_revealbastard_events.0018 = {
	type = character_event
	title = agot_hf_revealbastard_events.0018.t
	desc = agot_hf_revealbastard_events.0018.desc

	theme = court

	override_background = {
		reference = courtyard
	}

	right_portrait = {
		character = scope:bastard_parent
		animation = bribing
	}

	lower_right_portrait = {
		character = scope:bastard_character
	}

	immediate = {
		agot_hf_revealbastard_liege_finder = yes
	}

	option = {
		name = agot_hf_revealbastard_events.0018.a

		scope:bastard_parent = { pay_short_term_gold = { target = scope:bastard_revealer gold = 300 } }

		agot_hf_revealbastard_story_end_effect = yes

		scope:bastard_parent = {
			send_interface_toast = {
				type = event_generic_good
				title = agot_hf_revealbastard_events_bribe_accepted.t
				left_icon = scope:bastard_revealer
				custom_tooltip = agot_hf_revealbastard_events_bribe_accepted.tt
			}
		}

		ai_chance = {
			base = 1

			ai_value_modifier = {
				ai_greed = 1
			}
		}
	}

	option = {
		name = agot_hf_revealbastard_events.0018.a

		scope:bastard_parent = { trigger_event = { id = agot_hf_revealbastard_events.0020 days = 3 } }

		ai_chance = {
			base = 50
		}
	}
}

#Imprison the Revealer
agot_hf_revealbastard_events.0019 = {
	type = character_event
	title = agot_hf_revealbastard_events.0019.t
	desc = agot_hf_revealbastard_events.0019.desc

	theme = court

	override_background = {
		reference = courtyard
	}

	right_portrait = {
		character = scope:bastard_parent
		animation = war_defender
	}

	lower_right_portrait = {
		character = scope:bastard_character
	}

	immediate = {
		agot_hf_revealbastard_liege_finder = yes
		agot_hf_revealbastard_story_end_effect = yes
	}

	option = {
		name = agot_hf_revealbastard_events.0019.a

		scope:bastard_parent = {
			hard_imprison_character_effect = {
				TARGET = scope:bastard_revealer
				IMPRISONER = this
			}
		}
	}
}

#Revealer refused the money
agot_hf_revealbastard_events.0020 = {
	type = character_event
	title = agot_hf_revealbastard_events.0020.t
	desc = agot_hf_revealbastard_events.0020.desc

	theme = court

	override_background = {
		reference = courtyard
	}

	right_portrait = {
		character = scope:bastard_parent
		animation = war_defender
	}

	lower_right_portrait = {
		character = scope:bastard_character
	}

	immediate = {
		agot_hf_revealbastard_liege_finder = yes
	}

	#Flee
	option = {
		name = agot_hf_revealbastard_events.0016.a
		trigger = { scope:bastard_character = { agot_hf_special_secret_character_eligible = yes } }

		hidden_effect = {
			scope:bastard_character = {
				set_variable = {
					name = agot_hf_the_real_real_father
					value = scope:bastard_character.real_father
				}
				agot_start_secret_identity_effect = yes
			}
		}
		add_stress = major_stress_gain

		if = {
			limit = {
				exists = scope:bastard_character.father
				scope:bastard_character.father = {
					is_alive = yes
					is_playable_character = yes
				}
			}
			scope:bastard_character.father = {
				trigger_event = agot_hf_revealbastard_events.0017
			}
		}
		if = {
			limit = {
				exists = scope:bastard_character.mother
				scope:bastard_character.mother = {
					is_alive = yes
					is_playable_character = yes
				}
				NOT = { this = scope:bastard_character.mother }
			}
			scope:bastard_character.mother = {
				trigger_event = agot_hf_revealbastard_events.0017
			}
		}

		ai_chance = {
			base = 1

			ai_value_modifier = {
				ai_rationality = 1
				ai_boldness = 1
			}
		}
	}

	#Accident
	option = {
		name = agot_hf_revealbastard_events.0016.b

		scope:bastard_character = {
			death = { death_reason = death_accident }
		}
		add_stress = monumental_stress_gain

		ai_chance = {
			base = 1

			ai_value_modifier = {
				ai_honor = -1
				ai_compassion = -1
			}
		}
	}

	#Nothing
	option = {
		name = agot_hf_revealbastard_events.0016.c

		add_stress = minor_stress_gain

		ai_chance = {
			base = 1

			ai_value_modifier = {
				ai_boldness = -2
			}
		}
	}

	#Imprison
	option = {
		name = agot_hf_revealbastard_events.0016.d
		trigger = {
			is_landed = yes
			highest_held_title_tier > tier_barony
			OR = {
				this = scope:bastard_revealer.liege
				this = scope:bastard_revealer.top_liege
			}
		}

		show_as_tooltip = {
			hard_imprison_character_effect = {
				TARGET = scope:bastard_revealer
				IMPRISONER = this
			}
		}
		scope:bastard_revealer = {
			trigger_event = agot_hf_revealbastard_events.0019
		}

		ai_chance = {
			base = 1

			ai_value_modifier = {
				ai_vengefulness = 1
				ai_rationality = -1
			}
		}
	}
}

# I AM THE TRUE FATHER AND I'LL ADMIT IT
agot_hf_revealbastard_events.0021 = {
	type = character_event
	title = agot_hf_revealbastard_events.0021.t
	desc = agot_hf_revealbastard_events.0021.desc

	theme = bastardy

	override_background = {
		reference = courtyard
	}

	right_portrait = {
		character = scope:bastard_character
		animation = idle
	}

	lower_left_portrait = {
		character = scope:true_father
	}

	immediate = {
		agot_hf_revealbastard_liege_finder = yes
		scope:bastard_character.real_father = { save_scope_as = true_father }
	}

	option = {
		name = agot_hf_revealbastard_events.0021.a

		trigger_event = agot_hf_revealbastard_events.0010

		ai_chance = {
			base = 75
		}
	}

	option = {
		name = agot_hf_revealbastard_events.0021.b

		agot_hf_revealbastard_story_end_effect = yes

		ai_chance = {
			base = 1

			ai_value_modifier = {
				ai_boldness = -1
			}
		}
	}

	after = {
		if = {
			limit = { has_character_flag = agot_hf_witness_was_wrong }
			remove_character_flag = agot_hf_witness_was_wrong
		}
		if = {
			limit = { has_character_flag = agot_hf_witness_was_right }
			remove_character_flag = agot_hf_witness_was_right
		}
	}
}

#Other siblings are bastards too
agot_hf_revealbastard_events.0022 = {
	type = character_event
	hidden = yes

	immediate = {
		if = {
			limit = {
				any_sibling = { has_character_flag = agot_hf_bastard_sibling }
			}
			every_sibling = {
				limit = { has_character_flag = agot_hf_bastard_sibling }
				add_to_list = bastard_siblings
				ordered_in_list = {
					list = bastard_siblings
					order_by = age
					save_scope_as = bastard_sibling_a
				}
				agot_hf_revealbastard_final_siblings_effect = yes
				agot_hf_revealbastard_set_claims_and_events_siblings_effect = yes
			}
		}
		scope:bastard_revealer = {
			save_scope_as = i_am_the_exposer
		}
	}
}

#IS A BASTARD!
agot_hf_revealbastard_events.0023 = {
	type = character_event
	title = agot_hf_revealbastard_events.0023.t
	theme = bastardy

	desc = agot_hf_revealbastard_events.0023.base.desc

	override_background = {
		reference = bedchamber
	}

	left_portrait = {
		character = scope:bastard_sibling_a
		animation = worry
	}
	right_portrait = scope:bastard_character.real_father
	lower_right_portrait = scope:bastard_revealer
	lower_left_portrait = {
		trigger = { exists = scope:bastard_sibling_b }
		character = scope:bastard_sibling_b
	}
	lower_center_portrait = {
		trigger = { exists = scope:bastard_character }
		character = scope:bastard_character
	}

	immediate = {
		if = {
			limit = { has_character_flag = agot_hf_bastard_sibling }
			save_scope_as = this_sibling_bastard
		}
	}

	option = {
		name = agot_hf_revealbastard_events.0011.a
		trigger = {
			NOT = { this = scope:bastard_character.real_father }
		}

		hidden_effect = {
			if = {
				limit = {
					exists = scope:bastard_sibling_a
					scope:bastard_sibling_a = { is_playable_character = yes }
				}
				add_opinion = {
					target = scope:bastard_sibling_a
					opinion = -45
					modifier = agot_hf_revealbastard_illegitimate_ruler_opinion
				}
			}
			if = {
				limit = {
					exists = scope:bastard_sibling_b
					scope:bastard_sibling_b = { is_playable_character = yes }
				}
				add_opinion = {
					target = scope:bastard_sibling_b
					opinion = -45
					modifier = agot_hf_revealbastard_illegitimate_ruler_opinion
				}
			}
			if = {
				limit = {
					exists = scope:bastard_sibling_c
					scope:bastard_sibling_c = { is_playable_character = yes }
				}
				add_opinion = {
					target = scope:bastard_sibling_c
					opinion = -45
					modifier = agot_hf_revealbastard_illegitimate_ruler_opinion
				}
			}
			if = {
				limit = {
					exists = scope:bastard_sibling_d
					scope:bastard_sibling_d = { is_playable_character = yes }
				}
				add_opinion = {
					target = scope:bastard_sibling_d
					opinion = -45
					modifier = agot_hf_revealbastard_illegitimate_ruler_opinion
				}
			}
			if = {
				limit = {
					exists = scope:bastard_sibling_e
					scope:bastard_sibling_e = { is_playable_character = yes }
				}
				add_opinion = {
					target = scope:bastard_sibling_e
					opinion = -45
					modifier = agot_hf_revealbastard_illegitimate_ruler_opinion
				}
			}
			if = {
				limit = {
					exists = scope:bastard_sibling_f
					scope:bastard_sibling_f = { is_playable_character = yes }
				}
				add_opinion = {
					target = scope:bastard_sibling_f
					opinion = -45
					modifier = agot_hf_revealbastard_illegitimate_ruler_opinion
				}
			}
			if = {
				limit = {
					exists = scope:bastard_sibling_g
					scope:bastard_sibling_g = { is_playable_character = yes }
				}
				add_opinion = {
					target = scope:bastard_sibling_g
					opinion = -45
					modifier = agot_hf_revealbastard_illegitimate_ruler_opinion
				}
			}
			if = {
				limit = {
					exists = scope:bastard_sibling_h
					scope:bastard_sibling_h = { is_playable_character = yes }
				}
				add_opinion = {
					target = scope:bastard_sibling_h
					opinion = -45
					modifier = agot_hf_revealbastard_illegitimate_ruler_opinion
				}
			}
			if = {
				limit = {
					exists = scope:bastard_sibling_i
					scope:bastard_sibling_i = { is_playable_character = yes }
				}
				add_opinion = {
					target = scope:bastard_sibling_i
					opinion = -45
					modifier = agot_hf_revealbastard_illegitimate_ruler_opinion
				}
			}
			if = {
				limit = {
					exists = scope:bastard_sibling_j
					scope:bastard_sibling_j = { is_playable_character = yes }
				}
				add_opinion = {
					target = scope:bastard_sibling_j
					opinion = -45
					modifier = agot_hf_revealbastard_illegitimate_ruler_opinion
				}
			}
			if = {
				limit = {
					exists = scope:bastard_sibling_k
					scope:bastard_sibling_k = { is_playable_character = yes }
				}
				add_opinion = {
					target = scope:bastard_sibling_k
					opinion = -45
					modifier = agot_hf_revealbastard_illegitimate_ruler_opinion
				}
			}
		}

		ai_chance = {
			base = 75
			modifier = {
				add = 100
				has_trait = honest
			}
		}
	}

	option = {
		name = agot_hf_revealbastard_events.0011.b
		trigger = {
			NOT = { this = scope:bastard_character.real_father }
		}

		hidden_effect = {
			if = {
				limit = {
					exists = scope:bastard_sibling_a
					scope:bastard_sibling_a = { is_playable_character = yes }
				}
				add_opinion = {
					target = scope:bastard_sibling_a
					opinion = -65
					modifier = agot_hf_revealbastard_illegitimate_ruler_opinion
				}
			}
			if = {
				limit = {
					exists = scope:bastard_sibling_b
					scope:bastard_sibling_b = { is_playable_character = yes }
				}
				add_opinion = {
					target = scope:bastard_sibling_b
					opinion = -65
					modifier = agot_hf_revealbastard_illegitimate_ruler_opinion
				}
			}
			if = {
				limit = {
					exists = scope:bastard_sibling_c
					scope:bastard_sibling_c = { is_playable_character = yes }
				}
				add_opinion = {
					target = scope:bastard_sibling_c
					opinion = -65
					modifier = agot_hf_revealbastard_illegitimate_ruler_opinion
				}
			}
			if = {
				limit = {
					exists = scope:bastard_sibling_d
					scope:bastard_sibling_d = { is_playable_character = yes }
				}
				add_opinion = {
					target = scope:bastard_sibling_d
					opinion = -65
					modifier = agot_hf_revealbastard_illegitimate_ruler_opinion
				}
			}
			if = {
				limit = {
					exists = scope:bastard_sibling_e
					scope:bastard_sibling_e = { is_playable_character = yes }
				}
				add_opinion = {
					target = scope:bastard_sibling_e
					opinion = -65
					modifier = agot_hf_revealbastard_illegitimate_ruler_opinion
				}
			}
			if = {
				limit = {
					exists = scope:bastard_sibling_f
					scope:bastard_sibling_f = { is_playable_character = yes }
				}
				add_opinion = {
					target = scope:bastard_sibling_f
					opinion = -65
					modifier = agot_hf_revealbastard_illegitimate_ruler_opinion
				}
			}
			if = {
				limit = {
					exists = scope:bastard_sibling_g
					scope:bastard_sibling_g = { is_playable_character = yes }
				}
				add_opinion = {
					target = scope:bastard_sibling_g
					opinion = -65
					modifier = agot_hf_revealbastard_illegitimate_ruler_opinion
				}
			}
			if = {
				limit = {
					exists = scope:bastard_sibling_h
					scope:bastard_sibling_h = { is_playable_character = yes }
				}
				add_opinion = {
					target = scope:bastard_sibling_h
					opinion = -65
					modifier = agot_hf_revealbastard_illegitimate_ruler_opinion
				}
			}
			if = {
				limit = {
					exists = scope:bastard_sibling_i
					scope:bastard_sibling_i = { is_playable_character = yes }
				}
				add_opinion = {
					target = scope:bastard_sibling_i
					opinion = -65
					modifier = agot_hf_revealbastard_illegitimate_ruler_opinion
				}
			}
			if = {
				limit = {
					exists = scope:bastard_sibling_j
					scope:bastard_sibling_j = { is_playable_character = yes }
				}
				add_opinion = {
					target = scope:bastard_sibling_j
					opinion = -65
					modifier = agot_hf_revealbastard_illegitimate_ruler_opinion
				}
			}
			if = {
				limit = {
					exists = scope:bastard_sibling_k
					scope:bastard_sibling_k = { is_playable_character = yes }
				}
				add_opinion = {
					target = scope:bastard_sibling_k
					opinion = -65
					modifier = agot_hf_revealbastard_illegitimate_ruler_opinion
				}
			}
		}

		ai_chance = {
			base = 25
			modifier = {
				add = 50
				has_trait = deceitful
			}
			modifier = {
				add = 50
				has_trait = humble
			}
		}
	}

	option = {
		name = agot_hf_revealbastard_events.0011.d
		trigger = { this = scope:bastard_character.real_father }

		add_opinion = {
			target = scope:bastard_revealer
			opinion = -45
			modifier = agot_hf_revealbastard_revealed_the_truth_bad
		}

		ai_chance = {
			base = 1

			ai_value_modifier = {
				ai_vengefulness = 1
			}
		}
	}

	option = {
		name = agot_hf_revealbastard_events.0011.e
		trigger = { this = scope:bastard_character.real_father }

		add_opinion = {
			target = scope:bastard_revealer
			opinion = -45
			modifier = agot_hf_revealbastard_revealed_the_truth_bad
		}

		ai_chance = {
			base = 50
		}
	}

	option = {
		name = agot_hf_revealbastard_events.0011.d
		trigger = {
			exists = scope:this_sibling_bastard
			this = scope:this_sibling_bastard
			is_landed = yes
			trigger_if = {
				limit = { scope:bastard_character.real_father = { is_alive = yes } }
				scope:bastard_character.real_father = { NOT = { is_landed = yes } }
			}
		}

		add_opinion = {
			target = scope:bastard_revealer
			opinion = -45
			modifier = agot_hf_revealbastard_revealed_the_truth_bad
		}

		if = {
			limit = {
				is_landed = yes
				highest_held_title_tier > tier_barony
				scope:bastard_revealer = { NOT = { is_imprisoned = yes } }
				OR = {
					this = scope:bastard_revealer.liege
					this = scope:bastard_revealer.top_liege
				}
			}
			hard_imprison_character_effect = {
				TARGET = scope:bastard_revealer
				IMPRISONER = scope:suspect_a
			}
		}

		ai_chance = {
			base = 1

			ai_value_modifier = {
				ai_vengefulness = 1
			}
		}
	}

	option = {
		name = agot_hf_revealbastard_events.0011.e
		trigger = {
			exists = scope:this_sibling_bastard
			this = scope:this_sibling_bastard
		}

		add_opinion = {
			target = scope:bastard_revealer
			opinion = -45
			modifier = agot_hf_revealbastard_revealed_the_truth_bad
		}

		ai_chance = {
			base = 50
		}
	}
}