﻿namespace = gdp_republic_unrest

### Severity 1
# A List of Grievances
gdp_republic_unrest.0001 = {
	type = character_event
	window = big_event_window
	title = gdp_republic_unrest.0001.t
	desc = gdp_republic_unrest.0001.desc
	theme = republic
	override_background = { reference = courtyard }
	left_portrait = {
		character = root
		animation = dismissal
	}

	trigger = {
		exists = scope:faction
	}

	# Option A - Disperse the Crowd
	option = {
		name = gdp_republic_unrest.0001.a
		capital_county = { 
			add_popular_opinion = -15 
			change_county_control = 15
		}
		add_dread = 15
		scope:faction = { gdp_republic_unrest_resolve_partial_effect = yes }
		stress_and_fulfillment_impact = {
			compassionate = medium_stress_impact_gain
			just = minor_stress_impact_gain
			callous = minor_stress_impact_loss
		}
		ai_chance = { base = 0 }
	}

	# Option B - Stewardship duel (shown when stewardship >= diplomacy)
	option = {
		name = gdp_republic_unrest.0001.b
		trigger = {
			stewardship >= diplomacy
		}
		duel = {
			skill = stewardship
			value = high_skill_rating
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
				}
				desc = gdp_republic_unrest.0001.b.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = gdp_republic_unrest.0001.b.success.toast
					left_icon = root
					add_prestige = minor_prestige_gain
					capital_county = { add_popular_opinion = 10 }
					scope:faction = { gdp_republic_unrest_resolve_full_effect = yes }
					stress_and_fulfillment_impact = {
						arrogant = minor_stress_impact_loss
					}
				}
			}
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
				}
				desc = gdp_republic_unrest.0001.b.fail
				send_interface_toast = {
					type = event_toast_effect_bad
					title = gdp_republic_unrest.0001.b.fail.toast
					left_icon = root
					capital_county = { add_popular_opinion = -15 }
					add_prestige = minor_prestige_loss
					scope:faction = { gdp_republic_unrest_resolve_fail_effect = yes }
					add_stress = minor_stress_impact_gain
					stress_and_fulfillment_impact = {
						arrogant = minor_stress_impact_gain
					}
				}
			}
		}
		ai_chance = {
			base = 0
			modifier = {
				add = 50
				NOT = { gold >= medium_gold_value }
			}
		}
	}

	# Option C - Diplomacy duel (shown when diplomacy > stewardship)
	option = {
		name = gdp_republic_unrest.0001.c
		trigger = {
			diplomacy > stewardship
		}
		duel = {
			skill = diplomacy
			value = high_skill_rating
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
				}
				desc = gdp_republic_unrest.0001.c.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = gdp_republic_unrest.0001.c.success.toast
					left_icon = root
					add_prestige = minor_prestige_gain
					capital_county = { add_popular_opinion = 10 }
					scope:faction = { gdp_republic_unrest_resolve_full_effect = yes }
					stress_and_fulfillment_impact = {
						arrogant = minor_stress_impact_loss
					}
				}
			}
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
				}
				desc = gdp_republic_unrest.0001.c.fail
				send_interface_toast = {
					type = event_toast_effect_bad
					title = gdp_republic_unrest.0001.c.fail.toast
					left_icon = root
					capital_county = { add_popular_opinion = -15 }
					add_prestige = minor_prestige_loss
					scope:faction = { gdp_republic_unrest_resolve_fail_effect = yes }
					add_stress = minor_stress_impact_gain
					stress_and_fulfillment_impact = {
						arrogant = minor_stress_impact_gain
					}
				}
			}
		}
		ai_chance = {
			base = 0
			modifier = {
				add = 50
				NOT = { gold >= medium_gold_value }
			}
		}
	}

	# Option D - Concessions
	option = {
		name = gdp_republic_unrest.0001.d
		trigger = {
			gold >= medium_gold_value
		}
		remove_short_term_gold = medium_gold_value
		capital_county = { add_popular_opinion = 10 }
		add_prestige = minor_prestige_gain
		scope:faction = { gdp_republic_unrest_resolve_full_effect = yes }
		stress_and_fulfillment_impact = {
			greedy = minor_stress_impact_gain
			arbitrary = minor_stress_impact_gain
			generous = minor_stress_impact_loss
		}
		ai_chance = { base = 100 }
	}
}

# The Cold Reception - A visible shift in the city's mood
gdp_republic_unrest.0011 = {
	type = character_event
	window = big_event_window
	title = gdp_republic_unrest.0011.t
	desc = gdp_republic_unrest.0011.desc
	theme = republic
	override_background = { reference = gdp_artisan_street_crowd }
	left_portrait = {
		character = root
		animation = worry
	}

	trigger = {
		exists = scope:faction
	}

	# Option B - Investigate quietly (Intrigue duel, shown when intrigue >= diplomacy)
	option = {
		name = gdp_republic_unrest.0011.b
		trigger = { intrigue >= diplomacy }
		duel = {
			skill = intrigue
			value = high_skill_rating
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = 1
				}
				desc = gdp_republic_unrest.0011.b.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = gdp_republic_unrest.0011.b.success.toast
					left_icon = root
					capital_county = { add_popular_opinion = 10 }
					scope:faction = { gdp_republic_unrest_resolve_full_effect = yes }
				}
			}
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = 1
				}
				desc = gdp_republic_unrest.0011.b.fail
				send_interface_toast = {
					type = event_toast_effect_bad
					title = gdp_republic_unrest.0011.b.fail.toast
					left_icon = root
					capital_county = { add_popular_opinion = -10 }
					scope:faction = { gdp_republic_unrest_resolve_fail_effect = yes }
				}
			}
		}
		ai_chance = {
			base = 0
			modifier = {
				add = 50
				NOT = { gold >= minor_gold_value }
			}
		}
	}

	# Option C - Stop and talk to people (Diplomacy duel, shown when diplomacy > intrigue)
	option = {
		name = gdp_republic_unrest.0011.c
		trigger = { diplomacy > intrigue }
		duel = {
			skill = diplomacy
			value = high_skill_rating
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = 1
				}
				desc = gdp_republic_unrest.0011.c.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = gdp_republic_unrest.0011.c.success.toast
					left_icon = root
					capital_county = { add_popular_opinion = 10 }
					scope:faction = { gdp_republic_unrest_resolve_full_effect = yes }
				}
			}
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = 1
				}
				desc = gdp_republic_unrest.0011.c.fail
				send_interface_toast = {
					type = event_toast_effect_bad
					title = gdp_republic_unrest.0011.c.fail.toast
					left_icon = root
					capital_county = { add_popular_opinion = -10 }
					scope:faction = { gdp_republic_unrest_resolve_fail_effect = yes }
				}
			}
		}
		ai_chance = {
			base = 0
			modifier = {
				add = 50
				NOT = { gold >= minor_gold_value }
			}
		}
	}

	# Option D - Order a public gesture (gated on gold >= minor_gold_value)
	option = {
		name = gdp_republic_unrest.0011.d
		trigger = {
			gold >= minor_gold_value
		}
		remove_short_term_gold = minor_gold_value
		capital_county = { add_popular_opinion = 10 }
		scope:faction = { gdp_republic_unrest_resolve_full_effect = yes }
		stress_and_fulfillment_impact = {
			greedy = minor_stress_impact_gain
			generous = minor_stress_impact_loss
		}
		ai_chance = { base = 100 }
	}

	# Option A - Keep moving (always available)
	option = {
		name = gdp_republic_unrest.0011.a
		capital_county = { add_popular_opinion = -5 }
		scope:faction = { gdp_republic_unrest_resolve_fail_effect = yes }
		stress_and_fulfillment_impact = {
			compassionate = minor_stress_impact_gain
			just = minor_stress_impact_gain
			callous = minor_stress_impact_loss
		}
		ai_chance = { base = 0 }
	}
}

