﻿# This file contains events for the Rise and Fall mod's war enhancement mechanics.
# These events handle post-rebellion succession, fallen rulers' fates, and family revolts triggered by character deaths.

namespace = riseandfall_war_enhancement

# Event triggered after overthrowing a liege, allowing the attacker to decide the realm's fate.
riseandfall_war_enhancement.1 = {
	type = character_event
	title = riseandfall_war_enhancement.1.t
	desc = riseandfall_war_enhancement.1.desc
	theme = realm
	left_portrait = {
		character = root
		animation = dismissal
	}
	
	# Option: Press claims on titles if the attacker has them.
	option = { # press my claims
		name = riseandfall_war_enhancement.1.a
		trigger = {
			scope:riseandfall_war_enhancement_attacker.liege = {
				any_held_title = {
					root = {
						has_claim_on = prev
					}
				}
			}
		}
		war_enhancement_press_claims = yes
		
		ai_chance = {
			base = 800
			ai_value_modifier = {
				ai_greed = 0.5
				ai_boldness = 0.3
				ai_energy = 1
				ai_rationality = 1
			}
			modifier = {
				add = 100
				root = {
					has_trait = ambitious
				}
			}
			
			modifier = {
				add = -15
				root = {
					has_trait = content
				}
			}
		}
		
	}
	
	# Option: Clans have a more dynamic political system, and can seize control from other houses with much less trouble here compared to feudal.
	option = { # 
		name = riseandfall_war_enhancement.1.g
		trigger = {
			AND = {
				scope:riseandfall_war_enhancement_attacker = {
					has_government = clan_government
				}
				scope:riseandfall_war_enhancement_attacker.liege = {
					has_government = clan_government
				}
				scope:riseandfall_war_enhancement_attacker = {
					NOT = { house = scope:riseandfall_war_enhancement_attacker.liege.house }
				}
			}
		}
		war_enhancement_clan_overthrow = yes 
		war_enhancement_clan_seize = yes
		
		ai_chance = {
			base = -200
			ai_value_modifier = {
				ai_greed = 0.3
				ai_boldness = 0.5
				ai_energy = 0.2
				ai_rationality = 0.6
			}
			opinion_modifier = { # Opinion Factor
				who = root
				opinion_target = scope:riseandfall_war_enhancement_attacker.liege
				multiplier = -2
			}
			modifier = {
				add = 100
				root = {
					has_trait = ambitious
				}
			}
			modifier = {
				add = -60
				root = {
					house = scope:riseandfall_war_enhancement_attacker.liege.house 
				}
			}
			modifier = {
				add = -30
				root = {
					dynasty = scope:riseandfall_war_enhancement_attacker.liege.dynasty 
				}
			}
			
			modifier = {
				add = -15
				root = {
					has_trait = content
				}
			}
		}
		
	}
	
	# Option: Nomads/Tribes have a more dynamic political system, and can seize control from other houses with much less trouble here compared to feudal.
	option = { # 
		name = riseandfall_war_enhancement.1.h
		trigger = {
			AND = {
				scope:riseandfall_war_enhancement_attacker = {
					OR = {
						has_government = nomad_government
						has_government = tribal_government
					}
				}
				scope:riseandfall_war_enhancement_attacker.liege = {
					OR = {
						has_government = nomad_government
						has_government = tribal_government
					}
				}
			}
		}
		war_enhancement_primitive_overthrow = yes
		war_enhancement_primitive_seize = yes
		
		ai_chance = {
			base = -200
			ai_value_modifier = {
				ai_greed = 0.3
				ai_boldness = 0.5
				ai_energy = 0.2
				ai_rationality = 0.6
			}
			opinion_modifier = { # Opinion Factor
				who = root
				opinion_target = scope:riseandfall_war_enhancement_prev_liege
				multiplier = -1.5
			}
			modifier = {
				add = 100
				root = {
					has_trait = ambitious
				}
			}
			modifier = {
				add = -60
				root = {
					house = scope:riseandfall_war_enhancement_attacker.liege.house 
				}
			}
			modifier = {
				add = -30
				root = {
					dynasty = scope:riseandfall_war_enhancement_attacker.liege.dynasty 
				}
			}
			
			modifier = {
				add = -15
				root = {
					has_trait = content
				}
			}
		}
		
	}
	
	# Option: Elect a suitable ruler by setting up a diarchy. (Feudal behavior)
	option = { # lets elect a suitable ruler
		name = riseandfall_war_enhancement.1.b
		trigger = {
			scope:riseandfall_war_enhancement_attacker.liege = {
				has_government = feudal_government
				OR = {
					has_realm_law_flag = partition_succession_law
					has_realm_law_flag = advanced_succession_law
				}
			}
			scope:riseandfall_war_enhancement_attacker.liege.primary_title = {
				NOT = { has_title_law_flag = elective_succession_law }
			}
			root = {
				is_independent_ruler = no
			}
		}
		war_enhancement_council_formation = yes
		war_enhancement_elect_ruler = yes
		ai_chance = {
			base = -75
			ai_value_modifier = {
				ai_greed = -0.3
				ai_honor = 0.5
				ai_energy = 0.4
				ai_rationality = 0.75
				ai_sociability = 0.5
			}
			modifier = {
				add = 20
				root = {
					has_trait = just
				}
			}
			opinion_modifier = { # Opinion Factor
				who = root
				opinion_target = scope:riseandfall_war_enhancement_attacker.liege
				multiplier = -5
			}
			modifier = {
				add = 30
				root = {
					has_trait = ambitious
				}
			}
		}
	}
	
	# Option: Seize power tyrannically from an elective system.
	option = { # lets get rid of this silly elective system.
		name = riseandfall_war_enhancement.1.c
		trigger = {
			scope:riseandfall_war_enhancement_attacker.liege = {
				OR = {
					has_government = feudal_government
					has_government = tribal_government
				}
			}
			scope:riseandfall_war_enhancement_attacker.liege.primary_title = {
				has_title_law_flag = elective_succession_law
			}
			root = {
				is_independent_ruler = no
			}
		}
		war_enhancement_hereditary_succession_enforced = yes
		war_enhancement_overthrow_electoral_system = yes
		ai_chance = {
			base = -200
			ai_value_modifier = {
				ai_greed = 2
				ai_honor = -1.5
				ai_energy = 2.5
				ai_compassion = -2
				ai_boldness = 2.5
				ai_sociability = 0.5
				ai_vengefulness = 0.3
			}
			modifier = {
				add = 20
				root = {
					has_trait = ambitious
				}
			}
			opinion_modifier = { # Opinion Factor
				who = root
				opinion_target = scope:riseandfall_war_enhancement_attacker.liege
				multiplier = -5
			}
			modifier = {
				add = 30
				root = {
					has_trait = ambitious
				}
			}
		}
	}
	
	# Option: We should restore the Princely Elective system.
	option = { # 
		name = riseandfall_war_enhancement.1.f
		trigger = {
			scope:riseandfall_war_enhancement_attacker.liege = {
				has_government = feudal_government
			}
			scope:riseandfall_war_enhancement_attacker.liege.primary_title = {
					NOT = { has_title_law = princely_elective_succession_law }
					this = title:e_hre
			}
			root = {
				is_independent_ruler = no
			}
		}
		war_enhancement_princely_restoration = yes
		war_enhancement_restore_hre_electoral_system = yes

		ai_chance = {
			base = -50
			ai_value_modifier = {
				ai_greed = 2
				ai_honor = 1.5
				ai_energy = 0.5
				ai_compassion = 0.2
				ai_boldness = 0.2
				ai_sociability = 0.5
				ai_vengefulness = 0.3
			}
			modifier = {
				add = 20
				root = {
					has_trait = ambitious
				}
			}
			opinion_modifier = { # Opinion Factor
				who = root
				opinion_target = scope:riseandfall_war_enhancement_attacker.liege
				multiplier = -5
			}
			modifier = {
				add = 30
				root = {
					has_trait = ambitious
				}
			}
		}
	}
	
	# Option: Declare independence if titles allow.
	option = { #independence
		name = riseandfall_war_enhancement.1.d
		trigger = {
			OR = {
				AND = {
					scope:riseandfall_war_enhancement_liege = {
						highest_held_title_tier = tier_empire
					}
					root = {
						highest_held_title_tier = tier_kingdom
					}
				}
				AND = {
					scope:riseandfall_war_enhancement_liege = {
						highest_held_title_tier = tier_kingdom
					}
					root = {
						highest_held_title_tier = tier_duchy
					}				
				}
			}
		}
		war_enhancement_independence_affirmed = yes
		war_enhancement_declare_independence = yes
		ai_chance = {
			base = 0
			ai_value_modifier = {
				ai_greed = 0.2
				ai_boldness = 2
				ai_energy = 0.8
				ai_rationality = -0.75
				ai_vengefulness = 0.2
			}
			modifier = {
				add = 20
				root = {
					has_trait = ambitious
				}
			}
			
			modifier = {
				add = -50
				root = {
					has_trait = content
				}
			}
		}
	}
	
	# Option: Decline to take action.
	option = { # decline
		name = riseandfall_war_enhancement.1.e
		war_enhancement_enthroned_heir = yes
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = -0.75
				ai_boldness = -2.5
				ai_vengefulness = -1
				ai_honor = 0.3
				ai_compassion = 0.3
				ai_rationality = -0.2
				ai_sociability = -1
			}
			modifier = {
				add = 50
				root = {
					has_trait = content
				}
			}
			
			modifier = {
				add = -50
				root = {
					has_trait = ambitious
				}
			}
			opinion_modifier = { # Opinion Factor
				who = root
				opinion_target = scope:riseandfall_war_enhancement_attacker.liege
				multiplier = 2
			}
		}
	}
	
}

