#################################
#
# THE REPUBLIC
# - dynasty Feud Events
#
#################################

# Written by Henrik Eklund

namespace = REP

# The Great Ball (AI)
character_event = {
	id = REP.100
	hide_window = yes
	
	min_age = 15
	ai = yes
	is_patrician = yes
	capable_only = yes
	prisoner = no
	
	trigger = {
		has_dlc = "The Republic"
		liege = { is_merchant_republic = yes }
		in_command = no
		OR = {
			liege = { 
				is_patrician = yes
				ai = no
				age = 15
				in_command = no
				prisoner = no
				NOT = { trait = incapable }
				NOT = { reverse_opinion = { who = ROOT value = 0 } }
				NOT = { has_dynasty_flag = the_victims }
				NOT = { has_character_flag = the_grand_ball }
				NOT = { is_inaccessible_trigger = yes }
			}
			liege = {
				any_vassal = {
					is_patrician = yes
					ai = no
					age = 15
					in_command = no
					prisoner = no
					NOT = { reverse_opinion = { who = ROOT value = 0 } }
					NOT = { trait = incapable }
					NOT = { has_dynasty_flag = the_victims }
					NOT = { has_character_flag = the_grand_ball }
					NOT = { is_inaccessible_trigger = yes }
				}
			}
		}
		NOT = { has_dynasty_flag = the_feuders }
	}
	
	mean_time_to_happen = {
		months = 320
	}
	
	immediate = {
		if = {
			limit = {
				liege = { 
					ai = no
					NOT = {
						reverse_opinion = { who = ROOT value = 0 }
						has_dynasty_flag = the_victims
						any_vassal = { ai = no }
					}
					NOT = { is_inaccessible_trigger = yes }
				}
			}
			liege = { 
				narrative_event = { id = REP.101 }
				set_character_flag = the_grand_ball
			}
		}
		if = {
			limit = {
				liege = {
					ai = yes
					any_vassal = {
						is_patrician = yes
						ai = no
						NOT = { has_dynasty_flag = the_victims }
					}
				}
			}
			liege = {
				random_vassal = {
					limit = {
						is_patrician = yes
						ai = no
						age = 15
						in_command = no
						prisoner = no
						NOT = { reverse_opinion = { who = ROOT value = 0 } }
						NOT = { has_dynasty_flag = the_victims }
						NOT = { is_inaccessible_trigger = yes }
					}
					narrative_event = { id = REP.101 }
					set_character_flag = the_grand_ball
				}
			}
		}
	}
}

# The Great Ball (Player)
narrative_event = {
	id = REP.101
	title = EVTNAME_REP_101
	desc = EVTDESC_REP_101
	picture = GFX_evt_courtiers_talking
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_REP_101
		FROM = { set_dynasty_flag = the_feuders }
		set_dynasty_flag = the_victims
		narrative_event = { id = REP.102 days = 15 tooltip = EVTTOOLTIP_REP_102 } 
	}
	option = {
		name = EVTOPTB_REP_101
		prestige = -60
		custom_tooltip = { text = no_ball_tooltip }
		clr_character_flag = the_grand_ball
	}
}

# Arriving at the Ball...
narrative_event = {
	id = REP.102
	title = EVTNAME_REP_102
	desc = EVTDESC_REP_102
	picture = GFX_evt_scandal
	
	hide_from = yes
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_REP_102
		FROMFROM = {
			set_character_flag = shamed_player_at_ball
		}
		set_character_flag = shamed_at_ball
		prestige = -100
		FROMFROM = { prestige = 100 }
		custom_tooltip = { text = feud_begins_tooltip }
	}
}

# The Even Greater Ball (AI)
character_event = {
	id = REP.103
	hide_window = yes
	
	ai = yes
	is_patrician = yes
	has_character_flag = shamed_player_at_ball
	
	trigger = {
		has_dlc = "The Republic"
		liege = { is_merchant_republic = yes }
		OR = {
			liege = { 
				ai = no
				has_character_flag = shamed_at_ball
				is_patrician = yes
				in_command = no
				prisoner = no
				NOT = { 
					trait = incapable
					trait = infirm
				}
			}
			liege = {
				any_vassal = {
					ai = no
					has_character_flag = shamed_at_ball
					is_patrician = yes
					in_command = no
					prisoner = no
					NOT = { 
						trait = incapable
						trait = infirm
					}
				}
			}
		}
	}
	
	mean_time_to_happen = {
		months = 80
	}
	
	immediate = {
		clr_character_flag = shamed_player_at_ball
		if = {
			limit = {
				liege = { 
					ai = no
					has_character_flag = shamed_at_ball
				}
			}
			liege = { 
				narrative_event = { id = REP.104 } 
			}
		}
		if = {
			limit = {
				liege = { 
					any_vassal = {
						is_patrician = yes
						ai = no
						has_character_flag = shamed_at_ball
					}
				}
			}
			liege = {
				random_vassal = {
					limit = {
						is_patrician = yes
						ai = no
						has_character_flag = shamed_at_ball
					}
					narrative_event = { id = REP.104 } 
				}
			}
		}
	}
}