# The Anonymous Letter - A private note of criticism arrives at the palace
gdp_republic_unrest.0021 = {
	type = character_event
	window = big_event_window
	title = gdp_republic_unrest.0021.t
	desc = gdp_republic_unrest.0021.desc
	theme = republic
	override_background = { reference = study }
	left_portrait = {
		character = root
		animation = worry
	}

	trigger = {
		exists = scope:faction
	}

	# Option B - Investigate who wrote it (Intrigue duel, always available)
	option = {
		name = gdp_republic_unrest.0021.b
		duel = {
			skill = intrigue
			value = high_skill_rating
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = 1
				}
				desc = gdp_republic_unrest.0021.b.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = gdp_republic_unrest.0021.b.success.toast
					left_icon = root
					add_dread = 10
					capital_county = {
						add_popular_opinion = 10
						change_county_control = 5
					}
					scope:faction = { gdp_republic_unrest_resolve_full_effect = yes }
				}
			}
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = 1
				}
				desc = gdp_republic_unrest.0021.b.fail
				send_interface_toast = {
					type = event_toast_effect_bad
					title = gdp_republic_unrest.0021.b.fail.toast
					left_icon = root
					capital_county = { add_popular_opinion = -15 }
					scope:faction = { gdp_republic_unrest_resolve_fail_effect = yes }
				}
			}
		}
		ai_chance = { base = 50 }
	}

	# Option C - Draft a public response (Diplomacy duel, always available)
	option = {
		name = gdp_republic_unrest.0021.c
		duel = {
			skill = diplomacy
			value = high_skill_rating
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = 1
				}
				desc = gdp_republic_unrest.0021.c.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = gdp_republic_unrest.0021.c.success.toast
					left_icon = root
					capital_county = { add_popular_opinion = 15 }
					scope:faction = { gdp_republic_unrest_resolve_full_effect = yes }
				}
			}
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = 1
				}
				desc = gdp_republic_unrest.0021.c.fail
				send_interface_toast = {
					type = event_toast_effect_bad
					title = gdp_republic_unrest.0021.c.fail.toast
					left_icon = root
					capital_county = { add_popular_opinion = -10 }
					scope:faction = { gdp_republic_unrest_resolve_fail_effect = yes }
				}
			}
		}
		ai_chance = { base = 50 }
	}

	# Option A - Burn it (always available)
	option = {
		name = gdp_republic_unrest.0021.a
		capital_county = { add_popular_opinion = -5 }
		scope:faction = { gdp_republic_unrest_resolve_fail_effect = yes }
		stress_and_fulfillment_impact = {
			just = minor_stress_impact_gain
			diligent = minor_stress_impact_gain
			arrogant = minor_stress_impact_loss
		}
		ai_chance = { base = 0 }
	}
}

### Severity 2
# The Square Belongs to Them Now
gdp_republic_unrest.0101 = {
	type = character_event
	window = big_event_window
	title = gdp_republic_unrest.0101.t
	desc = gdp_republic_unrest.0101.desc
	theme = republic
	override_background = { reference = market }
	left_portrait = {
		character = root
		animation = stress
	}
	right_portrait = {
		character = scope:demagogue
		animation = anger
	}

	trigger = {
		exists = scope:faction
	}

	immediate = {
		random_courtier = {
			limit = {
				is_available_ai_adult = yes
				opinion = { target = root value < -10 }
				OR = {
					NOT = { exists = house }
					AND = {
						exists = root.house
						house = { NOT = { has_same_house_aspiration_as = root.house } }
					}
				}
			}
			weight = {
				base = 1
				modifier = {
					add = 20
					opinion = { target = root value < -20 }
				}
				modifier = {
					add = 40
					opinion = { target = root value < -40 }
				}
			}
			save_scope_as = demagogue
		}
		if = {
			limit = { NOT = { exists = scope:demagogue } }
			create_character = {
				template = gdp_republic_demagogue_template
				location = root.capital_province
				save_scope_as = demagogue
			}
		}
	}

	# Option A - Disperse the Crowd
	option = {
		name = gdp_republic_unrest.0101.a
		capital_county = { 
			add_popular_opinion = -20 
			change_county_control = 20
		}
		add_dread = 20
		scope:faction = { gdp_republic_unrest_resolve_partial_effect = yes }
		stress_and_fulfillment_impact = {
			compassionate = medium_stress_impact_gain
			just = minor_stress_impact_gain
			callous = minor_stress_impact_loss
		}
		ai_chance = { base = 0 }
	}

	# Option B - Intrigue duel (shown when intrigue >= diplomacy)
	option = {
		name = gdp_republic_unrest.0101.b
		trigger = {
			intrigue >= diplomacy
		}
		duel = {
			skill = intrigue
			value = very_high_skill_rating
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
				}
				desc = gdp_republic_unrest.0101.b.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = gdp_republic_unrest.0101.b.success.toast
					left_icon = root
					right_icon = scope:demagogue
					add_prestige = minor_prestige_gain
					capital_county = { add_popular_opinion = 20 }
					scope:faction = { gdp_republic_unrest_resolve_full_effect = yes }
					stress_and_fulfillment_impact = {
						arrogant = minor_stress_impact_loss
					}
				}
			}
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
				}
				desc = gdp_republic_unrest.0101.b.fail
				send_interface_toast = {
					type = event_toast_effect_bad
					title = gdp_republic_unrest.0101.b.fail.toast
					left_icon = root
					right_icon = scope:demagogue
					capital_county = { 
						add_popular_opinion = -20 
						change_county_control = -15
					}
					add_prestige = minor_prestige_loss
					scope:faction = { gdp_republic_unrest_resolve_fail_effect = yes }
					add_stress = minor_stress_impact_gain
					stress_and_fulfillment_impact = {
						arrogant = minor_stress_impact_gain
					}
				}
			}
		}
		ai_chance = {
			base = 0
			modifier = {
				add = 50
				NOT = { gold >= major_gold_value }
			}
		}
	}

	# Option C - Diplomacy duel (shown when diplomacy > intrigue)
	option = {
		name = gdp_republic_unrest.0101.c
		trigger = {
			diplomacy > intrigue
		}
		duel = {
			skill = diplomacy
			value = very_high_skill_rating
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
				}
				desc = gdp_republic_unrest.0101.c.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = gdp_republic_unrest.0101.c.success.toast
					left_icon = root
					right_icon = scope:demagogue
					add_prestige = minor_prestige_gain
					capital_county = { add_popular_opinion = 20 }
					scope:faction = { gdp_republic_unrest_resolve_full_effect = yes }
					stress_and_fulfillment_impact = {
						arrogant = minor_stress_impact_loss
					}
				}
			}
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
				}
				desc = gdp_republic_unrest.0101.c.fail
				send_interface_toast = {
					type = event_toast_effect_bad
					title = gdp_republic_unrest.0101.c.fail.toast
					left_icon = root
					right_icon = scope:demagogue
					capital_county = {
						add_popular_opinion = -20
						change_county_control = -15
					}
					add_prestige = minor_prestige_loss
					scope:faction = { gdp_republic_unrest_resolve_fail_effect = yes }
					add_stress = minor_stress_impact_gain
					stress_and_fulfillment_impact = {
						arrogant = minor_stress_impact_gain
					}
				}
			}
		}
		ai_chance = {
			base = 0
			modifier = {
				add = 50
				NOT = { gold >= major_gold_value }
			}
		}
	}

	# Option D - Concessions
	option = {
		name = gdp_republic_unrest.0101.d
		trigger = {
			gold >= major_gold_value
		}
		remove_short_term_gold = major_gold_value
		capital_county = { add_popular_opinion = 20 }
		add_prestige = minor_prestige_gain
		scope:faction = { gdp_republic_unrest_resolve_full_effect = yes }
		stress_and_fulfillment_impact = {
			greedy = minor_stress_impact_gain
			arbitrary = minor_stress_impact_gain
			generous = minor_stress_impact_loss
		}
		ai_chance = { base = 100 }
	}

	after = {
		if = {
			limit = {
				scope:demagogue ?= { has_character_flag = created }
			}
			scope:demagogue ?= { silent_disappearance_effect = yes }
		}
	}
}