# Event: Decide the fate of the previous liege after victory.
riseandfall_war_enhancement.2 = {
	type = character_event
	
	title = riseandfall_war_enhancement.2.t
	desc = riseandfall_war_enhancement.2.d

	theme = intrigue
	left_portrait = {
		character = root
		animation = admiration
	}
	right_portrait = {
		character = scope:riseandfall_war_enhancement_prev_liege
		animation = beg
	}
	
	# Option: Kill every member of their house you can find! Their house must learn.
	option = { 	
		name = riseandfall_war_enhancement.2.e
		trigger = { 
			OR = { 
				has_trait = sadistic
				has_trait = lunatic
				has_trait = possessed
				ai_vengefulness >= 95
				ai_compassion <= -90
				ai_honor <= -90
				has_government = tribal_government
				has_government = nomad_government
				has_government = celestial_government
				has_government = meritocratic_government
				has_government = steppe_admin_government
			}
		}
		war_enhancement_execute_liege_family = yes
		ai_chance = {
			base = -50
			ai_value_modifier = {
				ai_vengefulness = 0.5
				ai_boldness = 0.3
				ai_energy = 0.4
				ai_compassion = -0.6
				ai_honor = -0.4
			}
			opinion_modifier = { # Opinion Factor
				who = root
				opinion_target = scope:riseandfall_war_enhancement_prev_liege
				multiplier = -0.3
			}
			opinion_modifier = { # Opinion Factor
				who = root
				opinion_target = scope:riseandfall_war_enhancement_attacker.liege
				multiplier = -0.3
			}
			modifier = { #  we have a more savage form of government
				add = 125
				root = {
					OR = {
						has_government = nomad_government
					}
				}
			}
			modifier = { #  we have a more savage form of government
				add = 25
				root = {
					OR = {
						has_government = tribal_government
					}
				}
			}
			modifier = { #  human resources are plentiful
				add = 25
				root = {
					OR = {
						has_government = celestial_government
						has_government = meritocratic_government
						has_government = steppe_admin_government
						has_government = japan_administrative_government
						has_government = japan_feudal_government
					}
				}
			}
		}		
	}
	
	# Option: Imprison every member of their house you can find!
	option = { 	
		name = riseandfall_war_enhancement.2.g
		trigger = { 
			OR = { 
				ai_vengefulness >= 50
				ai_honor <= -50
				ai_rationality >= 30
				has_government = tribal_government
				has_government = nomad_government
				has_government = celestial_government
				has_government = meritocratic_government
				has_government = steppe_admin_government
			}
		}
		war_enhancement_imprison_liege_family = yes
		ai_chance = {
			base = 60
			ai_value_modifier = {
				ai_vengefulness = -0.1
				ai_energy = 0.3
				ai_boldness = -0.3
				ai_honor = -0.3
				ai_rationality = 0.6
			}
		}		
	}
	
	# Option: Execute just the previous liege.
	option = { 
		name = riseandfall_war_enhancement.2.a
		war_enhancement_execute_liege = yes
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_vengefulness = 0.2
				ai_boldness = 0.2
				ai_energy = 0.2
				ai_compassion = -0.2
			}
			modifier = {
				add = 15
				root = {
					has_trait = sadistic
				}
			}
			modifier = { #general uneasiness from executing kids (based on age) 
				add = -20
				scope:riseandfall_war_enhancement_prev_liege = {
					age < 20
				}
			}
			modifier = { 
				add = -20
				scope:riseandfall_war_enhancement_prev_liege = {
					age <= 12
				}
			}
			modifier = { 
				add = -20
				scope:riseandfall_war_enhancement_prev_liege = {
					age <= 6
				}
			}
			opinion_modifier = { # Opinion Factor
				who = root
				opinion_target = scope:riseandfall_war_enhancement_prev_liege
				multiplier = -0.2
			}
		}
			
	}

	# Option: Imprison just the previous liege.
	option = { #imprison him
		name = riseandfall_war_enhancement.2.f
		war_enhancement_imprison_liege = yes
		ai_chance = {
			base = 20
			ai_value_modifier = {
				ai_vengefulness = 0.2
				ai_energy = -0.5
				ai_compassion = 0.2
				ai_greed = -0.2
			}
			modifier = {
				add = 15
				root = {
					has_trait = sadistic
				}
			}
			opinion_modifier = { # Opinion Factor
				who = root
				opinion_target = scope:riseandfall_war_enhancement_prev_liege
				multiplier = -0.1
			}
		}
	}
	
	# Option: Do nothing (no punishment for previous liege).
	option = { #do nothing
		name = riseandfall_war_enhancement.2.c
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_vengefulness = -0.2
				ai_energy = -0.5
				ai_compassion = 0.2
				ai_greed = -0.2
			}
			modifier = { #general uneasiness from harshly punishing kids (based on age) 
				add = 10
				scope:riseandfall_war_enhancement_prev_liege = {
					age < 20
				}
			}
			modifier = { 
				add = 10
				scope:riseandfall_war_enhancement_prev_liege = {
					age <= 12
				}
			}
			modifier = { 
				add = 10
				scope:riseandfall_war_enhancement_prev_liege = {
					age <= 6
				}
			}
			opinion_modifier = { # Opinion Factor
				who = root
				opinion_target = scope:riseandfall_war_enhancement_prev_liege
				multiplier = 0.3
			}
		}
	}
}