# The Even Greater Ball (Player)
narrative_event = {
	id = REP.104
	title = EVTNAME_REP_104
	desc = EVTDESC_REP_104
	picture = GFX_evt_courtiers_talking
	
	hide_from = yes
	
	is_triggered_only = yes
	
	immediate = {
		clr_character_flag = shamed_at_ball
	}
	
	option = {
		name = EVTOPTA_REP_104
		wealth = -100
		narrative_event = { id = REP.105 days = 14 tooltip = EVTTOOLTIP_REP_105 } 
	}
	option = {
		name = EVTOPTB_REP_104
		prestige = -20
		custom_tooltip = { text = no_own_ball_tooltip }
	}
}

# The Day of the Ball
narrative_event = {
	id = REP.105
	title = EVTNAME_REP_105
	desc = EVTDESC_REP_105
	picture = GFX_evt_family_feud_republic
	
	hide_from = yes
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_REP_105
		prestige = 150
		FROMFROM = { prestige = -100 }
	}
}

# AI gets Feuding opinion modifier (AI only)
character_event = {
	id = REP.109
	hide_window = yes
	
	ai = yes
	is_patrician = yes
	
	trigger = {
		has_dlc = "The Republic"
		has_dynasty_flag = the_feuders
		liege = { is_merchant_republic = yes }
		OR = {
			liege = { 
				ai = no 
				has_dynasty_flag = the_victims
				NOT = {
					reverse_has_opinion_modifier = {
						who = ROOT
						modifier = opinion_feuding_family
					}
				}
			}
			liege = {
				any_vassal = {
					is_patrician = yes
					ai = no
					has_dynasty_flag = the_victims
					NOT = {
						reverse_has_opinion_modifier = {
							who = ROOT
							modifier = opinion_feuding_family
						}
					}
				}
			}
		}
	}
	
	mean_time_to_happen = {
		days = 1
	}
	
	immediate = {
		if = {
			limit = {
				liege = { 
					ai = no
					has_dynasty_flag = the_victims
					NOT = {
						reverse_has_opinion_modifier = {
							who = ROOT
							modifier = opinion_feuding_family
						}
					}
				}
			}
			liege = { 
				reverse_opinion = {
					who = ROOT
					modifier = opinion_feuding_family
				}
				ROOT = {
					any_dynasty_member = {
						limit = {
							NOT = {
								has_opinion_modifier = {
									who = PREVPREV
									modifier = opinion_feuding_family_light
								}
							}
						}
						opinion = {
							who = PREVPREV
							modifier = opinion_feuding_family_light
						}
					}
				}
			}
		}
		if = {
			limit = {
				liege = { 
					any_vassal = {
						is_patrician = yes
						ai = no
						has_dynasty_flag = the_victims
						NOT = {
							reverse_has_opinion_modifier = {
								who = ROOT
								modifier = opinion_feuding_family
							}
						}
					}
				}
			}
			liege = {
				random_vassal = {
					limit = {
						is_patrician = yes
						ai = no
						has_dynasty_flag = the_victims
						NOT = {
							reverse_has_opinion_modifier = {
								who = ROOT
								modifier = opinion_feuding_family
							}
						}
					}
					reverse_opinion = {
						who = ROOT
						modifier = opinion_feuding_family
					}
					ROOT = {
						any_dynasty_member = {
							limit = {
								NOT = {
									has_opinion_modifier = {
										who = PREVPREV
										modifier = opinion_feuding_family_light
									}
								}
							}
							opinion = {
								who = PREVPREV
								modifier = opinion_feuding_family_light
							}
						}
					}
				}
			}
		}
	}
}

### The Flagship

# The New Flagship (AI)
character_event = {
	id = REP.150
	hide_window = yes
	
	ai = yes
	is_patrician = yes
	
	trigger = {
		has_dlc = "The Republic"
		has_dynasty_flag = the_feuders
		liege = { is_merchant_republic = yes }
		OR = {
			liege = { 
				ai = no
				has_dynasty_flag = the_victims
				NOT = { has_dynasty_flag = flagship_feud }
				is_patrician = yes
				age = 15
				in_command = no
				prisoner = no
				job_spymaster = {
					NOT = { character = ROOT }
				}
				NOT = { 
					trait = incapable
					trait = infirm
				}
				NOT = { is_inaccessible_trigger = yes }
			}
			liege = {
				any_vassal = {
					is_patrician = yes
					ai = no
					has_dynasty_flag = the_victims
					NOT = { has_dynasty_flag = flagship_feud }
					age = 15
					in_command = no
					prisoner = no
					NOT = { 
						trait = incapable
						trait = infirm
					}
					NOT = { is_inaccessible_trigger = yes }
				}
			}
		}
	}
	
	mean_time_to_happen = {
		months = 520
	}
	
	immediate = {
		if = {
			limit = {
				liege = { 
					ai = no
					has_dynasty_flag = the_victims
					NOT = { has_dynasty_flag = flagship_feud }
					NOT = { is_inaccessible_trigger = yes }
				}
			}
			liege = { 
				narrative_event = { id = REP.151 }
			}
		}
		if = {
			limit = {
				liege = { 
					any_vassal = {
						is_patrician = yes
						ai = no
						has_dynasty_flag = the_victims
						NOT = { has_dynasty_flag = flagship_feud }
						NOT = { is_inaccessible_trigger = yes }
					}
				}
			}
			liege = {
				random_vassal = {
					limit = {
						is_patrician = yes
						ai = no
						has_dynasty_flag = the_victims
						NOT = { is_inaccessible_trigger = yes }
					}
					narrative_event = { id = REP.151 }
				}
			}
		}
	}
}