scripted_trigger district_types_for_gdp_unrest = {
	OR = {
		district_type = district_type:guild_district
		district_type = district_type:market_district
		district_type = district_type:port_district
		district_type = district_type:bureaucratic_district
		district_type = district_type:temple_district
		district_type = district_type:entertainment_district
		district_type = district_type:urban_housing_district
	}
}

# The Closed Quarter - A district shuts itself off from city authority
gdp_republic_unrest.0111 = {
	type = character_event
	window = big_event_window
	title = gdp_republic_unrest.0111.t
	desc = gdp_republic_unrest.0111.desc
	theme = republic
	override_background = { reference = gdp_artisan_street }
	left_portrait = {
		character = root
		animation = worry
	}

	trigger = {
		exists = scope:faction
		capital_county.title_province = {
			any_built_regular_district = {
				district_types_for_gdp_unrest = yes
			}
		}
	}

	immediate = {
		capital_county.title_province = {
			random_built_regular_district = {
				limit = {
					district_types_for_gdp_unrest = yes
				}
				save_scope_as = closed_district
			}
		}
	}

	# Option A - Force entry (always available)
	option = {
		name = gdp_republic_unrest.0111.a
		add_dread = 15
		capital_county = {
			add_popular_opinion = -20
			change_county_control = 15
		}
		scope:faction = { gdp_republic_unrest_resolve_partial_effect = yes }
		stress_and_fulfillment_impact = {
			compassionate = medium_stress_impact_gain
			callous = minor_stress_impact_loss
		}
		ai_chance = { base = 0 }
	}

	# Option B - Negotiate (Stewardship duel, shown when stewardship >= diplomacy)
	option = {
		name = gdp_republic_unrest.0111.b
		trigger = { stewardship >= diplomacy }
		stress_and_fulfillment_impact = {
			greedy = minor_stress_impact_gain
		}
		duel = {
			skill = stewardship
			value = high_skill_rating
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = 1
				}
				desc = gdp_republic_unrest.0111.b.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = gdp_republic_unrest.0111.b.success.toast
					left_icon = root
					remove_short_term_gold = minor_gold_value
					capital_county = { add_popular_opinion = 20 }
					scope:faction = { gdp_republic_unrest_resolve_full_effect = yes }
				}
			}
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = 1
				}
				desc = gdp_republic_unrest.0111.b.fail
				send_interface_toast = {
					type = event_toast_effect_bad
					title = gdp_republic_unrest.0111.b.fail.toast
					left_icon = root
					capital_county = { add_popular_opinion = -10 }
					gdp_republic_unrest_district_shutdown_modifier_effect = yes
					scope:faction = { gdp_republic_unrest_resolve_fail_effect = yes }
				}
			}
		}
		ai_chance = { base = 100 }
	}

	# Option C - Persuade (Diplomacy duel, shown when diplomacy > stewardship)
	option = {
		name = gdp_republic_unrest.0111.c
		trigger = { diplomacy > stewardship }
		stress_and_fulfillment_impact = {
			arrogant = minor_stress_impact_loss
		}
		duel = {
			skill = diplomacy
			value = high_skill_rating
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = 1
				}
				desc = gdp_republic_unrest.0111.c.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = gdp_republic_unrest.0111.c.success.toast
					left_icon = root
					add_prestige = medium_prestige_gain
					capital_county = { add_popular_opinion = 20 }
					scope:faction = { gdp_republic_unrest_resolve_full_effect = yes }
				}
			}
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = 1
				}
				desc = gdp_republic_unrest.0111.c.fail
				send_interface_toast = {
					type = event_toast_effect_bad
					title = gdp_republic_unrest.0111.c.fail.toast
					left_icon = root
					capital_county = { add_popular_opinion = -10 }
					gdp_republic_unrest_district_shutdown_modifier_effect = yes
					scope:faction = { gdp_republic_unrest_resolve_fail_effect = yes }
				}
			}
		}
		ai_chance = { base = 100 }
	}

	# Option D - Leave it (always available)
	option = {
		name = gdp_republic_unrest.0111.d
		capital_county = { add_popular_opinion = -5 }
		gdp_republic_unrest_district_shutdown_modifier_effect = yes
		scope:faction = { gdp_republic_unrest_resolve_fail_effect = yes }
		stress_and_fulfillment_impact = {
			just = minor_stress_impact_gain
			diligent = minor_stress_impact_gain
			arbitrary = minor_stress_impact_loss
		}
		ai_chance = { base = 0 }
	}
}