# Event: The previous liege escaped, now deal with the realm.
riseandfall_war_enhancement.21 = {
	type = character_event
	
	title = riseandfall_war_enhancement.21.t
	desc = riseandfall_war_enhancement.21.d

	theme = intrigue
	left_portrait = {
		character = scope:riseandfall_war_enhancement_prev_liege
		animation = admiration
	}
	
	option = { # escaped, time to deal with the realm
		name = riseandfall_war_enhancement.21.a
			scope:riseandfall_war_enhancement_attacker = {
				trigger_event = {
					id = riseandfall_war_enhancement.1
				}			
			}
	}
}

# Event: Family member considers starting a war against the liege who killed their relative.
riseandfall_war_enhancement.3 = {
	type = character_event
	
	title = riseandfall_war_enhancement.3.t
	desc = riseandfall_war_enhancement.3.d

	theme = realm
	left_portrait = {
		character = root
		animation = rage
	}
	lower_center_portrait = {
		character = scope:killed_man
	}
	right_portrait = {
		character = root.liege
		animation = marshal
	}
	
	trigger = {
		NOT = { root = root.liege }
		scope:killed_man = {
			NOT = {
				OR = {
					death_reason = death_disappearance
					death_reason = death_mysterious
				}
			}
		}
	}
	
	option = {
		name = riseandfall_war_enhancement.3.a
		war_enhancement_start_war_against_liege = yes
		ai_chance = {
			base = -50

			modifier = {
				add = 20
				desc = cft_is_rival_accept_potential
				liege = {
					has_relation_potential_rival = root
				}
			}

			modifier = {
				add = 100
				desc = cft_is_rival_accept
				liege = {
					has_relation_rival = root
				}
			}

			opinion_modifier = { # Opinion Factor
				who = root.liege
				opinion_target = root
				multiplier = -2
			}
			
			modifier = {
				add = 20
				root = {
					has_trait = vengeful
				}
			}
			
			modifier = {
				add = -20
				root.current_military_strength > root.liege.current_military_strength
				root = {
					has_trait = craven
				}
			}
			
			modifier = {
				add = 20
				ai_honor > 0
			}
			
			modifier = {
				add = 30
				ai_vengefulness > medium_positive_ai_value
			}

			modifier = {
				add = -15
				liege = {
					has_dread_level_towards = {
						target = root
						level = 1
					}
				}
			}
			
			modifier = {
				add = -15
				liege = {
					has_dread_level_towards = {
						target = root
						level = 2
					}
				}
			}
			
			modifier = { #Comparative military strength.
				add = {
					value = 1
					subtract = {
						value = root.liege.current_military_strength
						divide = { value = root.current_military_strength min = 1 }
					}
					multiply = 50
					max = 20
				}
			}
		}
	}
	option = {
		name = riseandfall_war_enhancement.3.b
	}
}

