﻿# The outcome of a agotma_claimant scheme

namespace = agotma_claimant_outcome

# NOTE: To set up a new scheme outcome, make sure that you make an event for the owner and one for the target, and add them to their relevant on_actions.



######################################################
# DYNASTIC CLAIMANT EVENTS
######################################################

#investigation finished
agotma_claimant_outcome.0001 = {
	type = character_event
	title = agotma_claimant_outcome.0001.t
	desc = {
		desc = agotma_claimant_outcome.0001.desc
		first_valid = {
			triggered_desc = {
				trigger = { scope:scheme.scheme_success_chance >= 60 }
				desc = agotma_claimant_outcome.0001.positive.desc
			}
			desc = agotma_claimant_outcome.0001.negative.desc
		}
	}
	theme = claim_throne_scheme

	left_portrait = scope:owner
	right_portrait = scope:target
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	immediate = {
		scope:target = { liege = { save_scope_as = discoverer } }
	}

	option = {
		name = agotma_claimant_outcome.0001.a
		custom_tooltip = agotma_claimant_outcome.0001.a.tt
		trigger_event = agotma_claimant_outcome.0002

		stress_impact = {
			craven = minor_stress_impact_gain
		}
	}

	option = {
		name = agotma_claimant_outcome.0001.b
		scope:scheme = {
			end_scheme = yes
		}
	}
}




#setting the proper heritage
agotma_claimant_outcome.0002 = {
	type = character_event

	hidden = yes

	immediate = {
		if = {
			limit = { scope:owner.house = scope:target.dynasty.dynast.house }
			save_scope_as = scheme_dynasty_claimant
		}
		if = {
			limit = {
				NOT = {scope:owner.house = scope:target.dynasty.dynast.house }
			}
			save_scope_as = scheme_house_claimant
		}

		scope:owner = {
			trigger_event = {
				id = agotma_claimant_outcome.0003
			}
		}
	}
}