# The Effigy - A likeness of the ruler is put on display in the public square
gdp_republic_unrest.0121 = {
	type = character_event
	window = big_event_window
	title = gdp_republic_unrest.0121.t
	desc = gdp_republic_unrest.0121.desc
	theme = republic
	override_background = { reference = market }
	left_portrait = {
		character = root
		animation = stress
	}

	trigger = {
		exists = scope:faction
	}

	# Option A - Tear it down (always available)
	option = {
		name = gdp_republic_unrest.0121.a
		flavor = gdp_republic_unrest.0121.a.flavor
		capital_county = {
			add_popular_opinion = -15
			change_county_control = 10
		}
		scope:faction = { gdp_republic_unrest_resolve_partial_effect = yes }
		stress_and_fulfillment_impact = {
			compassionate = medium_stress_impact_gain
			callous = minor_stress_impact_loss
		}
		ai_chance = { base = 0 }
	}

	# Option B - Hunt the organizers (Intrigue duel, shown when intrigue >= diplomacy)
	option = {
		name = gdp_republic_unrest.0121.b
		trigger = { intrigue >= diplomacy }
		stress_and_fulfillment_impact = {
			honest = minor_stress_impact_gain
			deceitful = minor_stress_impact_loss
		}
		duel = {
			skill = intrigue
			value = high_skill_rating
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = 1
				}
				desc = gdp_republic_unrest.0121.b.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = gdp_republic_unrest.0121.b.success.toast
					left_icon = root
					add_dread = 10
					capital_county = { add_popular_opinion = 20 }
					scope:faction = { gdp_republic_unrest_resolve_full_effect = yes }
				}
			}
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = 1
				}
				desc = gdp_republic_unrest.0121.b.fail
				send_interface_toast = {
					type = event_toast_effect_bad
					title = gdp_republic_unrest.0121.b.fail.toast
					left_icon = root
					capital_county = { add_popular_opinion = -20 }
					scope:faction = { gdp_republic_unrest_resolve_fail_effect = yes }
				}
			}
		}
		ai_chance = { base = 0 }
	}

	# Option C - Address it publicly (Diplomacy duel, shown when diplomacy > intrigue)
	option = {
		name = gdp_republic_unrest.0121.c
		trigger = { diplomacy > intrigue }
		stress_and_fulfillment_impact = {
			arrogant = minor_stress_impact_loss
		}
		duel = {
			skill = diplomacy
			value = high_skill_rating
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = 1
				}
				desc = gdp_republic_unrest.0121.c.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = gdp_republic_unrest.0121.c.success.toast
					left_icon = root
					add_prestige = minor_prestige_gain
					capital_county = { add_popular_opinion = 20 }
					scope:faction = { gdp_republic_unrest_resolve_full_effect = yes }
				}
			}
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = 1
				}
				desc = gdp_republic_unrest.0121.c.fail
				send_interface_toast = {
					type = event_toast_effect_bad
					title = gdp_republic_unrest.0121.c.fail.toast
					left_icon = root
					capital_county = { add_popular_opinion = -20 }
					scope:faction = { gdp_republic_unrest_resolve_fail_effect = yes }
					stress_and_fulfillment_impact = {
						arrogant = minor_stress_impact_gain
					}
				}
			}
		}
		ai_chance = { base = 0 }
	}

	# Option D - Ignore it (always available)
	option = {
		name = gdp_republic_unrest.0121.d
		capital_county = { add_popular_opinion = -10 }
		scope:faction = { gdp_republic_unrest_resolve_fail_effect = yes }
		stress_and_fulfillment_impact = {
			arrogant = medium_stress_impact_gain
			just = minor_stress_impact_gain
			callous = minor_stress_impact_loss
		}
		ai_chance = { base = 100 }
	}
}

### Severity 3
# The City is Burning
gdp_republic_unrest.0201 = {
	type = character_event
	window = big_event_window
	title = gdp_republic_unrest.0201.t
	desc = gdp_republic_unrest.0201.desc
	theme = republic
	override_background = { reference = burning_building }
	left_portrait = {
		character = root
		animation = stress
	}
	right_portrait = {
		character = scope:demagogue
		animation = anger
	}

	trigger = {
		exists = scope:faction
	}

	immediate = {
		random_courtier = {
			limit = {
				is_ai = yes
				is_adult = yes
				opinion = { target = root value < -10 }
				OR = {
					NOT = { exists = house }
					AND = {
						exists = root.house
						house = { NOT = { has_same_house_aspiration_as = root.house } }
					}
				}
			}
			weight = {
				base = 1
				modifier = {
					add = 20
					opinion = { target = root value < -20 }
				}
				modifier = {
					add = 40
					opinion = { target = root value < -40 }
				}
			}
			save_scope_as = demagogue
		}
		if = {
			limit = { NOT = { exists = scope:demagogue } }
			create_character = {
				template = gdp_republic_demagogue_template
				location = root.capital_province
				save_scope_as = demagogue
			}
		}
	}

	# Option A - Military crackdown
	option = {
		name = gdp_republic_unrest.0201.a
		capital_county = { 
			add_popular_opinion = -30 
			change_county_control = 30
			change_prosperity_level = -5
			add_county_modifier = {
				modifier = gdp_republic_riot_aftermath
				years = 2
			}
		}
		add_dread = 30
		scope:faction = { gdp_republic_unrest_resolve_partial_effect = yes }
		stress_and_fulfillment_impact = {
			compassionate = major_stress_impact_gain
			just = medium_stress_impact_gain
			callous = minor_stress_impact_loss
		}
		ai_chance = { base = 0 }
	}

	# Option B - Lead the guard (Martial duel - shown when martial >= diplomacy)
	option = {
		name = gdp_republic_unrest.0201.b
		trigger = {
			martial >= diplomacy
		}
		duel = {
			skill = martial
			value = extremely_high_skill_rating
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
				}
				desc = gdp_republic_unrest.0201.b.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = gdp_republic_unrest.0201.b.success.toast
					left_icon = root
					right_icon = scope:demagogue
					add_prestige = minor_prestige_gain
					capital_county = { add_popular_opinion = 20 }
					scope:faction = { gdp_republic_unrest_resolve_full_effect = yes }
					stress_and_fulfillment_impact = {
						arrogant = minor_stress_impact_loss
					}
				}
			}
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
				}
				desc = gdp_republic_unrest.0201.b.fail
				send_interface_toast = {
					type = event_toast_effect_bad
					title = gdp_republic_unrest.0201.b.fail.toast
					left_icon = root
					right_icon = scope:demagogue
					capital_county = {
						add_popular_opinion = -30
						change_county_control = -20
						change_prosperity_level = -5
					}
					add_prestige = minor_prestige_loss
					increase_wounds_no_death_effect = { REASON = fight }
					scope:faction = { gdp_republic_unrest_resolve_fail_effect = yes }
					add_stress = minor_stress_impact_gain
					stress_and_fulfillment_impact = {
						arrogant = minor_stress_impact_gain
					}
				}
			}
		}
		ai_chance = { base = 0 }
	}

	# Option C - Address the crowd (Diplomacy duel - shown when diplomacy > martial)
	option = {
		name = gdp_republic_unrest.0201.c
		trigger = {
			diplomacy > martial
		}
		duel = {
			skill = diplomacy
			value = extremely_high_skill_rating
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
				}
				desc = gdp_republic_unrest.0201.c.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = gdp_republic_unrest.0201.c.success.toast
					left_icon = root
					right_icon = scope:demagogue
					add_prestige = minor_prestige_gain
					capital_county = { add_popular_opinion = 20 }
					scope:faction = { gdp_republic_unrest_resolve_full_effect = yes }
					stress_and_fulfillment_impact = {
						arrogant = minor_stress_impact_loss
					}
				}
			}
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
				}
				desc = gdp_republic_unrest.0201.c.fail
				send_interface_toast = {
					type = event_toast_effect_bad
					title = gdp_republic_unrest.0201.c.fail.toast
					left_icon = root
					right_icon = scope:demagogue
					capital_county = {
						add_popular_opinion = -30
						change_county_control = -20
						change_prosperity_level = -5
					}
					add_prestige = minor_prestige_loss
					increase_wounds_no_death_effect = { REASON = fight }
					scope:faction = { gdp_republic_unrest_resolve_fail_effect = yes }
					add_stress = minor_stress_impact_gain
					stress_and_fulfillment_impact = {
						arrogant = minor_stress_impact_gain
					}
				}
			}
		}
		ai_chance = { base = 0 }
	}

	# Option D - Empty the treasury
	option = {
		name = gdp_republic_unrest.0201.d
		remove_short_term_gold = root.gold
		remove_short_term_treasury = root.treasury
		capital_county = { add_popular_opinion = 25 }
		add_prestige = minor_prestige_gain
		scope:faction = { gdp_republic_unrest_resolve_full_effect = yes }
		every_vassal = {
			custom = republic_vassals
			limit = { government_has_flag = government_is_republic }
			add_opinion = {
				modifier = wasted_treasury_opinion
				target = root
				opinion = -20
			}
		}
		stress_and_fulfillment_impact = {
			greedy = minor_stress_impact_gain
			arbitrary = minor_stress_impact_gain
			generous = minor_stress_impact_loss
		}
		ai_chance = { base = 100 }
	}

	after = {
		if = {
			limit = {
				exists = scope:demagogue
				scope:demagogue = { has_character_flag = created }
			}
			scope:demagogue = { silent_disappearance_effect = yes }
		}
	}
}