# The New Flagship (Player)
narrative_event = {
	id = REP.151
	title = EVTNAME_REP_151
	desc = EVTDESC_REP_151
	picture = GFX_evt_busy_trading_dock_republic
	
	is_triggered_only = yes
	
	immediate = {
		set_dynasty_flag = flagship_feud
	}
	
	option = {
		name = EVTOPTA_REP_151
		hidden_tooltip = {
			random_list = {
				70 = {
					narrative_event = { id = REP.153 days = 46 }
				}
				30 = {
					narrative_event = { id = REP.155 days = 46 }
				}
			}
		}
		custom_tooltip = { text = flagship_plan_approved_tooltip }
	}
	option = {
		name = EVTOPTB_REP_151
		hidden_tooltip = {
			narrative_event = { id = REP.154 days = 46 }
		}
		custom_tooltip = { text = flagship_plan_refused_tooltip }
	}
}

# The Ship is Launched
narrative_event = {
	id = REP.153
	title = EVTNAME_REP_153
	desc = EVTDESC_REP_153
	picture = GFX_evt_merchant_ship_at_sea_republic
	
	hide_from = yes
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_REP_152
		prestige = 50
		FROMFROM = { prestige = -100 }
		set_dynasty_flag = feud_phase_two
	}
}

# The Lion of the Sea
narrative_event = {
	id = REP.154
	title = EVTNAME_REP_154
	desc = EVTDESC_REP_154
	picture = GFX_evt_merchant_ship_at_sea_republic
	
	hide_from = yes
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_REP_154
		prestige = -50
		FROMFROM = { prestige = 100 }
		set_dynasty_flag = feud_phase_two
	}
}

# You Are Cordially Invited...
narrative_event = {
	id = REP.155
	title = EVTNAME_REP_155
	desc = EVTDESC_REP_155
	picture = GFX_evt_family_feud_republic
	
	hide_from = yes
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_REP_155
		prestige = -50
		FROMFROM = { prestige = 100 }
		set_dynasty_flag = feud_phase_two
	}
}

### Romeo & Juliet

# A Nightly Visit... (Daughter) (AI)
character_event = {
	id = REP.160
	hide_window = yes
	
	min_age = 15
	ai = yes
	only_men = yes
	capable_only = yes
	prisoner = no
	has_dlc = "The Republic"
	is_married = no
	
	trigger = {
		has_dynasty_flag = the_feuders
		in_command = no
		father = {
			has_dynasty_flag = the_feuders
			liege = { is_merchant_republic = yes }
			is_patrician = yes
			prisoner = no
			in_command = no
			NOT = { trait = incapable }
			NOT = { is_inaccessible_trigger = yes }
		}
		NOT = { 
			age = 30 
			trait = homosexual
			trait = infirm
			trait = incapable
			trait = eunuch
		}
		NOT = { is_inaccessible_trigger = yes }
		father = {
			OR = {
				liege = { 
					ai = no
					has_dynasty_flag = the_victims
					has_dynasty_flag = feud_phase_two
					NOT = { has_dynasty_flag = romeo_juliet_feud }
					is_patrician = yes
					in_command = no
					prisoner = no
					NOT = { 
						trait = incapable
					}
					NOT = { is_inaccessible_trigger = yes }
					any_child = {
						is_female = yes
						is_married = no
						age = 15
						NOT = { age = 30 }
						prisoner = no
						NOT = { 
							trait = incapable
							trait = infirm
							trait = homosexual
						}
						NOT = { is_inaccessible_trigger = yes }
					}
				}
				liege = {
					any_vassal = {
						is_patrician = yes
						ai = no
						has_dynasty_flag = the_victims
						has_dynasty_flag = feud_phase_two
						NOT = { has_dynasty_flag = romeo_juliet_feud }
						prisoner = no
						in_command = no
						NOT = { trait = incapable }
						NOT = { is_inaccessible_trigger = yes }
						any_child = {
							is_female = yes
							is_married = no
							age = 15
							NOT = { age = 30 }
							prisoner = no
							NOT = { 
								trait = incapable
								trait = infirm
								trait = homosexual
							}
							NOT = { is_inaccessible_trigger = yes }
						}
					}
				}
			}
		}
	}
	
	immediate = {
		father = {
			if = {
				limit = {
					liege = { 
						ai = no
						has_dynasty_flag = the_victims
						has_dynasty_flag = feud_phase_two
						NOT = { is_inaccessible_trigger = yes }
					}
				}
				liege = { 
					narrative_event = { id = REP.161 }
				}
			}
			if = {
				limit = {
					liege = { 
						any_vassal = {
							is_patrician = yes
							ai = no
							has_dynasty_flag = the_victims
							has_dynasty_flag = feud_phase_two
							NOT = { is_inaccessible_trigger = yes }
						}
					}
				}
				liege = {
					random_vassal = {
						limit = {
							is_patrician = yes
							ai = no
							has_dynasty_flag = the_victims
							has_dynasty_flag = feud_phase_two
							prisoner = no
							in_command = no
							NOT = { trait = incapable }
							NOT = { is_inaccessible_trigger = yes }
						}
						narrative_event = { id = REP.161 }
					}
				}
			}
		}
		set_character_flag = romeo
	}
	
	mean_time_to_happen = {
		months = 100
	}
}

