﻿namespace = provoke_vassals_outcome

# Successful and secret
provoke_vassals_outcome.0001 = {
	type = character_event
	window = scheme_successful_event
	theme = provoke_vassals_scheme
	title = provoke_vassals_outcome.0001.t
	desc = provoke_vassals_outcome.0001.desc
	left_portrait = {
		character = scope:owner
		animation = toast_goblet
	}
	center_portrait = {
		character = scope:owner.court_position:rabble_rouser_court_position
		animation = drink_goblet
	}
	right_portrait = {
		character = scope:target
		animation = dismissal
	}

	option = {
		name = provoke_vassals_outcome.0001.a
		hidden_effect = {
			scope:target = {
				ordered_vassal = {
					limit = { 
						is_ai = yes
						highest_held_title_tier >= tier_county
						NOT = {
							government_has_flag = government_is_republic
							government_has_flag = government_is_theocracy
						}
						can_create_faction = {
							type = independence_faction
							target = scope:target
						}
					}
					order_by = {
						value = "opinion(scope:target)"
						multiply = -1
					}
					max = 1
					check_range_bounds = no
					save_scope_as = independence_vassal
				}
				primary_title = {
					set_variable = {
						name = provoke_vassals_schemer
						value = scope:owner
					}
				}
			}
		}
		scope:independence_vassal = {
			add_character_modifier = {
				modifier = provoked_independence_character_modifier
			}
			create_faction = {
				type = provoked_independence_faction
				target = scope:target
			}
		}	
	}

	option = {
		trigger = { 
			AND = {
				intrigue > 15
				OR = {
					has_trait = populist_leader
					has_trait = peasant_leader
				}
				scope:owner.court_position:rabble_rouser_court_position = { 
					aptitude = {
						court_position = rabble_rouser_court_position
						value >= 4
					}
				}
				scope:target = {
					any_vassal = {
						can_create_faction = {
							type = nation_fracturing_faction
							target = scope:target
						}
					}
				}
			}
		}
		name = provoke_vassals_outcome.0001.b
		hidden_effect = {
			scope:target = {
				ordered_vassal = {
					limit = { 
						is_ai = yes
						highest_held_title_tier >= tier_county
						NOT = {
							government_has_flag = government_is_republic
							government_has_flag = government_is_theocracy
						}
						can_create_faction = {
							type = nation_fracturing_faction
							target = scope:target
						}
					}
					order_by = {
						value = "opinion(scope:target)"
						multiply = -1
					}
					max = 1
					check_range_bounds = no
					save_scope_as = dissolution_vassal
				}
				primary_title = {
					set_variable = {
						name = provoke_vassals_schemer
						value = scope:owner
					}
				}
			}
		}
		scope:dissolution_vassal = {
			add_character_modifier = {
				modifier = provoked_dissolution_character_modifier
			}
			create_faction = {
				type = provoked_dissolution_faction
				target = scope:target
			}
		}	
	}

	after = {
		if = {
			limit = { exists = scope:scheme }
			scope:scheme = {
				end_scheme = yes
			}
		}
	}
}

# # Successful and discovered
provoke_vassals_outcome.0002 = {
	type = character_event
	window = scheme_successful_event
	theme = provoke_vassals_scheme
	title = provoke_vassals_outcome.0002.t
	desc = provoke_vassals_outcome.0002.desc
	left_portrait = {
		character = scope:owner
		animation = toast_goblet
	}
	center_portrait = {
		character = scope:owner.court_position:rabble_rouser_court_position
		animation = drink_goblet
	}
	right_portrait = {
		character = scope:target
		animation = rage
	}

	option = {
		name = provoke_vassals_outcome.0002.a
		hidden_effect = {
			scope:target = {
				ordered_vassal = {
					limit = { 
						is_ai = yes
						highest_held_title_tier >= tier_county
						NOT = {
							government_has_flag = government_is_republic
							government_has_flag = government_is_theocracy
						}
						can_create_faction = {
							type = independence_faction
							target = scope:target
						}
					}
					order_by = {
						value = "opinion(scope:target)"
						multiply = -1
					}
					max = 1
					check_range_bounds = no
					save_scope_as = independence_vassal
				}
				primary_title = {
					set_variable = {
						name = provoke_vassals_schemer
						value = scope:owner
					}
				}
			}
		}
		scope:independence_vassal = {
			add_character_modifier = {
				modifier = provoked_independence_character_modifier
			}
			create_faction = {
				type = provoked_independence_faction
				target = scope:target
			}
		}	
	}

	option = {
		trigger = { 
			AND = {
				intrigue > 15
				OR = {
					has_trait = populist_leader
					has_trait = peasant_leader
				}
				scope:owner.court_position:rabble_rouser_court_position = { 
					aptitude = {
						court_position = rabble_rouser_court_position
						value >= 4
					}
				}
				scope:target = {
					any_vassal = {
						can_create_faction = {
							type = nation_fracturing_faction
							target = scope:target
						}
					}
				}
			}
		}
		name = provoke_vassals_outcome.0002.b
		hidden_effect = {
			scope:target = {
				ordered_vassal = {
					limit = { 
						is_ai = yes
						highest_held_title_tier >= tier_county
						NOT = {
							government_has_flag = government_is_republic
							government_has_flag = government_is_theocracy
						}
						can_create_faction = {
							type = nation_fracturing_faction
							target = scope:target
						}
					}
					order_by = {
						value = "opinion(scope:target)"
						multiply = -1
					}
					max = 1
					check_range_bounds = no
					save_scope_as = dissolution_vassal
				}
				primary_title = {
					set_variable = {
						name = provoke_vassals_schemer
						value = scope:owner
					}
				}
			}
		}
		scope:dissolution_vassal = {
			add_character_modifier = {
				modifier = provoked_dissolution_character_modifier
			}
			create_faction = {
				type = provoked_dissolution_faction
				target = scope:target
			}
		}	
	}

	after = {
		if = {
			limit = { exists = scope:scheme }
			scope:scheme = {
				end_scheme = yes
			}
		}
	}
}

# Unsuccessful and secret
provoke_vassals_outcome.0003 = {
	type = character_event
	window = scheme_failed_event
	theme = provoke_vassals_scheme
	title = provoke_vassals_outcome.0003.t
	desc = provoke_vassals_outcome.0003.desc
	left_portrait = {
		character = scope:owner
		animation = disappointed
	}
	right_portrait = {
		character = scope:owner.court_position:rabble_rouser_court_position
		animation = shame
	}
	option = {
		name = provoke_vassals_outcome.0003.a
	}
	after = {
		if = {
			limit = { exists = scope:scheme }
			scope:scheme = {
				end_scheme = yes
			}
		}
	}
}

# Unsuccessful and discovered
provoke_vassals_outcome.0004 = {
	type = character_event
	window = scheme_failed_event
	theme = provoke_vassals_scheme
	title = provoke_vassals_outcome.0004.t
	desc = provoke_vassals_outcome.0004.desc
	left_portrait = {
		character = scope:owner
		animation = disappointed
	}
	center_portrait = {
		character = scope:owner.court_position:rabble_rouser_court_position
		animation = shame
	}
	right_portrait = {
		character = scope:target
		animation = rage
	}
	option = {
		name = provoke_vassals_outcome.0004.a
		provoke_vassals_failure_effect = yes
	}
	after = {
		if = {
			limit = { exists = scope:scheme }
			scope:scheme = {
				end_scheme = yes
			}
		}
	}
}