# The Strike - The guilds and merchants have shut down commerce
gdp_republic_unrest.0211 = {
	type = character_event
	window = big_event_window
	title = gdp_republic_unrest.0211.t
	desc = gdp_republic_unrest.0211.desc
	theme = republic
	override_background = { reference = gdp_artisan_street }
	left_portrait = {
		character = root
		animation = stress
	}

	trigger = {
		exists = scope:faction
	}

	# Option A - Negotiate (Diplomacy duel, shown when diplomacy >= stewardship)
	option = {
		name = gdp_republic_unrest.0211.a
		trigger = { diplomacy >= stewardship }
		duel = {
			skill = diplomacy
			value = very_high_skill_rating
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = 1
				}
				desc = gdp_republic_unrest.0211.a.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = gdp_republic_unrest.0211.a.success.toast
					left_icon = root
					capital_county = { add_popular_opinion = 20 }
					scope:faction = { gdp_republic_unrest_resolve_full_effect = yes }
				}
			}
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = 1
				}
				desc = gdp_republic_unrest.0211.a.fail
				send_interface_toast = {
					type = event_toast_effect_bad
					title = gdp_republic_unrest.0211.a.fail.toast
					left_icon = root
					capital_county = { add_popular_opinion = -20 }
					scope:faction = { gdp_republic_unrest_resolve_fail_effect = yes }
				}
			}
		}
		ai_chance = { base = 0 }
	}

	# Option B - Pay their demands (Stewardship duel, shown when stewardship > diplomacy)
	option = {
		name = gdp_republic_unrest.0211.b
		trigger = { stewardship > diplomacy }
		duel = {
			skill = stewardship
			value = very_high_skill_rating
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = 1
				}
				desc = gdp_republic_unrest.0211.b.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = gdp_republic_unrest.0211.b.success.toast
					left_icon = root
					remove_short_term_gold = medium_gold_value
					capital_county = { add_popular_opinion = 20 }
					scope:faction = { gdp_republic_unrest_resolve_full_effect = yes }
				}
			}
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = 1
				}
				desc = gdp_republic_unrest.0211.b.fail
				send_interface_toast = {
					type = event_toast_effect_bad
					title = gdp_republic_unrest.0211.b.fail.toast
					left_icon = root
					capital_county = { add_popular_opinion = -20 }
					scope:faction = { gdp_republic_unrest_resolve_fail_effect = yes }
				}
			}
		}
		ai_chance = { base = 0 }
	}

	# Option C - Force them back (always available)
	option = {
		name = gdp_republic_unrest.0211.c
		add_dread = 20
		capital_county = {
			add_popular_opinion = -25
			change_county_control = 20
		}
		scope:faction = { gdp_republic_unrest_resolve_partial_effect = yes }
		stress_and_fulfillment_impact = {
			compassionate = medium_stress_impact_gain
			callous = minor_stress_impact_loss
		}
		ai_chance = { base = 0 }
	}

	# Option D - Give in entirely (always available)
	option = {
		name = gdp_republic_unrest.0211.d
		remove_short_term_treasury = major_treasury_value
		capital_county = {
			add_popular_opinion = 30
			change_county_control = -20
		}
		scope:faction = { gdp_republic_unrest_resolve_full_effect = yes }
		stress_and_fulfillment_impact = {
			base = 50
		}
		ai_chance = { base = 100 }
	}
}

# The Manuscript - Anonymous accusations spread across the city
gdp_republic_unrest.0221 = {
	type = character_event
	window = big_event_window
	title = gdp_republic_unrest.0221.t
	desc = gdp_republic_unrest.0221.desc
	theme = republic
	override_background = { reference = study }
	left_portrait = {
		character = root
		animation = worry
	}

	trigger = {
		exists = scope:faction
	}

	# Option A - Hunt the author (Intrigue duel, shown when intrigue >= diplomacy)
	option = {
		name = gdp_republic_unrest.0221.a
		trigger = { intrigue >= diplomacy }
		duel = {
			skill = intrigue
			value = very_high_skill_rating
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = 1
				}
				desc = gdp_republic_unrest.0221.a.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = gdp_republic_unrest.0221.a.success.toast
					left_icon = root
					add_prestige = minor_prestige_gain
					capital_county = { add_popular_opinion = 20 }
					scope:faction = { gdp_republic_unrest_resolve_full_effect = yes }
				}
			}
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = 1
				}
				desc = gdp_republic_unrest.0221.a.fail
				send_interface_toast = {
					type = event_toast_effect_bad
					title = gdp_republic_unrest.0221.a.fail.toast
					left_icon = root
					add_prestige = minor_prestige_loss
					capital_county = { add_popular_opinion = -20 }
					scope:faction = { gdp_republic_unrest_resolve_fail_effect = yes }
				}
			}
		}
		ai_chance = {
			base = 0
			modifier = {
				add = 50
				NOT = { gold >= major_gold_value }
			}
		}
	}

	# Option B - Counter publicly (Diplomacy duel, shown when diplomacy > intrigue)
	option = {
		name = gdp_republic_unrest.0221.b
		trigger = { diplomacy > intrigue }
		duel = {
			skill = diplomacy
			value = very_high_skill_rating
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = 1
				}
				desc = gdp_republic_unrest.0221.b.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = gdp_republic_unrest.0221.b.success.toast
					left_icon = root
					add_prestige = minor_prestige_gain
					capital_county = { add_popular_opinion = 20 }
					scope:faction = { gdp_republic_unrest_resolve_full_effect = yes }
				}
			}
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = 1
				}
				desc = gdp_republic_unrest.0221.b.fail
				send_interface_toast = {
					type = event_toast_effect_bad
					title = gdp_republic_unrest.0221.b.fail.toast
					left_icon = root
					add_prestige = minor_prestige_loss
					capital_county = { add_popular_opinion = -20 }
					scope:faction = { gdp_republic_unrest_resolve_fail_effect = yes }
				}
			}
		}
		ai_chance = {
			base = 0
			modifier = {
				add = 50
				NOT = { gold >= major_gold_value }
			}
		}
	}

	# Option C - Buy up the copies (gated on gold >= major_gold_value)
	option = {
		name = gdp_republic_unrest.0221.c
		trigger = {
			gold >= major_gold_value
		}
		remove_short_term_gold = major_gold_value
		capital_county = { add_popular_opinion = 10 }
		scope:faction = { gdp_republic_unrest_resolve_partial_effect = yes }
		ai_chance = { base = 100 }
	}

	# Option D - Ignore it (always available)
	option = {
		name = gdp_republic_unrest.0221.d
		capital_county = { add_popular_opinion = -10 }
		scope:faction = { gdp_republic_unrest_resolve_fail_effect = yes }
		ai_chance = { base = 0 }
	}
}