# A Nightly Visit... (Daughter)
narrative_event = {
	id = REP.161
	title = EVTNAME_REP_161
	desc = EVTDESC_REP_161
	picture = GFX_evt_family_feud_republic
	
	is_triggered_only = yes
	
	immediate = {
		set_dynasty_flag = romeo_juliet_feud
	}
	
	option = {
		name = EVTOPTA_REP_161
		hidden_tooltip = {
			random_list = {
				80 = {
					narrative_event = { id = REP.164 days = 46 }
				}
				20 = {
				}
			}
		}
		random_child = {
			limit = {
				is_female = yes
				is_married = no
				age = 15
				NOT = { age = 30 }
				prisoner = no
				NOT = { 
					trait = incapable
					trait = infirm
					trait = homosexual
				}
			}
			set_character_flag = julia
			custom_tooltip = { text = forbid_daughter_tooltip }
		}
	}
	option = {
		name = EVTOPTB_REP_161
		hidden_tooltip = {
			random_list = {
				60 = {
					narrative_event = { id = REP.164 days = 46 }
				}
				40 = {
					narrative_event = { id = REP.166 days = 46 }
				}
			}
		}
		random_child = {
			limit = {
				is_female = yes
				is_married = no
				age = 15
				NOT = { age = 30 }
				prisoner = no
				NOT = { 
					trait = incapable
					trait = infirm
					trait = homosexual
				}
			}
			set_character_flag = julia
			custom_tooltip = { text = permit_love_tooltip }
		}
	}
}

# A Nightly Visit... (Son) (AI)
character_event = {
	id = REP.162
	hide_window = yes
	
	min_age = 15
	ai = yes
	only_women = yes
	capable_only = yes
	prisoner = no
	has_dlc = "The Republic"
	is_married = no
	
	trigger = {
		has_dynasty_flag = the_feuders
		father = {
			has_dynasty_flag = the_feuders
			liege = { is_merchant_republic = yes }
			is_patrician = yes
			prisoner = no
			in_command = no
			NOT = { trait = incapable }
			NOT = { is_inaccessible_trigger = yes }
		}
		NOT = { 
			age = 30 
			trait = homosexual
			trait = incapable
		}
		NOT = { is_inaccessible_trigger = yes }
		father = {
			OR = {
				liege = { 
					ai = no
					has_dynasty_flag = the_victims
					has_dynasty_flag = feud_phase_two
					NOT = { has_dynasty_flag = romeo_juliet_feud }
					prisoner = no
					in_command = no
					NOT = { trait = incapable }
					NOT = { is_inaccessible_trigger = yes }
					any_child = {
						age = 15
						is_female = no
						NOT = { 
							age = 30 
							trait = homosexual
							trait = infirm
							trait = incapable
							trait = eunuch
						}
						NOT = { is_inaccessible_trigger = yes }
						prisoner = no
						is_married = no
						in_command = no
					}
				}
				liege = {
					any_vassal = {
						is_patrician = yes
						ai = no
						has_dynasty_flag = the_victims
						has_dynasty_flag = feud_phase_two
						NOT = { has_dynasty_flag = romeo_juliet_feud }
						prisoner = no
						in_command = no
						NOT = { trait = incapable }
						NOT = { is_inaccessible_trigger = yes }
						any_child = {
							age = 15
							is_female = no
							NOT = { 
								age = 30 
								trait = homosexual
								trait = infirm
								trait = incapable
								trait = eunuch
							}
							NOT = { is_inaccessible_trigger = yes }
							prisoner = no
							is_married = no
							in_command = no
						}
					}
				}
			}
		}
	}
	
	immediate = {
		father = {
			if = {
				limit = {
					liege = { 
						ai = no
						has_dynasty_flag = the_victims
						has_dynasty_flag = feud_phase_two
					}
				}
				liege = { 
					narrative_event = { id = REP.163 }
				}
			}
			if = {
				limit = {
					liege = { 
						any_vassal = {
							is_patrician = yes
							ai = no
							has_dynasty_flag = the_victims
							has_dynasty_flag = feud_phase_two
						}
					}
				}
				liege = {
					random_vassal = {
						limit = {
							is_patrician = yes
							ai = no
							has_dynasty_flag = the_victims
							has_dynasty_flag = feud_phase_two
						}
						narrative_event = { id = REP.163 }
					}
				}
			}
		}
		set_character_flag = julia
	}
	
	mean_time_to_happen = {
		months = 100
	}
}