# Event: Family member joins a civil war against the liege.
riseandfall_war_enhancement.4 = {
	type = character_event
	
	title = riseandfall_war_enhancement.4.t
	desc = riseandfall_war_enhancement.4.d

	theme = realm
	left_portrait = {
		character = scope:riseandfall_war_enhancement_highest_title_man
		animation = rage
	}
	lower_center_portrait = {
		character = scope:killed_man
	}
	right_portrait = {
		character = root.liege
		animation = marshal
	}
	
	trigger = {
		scope:riseandfall_war_enhancement_highest_title_man = {
			is_at_war_with_liege = yes
		}
	}
	
	option = {
		name = riseandfall_war_enhancement.4.a
		war_enhancement_join_civil_war = yes
		ai_chance = {
			base = -50

			modifier = {
				add = 20
				liege = {
					has_relation_potential_rival = root
				}
			}

			modifier = {
				add = 100

				liege = {
					has_relation_rival = root
				}
			}

			opinion_modifier = { # Opinion Factor
				who = root.liege
				opinion_target = root
				multiplier = -0.8
			}
			
			opinion_modifier = { # Opinion Factor
				who = scope:riseandfall_war_enhancement_highest_title_man
				opinion_target = root
				multiplier = 0.8
			}
			
			modifier = {
				add = 20
				root = {
					has_trait = vengeful
				}
			}
			
			modifier = {
				add = -20
				root.current_military_strength > root.liege.current_military_strength
				scope:recipient = {
					has_trait = craven
				}
			}
			
			modifier = {
				add = 20
				ai_honor > 0
			}
			
			modifier = {
				add = 30
				ai_vengefulness > medium_positive_ai_value
			}

			modifier = {
				add = -15
				liege = {
					has_dread_level_towards = {
						target = root
						level = 1
					}
				}
			}
			
			modifier = {
				add = -15
				liege = {
					has_dread_level_towards = {
						target = root
						level = 2
					}
				}
			}
			
			modifier = { #Comparative military strength.
				add = {
					value = 1
					subtract = {
						value = root.liege.current_military_strength
						divide = { value = root.current_military_strength min = 1 }
					}
					multiply = 50
					max = 20
				}
			}
		}
	}
	option = {
		name = riseandfall_war_enhancement.4.b
	}
}