### Severity 4
# They Are at the Gates
gdp_republic_unrest.0301 = {
	type = character_event
	window = big_event_window
	title = gdp_republic_unrest.0301.t
	desc = gdp_republic_unrest.0301.desc
	theme = republic
	override_background = { reference = throne_room }
	left_portrait = {
		character = root
		animation = fear
	}
	lower_right_portrait = scope:republic_heir

	trigger = {
		exists = scope:faction
	}

	immediate = {
		play_music_cue = mx_cue_combat_stinger
		save_scope_as = despot
		primary_title = { save_scope_as = republic_title }
		capital_county = { save_scope_as = republic_capital }
		gdp_find_deposed_republic_successor_effect = yes
	}

	# Option A - Last stand (Prowess duel)
	option = {
		name = gdp_republic_unrest.0301.a
		skill = prowess
		stress_and_fulfillment_impact = {
			base = 100
			craven = major_stress_impact_gain
		}
		scope:faction = { destroy_faction = yes }
		scope:republic_capital = {
			add_county_modifier = {
				modifier = gdp_republic_uprising_aftermath
				years = 5
			}
		}
		duel = {
			skill = prowess
			value = 100
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -45
				}
				desc = gdp_republic_unrest.0301.a.success
				if = {
					limit = { NOT = { has_any_nickname = yes } }
					give_nickname = nick_the_defiant
				}
				trigger_event = { id = gdp_republic_unrest.0302 }
				scope:republic_heir = {
					if = {
						limit = { has_character_flag = generated_character }
						death = { death_reason = death_battle killer = scope:despot }
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
				}
				desc = gdp_republic_unrest.0301.a.fail
				save_scope_as = old_doge
				every_vassal = {
					limit = { government_has_flag = government_is_republic }
					trigger_event = { id = gdp_republic_unrest.0304 }
				}
				gdp_restore_republic_elections_effect = yes
				death = { death_reason = death_battle }
			}
		}
		ai_chance = { base = 0 }
	}

	# Option B - Fight your way out (Martial duel)
	option = {
		name = gdp_republic_unrest.0301.b
		skill = martial
		show_as_tooltip = { gdp_restore_republic_elections_effect = yes } # tooltipped here, but order of effects is maintained below
		duel = {
			skill = martial
			value = high_skill_rating
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = 1
				}
				desc = gdp_republic_unrest.0301.b.success
				save_scope_as = old_doge
				every_vassal = {
					limit = { government_has_flag = government_is_republic }
					trigger_event = { id = gdp_republic_unrest.0305 }
				}
				hidden_effect = { gdp_restore_republic_elections_merchant_effect = yes }
				show_as_tooltip = { change_government = merchant_government }
				trigger_event = { id = gdp_republic_unrest.0303 }
				stress_and_fulfillment_impact = {
					brave = minor_stress_impact_loss
				}
			}
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = 1
				}
				desc = gdp_republic_unrest.0301.b.fail
				save_scope_as = old_doge
				every_vassal = {
					limit = { government_has_flag = government_is_republic }
					trigger_event = { id = gdp_republic_unrest.0304 }
				}
				hidden_effect = { gdp_restore_republic_elections_effect = yes }
				death = { death_reason = death_battle }
			}
		}
		gdp_republic_unrest_0301_aftermath_effect = yes
		ai_chance = { base = 0 }
	}

	# Option C - Slip away in disguise (Intrigue duel)
	option = {
		name = gdp_republic_unrest.0301.c
		skill = intrigue
		show_as_tooltip = { gdp_restore_republic_elections_effect = yes } # tooltipped here, but order of effects is maintained below
		duel = {
			skill = intrigue
			value = high_skill_rating
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = 1
				}
				desc = gdp_republic_unrest.0301.c.success
				save_scope_as = old_doge
				every_vassal = {
					limit = { government_has_flag = government_is_republic }
					trigger_event = { id = gdp_republic_unrest.0305 }
				}
				hidden_effect = { gdp_restore_republic_elections_merchant_effect = yes }
				show_as_tooltip = { change_government = merchant_government }
				trigger_event = { id = gdp_republic_unrest.0303 }
				stress_and_fulfillment_impact = {
					arrogant = major_stress_impact_gain
				}
			}
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = 1
				}
				desc = gdp_republic_unrest.0301.c.fail
				save_scope_as = old_doge
				every_vassal = {
					limit = { government_has_flag = government_is_republic }
					trigger_event = { id = gdp_republic_unrest.0304 }
				}
				hidden_effect = { gdp_restore_republic_elections_effect = yes }
				death = { death_reason = death_murder }
			}
		}
		gdp_republic_unrest_0301_aftermath_effect = yes
		ai_chance = { base = 0 }
	}

	# Option D - Retire
	option = {
		name = gdp_republic_unrest.0301.d
		flavor = gdp_republic_unrest.0301.d.flavor
		gdp_restore_republic_elections_effect = yes
		gdp_republic_unrest_0301_aftermath_effect = yes
		stress_and_fulfillment_impact = {
			arrogant = major_stress_impact_gain
			humble = minor_stress_impact_loss
		}
		ai_chance = { base = 100 }
	}
}

# Survived the onslaught
gdp_republic_unrest.0302 = {
	type = character_event
	window = big_event_window
	title = gdp_republic_unrest.0302.t
	desc = gdp_republic_unrest.0302.desc
	theme = republic
	override_background = { reference = throne_room }
	left_portrait = {
		character = root
		animation = sword_yield_start
	}

	option = {
		name = gdp_republic_unrest.0302.a
		if = {
			limit = { NOT = { has_trait = brave } }
			add_trait = brave
		}
		add_dread = 50
		capital_county = { change_county_control = 30 }
	}
}