#time to reveal
agotma_claimant_outcome.0003 = {
	type = character_event
	title = agotma_claimant_outcome.0003.t

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { exists = scope:scheme_dynasty_claimant }
				desc = agotma_claimant_outcome.0003.success.desc
			}
			triggered_desc = {
				trigger = { exists = scope:scheme_house_claimant }
				desc = agotma_claimant_outcome.0003.failure.desc
			}
		}
	}


	theme = claim_throne_scheme
	left_portrait = scope:owner

	#Success:
	option = {
		name = agotma_claimant_outcome.0003.a.success
		trigger = { exists = scope:scheme_dynasty_claimant }
		show_as_tooltip = {	custom_tooltip = agotma_claimant_outcome.0003.a.tt }

		if = {
			limit = {
				scope:target = {
					OR = {
						highest_held_title_tier >= tier_kingdom
						is_independent_ruler = yes
					}
				}
			}
			if = {
				limit = {
					OR = {
						scope:target.capital_province = { geographical_region = world_westeros_dorne }
						scope:target.capital_province = { geographical_region = world_westeros_the_crownlands }
						scope:target.capital_province = { geographical_region = world_westeros_the_iron_islands }
						scope:target.capital_province = { geographical_region = world_westeros_the_north }
						scope:target.capital_province = { geographical_region = world_westeros_the_reach }
						scope:target.capital_province = { geographical_region = world_westeros_the_riverlands }
						scope:target.capital_province = { geographical_region = world_westeros_the_stormlands }
						scope:target.capital_province = { geographical_region = world_westeros_the_vale }
						scope:target.capital_province = { geographical_region = world_westeros_the_westerlands }
					}
				}
				title:h_the_iron_throne = {
					every_de_jure_county_holder = {
						add_to_list = agotma_the_world_claimant
					}
				}
			}
			if = {
				limit = {
					OR = {
						scope:target.capital_province = { geographical_region = world_stepstones }
						scope:target.capital_province = { geographical_region = world_essos_tyrosh }
						scope:target.capital_province = { geographical_region = world_essos_lys }
						scope:target.capital_province = { geographical_region = world_essos_disputed_lands }
						scope:target.capital_province = { geographical_region = world_essos_myr }
					}
				}
				title:e_three_daughters = {
					every_de_jure_county_holder = {
						add_to_list = agotma_the_world_claimant
					}
				}
			}
			if = {
				limit = {
					OR = {
						scope:target.capital_province = { geographical_region = world_essos_andalos }
						scope:target.capital_province = { geographical_region = world_essos_pentos }
					}
				}
				title:e_pentos = {
					every_de_jure_county_holder = {
						add_to_list = agotma_the_world_claimant
					}
				}
			}
		}
		else = {
			scope:target.liege = {
				every_vassal_or_below = {
					limit = { highest_held_title_tier >= tier_county }
					add_to_list = iron_throne_realm
				}
			}
		}

		every_in_list = {
			list = agotma_the_world_claimant
			trigger_event = {
				id = agotma_claimant_outcome.0004
				days = 1
			}
		}
		scope:scheme = {
			end_scheme = yes
		}


		add_character_modifier = {
			modifier = agotma_claimant_final_modifier
			years = 50
		}

		scope:target.house.house_head = {
			if = {
				limit = { highest_held_title_tier > tier_barony }
				every_held_title = {
					limit = { tier > tier_barony }
					add_to_list = agotma_titles_to_claim_claimant
				}
				every_in_list = {
					list = agotma_titles_to_claim_claimant
					save_scope_as = agotma_claimed_title_claimant
					scope:owner = {
						add_pressed_claim = scope:agotma_claimed_title_claimant
					}
				}
			}
		}
		save_scope_as = momspagetthi
	}

	option = {
		name = agotma_claimant_outcome.0003.a.failure
		trigger = { exists = scope:scheme_house_claimant }
		show_as_tooltip = {	custom_tooltip = agotma_claimant_outcome.0003.b.tt }

		if = {
			limit = {
				scope:target = {
					OR = {
						highest_held_title_tier >= tier_kingdom
						is_independent_ruler = yes
					}
				}
			}
			if = {
				limit = {
					OR = {
						scope:target.capital_province = { geographical_region = world_westeros_dorne }
						scope:target.capital_province = { geographical_region = world_westeros_the_crownlands }
						scope:target.capital_province = { geographical_region = world_westeros_the_iron_islands }
						scope:target.capital_province = { geographical_region = world_westeros_the_north }
						scope:target.capital_province = { geographical_region = world_westeros_the_reach }
						scope:target.capital_province = { geographical_region = world_westeros_the_riverlands }
						scope:target.capital_province = { geographical_region = world_westeros_the_stormlands }
						scope:target.capital_province = { geographical_region = world_westeros_the_vale }
						scope:target.capital_province = { geographical_region = world_westeros_the_westerlands }
					}
				}
				title:h_the_iron_throne = {
					every_de_jure_county_holder = {
						add_to_list = agotma_the_world_claimant
					}
				}
			}
			if = {
				limit = {
					OR = {
						scope:target.capital_province = { geographical_region = world_stepstones }
						scope:target.capital_province = { geographical_region = world_essos_tyrosh }
						scope:target.capital_province = { geographical_region = world_essos_lys }
						scope:target.capital_province = { geographical_region = world_essos_disputed_lands }
						scope:target.capital_province = { geographical_region = world_essos_myr }
					}
				}
				title:e_three_daughters = {
					every_de_jure_county_holder = {
						add_to_list = agotma_the_world_claimant
					}
				}
			}
			if = {
				limit = {
					OR = {
						scope:target.capital_province = { geographical_region = world_essos_andalos }
						scope:target.capital_province = { geographical_region = world_essos_pentos }
					}
				}
				title:e_pentos = {
					every_de_jure_county_holder = {
						add_to_list = agotma_the_world_claimant
					}
				}
			}
		}
		else = {
			scope:target.liege = {
				every_vassal_or_below = {
					limit = { highest_held_title_tier >= tier_county }
					add_to_list = iron_throne_realm
				}
			}
		}

		every_in_list = {
			list = agotma_the_world_claimant
			trigger_event = {
				id = agotma_claimant_outcome.0005
				days = 1
			}
		}
		scope:scheme = {
			end_scheme = yes
		}
		add_character_modifier = {
			modifier = agotma_claimant_final_modifier
			years = 50
		}

		scope:target.house.house_head = {
			if = {
				limit = { highest_held_title_tier > tier_barony }
				every_held_title = {
					limit = { tier > tier_barony }
					add_to_list = agotma_titles_to_claim_claimant
				}
				every_in_list = {
					list = agotma_titles_to_claim_claimant
					save_scope_as = agotma_claimed_title_claimant
					scope:owner = {	add_pressed_claim = scope:agotma_claimed_title_claimant	}
				}
			}
		}

	}
}