# Event: Fallen ruler's options when everything is falling apart.
riseandfall_war_enhancement.5 = { #Everything is falling apart, try to escape or do nothing? (other options as well depending on personality)
	type = character_event
	
	title = riseandfall_war_enhancement.5.t
	desc = riseandfall_war_enhancement.5.d

	theme = intrigue
	left_portrait = {
		character = root
		animation = beg
	}
	
	# Option: Attempt to escape via intrigue duel.
	option = { #attempt to escape (with options such as hide, rally allies, or use martial maybe) #intrigue/craven characters prefer, most common
		name = riseandfall_war_enhancement.5.a
		
		duel = {
			skill = intrigue
			target = scope:riseandfall_war_enhancement_attacker

			# Success: root escapes
			60 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}

				hidden_effect = {
					#riseandfall_palace_coup_root_flees_success = yes
					scope:riseandfall_war_enhancement_attacker = { 
						trigger_event = {
							id = riseandfall_war_enhancement.21
						}
					}
				}
			}			# Failure: challenger captures/seizes the ruler
			40 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				hidden_effect = {
					scope:riseandfall_war_enhancement_attacker = {
						trigger_event = { 
							id = riseandfall_war_enhancement.2
						}
					}
				}
			}
		}
		
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_boldness = -0.2
				ai_energy = 0.4
				ai_rationality = 0.2
				ai_honor = -0.6
			}
		}
	}
	
	# Option: Surrender and give up.
	option = { #do nothing/surrender/give up
		name = riseandfall_war_enhancement.5.b
		scope:riseandfall_war_enhancement_attacker = {
			trigger_event = { id = riseandfall_war_enhancement.2 }
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_boldness = -1
				ai_honor = 0.5
				ai_energy = -0.8
				ai_rationality = 0.2
			}
		}
	}
	
	# Option: Fight to the end (requires brave or lunatic trait).
	option = { #Fight to the end (bravery required)
		name = riseandfall_war_enhancement.5.c
		trigger = { 
			OR = {
				has_trait = brave
				has_trait = lunatic
				ai_boldness >= 90
			}
		}
		scope:riseandfall_war_enhancement_attacker = {
			trigger_event = { id = riseandfall_war_enhancement.21 }
		}
		hidden_effect = {
		if = {
			limit = {
				root = {
					martial >= 25
				}
			}
			root = {
				every_knight = {
					limit = { is_alive = yes is_imprisoned = no }
					random_list = {
						60 = { death = { death_reason = death_battle } }
						20 = { add_trait = wounded_1 }
						10 = { add_trait = maimed }
						10 = { }
					}
				}
				death = { death_reason = death_battle } 
			}
		}
		else_if = {
			limit = {
				root = {
					martial >= 20
				}
			}
			root = {
				every_knight = {
					limit = { is_alive = yes is_imprisoned = no }
					random_list = {
						30 = { death = { death_reason = death_battle } }
						20 = { add_trait = wounded_1 }
						10 = { add_trait = maimed }
						30 = { }
					}
				}
				death = { death_reason = death_battle } 
			}
		}
		else_if = {
			limit = {
				root = {
					martial >= 10
				}
			}
			root = {
				every_knight = {
					limit = { is_alive = yes is_imprisoned = no }
					random_list = {
						20 = { death = { death_reason = death_battle } }
						10 = { add_trait = wounded_1 }
						10 = { add_trait = maimed }
						60 = { }
					}
				}
				death = { death_reason = death_battle } 
			}
		}
		else_if = {
			limit = {
				root = {
					martial > 6
				}
			}
			root = {
				every_knight = {
					limit = { is_alive = yes is_imprisoned = no }
					random_list = {
						10 = { death = { death_reason = death_battle } }
						10 = { add_trait = wounded_1 }
						10 = { add_trait = maimed }
						70 = { }
					}
				}
			death = { death_reason = death_battle } 
			}
		}
		else = { #Your knights refused to fight and you were handed over and captured
			scope:riseandfall_war_enhancement_attacker = {
				trigger_event = { id = riseandfall_war_enhancement.2 }
			}
		}
		}
		
		ai_chance = {
			base = 0
			ai_value_modifier = {
				ai_boldness = 0.3
				ai_zeal = 0.3
				ai_rationality = -0.4
			}
		}

	}
	
	# Option: Commit suicide (requires specific traits or flags).
	option = { #commit suicide flavors
		name = riseandfall_war_enhancement.5.d
		trigger = { 
			OR = {
				has_trait = depressed_1
				has_trait = depressed_genetic
				has_trait = lunatic_1
				has_trait = lunatic_genetic
				has_character_flag = make_suicide_available
				has_character_flag = mourning_soulmate
				stress >= extremely_high_stress
			}
		}
	
		
		root = {
			death = { death_reason = death_suicide }
		}
		
		show_as_tooltip = {
			committed_suicide_effect = yes
		}
		scope:riseandfall_war_enhancement_attacker = {
			trigger_event = { id = riseandfall_war_enhancement.21 } #escaped
		}

		ai_chance = {
			base = 0
			ai_value_modifier = {
				ai_boldness = -0.2
				ai_zeal = -0.2
				ai_honor = -0.2
				ai_greed = 0.2
			}
			modifier = {
				add = 10
				has_trait = lunatic_1
			}
			modifier = {
				add = 10
				has_trait = lunatic_genetic
			}
			modifier = {
				add = 10
				stress >= extremely_high_stress
			}
			modifier = {
				factor = 2
				has_trait = depressed_1
			}
			modifier = {
				factor = 2
				has_trait = depressed_genetic
			}
		}
	}
}