# A Nightly Visit... (Son)
narrative_event = {
	id = REP.163
	title = EVTNAME_REP_161
	desc = EVTDESC_REP_163
	picture = GFX_evt_family_feud_republic
	
	is_triggered_only = yes
	
	immediate = {
		set_dynasty_flag = romeo_juliet_feud
	}
	
	option = {
		name = EVTOPTA_REP_163
		hidden_tooltip = {
			random_list = {
				80 = {
					narrative_event = { id = REP.165 days = 46 }
				}
				20 = {
				}
			}
		}
		random_child = {
			limit = {
				age = 15
				is_female = no
				NOT = { 
					age = 30 
					trait = homosexual
					trait = infirm
					trait = incapable
					trait = eunuch
				}
				is_married = no
				prisoner = no
				in_command = no
			}
			set_character_flag = romeo
			custom_tooltip = { text = forbid_son_tooltip }
		}
	}
	option = {
		name = EVTOPTB_REP_161
		hidden_tooltip = {
			random_list = {
				60 = {
					narrative_event = { id = REP.165 days = 46 }
				}
				40 = {
					narrative_event = { id = REP.166 days = 46 }
				}
			}
		}
		random_child = {
			limit = {
				age = 15
				is_female = no
				NOT = { 
					age = 30 
					trait = homosexual
					trait = infirm
					trait = incapable
					trait = eunuch
				}
				is_married = no
				prisoner = no
				in_command = no
			}
			set_character_flag = romeo
			custom_tooltip = { text = permit_love_tooltip }
		}
	}
}

# Never Was a Story of More Woe... (Daughter)
narrative_event = {
	id = REP.164
	title = EVTNAME_REP_164
	desc = EVTDESC_REP_164
	picture = GFX_evt_family_feud_republic
	
	hide_from = yes
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_REP_164
		hidden_tooltip = {
			character_event = { id = REP.167 days = 14 }
		}
		set_dynasty_flag = feud_peace_1
		FROMFROM = {
			father = { set_dynasty_flag = feud_peace_2 }
			death = { death_reason = death_suicide_poison }
		}
		random_child = {
			limit = { has_character_flag = julia }
			death = { death_reason = death_suicide_poison }
		}
		custom_tooltip = { text = end_feud_tooltip }
	}
	option = {
		name = EVTOPTB_REP_164
		FROMFROM = {
			death = { death_reason = death_suicide_poison }
		}
		random_child = {
			limit = { has_character_flag = julia }
			death = { death_reason = death_suicide_poison }
		}
		custom_tooltip = { text = continue_feud_tooltip }
	}
}

# Never Was a Story of More Woe... (Son)
narrative_event = {
	id = REP.165
	title = EVTNAME_REP_164
	desc = EVTDESC_REP_165
	picture = GFX_evt_family_feud_republic
	
	hide_from = yes
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_REP_164
		hidden_tooltip = {
			character_event = { id = REP.167 days = 14 }
		}
		set_dynasty_flag = feud_peace_1
		FROMFROM = {
			father = { set_dynasty_flag = feud_peace_2 }
			death = { death_reason = death_suicide_poison }
		}
		random_child = {
			limit = { has_character_flag = romeo }
			death = { death_reason = death_suicide_poison }
		}
		custom_tooltip = { text = end_feud_tooltip }
	}
	option = {
		name = EVTOPTB_REP_165
		FROMFROM = {
			death = { death_reason = death_suicide_poison }
		}
		random_child = {
			limit = { has_character_flag = romeo }
			death = { death_reason = death_suicide_poison }
		}
		custom_tooltip = { text = continue_feud_tooltip }
	}
}

# Wedding Bells
narrative_event = {
	id = REP.166
	title = EVTNAME_REP_166
	desc = EVTDESC_REP_166
	picture = GFX_evt_marriage
	
	hide_from = yes
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_REP_166
		random_child = {
			limit = {
				OR = {
					has_character_flag = romeo
					has_character_flag = julia
				}
			}
			add_spouse = FROMFROM
			clr_character_flag = romeo
			clr_character_flag = julia
		}
		FROMFROM = {
			clr_character_flag = romeo
			clr_character_flag = julia
		}
		prestige = 100
		clr_dynasty_flag = the_victims
		FROMFROM = {
			father = {
				clr_dynasty_flag = the_feuders
				prestige = 100
				any_dynasty_member = {
					remove_opinion = { who = ROOT modifier = opinion_feuding_family }
					remove_opinion = { who = ROOT modifier = opinion_feuding_family_light }
				}
			}
		}
	}
}

# Two Funerals and a Truce (AI)
character_event = {
	id = REP.167
	hide_window = yes
	
	is_patrician = yes
	
	trigger = {
		has_dlc = "The Republic"
		has_dynasty_flag = feud_peace_2
		OR = {
			AND = {
				liege = { ai = no }
				has_dynasty_flag = feud_peace_1
			}
			liege = {
				any_vassal = {
					is_patrician = yes
					ai = no
					has_dynasty_flag = feud_peace_1
				}
			}
		}
	}
	
	mean_time_to_happen = {
		days = 1
	}
	
	immediate = {
		clr_dynasty_flag = feud_peace_2
		if = {
			limit = {
				liege = { 
					ai = no
					has_dynasty_flag = feud_peace_1
				}
			}
			liege = { 
				narrative_event = { id = REP.168 }
				clr_dynasty_flag = feud_peace_1
			}
		}
		if = {
			limit = {
				liege = { 
					any_vassal = {
						is_patrician = yes
						ai = no
						has_dynasty_flag = feud_peace_1
					}
				}
			}
			liege = {
				random_vassal = {
					limit = {
						is_patrician = yes
						ai = no
						has_dynasty_flag = feud_peace_1
					}
					narrative_event = { id = REP.168 }
					clr_dynasty_flag = feud_peace_1
				}
			}
		}
	}	
}