# A merchant's new beginning
gdp_republic_unrest.0303 = {
	type = character_event
	window = big_event_window
	title = gdp_republic_unrest.0303.t
	desc = gdp_republic_unrest.0303.desc
	theme = republic
	left_portrait = {
		character = root
		animation = biting_coin
	}

	widgets = {
		widget = {
			gui = "event_window_widget_name_child"
			container = "dynamic_birth_name"
			controller = name_character
			setup_scope = { root = { save_scope_as = name_character_target } }
		}

		widget = { 
			gui = event_window_widget_vfx_godray 
			container = foreground_shader_vfx_container 
		}
	}

	immediate = {
		hidden_effect = {
			gdp_republic_unrest_flee_reset_domicile_effect = yes
		}
		custom_tooltip = gdp_republic_unrest.0303.tt
		capital_county = { save_scope_as = old_capital_county }
		hidden_effect = {
			capital_county.empire = {
				every_de_jure_county = {
					limit = {
						NOT = { this = scope:old_capital_county }
						title_province = { province_size_level > 3 }
					}
					add_to_list = potential_new_home
				}
				every_title_to_title_neighboring_empire = {
					every_de_jure_county = {
						limit = {
							NOT = { this = scope:old_capital_county }
							title_province = { province_size_level > 3 }
						}
						add_to_list = potential_new_home
					}
				}
			}
			ordered_in_list = {
				list = potential_new_home
				order_by = {
					subtract = "squared_distance(root.location)"
				}
				save_scope_as = destination_a
			}
			ordered_in_list = {
				list = potential_new_home
				limit = {
					exists = scope:destination_a
					NOT = { this = scope:destination_a }
				}
				order_by = {
					subtract = "squared_distance(root.location)"
				}
				save_scope_as = destination_b
			}
			ordered_in_list = {
				list = potential_new_home
				limit = {
					exists = scope:destination_a
					exists = scope:destination_b
					NOR = { 
						this = scope:destination_a 
						this = scope:destination_b
					}
				}
				order_by = {
					subtract = "squared_distance(root.location)"
				}
				save_scope_as = destination_c
			}
		}
	}

	option = {
		name = gdp_republic_unrest.0303.a
		trigger = { exists = scope:destination_a }
		custom_tooltip = gdp_republic_unrest.0303.a.tt
		start_travel_plan = {
			destination = scope:destination_a.title_province
			on_arrival_event = gdp_republic_unrest.0306
			on_arrival_destinations = last
			players_use_planner = no
			return_trip = no
		}
	}

	option = {
		name = gdp_republic_unrest.0303.b
		trigger = { exists = scope:destination_b }
		custom_tooltip = gdp_republic_unrest.0303.b.tt
		start_travel_plan = {
			destination = scope:destination_b.title_province
			on_arrival_event = gdp_republic_unrest.0306
			on_arrival_destinations = last
			players_use_planner = no
			return_trip = no
		}
	}

	option = {
		name = gdp_republic_unrest.0303.c
		trigger = { exists = scope:destination_c }
		custom_tooltip = gdp_republic_unrest.0303.c.tt
		start_travel_plan = {
			destination = scope:destination_c.title_province
			on_arrival_event = gdp_republic_unrest.0306
			on_arrival_destinations = last
			players_use_planner = no
			return_trip = no
		}
	}

	option = {
		name = gdp_republic_unrest.0303.d
		trigger = {
			NOR = {
				exists = scope:destination_a
				exists = scope:destination_b
				exists = scope:destination_c
			}
		}
		start_tributary_interaction_effect = {
			TRIBUTARY = root
			SUZERAIN = capital_county.holder
		}
	}
}

# Patrician notification - the doge died
gdp_republic_unrest.0304 = {
	type = character_event
	window = big_event_window
	title = gdp_republic_unrest.0304.t
	desc = gdp_republic_unrest.0304.desc
	theme = republic
	left_portrait = {
		character = scope:old_doge
		animation = stress
	}

	immediate = {
		show_as_tooltip = {
			gdp_restore_republic_elections_effect = yes
		}
	}

	option = {
		name = gdp_republic_unrest.0304.a
	}
}

# Patrician notification - the doge vanished
gdp_republic_unrest.0305 = {
	type = character_event
	window = big_event_window
	title = gdp_republic_unrest.0305.t
	desc = gdp_republic_unrest.0305.desc
	theme = republic
	left_portrait = {
		character = scope:old_doge
		animation = standing
	}

	immediate = {
		show_as_tooltip = {
			gdp_restore_republic_elections_effect = yes
		}
	}

	option = {
		name = gdp_republic_unrest.0305.a
	}
}

# Arrived at new home
gdp_republic_unrest.0306 = {
	type = character_event
	window = big_event_window
	title = gdp_republic_unrest.0306.t
	desc = gdp_republic_unrest.0306.desc
	theme = republic
	override_background = { reference = market }
	left_portrait = {
		character = root
		animation = personality_content
	}

	immediate = {
		hidden_effect = {
			start_tributary_interaction_effect = {
				TRIBUTARY = root
				SUZERAIN = location.county.holder
			}
			gdp_move_company_invalidate_trade_effect = yes
		}
		domicile = { move_domicile = root.location }
	}

	option = {
		name = gdp_republic_unrest.0306.a
	}
}

# An Assassin in Broad Daylight
gdp_republic_unrest.0311 = {
	type = character_event
	window = big_event_window
	title = gdp_republic_unrest.0311.t
	desc = gdp_republic_unrest.0311.desc
	theme = republic
	override_background = { reference = market }
	left_portrait = {
		character = root
		animation = fear
	}
	right_portrait = {
		character = scope:assassin
		animation = aggressive_dagger
		hide_info = yes
	}

	trigger = {
		exists = scope:faction
	}

	immediate = {
		play_music_cue = mx_cue_combat_stinger
		create_character = {
			template = gdp_republic_assassin_template
			location = root.capital_province
			save_scope_as = assassin
		}
	}

	# Option A - Fight back (Prowess duel)
	option = {
		name = gdp_republic_unrest.0311.a
		duel = {
			skill = prowess
			value = medium_skill_rating
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = 1
				}
				desc = gdp_republic_unrest.0311.a.success
				scope:faction = { gdp_republic_unrest_resolve_partial_effect = yes }
				trigger_event = { id = gdp_republic_unrest.0312 }
			}
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = 1
				}
				desc = gdp_republic_unrest.0311.a.fail
				scope:faction = { destroy_faction = yes }
				capital_county = { add_popular_opinion = 75 }
				death = { death_reason = death_murder }
			}
		}
		ai_chance = { base = 50 }
	}

	# Option B - Slip away (Intrigue duel)
	option = {
		name = gdp_republic_unrest.0311.b
		duel = {
			skill = intrigue
			value = medium_skill_rating
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = 1
				}
				desc = gdp_republic_unrest.0311.b.success
				scope:faction = { gdp_republic_unrest_resolve_partial_effect = yes }
				trigger_event = { id = gdp_republic_unrest.0312 }
			}
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = 1
				}
				desc = gdp_republic_unrest.0311.b.fail
				scope:faction = { destroy_faction = yes }
				capital_county = { add_popular_opinion = 75 }
				death = { death_reason = death_murder }
			}
		}
		ai_chance = { base = 50 }
	}

	after = {
		scope:assassin = { silent_disappearance_effect = yes }
	}
}

# Survived the assassination attempt
gdp_republic_unrest.0312 = {
	type = character_event
	window = big_event_window
	title = gdp_republic_unrest.0312.t
	desc = gdp_republic_unrest.0312.desc
	theme = republic
	override_background = { reference = market }
	left_portrait = {
		character = root
		animation = stress
	}

	option = {
		name = gdp_republic_unrest.0312.a
		stress_and_fulfillment_impact = {
			base = 50
		}
	}
}