# Event: Diarch abdication or power seizure.
riseandfall_war_enhancement.6 = {
	title = riseandfall_war_enhancement.6.t
	desc = riseandfall_war_enhancement.6.d
	type = character_event
	theme = realm
	
	# Option: Abdicate as planned, passing titles to heir.
	option = { #Abdicate as planned (x will become ruler) 
		name = riseandfall_war_enhancement.6.a
		root = {
			save_scope_as = riseandfall_council_regent
		}
		war_enhancement_abdicate_to_heir = yes
		war_enhancement_smooth_election = yes
		ai_chance = {
			base = 100
			ai_value_modifier = {
			ai_honor = 2
			ai_compassion = 2
			ai_vengefulness = -0.6
			}
			
			opinion_modifier = { # Opinion Factor
				who = root
				opinion_target = scope:riseandfall_liege_elective_title.current_heir
				multiplier = 2
			}

			modifier = { #I am the heir.
				add = 100
				scope:riseandfall_liege_elective_title.current_heir = {
					this = root
				}
			}
			
		}
	}
	
	# Option: Extend rule temporarily with some strife.
	option = { #extend our rule for a time (less tyrannical)
		name = riseandfall_war_enhancement.6.b
		root = {
			save_scope_as = riseandfall_council_regent
		}
		war_enhancement_extend_rule = yes
		war_enhancement_delay_council = yes
		ai_chance = {
			base = 100 
			ai_value_modifier = {
			ai_honor = -1
			ai_energy = -1
			ai_compassion = -0.3
			}
			
			opinion_modifier = { # Opinion Factor
				who = root
				opinion_target = scope:riseandfall_liege_elective_title.current_heir
				multiplier = -2
			}
		}
	}
	
	# Option: Seize power tyrannically.
	option = { #seize power (tyrannical)
		root = {
			save_scope_as = riseandfall_council_regent
		}
		name = riseandfall_war_enhancement.6.c
		war_enhancement_seize_power = yes
		war_enhancement_council_overthrow = yes
		ai_chance = {
			base = -100 
			ai_value_modifier = {
			ai_honor = -2
			ai_compassion = -0.3
			ai_greed = 2
			ai_vengefulness = 0.5
			ai_energy = 1
			ai_boldness = 0.8
			}
			
			modifier = { #I am already the heir, there is no reason to seize the realm.
				add = -300
				scope:riseandfall_liege_elective_title.current_heir = {
					this = root
				}
			}
			
			opinion_modifier = { # Opinion Factor
				who = root
				opinion_target = scope:riseandfall_liege_elective_title.current_heir
				multiplier = -3
			}
		}
	}
}