# Two Funerals and a Truce (Player)
narrative_event = {
	id = REP.168
	title = EVTNAME_REP_168
	desc = EVTDESC_REP_168
	picture = GFX_evt_death
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_REP_168
		clr_dynasty_flag = the_victims
		hidden_tooltip = {
			FROM = {
				clr_dynasty_flag = the_feuders
				remove_opinion = { who = ROOT modifier = opinion_feuding_family }
				any_dynasty_member = {
					remove_opinion = { who = FROM modifier = opinion_feuding_family_light }
				}
			}
		}
	}
}

### The Smugglers

# The Smugglers (AI Patrician)
character_event = {
	id = REP.180
	hide_window = yes
	
	min_age = 30
	ai = yes
	is_patrician = yes
	capable_only = yes
	prisoner = no
	
	trigger = {
		has_dlc = "The Republic"
		has_dynasty_flag = the_feuders
		liege = { is_merchant_republic = yes }
		wealth = 200
		OR = {
			liege = { 
				is_patrician = yes
				ai = no
				in_command = no
				prisoner = no
				NOT = { trait = incapable }
				has_dynasty_flag = the_victims
				NOT = { has_dynasty_flag = smugglers_feud }
				any_child = {
					is_female = no
					is_alive = yes
					age = 15
					NOT = { age = 35 }
					in_command = no
					prisoner = no
					NOT = { 
						trait = incapable 
						trait = infirm
						trait = blinded
						trait = craven
					}
					NOT = { is_inaccessible_trigger = yes }
				}
			}
			liege = {
				any_vassal = {
					is_patrician = yes
					ai = no
					has_dynasty_flag = the_victims
					NOT = { has_dynasty_flag = smugglers_feud }
					any_child = {
						is_female = no
						is_alive = yes
						age = 15
						NOT = { age = 35 }
						in_command = no
						prisoner = no
						NOT = { 
							trait = incapable 
							trait = infirm
							trait = blinded
							trait = craven
						}
						NOT = { is_inaccessible_trigger = yes }
					}
				}
			}
		}
	}
	
	mean_time_to_happen = {
		months = 420
	}
	
	immediate = {
		if = {
			limit = {
				liege = { 
					ai = no
					has_dynasty_flag = the_victims
				}
			}
			liege = { 
				random_child = {
					limit = {
						is_female = no
						is_alive = yes
						age = 15
						NOT = { age = 35 }
						in_command = no
						prisoner = no
						NOT = { 
							trait = incapable 
							trait = infirm
							trait = blinded
						}
						NOT = { is_inaccessible_trigger = yes }
					}
					character_event = { id = REP.181 }
				}
			}
		}
		if = {
			limit = {
				liege = { 
					any_vassal = {
						is_patrician = yes
						ai = no
						has_dynasty_flag = the_victims
					}
				}
			}
			liege = {
				random_vassal = {
					limit = {
						is_patrician = yes
						ai = no
						has_dynasty_flag = the_victims
					}
					random_child = {
						limit = {
							is_female = no
							is_alive = yes
							age = 15
							NOT = { age = 35 }
							in_command = no
							prisoner = no
							NOT = { 
								trait = incapable 
								trait = infirm
								trait = blinded
							}
							NOT = { is_inaccessible_trigger = yes }
						}
						character_event = { id = REP.181 }
					}
				}
			}
		}
	}
}

# The Smugglers (AI Son)
character_event = {
	id = REP.181
	hide_window = yes
	
	ai = yes
	
	is_triggered_only = yes
	
	immediate = {
		father = {
			narrative_event = { id = REP.182 }
		}
	}
}

# The Smugglers
narrative_event = {
	id = REP.182
	title = EVTNAME_REP_182
	desc = EVTDESC_REP_182
	picture = GFX_evt_family_feud_republic
	
	is_triggered_only = yes
	
	immediate = {
		set_dynasty_flag = smugglers_feud
	}
	
	option = {
		name = EVTOPTA_REP_182
		
		custom_tooltip = {
			text = approve_plan_tooltip
			hidden_tooltip = {
				FROMFROM = {
					character_event = { id = REP.183 days = 26 }
				}
			}
		}
	}
	option = {
		name = EVTOPTB_REP_182
		custom_tooltip = { text = refuse_plan_tooltip }
	}
}

# Plan is approved (AI Patrician)
character_event = {
	id = REP.183
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		FROMFROM = {
			character_event = { id = REP.184 }
		}
	}
}

# Plan is approved (AI Son)
character_event = {
	id = REP.184
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		FROMFROM = {
			random_list = {
				60 = {
					narrative_event = { id = REP.185 }
				}
				40 = {
					if = {
						limit = { NOT = { has_character_modifier = protection_spell } }
						narrative_event = { id = REP.186 }
					}
					if = {
						limit = { has_character_modifier = protection_spell }
						narrative_event = { id = REP.185 }
					}
				}
			}
		}
	}
}