# Blood for Blood - The heir has been kidnapped by the mob
gdp_republic_unrest.0321 = {
	type = character_event
	window = big_event_window
	title = gdp_republic_unrest.0321.t
	desc = gdp_republic_unrest.0321.desc
	theme = republic
	override_background = { reference = study }
	left_portrait = {
		character = root
		animation = chancellor
		camera = camera_event_center_away_pointing_left_fov25
	}
	lower_right_portrait = {
		character = scope:heir
		animation = fear
	}

	trigger = {
		exists = scope:faction
		OR = {
			exists = root.player_heir
			exists = root.primary_heir
		}
	}

	immediate = {
		play_music_cue = mx_cue_combat_stinger
		save_scope_as = despot
		if = {
			limit = { is_ai = no }
			player_heir = { save_scope_as = heir }
		}
		else = {
			primary_heir = { save_scope_as = heir }
		}
		primary_title = { save_scope_as = republic_title }
		capital_county = { save_scope_as = republic_capital }
		if = {
			limit = {
				has_relation_rival = scope:heir
			}
			save_scope_value_as = {
				name = heir_was_rival
				value = yes
			}
		}
		else = {
			save_scope_value_as = {
				name = heir_was_rival
				value = no
			}
			stress_and_fulfillment_impact = {
				base = 50
			}
		}
		save_scope_value_as = {
			name = abdicated_for_heir
			value = no
		}
	}

	# Option R - Let them have the heir (only available if rival/nemesis with heir)
	option = {
		name = gdp_republic_unrest.0321.rival
		trigger = {
			scope:heir_was_rival = yes
		}
		scope:faction = { gdp_republic_unrest_resolve_partial_effect = yes }
		scope:heir = { death = { death_reason = death_murder } }
		trigger_event = { id = gdp_republic_unrest.0323 }
		stress_and_fulfillment_impact = {
			compassionate = medium_stress_impact_gain
			callous = minor_stress_impact_loss
		}
		ai_chance = { base = 50 }
	}

	# Option A - Rescue by force (Martial duel, shown when martial >= intrigue)
	option = {
		name = gdp_republic_unrest.0321.a
		trigger = { martial >= intrigue }
		scope:faction = { gdp_republic_unrest_resolve_partial_effect = yes }
		duel = {
			skill = martial
			value = high_skill_rating
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
				}
				desc = gdp_republic_unrest.0321.a.success
				custom_tooltip = gdp_republic_unrest.0321.heir_survives
				trigger_event = { id = gdp_republic_unrest.0322 }
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
				}
				desc = gdp_republic_unrest.0321.a.fail
				scope:heir = { death = { death_reason = death_murder } }
				trigger_event = { id = gdp_republic_unrest.0323 }
			}
		}
		ai_chance = { base = 0 }
	}

	# Option B - Outsmart them (Intrigue duel, shown when intrigue > martial)
	option = {
		name = gdp_republic_unrest.0321.b
		trigger = { intrigue > martial }
		scope:faction = { gdp_republic_unrest_resolve_partial_effect = yes }
		duel = {
			skill = intrigue
			value = high_skill_rating
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
				}
				desc = gdp_republic_unrest.0321.b.success
				custom_tooltip = gdp_republic_unrest.0321.heir_survives
				trigger_event = { id = gdp_republic_unrest.0322 }
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
				}
				desc = gdp_republic_unrest.0321.b.fail
				scope:heir = { death = { death_reason = death_murder } }
				trigger_event = { id = gdp_republic_unrest.0323 }
			}
		}
		ai_chance = { base = 0 }
	}

	# Option C - Pay the ransom (requires at least 12 months of income)
	option = {
		name = gdp_republic_unrest.0321.c
		trigger = {
			gold >= {
				value = monthly_character_income
				multiply = 12
			}
		}
		remove_short_term_gold = root.gold
		scope:faction = { gdp_republic_unrest_resolve_partial_effect = yes }
		custom_tooltip = gdp_republic_unrest.0321.heir_survives
		trigger_event = { id = gdp_republic_unrest.0322 }
		ai_chance = { base = 100 }
	}

	# Option D - Abdicate to save the heir
	option = {
		name = gdp_republic_unrest.0321.d
		flavor = gdp_republic_unrest.0321.d.flavor
		scope:faction = { destroy_faction = yes }
		gdp_restore_republic_elections_effect = yes
		custom_tooltip = gdp_republic_unrest.0321.heir_survives
		stress_and_fulfillment_impact = {
			arrogant = major_stress_impact_gain
			humble = minor_stress_impact_loss
		}
		ai_chance = {
			base = 0
			modifier = {
				add = 75
				NOT = {
					gold >= {
						value = monthly_character_income
						multiply = 12
					}
				}
			}
		}
	}
}

# Heir recovered
gdp_republic_unrest.0322 = {
	type = character_event
	window = big_event_window
	title = gdp_republic_unrest.0322.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:heir_was_rival = yes
				}
				desc = gdp_republic_unrest.0322.desc.rival
			}
			desc = gdp_republic_unrest.0322.desc
		}
	}
	theme = republic
	override_background = { reference = sitting_room }
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { scope:heir_was_rival = yes }
			animation = writing
		}
		triggered_animation = {
			trigger = { scope:heir_was_rival = no }
			animation = wedding_happy_cry
		}
	}
	right_portrait = {
		trigger = { scope:heir_was_rival = no }
		character = scope:heir
		animation = happiness
	}
	lower_right_portrait = {
		trigger = { scope:heir_was_rival = yes }
		character = scope:heir
		animation = personality_content
	}

	override_effect_2d = {
		trigger = { scope:heir_was_rival = no }
		reference = legend_glow
	}

	option = {
		name = {
			trigger = { scope:heir_was_rival = no }
			text = gdp_republic_unrest.0322.a
		}
		name = {
			trigger = { scope:heir_was_rival = yes }
			text = gdp_republic_unrest.0322.a.rival
		}

		if = {
			limit = { scope:heir_was_rival = no }
			stress_and_fulfillment_impact = {
				base = -50
			}
		}
	}
}

# Heir died
gdp_republic_unrest.0323 = {
	type = character_event
	window = big_event_window
	title = gdp_republic_unrest.0323.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:heir_was_rival = yes
				}
				desc = gdp_republic_unrest.0323.desc.rival
			}
			desc = gdp_republic_unrest.0323.desc
		}
	}
	theme = republic
	override_background = { reference = courtyard }
	left_portrait = {
		character = root
		animation = grief
	}
	lower_right_portrait = {
		character = scope:heir
		animation = dead
	}

	widgets = {
		widget = { 
			gui = event_window_widget_vfx_background_night_scene 
			container = foreground_shader_vfx_container 
		}

		widget = { 
			gui = event_window_widget_vfx_left_character_night_scene 
			container = foreground_shader_vfx_container 
		}
	}

	option = {
		name = {
			trigger = {
				scope:heir_was_rival = no
				scope:heir = {
					OR = {
						is_child_of = root
						is_grandchild_of = root
					}
				}
			}
			text = gdp_republic_unrest.0323.a.child
		}
		name = {
			trigger = {
				OR = {
					scope:heir_was_rival = yes
					scope:heir = {
						NOR = {
							is_child_of = root
							is_grandchild_of = root
						}
					}
				}
			}
			text = gdp_republic_unrest.0323.a
		}
		
		if = {
			limit = { scope:heir_was_rival = no }
			stress_and_fulfillment_impact = {
				base = 100
			}
			add_character_modifier = {
				modifier = gdp_republic_grieving_parent_modifier
				years = 6
			}
		}
		else = {
			stress_and_fulfillment_impact = {
				compassionate = minor_stress_impact_gain
			}
		}
	}
}