#realmwide letter about the bastard
agotma_claimant_outcome.0004 = {
	type = character_event
	title = agotma_claimant_outcome.0004.t

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {	exists = scope:scheme_dynasty_claimant }
				desc = agotma_claimant_outcome.0004.1.desc
			}
			triggered_desc = {
				trigger = { exists = scope:scheme_house_claimant }
				desc = agotma_claimant_outcome.0004.3.desc
			}
			desc = agotma_claimant_outcome.0004.2.desc
		}
	}

	theme = claim_throne_scheme

	override_background = {
		reference = army_camp
	}

	left_portrait = {
		character = scope:owner

	}
	right_portrait = {
		character = scope:target
		animation = stress
	}

	immediate = {
		hidden_effect = {
			if = {
				limit = { scope:target = { is_playable_character = yes } }
				every_ruler = {
					limit = {
						NOT = { this = scope:target }
						NOT = { this = scope:owner }
					}
					add_opinion = {
						target = scope:owner
						modifier = agotma_claimant_pretender
					}
				}
			}
			scope:target = {
				add_opinion = {
					target = scope:owner
					opinion = -25
					modifier = agotma_claimant_claimed_title
				}
			}
		}
	}

	option = {
		name = agotma_claimant_outcome.0004.a
		ai_chance = {
			base = 75
			modifier = {
				add = 100
				has_trait = honest
			}
		}
	}

	option = {
		name = agotma_claimant_outcome.0004.b
		ai_chance = {
			base = 25
			modifier = {
				add = 50
				has_trait = deceitful
			}
			modifier = {
				add = 50
				has_trait = humble
			}
		}
	}
}

#realmwide letter about the trueborn
agotma_claimant_outcome.0005 = {
	type = character_event
	title = agotma_claimant_outcome.0005.t

	desc = {
		desc = agotma_claimant_outcome.0005.desc
	}

	theme = claim_throne_scheme

	override_background = {
		reference = army_camp
	}

	left_portrait = {
		character = scope:owner

	}
	right_portrait = {
		character = scope:target
		animation = stress
	}

	immediate = {
		hidden_effect = {
			scope:target = {
				add_opinion = {
					target = scope:owner
					opinion = 25
					modifier = agotma_claimant_pretender
				}
			}
			scope:target = {
				add_opinion = {
					target = scope:owner
					opinion = -25
					modifier = agotma_claimant_cadet_claimed_title
				}
			}
		}
	}

	option = {
		name = agotma_claimant_outcome.0005.a
		ai_chance = {
			base = 75
			modifier = {
				add = 100
				has_trait = honest
			}
		}
	}

	option = {
		name = agotma_claimant_outcome.0005.b
		ai_chance = {
			base = 25
			modifier = {
				add = 50
				has_trait = deceitful
			}
			modifier = {
				add = 50
				has_trait = humble
			}
		}
	}
}


#target died
agotma_claimant_outcome.0006 = {
	type = character_event
	title = agotma_claimant_outcome.0006.t
	desc = agotma_claimant_outcome.0006.desc

	theme = court
	left_portrait = scope:target
	#No scheme, no widget

	option = {
		name = agotma_claimant_outcome.0006.a
	}
}

#not landed anymore
agotma_claimant_outcome.0007 = {
	type = character_event
	title = agotma_claimant_outcome.0007.t
	desc = agotma_claimant_outcome.0007.desc

	theme = court
	left_portrait = scope:target
	#No scheme, no widget

	option = {
		name = agotma_claimant_outcome.0007.a
	}
}