# The Only Good Smuggler...
narrative_event = {
	id = REP.185
	title = EVTNAME_REP_185
	desc = EVTDESC_REP_185
	picture = GFX_evt_family_feud_republic
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_REP_185
		wealth = 200
		prestige = 100
		FROMFROM = {
			wealth = -200
			prestige = -100
		}
		set_dynasty_flag = feud_phase_two
	}
}

# The Ultimate Sacrifice
narrative_event = {
	id = REP.186
	title = EVTNAME_REP_186
	desc = EVTDESC_REP_186
	picture = GFX_evt_family_feud_republic
	
	is_triggered_only = yes
	
	immediate = {
		set_dynasty_flag = feud_phase_two
	}
	
	option = {
		name = EVTOPTA_REP_186
		trigger = {
			NOT = { wealth = 200 }
		}
		FROM = {
			death = {
				death_reason = death_murder_beheading
				killer = FROM
			}
		}
	}
	option = {
		name = EVTOPTB_REP_186
		trigger = {
			wealth = 200
		}
		wealth = -200
	}
	option = {
		name = EVTOPTC_REP_186
		FROM = {
			death = {
				death_reason = death_murder_beheading
				killer = FROM
			}
		}
	}
}

### The Battle

# The Right of Way (AI)
character_event = {
	id = REP.190
	hide_window = yes
	
	min_age = 15
	ai = yes
	is_patrician = yes
	capable_only = yes
	prisoner = no
	
	trigger = {
		has_dlc = "The Republic"
		in_command = no
		NOT = {
			trait = infirm
			trait = blinded
		}
		NOT = { is_inaccessible_trigger = yes }
		has_dynasty_flag = the_feuders
		liege = { is_merchant_republic = yes }
		OR = {
			liege = { 
				ai = no
				age = 15
				in_command = no
				prisoner = no
				is_patrician = yes
				NOT = { 
					trait = incapable 
					trait = infirm
					trait = blinded
				}
				NOT = { is_inaccessible_trigger = yes }
				has_dynasty_flag = the_victims
				has_dynasty_flag = feud_phase_two
				NOT = { has_dynasty_flag = pirate_feud }
			}
			liege = {
				any_vassal = {
					is_patrician = yes
					ai = no
					age = 15
					in_command = no
					prisoner = no
					NOT = { 
						trait = incapable 
						trait = infirm
						trait = blinded
					}
					NOT = { is_inaccessible_trigger = yes }
					has_dynasty_flag = the_victims
					has_dynasty_flag = feud_phase_two
					NOT = { has_dynasty_flag = pirate_feud }
				}
			}
		}
	}
	
	mean_time_to_happen = {
		months = 720
	}
	
	immediate = {
		if = {
			limit = {
				liege = { 
					ai = no
					has_dynasty_flag = the_victims
					has_dynasty_flag = feud_phase_two
					NOT = { has_dynasty_flag = pirate_feud }
					NOT = { is_inaccessible_trigger = yes }
				}
			}
			liege = { 
				narrative_event = { id = REP.191 }
			}
		}
		if = {
			limit = {
				liege = { 
					any_vassal = {
						is_patrician = yes
						ai = no
						has_dynasty_flag = the_victims
						has_dynasty_flag = feud_phase_two
						NOT = { has_dynasty_flag = pirate_feud }
						NOT = { is_inaccessible_trigger = yes }
					}
				}
			}
			liege = {
				random_vassal = {
					limit = {
						is_patrician = yes
						ai = no
						has_dynasty_flag = the_victims
						has_dynasty_flag = feud_phase_two
						NOT = { has_dynasty_flag = pirate_feud }
						NOT = { is_inaccessible_trigger = yes }
					}
					narrative_event = { id = REP.191 }
				}
			}
		}
	}
}

# The Right of Way
narrative_event = {
	id = REP.191
	title = EVTNAME_REP_191
	desc = EVTDESC_REP_191
	picture = GFX_evt_busy_trading_dock_republic
	
	is_triggered_only = yes
	
	immediate = {
		set_dynasty_flag = pirate_feud
	}
	
	option = {
		name = EVTOPTA_REP_191
		custom_tooltip = { 
			text = battle_tooltip
			hidden_tooltip = {	
				narrative_event = { id = REP.192 days = 5 }
			}
		}
	}
	option = {
		name = EVTOPTB_REP_191
		custom_tooltip = { text = no_battle_tooltip }
		prestige = -100
		FROM = { prestige = 100 }
	}
}

# Battle is Joined!
narrative_event = {
	id = REP.192
	title = EVTNAME_REP_192
	desc = EVTDESC_REP_192
	picture = GFX_evt_kraken
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_REP_192
		custom_tooltip = { 
			text = flotsam_tooltip
			hidden_tooltip = {
				FROMFROM = {
					character_event = { id = REP.193 }
				}
			}
		}
	}
}

# Days of Toil and Hardship (AI)
character_event = {
	id = REP.193
	hide_window = yes
	
	ai = yes
	
	is_triggered_only = yes
	
	immediate = {
		FROM = {
			narrative_event = { id = REP.194 }
		}
	}
}