# Event: Liege overthrown! The rebel has left our liege alone. (the liege's heir takes the throne)
riseandfall_war_enhancement.7 = {
	title = riseandfall_war_enhancement.7.t
	desc = riseandfall_war_enhancement.7.d
	type = character_event
	theme = realm
	
	option = { #how shocking
		name = riseandfall_war_enhancement.7.a
	}
}

# Event: Liege overthrown! The rebel is forming a council to select a new suitable liege and I should vote.
riseandfall_war_enhancement.8 = {
	title = riseandfall_war_enhancement.8.t
	desc = riseandfall_war_enhancement.8.d
	type = character_event
	theme = realm
	
	option = { #how shocking, I better vote
		name = riseandfall_war_enhancement.8.a
	}
}

# Event: Liege overthrown! The rebel has restored princely elective succession.
riseandfall_war_enhancement.9 = {
	title = riseandfall_war_enhancement.9.t
	desc = riseandfall_war_enhancement.9.d
	type = character_event
	theme = realm
	
	option = { # well that's nice
		name = riseandfall_war_enhancement.9.a
	}
}

# Event: Liege overthrown! The rebel has affirmed their independence from the realm.
riseandfall_war_enhancement.10 = {
	title = riseandfall_war_enhancement.10.t
	desc = riseandfall_war_enhancement.10.d
	type = character_event
	theme = realm
	
	option = { #Suicidal!
		name = riseandfall_war_enhancement.10.a
	}
}

# Event: Liege overthrown! The rebel has removed our elective system.
riseandfall_war_enhancement.11 = {
	title = riseandfall_war_enhancement.11.t
	desc = riseandfall_war_enhancement.11.d
	type = character_event
	theme = realm
	
	option = { #That wasn't very nice
		name = riseandfall_war_enhancement.11.a
	}
}

# Event: The regent has delayed the council meeting to choose a new liege.
riseandfall_war_enhancement.12 = {
	title = riseandfall_war_enhancement.12.t
	desc = riseandfall_war_enhancement.12.d
	type = character_event
	theme = realm
	
	option = { #What's he up to?
		name = riseandfall_war_enhancement.12.a
	}
}

# Event: The regent has overthrown the council and crowned themselves ruler!
riseandfall_war_enhancement.13 = {
	title = riseandfall_war_enhancement.13.t
	desc = riseandfall_war_enhancement.13.d
	type = character_event
	theme = realm
	
	option = { #That is not very feudal of them
		name = riseandfall_war_enhancement.13.a
	}
}

# Event: The council has elected a liege and the regent has given up power.
riseandfall_war_enhancement.14 = {
	title = riseandfall_war_enhancement.14.t
	desc = riseandfall_war_enhancement.14.d
	type = character_event
	theme = realm
	
	option = { #So, everything went well.
		name = riseandfall_war_enhancement.14.a
	}
}

# Event: Liege clan house overthrown!
riseandfall_war_enhancement.15 = {
	title = riseandfall_war_enhancement.15.t
	desc = riseandfall_war_enhancement.15.d
	type = character_event
	theme = realm
	
	option = { #Their house has shown their strength. Is this the will of the one?
		name = riseandfall_war_enhancement.15.a
	}
}

# Event: Liege overthrown in a primitive system.
riseandfall_war_enhancement.16 = {
	title = riseandfall_war_enhancement.16.t
	desc = riseandfall_war_enhancement.16.d
	type = character_event
	theme = realm
	
	option = { # These things happen.
		name = riseandfall_war_enhancement.16.a
	}
}


	