# Days of Toil and Hardship
narrative_event = {
	id = REP.194
	title = EVTNAME_REP_194
	desc = EVTDESC_REP_194
	picture = GFX_evt_trade_post_republic
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_REP_194
		FROM = {
			death = { death_reason = death_dungeon }
		}
		custom_tooltip = { text = flee_ship_tooltip }
	}
	option = {
		name = EVTOPTB_REP_194
		custom_tooltip = {
			text = rescue_rival_tooltip
			hidden_tooltip = {
				narrative_event = { id = REP.195 } 
			}
		}
	}
}

# The Mutiny
narrative_event = {
	id = REP.195
	title = EVTNAME_REP_195
	desc = EVTDESC_REP_195
	picture = GFX_evt_merchant_ship_at_sea_republic
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_REP_195
		custom_tooltip = { text = feud_over_tooltip }
		clr_dynasty_flag = the_victims
		FROMFROM = {
			clr_dynasty_flag = the_feuders
			remove_opinion = { who = ROOT modifier = opinion_feuding_family }
			any_dynasty_member = {
				remove_opinion = { who = FROM modifier = opinion_feuding_family_light }
			}
		}
	}
	option = {
		name = EVTOPTB_REP_195
		custom_tooltip = { text = feud_continues_tooltip }
	}
}

### Rival Dynasty Rules the Republic

# Rival Dynasty Rules the Republic (AI)
character_event = {
	id = REP.200
	hide_window = yes
	
	min_age = 15
	ai = yes
	is_patrician = yes
	prisoner = no
	capable_only = yes
	
	trigger = {
		has_dlc = "The Republic"
		has_dynasty_flag = the_feuders
		is_merchant_republic = yes
		any_vassal = {
			is_patrician = yes
			ai = no
			has_dynasty_flag = the_victims
			NOT = { has_dynasty_flag = evil_ruler_feud }
		}
	}
	
	mean_time_to_happen = {
		months = 320
	}
	
	immediate = {
		random_vassal = {
			limit = {
				is_patrician = yes
				ai = no
				has_dynasty_flag = the_victims
				NOT = { has_dynasty_flag = evil_ruler_feud }
			}
			narrative_event = { id = REP.201 }
		}
	}
}

# Rival Dynasty Rules the Republic
narrative_event = {
	id = REP.201
	title = EVTNAME_REP_201
	desc = EVTDESC_REP_201
	picture = GFX_evt_doge_republic
	
	is_triggered_only = yes
	
	immediate = {
		set_dynasty_flag = evil_ruler_feud
	}
	
	option = {
		name = EVTOPTA_REP_201
		prestige = -100
		FROM = { prestige = 50 }
	}
}

### Player Dynasty Rules the Republic

# Player Dynasty Rules the Republic (AI)
character_event = {
	id = REP.202
	hide_window = yes
	
	ai = yes
	is_patrician = yes
	
	trigger = {
		has_dlc = "The Republic"
		has_dynasty_flag = the_feuders
		liege = { is_merchant_republic = yes }
		liege = { 
			ai = no
			has_dynasty_flag = the_victims
			NOT = { has_dynasty_flag = player_ruler_feud }
			is_patrician = yes
			age = 15
			prisoner = no
			NOT = { trait = incapable }
		}
	}
	
	mean_time_to_happen = {
		months = 320
	}
	
	immediate = {
		liege = {
			narrative_event = { id = REP.203 }
		}
	}
}

# Player Dynasty Rules the Republic
narrative_event = {
	id = REP.203
	title = EVTNAME_REP_201
	desc = EVTDESC_REP_203
	picture = GFX_evt_doge_republic
	
	is_triggered_only = yes
	
	immediate = {
		set_dynasty_flag = player_ruler_feud
	}
	
	option = {
		name = EVTOPTA_REP_203
		prestige = 50
		FROM = { prestige = -100 }
	}
}

### Riots

# Riots (AI)
character_event = {
	id = REP.205
	hide_window = yes
	
	ai = yes
	is_patrician = yes
	
	trigger = {
		has_dlc = "The Republic"
		has_dynasty_flag = the_feuders
		liege = { is_merchant_republic = yes }
		OR = {
			liege = { 
				ai = no
				has_dynasty_flag = the_victims
				is_patrician = yes
			}
			liege = {
				any_vassal = {
					is_patrician = yes
					ai = no
					has_dynasty_flag = the_victims
				}
			}
		}
	}
	
	mean_time_to_happen = {
		months = 420
	}
	
	immediate = {
		if = {
			limit = {
				liege = { 
					ai = no
					has_dynasty_flag = the_victims
				}
			}
			liege = { 
				narrative_event = { id = REP.206 }
			}
		}
		if = {
			limit = {
				liege = { 
					any_vassal = {
						is_patrician = yes
						ai = no
						has_dynasty_flag = the_victims
					}
				}
			}
			liege = {
				random_vassal = {
					limit = {
						is_patrician = yes
						ai = no
						has_dynasty_flag = the_victims
					}
					narrative_event = { id = REP.206 }
				}
			}
		}
	}
}

# Riots
narrative_event = {
	id = REP.206
	title = EVTNAME_REP_206
	desc = EVTDESC_REP_206
	picture = GFX_evt_family_feud_republic
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_REP_206
		prestige = -100
		FROM = { prestige = -100 }
	}
}
