# Carnal sins
country_event = {
	id = 9450
	title = "EVTNAME9450"
	desc = "EVTDESC9450"
	picture = RELIGION_eventPicture
	
	trigger = {
		papacy_active = yes
		has_heir = no
		has_regency = no
		is_female = no
		is_lesser_in_union = no
		religion = catholic
		government = monarchy
		dip = 2
		NOT = { has_government_attribute = has_harem_events }
		has_government_attribute = heir
	}
	
	mean_time_to_happen = {
		months = 400
		
		modifier = {
			factor = 0.5
			dip = 4
		}
	}
	
	option = {
		name = "EVTOPTA9450"
		define_heir = {
			dynasty = ROOT
			claim = 30
		}
		add_papal_influence = -5
		add_reform_desire = 0.005
	}
	option = {
		name = "EVTOPTB9450"
		add_papal_influence = 2
	}
}

# A beloved heir dies
country_event = {
	id = 9451
	title = "EVTNAME9451"
	desc = "EVTDESC9451"
	picture = DEATH_OF_HEIR_eventPicture
	
	trigger = {
		has_heir = yes
		heir_claim = 90
		is_female = no
		is_lesser_in_union = no
		has_regency = no
		government = monarchy
		NOT = { has_reform = elective_monarchy }
		NOT = { has_reform = polish_elective_monarchy }
		NOT = { has_reform = mamluk_government }
		NOT = { has_government_attribute = has_harem_events }
		any_owned_province = {
			num_free_building_slots = 1
			NOT = { has_building = cathedral }
			NOT = { has_building = temple }
		}
		has_government_attribute = heir
	}
	
	mean_time_to_happen = {
		months = 3600
	}
	
	option = {
		name = "EVTOPTA9451"
		kill_heir = {}
		random_owned_province = {
			limit = {
				NOT = {
					has_building = temple
				}
				NOT = { has_building = cathedral }
				num_free_building_slots = 1
			}
			add_building = temple
		}
	}
	
	option = {
		name = "EVTOPTB9451"
		kill_heir = { allow_new_heir = no }
		define_heir = {
			dynasty = ROOT
			claim = 30
		}
	}
}

# Palace Coup
country_event = {
	id = 9452
	title = "EVTNAME9452"
	desc = "EVTDESC9452"
	picture = ASSASSINATION_eventPicture
	
	trigger = {
		has_heir = yes
		heir_age = 15
		heir_claim = 90
		is_lesser_in_union = no
		NOT = {
			stability = -2
		}
		has_regency = no
		government = monarchy
		NOT = { has_reform = mamluk_government }
		NOT = { has_reform = elective_monarchy }
		NOT = { has_reform = polish_elective_monarchy }
		NOT = { has_government_attribute = has_harem_events }
	}
	
	mean_time_to_happen = {
		months = 200
		modifier = {
			factor = 0.5
			is_at_war = yes
		}
	}
	
	option = {
		name = "EVTOPTA9452"
		kill_ruler = yes
		add_country_modifier = {
			name = "illegitimate_ruler"
			duration = 1825
		}
	}
	
	option = {
		name = "EVTOPTB9452"
		kill_heir = {}
	}
}

# The Weeping Song
country_event = {
	id = 9453
	title = "EVTNAME9453"
	desc = "EVTDESC9453"
	picture = COURT_eventPicture
	
	trigger = {
		has_heir = yes
		has_wartaxes = yes
		is_lesser_in_union = no
		treasury = 40
		war_exhaustion = 4
		OR = {
			has_regency = no
			AND = {
				has_consort_regency = yes
				has_female_consort = no
			}
		}
		government = monarchy
		NOT = { has_reform = mamluk_government }
		heir_age = 4
		NOT = { has_reform = elective_monarchy }
		NOT = { has_reform = polish_elective_monarchy }
	}
	
	mean_time_to_happen = {
		months = 50
	}
	
	option = {
		name = "EVTOPTA9453"
		add_treasury = -40
		add_war_exhaustion = -2
	}
	
	option = {
		name = "EVTOPTB9453"
		add_manpower = 1
	}
}

# Springtime
country_event = {
	id = 9454
	title = "EVTNAME9454"
	desc = "EVTDESC9454"
	picture = COURT_eventPicture
	
	trigger = {
		government = monarchy
		NOT = { has_government_attribute = has_harem_events }
		NOT = { has_reform = mamluk_government }
		is_month = 3
		NOT = { is_month = 6 }
		has_heir = no
		is_female = no
		is_lesser_in_union = no
		has_regency = no
		has_government_attribute = queen
		has_government_attribute = heir
		OR = {
			NOT = { has_dlc = "Rights of Man" }
			has_consort = no
		}
		any_known_country = {
			religion = ROOT
			government = monarchy
			is_lesser_in_union = no
			alliance_with = ROOT
			ai = yes
		}
	}
	
	mean_time_to_happen = {
		months = 400
	}
	
	immediate = {
		hidden_effect = {
			random_known_country = {
				limit = {
					religion = ROOT
					government = monarchy
					is_lesser_in_union = no
					alliance_with = ROOT
					NOT = { marriage_with = ROOT }
					ai = yes
				}
				save_event_target_as = bargaining_chip_country
			}
		}
	}
	
	option = {
		name = "EVTOPTA9454"
		define_heir = {
			dynasty = ROOT
			claim = 30
		}
	}
	option = {
		name = "EVTOPTB9454"
		trigger = {
			any_known_country = {
				religion = ROOT
				government = monarchy
				is_lesser_in_union = no
				alliance_with = ROOT
				NOT = { marriage_with = ROOT }
				ai = yes
			}
		}
		event_target:bargaining_chip_country = {
			create_marriage = ROOT
		}
		if = {
			limit = {
				has_dlc = "Rights of Man"
			}
			define_consort = {
				country_of_origin = event_target:bargaining_chip_country
				culture = event_target:bargaining_chip_country
				religion = event_target:bargaining_chip_country
			}
		}
	}
}

# Soir�e
country_event = {
	id = 9455
	title = "EVTNAME9455"
	desc = "EVTDESC9455"
	picture = COURT_eventPicture
	
	trigger = {
		has_heir = no
		is_lesser_in_union = no
		government = monarchy
		has_regency = no
		NOT = { has_government_attribute = has_harem_events }
		NOT = { has_reform = mamluk_government }
		has_government_attribute = heir
	}
	
	mean_time_to_happen = {
		months = 800
	}
	
	immediate = {
		check_if_non_state_advisor_effect = { #Hidden scripted effect, is used by scripted effect and must always be cleared in after = { } using erase_advisor_flags_effect.
			chance_of_primary = 85 #Not percentages!
			chance_of_tertiary = 5
			chance_of_secondary = 15
		}
		hidden_effect = {
			random_list = {
				33 = { set_country_flag = treasurer_flag }
				33 = { set_country_flag = philosopher_flag }
				33 = { set_country_flag = diplomat_flag }
			}
		}
		
	}
	
	option = {
		name = "EVTOPTA9455"
		trigger = {
			is_female = no
		}
		define_heir = {
			dynasty = ROOT
			claim = 30
		}
		add_prestige = -10
	}
	option = {
		name = "EVTOPTB9455"
		trigger = {
			is_female = yes
		}
		define_heir = {
			dynasty = ROOT
			claim = 30
		}
		add_prestige = -10
	}
	option = {
		name = "EVTOPTC9455"
		trigger_switch = {
			on_trigger = has_country_flag
			treasurer_flag = {
				generate_advisor_of_type_and_semi_random_religion_effect = {
					advisor_type=treasurer
					advisor_type_if_not_state=trader
					skill=1
					discount=yes
				}
			}
			philosopher_flag = {
				generate_advisor_of_type_and_semi_random_religion_effect = {
					advisor_type=philosopher
					advisor_type_if_not_state=artist
					skill=1
					discount=yes
				}
			}
			diplomat_flag = {
				generate_advisor_of_type_and_semi_random_religion_effect = {
					advisor_type=diplomat
					advisor_type_if_not_state=spymaster
					skill=1
					discount=yes
				}
			}
		}
		add_prestige = -5
	}
	after = {
		erase_advisor_flags_effect = yes
		trigger_switch = {
			on_trigger = has_country_flag
			treasurer_flag = { clr_country_flag = treasurer_flag }
			philosopher_flag = { clr_country_flag = philosopher_flag }
			diplomat_flag = { clr_country_flag = diplomat_flag }
		}
	}
}

# Heir Falls ill
country_event = {
	id = 9456
	title = "EVTNAME9456"
	desc = "EVTDESC9456"
	picture = PLAGUE_eventPicture
	
	trigger = {
		has_heir = yes
		government = monarchy
		has_regency = no
		is_lesser_in_union = no
		NOT = { has_reform = elective_monarchy }
		NOT = { has_reform = polish_elective_monarchy }
		NOT = { has_country_flag = healthy_heir_diet }
	}
	
	mean_time_to_happen = {
		months = 2400
	}
	option = {
		name = "EVTOPTA9456"
		add_years_of_income = -0.2
		random_list = {
			50 = { kill_heir = {} }
			50 = {
				add_legitimacy = 5
				add_horde_unity = 5
			}
		}
	}
	
	option = {
		name = "EVTOPTB9456"
		random_list = {
			75 = { kill_heir = {}}
			25 = {
				add_legitimacy = 30
				add_horde_unity = 30
			}
		}
	}
}

# Child in the Reeds
country_event = {
	id = 9457
	title = "EVTNAME9457"
	desc = "EVTDESC9457"
	picture = NEW_HEIR_eventPicture
	
	trigger = {
		has_heir = no
		is_lesser_in_union = no
		government = monarchy
		religion_group = christian
		has_regency = no
		NOT = { has_government_attribute = has_harem_events }
		NOT = { has_reform = mamluk_government }
		NOT = { has_reform = elective_monarchy }
		NOT = { has_reform = polish_elective_monarchy }
		has_government_attribute = heir
	}
	
	mean_time_to_happen = {
		months = 1500
		modifier = {
			factor = 0.7
			is_defender_of_faith = yes
		}
	}
	
	option = {
		name = "EVTOPTA9457"
		define_heir = {
			claim = 20
			dynasty = ROOT
			change_adm = 1
			change_dip = 1
			change_mil = 1
			male = yes
			no_consort_with_heir = yes
		}
		add_prestige = -5
		add_country_modifier = {
			name = adopted_heir
			duration = 1825
		}
	}
	option = {
		name = "EVTOPTB9457"
		add_treasury = 5
	}
}

# Tournament
country_event = {
	id = 9458
	title = "EVTNAME9458"
	desc = "EVTDESC9458"
	picture = TOURNAMENT_eventPicture
	
	trigger = {
		has_heir = yes
		heir_age = 15
		is_lesser_in_union = no
		NOT = { has_reform = elective_monarchy }
		NOT = { has_reform = polish_elective_monarchy }
		NOT = { has_government_attribute = has_harem_events }
		NOT = { has_reform = mamluk_government }
		NOT = {
			is_year = 1450
		}
		NOT = {
			has_country_flag = last_jousting_tournament_held
		}
		army_tradition =  20
		technology_group = western
	}
	
	mean_time_to_happen = {
		months = 2400
		modifier = {
			factor = 0.9
			army_tradition = 40
		}
	}
	
	option = {
		name = "EVTOPTA9458"
		random_list = {
			50 = { add_years_of_income = 0.05 }
			45 = { add_legitimacy = 20}
			5 = { kill_heir = {}}
		}
	}
	
	option = {
		name = "EVTOPTB9458"
		add_adm_power = 20
	}
	
	option = {
		name = "EVTOPTC9458"
		add_prestige = 5
	}
}


# Hunting accident
country_event = {
	id = 9459
	title = "EVTNAME9459"
	desc = "EVTDESC9459"
	picture = DEATH_OF_HEIR_eventPicture
	
	trigger = {
		has_heir = yes
		heir_age = 15
		is_lesser_in_union = no
		NOT = { has_reform = elective_monarchy }
		NOT = { has_reform = polish_elective_monarchy }
		NOT = { has_country_flag = no_more_hunting_for_heir }
	}
	mean_time_to_happen = {
		months = 2700
		modifier = {
			factor = 10
			has_country_flag = selective_hunting_accident
			heir_mil = 6
		}
		modifier = {
			factor = 10
			has_country_flag = selective_hunting_accident
			heir_mil = 5
		}
		modifier = {
			factor = 10
			has_country_flag = selective_hunting_accident
			heir_mil = 4
		}
	}
	option = {
		name = "EVTOPTA9459"
		kill_heir = {}
		add_stability = -1
	}
	option = {
		name = "EVTOPTB9459"
		kill_heir = {}
		add_prestige = -10
	}
}


# Heir goes out at night
country_event = {
	id = 9460
	title = "EVTNAME9460"
	desc = "EVTDESC9460"
	picture = COURT_eventPicture
	
	trigger = {
		capital_scope = { continent = europe }
		religion_group = christian
		has_heir = yes
		heir_age = 15
		is_lesser_in_union = no
		government = monarchy
		NOT = { has_reform = mamluk_government }
		NOT = { has_reform = elective_monarchy }
		NOT = { has_reform = polish_elective_monarchy }
	}
	
	mean_time_to_happen = {
		months = 2000
		
	}
	option = {
		name = "EVTOPTA9460"
		add_prestige = -20
	}
	
	option = {
		name = "EVTOPTB9460"
		add_heir_claim = -10
	}
}

# Scheming Bureaucracy
country_event = {
	id = 9462
	title = "EVTNAME9462"
	desc = "EVTDESC9462"
	picture = DEBATE_REPUBLICAN_eventPicture
	
	trigger = {
		always = no
		government = monarchy
		NOT = { has_dlc = "Dharma" }
		NOT = { has_dlc = "Emperor" }
		is_free_or_tributary_trigger = yes
		NOT = { has_reform = mamluk_government }
		NOT = { has_government_attribute = has_harem_events }
		NOT = { has_reform = celestial_empire }
		adm_tech = 20
		adm_power = 200
		has_factions = no
	}
	
	mean_time_to_happen = {
		months = 5000
	}
	
	option = {
		name = "EVTOPTA9462"
		ai_chance = { factor = 100 }
		add_adm_power = -100
		add_stability = -1
	}
	option = {
		name = "EVTOPTB9462"
		ai_chance = { factor = 0 }
		#set_legacy_government = bureaucratic_despotism
		kill_ruler = yes
		add_stability = -6
	}
}

# The Family
country_event = {
	id = 9463
	title = "EVTNAME9463"
	desc = "EVTDESC9463"
	picture = GOOD_WITH_MONARCH_eventPicture
	
	trigger = {
		stability = 3
		treasury = 100
		government = monarchy
		NOT = { has_reform = mamluk_government }
		has_regency = no
		is_lesser_in_union = no
		any_known_country = {
			dynasty = ROOT
			government = monarchy
			NOT = { stability = -2 }
			NOT = { senior_union_with = ROOT }
			NOT = { junior_union_with = ROOT }
		}
	}
	
	mean_time_to_happen = {
		months = 18
	}
	
	option = {
		name = "EVTOPTA9463"
		random_country = {
			limit = {
				dynasty = ROOT
				government = monarchy
				NOT = { stability = -2 }
				NOT = { senior_union_with = ROOT }
				NOT = { junior_union_with = ROOT }
			}
			country_event = { id = 9476 }
			add_opinion = { who = ROOT modifier = opinion_dynastic_helper }
		}
		add_treasury = -100
		add_prestige = 10
	}
	option = {
		name = "EVTOPTB9463"
		random_country = {
			limit = { 
				dynasty = ROOT
				government = monarchy
				NOT = { stability = -2 }
				NOT = { senior_union_with = ROOT }
				NOT = { junior_union_with = ROOT }
			}
			country_event  = { id = 9477 }
			add_opinion = { who = ROOT modifier = opinion_ignore_dynasty }
		}
	}
}

# Regent usurps throne
country_event = {
	id = 9468
	title = "EVTNAME9468"
	desc = "EVTDESC9468"
	picture = DEATH_OF_HEIR_eventPicture
	
	trigger = {
		NOT = { stability = -1 }
		is_lesser_in_union = no
		government = monarchy
		NOT = { legitimacy_or_horde_unity = 50 }
		NOT = { has_government_attribute = has_harem_events }
		NOT = { has_reform = celestial_empire }
		NOT = { has_reform = mamluk_government }
		has_regency = yes
		has_consort_regency = no
		has_heir = yes
	}
	
	mean_time_to_happen = {
		months = 700
	}
	
	option = {
		name = "EVTOPTA9468"
		kill_heir = { allow_new_heir = no }
		define_ruler = {
		}
		if = {
			limit = {
				has_states_general_mechanic = yes
			}
			change_statists_vs_orangists = 1
		}
		add_stability = -1
	}
	option = {
		name = "EVTOPTB9468"
		add_stability = -2
		add_heir_claim = 30
	}
}

# Born under a star
country_event = {
	id = 9469
	title = "EVTNAME9469"
	desc = "EVTDESC9469"
	picture = NEW_HEIR_eventPicture
	
	trigger = {
		OR = {
			has_country_flag = unlock_lux_stella_flag
			AND = {
				government = monarchy
				NOT = { has_government_attribute = has_harem_events }
				NOT = { has_reform = mamluk_government }
				NOT = { has_reform = elective_monarchy }
				NOT = { has_reform = polish_elective_monarchy }
				is_lesser_in_union = no
				has_heir = no
				has_regency = no
				OR = {
					NOT = { has_dlc = "Rights of Man" }
					has_consort = yes
				}
				has_government_attribute = heir
			}
		}
	}
	
	mean_time_to_happen = {
		months = 5000
	}
	
	option = {
		name = "EVTOPTA9469"
		trigger = {
			NOT = { religion_group = muslim }
			NOT = { religion_group = eastern }
			NOT = { religion_group = dharmic }
			NOT = { religion_group = pagan }
			NOT = { religion_group = jewish_group }
			NOT = { religion_group = zoroastrian_group }
		}
		define_heir = {
			male = yes
			dynasty = ROOT
			name = "0000000"
			claim = 100
			mil = 6
		}
	}
	option = {
		name = "EVTOPTAb9469"
		trigger = {
			NOT = { religion_group = christian }
			NOT = { religion_group = eastern }
			NOT = { religion_group = dharmic }
			NOT = { religion_group = pagan }
			NOT = { religion_group = jewish_group }
			NOT = { religion_group = zoroastrian_group }
		}
		define_heir = {
			dynasty = ROOT
			male = yes
			name = "Iskandar"
			claim = 100
			mil = 6
		}
	}
	option = {
		name = "EVTOPTAc9469"
		trigger = {
			NOT = { religion_group = christian }
			NOT = { religion_group = eastern }
			NOT = { religion_group = muslim }
			NOT = { religion_group = pagan }
			NOT = { religion_group = jewish_group }
			NOT = { religion_group = zoroastrian_group }
		}
		define_heir = {
			dynasty = ROOT
			male = yes
			name = "00000"
			claim = 100
			mil = 6
		}
	}
	option = {
		name = "EVTOPTAd9469"
		trigger = {
			religion = tengri_pagan_reformed
		}
		define_heir = {
			dynasty = ROOT
			male = yes
			name = "Genghis"
			claim = 100
			mil = 6
		}
	}
	option = {
		name = "EVTOPTAe9469"
		trigger = {
			religion = norse_pagan_reformed
		}
		define_heir = {
			dynasty = ROOT
			male = yes
			name = "Gunnarr"
			claim = 100
			mil = 6
		}
	}
	option = {
		name = "EVTOPTAf9469"
		trigger = {
			OR = {
				religion = mesoamerican_religion
				religion = nahuatl
			}
		}
		define_heir = {
			dynasty = ROOT
			male = yes
			name = "Ahuizotl"
			claim = 100
			mil = 6
		}
	}
	option = {
		name = "EVTOPTAg9469"
		trigger = {
			religion = inti
		}
		define_heir = {
			dynasty = ROOT
			male = yes
			name = "Pachakutiq"
			claim = 100
			mil = 6
		}
	}
	option = {
		name = "EVTOPTAh9469"
		trigger = {
			religion = totemism
		}
		define_heir = {
			dynasty = ROOT
			male = yes
			name = "Deganawida"
			claim = 100
			mil = 6
		}
	}
	option = {
		name = "EVTOPTAi9469"
		trigger = {
			religion = shamanism #Fetishism
		}
		define_heir = {
			dynasty = ROOT
			male = yes
			name = "Ruhinda"
			claim = 100
			mil = 6
		}
	}
	option = {
		name = "EVTOPTAj9469"
		trigger = {
			religion = animism
		}
		define_heir = {
			dynasty = ROOT
			male = yes
			name = "Cacique"
			claim = 100
			mil = 6
		}
	}
	option = {
		name = "EVTOPTAk9469"
		trigger = {
			NOT = { religion_group = christian }
			NOT = { religion_group = dharmic }
			NOT = { religion_group = muslim }
			NOT = { religion_group = pagan }
			NOT = { religion_group = jewish_group }
			NOT = { religion_group = zoroastrian_group }
		}
		define_heir = {
			dynasty = ROOT
			male = yes
			name = "00000"
			claim = 100
			mil = 6
		}
	}
	option = {
		name = "EVTOPTAl9469"
		trigger = {
			NOT = { religion_group = christian }
			NOT = { religion_group = dharmic }
			NOT = { religion_group = muslim }
			NOT = { religion_group = pagan }
			NOT = { religion_group = jewish_group }
			NOT = { religion_group = eastern }
		}
		define_heir = {
			dynasty = ROOT
			male = yes
			name = "Rustam"
			claim = 100
			mil = 6
		}
	}
	option = {
		name = "EVTOPTAm9469"
		trigger = {
			NOT = { religion_group = christian }
			NOT = { religion_group = dharmic }
			NOT = { religion_group = muslim }
			NOT = { religion_group = pagan }
			NOT = { religion_group = zoroastrian_group }
			NOT = { religion_group = eastern }
		}
		define_heir = {
			dynasty = ROOT
			male = yes
			name = "0000H&"
			claim = 100
			mil = 6
		}
	}
	
	option = {
		name = "EVTOPTB9469"
		trigger = {
			NOT = { religion_group = muslim }
			NOT = { religion_group = eastern }
			NOT = { religion_group = dharmic }
			NOT = { religion_group = pagan }
			NOT = { religion_group = jewish_group }
			NOT = { religion_group = zoroastrian_group }
		}
		define_heir = {
			dynasty = ROOT
			male = yes
			name = "0000"
			claim = 100
			adm = 6
		}
	}
	option = {
		name = "EVTOPTBb9469"
		trigger = {
			NOT = { religion_group = christian }
			NOT = { religion_group = eastern }
			NOT = { religion_group = dharmic }
			NOT = { religion_group = pagan }
			NOT = { religion_group = jewish_group }
			NOT = { religion_group = zoroastrian_group }
		}
		define_heir = {
			dynasty = ROOT
			male = yes
			name = "00000"
			claim = 100
			adm = 6
		}
	}
	option = {
		name = "EVTOPTBc9469"
		trigger = {
			NOT = { religion_group = christian }
			NOT = { religion_group = eastern }
			NOT = { religion_group = muslim }
			NOT = { religion_group = pagan }
			NOT = { religion_group = jewish_group }
			NOT = { religion_group = zoroastrian_group }
		}
		define_heir = {
			dynasty = ROOT
			male = yes
			name = "00000"
			claim = 100
			adm = 6
		}
	}
	option = {
		name = "EVTOPTBd9469"
		trigger = {
			religion = tengri_pagan_reformed
		}
		define_heir = {
			dynasty = ROOT
			male = yes
			name = "Kubilai"
			claim = 100
			adm = 6
		}
	}
	option = {
		name = "EVTOPTBe9469"
		trigger = {
			religion = norse_pagan_reformed
		}
		define_heir = {
			male = yes
			dynasty = ROOT
			name = "000"
			claim = 100
			adm = 6
		}
	}
	option = {
		name = "EVTOPTBf9469"
		trigger = {
			OR = {
				religion = mesoamerican_religion
				religion = nahuatl
			}
		}
		define_heir = {
			male = yes
			dynasty = ROOT
			name = "000000"
			claim = 100
			adm = 6
		}
	}
	option = {
		name = "EVTOPTBg9469"
		trigger = {
			religion = inti
		}
		define_heir = {
			male = yes
			dynasty = ROOT
			name = "00000"
			claim = 100
			adm = 6
		}
	}
	option = {
		name = "EVTOPTBh9469"
		trigger = {
			religion = totemism
		}
		define_heir = {
			male = yes
			dynasty = ROOT
			name = "00000"
			claim = 100
			adm = 6
		}
	}
	option = {
		name = "EVTOPTBi9469"
		trigger = {
			religion = shamanism #Fetishism
		}
		define_heir = {
			male = yes
			dynasty = ROOT
			name = "Ruhanga"
			claim = 100
			adm = 6
		}
	}
	option = {
		name = "EVTOPTBj9469"
		trigger = {
			religion = animism
		}
		define_heir = {
			male = yes
			dynasty = ROOT
			name = "Bochica"
			claim = 100
			adm = 6
		}
	}
	option = {
		name = "EVTOPTBk9469"
		trigger = {
			NOT = { religion_group = christian }
			NOT = { religion_group = dharmic }
			NOT = { religion_group = muslim }
			NOT = { religion_group = pagan }
			NOT = { religion_group = jewish_group }
			NOT = { religion_group = zoroastrian_group }
		}
		define_heir = {
			male = yes
			dynasty = ROOT
			name = "Ashoka"
			claim = 100
			adm = 6
		}
	}
	option = {
		name = "EVTOPTBl9469"
		trigger = {
			NOT = { religion_group = christian }
			NOT = { religion_group = dharmic }
			NOT = { religion_group = muslim }
			NOT = { religion_group = pagan }
			NOT = { religion_group = jewish_group }
			NOT = { religion_group = eastern }
		}
		define_heir = {
			male = yes
			dynasty = ROOT
			name = "Zal"
			claim = 100
			adm = 6
		}
	}
	option = {
		name = "EVTOPTBm9469"
		trigger = {
			NOT = { religion_group = christian }
			NOT = { religion_group = dharmic }
			NOT = { religion_group = muslim }
			NOT = { religion_group = pagan }
			NOT = { religion_group = zoroastrian_group }
			NOT = { religion_group = eastern }
		}
		define_heir = {
			male = yes
			dynasty = ROOT
			name = "Solomon"
			claim = 100
			adm = 6
		}
	}
	option = {
		name = "EVTOPTC9469"
		define_heir = {
			male = yes
			dynasty = ROOT
			name = "000H&"
			claim = 100
			dip = 6
		}
	}
}

# Heir is of our Dynasty
country_event = {
	id = 9470
	title = "EVTNAME9470"
	desc = "EVTDESC9470"
	picture = DIPLOMACY_eventPicture
	
	trigger = {
		religion_group = christian
		government = monarchy
		NOT = { has_reform = elective_monarchy }
		NOT = { has_reform = polish_elective_monarchy }
		NOT = { has_government_attribute = has_harem_events }
		NOT = { has_reform = mamluk_government }
		has_regency = no
		is_lesser_in_union = no
		num_of_royal_marriages = 4
		has_government_attribute = heir
		has_states_general_mechanic = no
		any_country = {
			religion_group = christian
			government = monarchy
			NOT = { has_reform = elective_monarchy }
			NOT = { has_reform = polish_elective_monarchy }
			NOT = { has_government_attribute = has_harem_events }
			NOT = { has_reform = mamluk_government }
			marriage_with = ROOT
			NOT = { dynasty = ROOT }
			has_heir = no
			has_government_attribute = heir
			has_states_general_mechanic = no
			is_lesser_in_union = no
		}
	}
	
	immediate = {
		hidden_effect = {
			random_country = {
				limit = {
					government = monarchy
					marriage_with = ROOT
					NOT = { dynasty = ROOT }
					has_heir = no
					is_lesser_in_union = no
					has_government_attribute = heir
					has_states_general_mechanic = no
				}
				save_event_target_as = marriage_policy_paid_off_here
			}
		}
	}
	
	mean_time_to_happen = {
		months = 1500
		modifier = {
			factor = 0.9
			num_of_royal_marriages = 6
		}
	}
	
	option = {
		name = "EVTOPTA9470"
		trigger = {
			NOT = { dynasty = "0000000000" }
		}
		event_target:marriage_policy_paid_off_here = {
			define_heir = { #Generated immediately, rather than in the followup event, so that the actual heir matches the tooltip for ROOT.
				dynasty = ROOT
				age = 14
			}
			hidden_effect = {
				country_event = { id = dynastic_events.8 }
				set_heir_culture = FROM
				set_heir_religion = FROM
			}
		}
	}
	option = {
		name = "EVTOPTB9470"
		trigger = {
			dynasty = "0000000000"
		}
		event_target:marriage_policy_paid_off_here = {
			define_heir = { #Generated immediately, rather than in the followup event, so that the actual heir matches the tooltip for ROOT.
				dynasty = ROOT
				age = 14
			}
			hidden_effect = {
				country_event = { id = dynastic_events.8 }
				set_heir_culture = FROM
				set_heir_religion = FROM
			}
		}
	}
}

# The Family Opt 1
country_event = {
	id = 9476
	title = "EVTNAME9476"
	desc = "EVTDESC9476"
	picture = DIPLOMACY_eventPicture
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA9476"
		add_treasury = 100
		if = {
			limit = {
				stability = 3
			}
			add_stability_or_adm_power = yes
		}
		if = {
			limit = {
				NOT = { stability = 3 }
			}
			random_list = {
				10 = {
					add_stability = 1
				}
				10 = {
					add_stability = 2
				}
				
				10 = { 
					add_stability = 3
				}
			}
		}
	}
}

# The Family Opt 2
country_event = {
	id = 9477
	title = "EVTNAME9477"
	desc = "EVTDESC9477"
	picture = DIPLOMACY_eventPicture
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA9477"
		random_list = {
			10 = {
				add_stability_or_adm_power = yes
			}
			10 = {
				kill_ruler = yes
			}
			10 = {
				add_stability = -2
			}
		}
	}
}

# Fear and Loathing 1/3
province_event = {
	id = 9481
	title = "EVTNAME9481"
	desc = "EVTDESC9481"
	picture = ASSASSINATION_eventPicture
	
	trigger = {
		papacy_active = yes
		is_capital = yes
		owner = {
			has_regency = no
			has_heir = yes
			religion_group = christian
			NOT = { has_reform = elective_monarchy }
			NOT = { has_reform = polish_elective_monarchy }
			NOT = { has_government_attribute = has_harem_events }
			is_lesser_in_union = no
			NOT = { has_country_flag = murdering_bastard }
			NOT = { has_country_flag = contained_insanity }
			NOT = { heir_age = 3 }
		}
	}
	
	mean_time_to_happen = {
		months = 4000
		modifier = {
			factor = 0.75
			owner = { ruler_has_personality = malevolent_personality }
		}
	}
	
	option = {
		name = "EVTOPTA9481"
		owner = {
			kill_heir = {}
			set_country_flag = murdering_bastard
		}
	}
	
	option = {
		name = "EVTOPTB9481"
		owner = {
			add_papal_influence = 5
			set_country_flag = contained_insanity
		}
	}
}

# Fear and Loathing 2/3
country_event = {
	id = 9482
	title = "EVTNAME9482"
	desc = "EVTDESC9482"
	picture = DEATH_OF_HEIR_eventPicture
	
	trigger = {
		has_country_flag = murdering_bastard
		NOT = { has_country_flag = contained_insanity }
		has_regency = no
		is_lesser_in_union = no
	}
	
	mean_time_to_happen = {
		months = 12
	}
	
	option = {
		name = "EVTOPTA9482"
		kill_ruler = yes
		clr_country_flag = murdering_bastard
	}
	
	option = {
		name = "EVTOPTB9482"
		add_prestige = -5
		add_treasury = -100
		set_country_flag = contained_insanity
	}
}

# Fear and Loathing 3/3
country_event = {
	id = 9483
	title = "EVTNAME9483"
	desc = "EVTDESC9483"
	picture = DEATH_OF_HEIR_eventPicture

	trigger = {
		has_country_flag = contained_insanity
		has_regency = no
		is_lesser_in_union = no
	}
	
	mean_time_to_happen = {
		months = 300
	}
	
	option = {
		name = "EVTOPTA9483"
		add_stability = -3
		add_prestige = -20
		clr_country_flag = contained_insanity
	}
	
	option = {
		name = "EVTOPTB9483"
		kill_ruler = yes
		add_country_modifier = {
			name = "relief_from"
			duration = 3650
		}
		clr_country_flag = contained_insanity
	}
}

# Fear and Loathing removal on ruler death, ontriggered
country_event = {
	id = 9492
	title = "EVTNAME9492"
	desc = "EVTDESC9492"
	picture = DEATH_OF_HEIR_eventPicture
	
	trigger = {
		OR = {
			has_country_flag = contained_insanity
			has_country_flag = murdering_bastard
		}
	}
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA9492"
		add_country_modifier = {
			name = "relief_from"
			duration = 3650
		}
		clr_country_flag = contained_insanity
		clr_country_flag = murdering_bastard
	}
}

# Wedding bells
country_event = {
	id = 9484
	title = "EVTNAME9484"
	desc = "EVTDESC9484"
	picture = GOOD_WITH_MONARCH_eventPicture
	
	trigger = {
		prestige = 30
		government = monarchy
		NOT = { has_government_attribute = has_harem_events }
		is_lesser_in_union = no
		is_at_war = no
		has_regency = no
		has_heir = no
		is_female = no
		has_government_attribute = queen
		has_government_attribute = heir
		OR = {
			NOT = { num_of_royal_marriages = 2 }
			AND = {
				has_dlc = "Rights of Man"
				has_consort = no
			}
		}
		any_known_country = {
			religion = ROOT
			government = monarchy
			is_lesser_in_union = no
			alliance_with = ROOT
			ai = yes
			NOT = { marriage_with = root }
		}
	}
	
	mean_time_to_happen = {
		months = 500
	}
	
	option = {
		name = "EVTOPTA9484"   #Time to settle down
		random_country = {
			limit = {
				religion = ROOT
				government = monarchy
				is_lesser_in_union = no
				alliance_with = ROOT
				ai = yes
				NOT = { marriage_with = root }
			}
			create_marriage = ROOT
		}
		
	}
	
	option = {
		name = "EVTOPTB9484"  #No
		add_prestige = 5
		add_country_modifier = {
			name = "sought_after_bachelor"
			duration = -1
		}
	}
}

# A modest proposal
country_event = {
	id = 9485
	title = "EVTNAME9485"
	desc = "EVTDESC9485"
	picture = DIPLOMACY_eventPicture
	
	trigger = {
		any_known_country = {
			has_country_modifier = sought_after_bachelor
			is_lesser_in_union = no
			government = monarchy
			religion_group = ROOT
			NOT = { marriage_with = ROOT }
		}
		government = monarchy
		is_lesser_in_union = no
	}
	
	mean_time_to_happen = {
		months = 400
	}
	
	option = {
		name = "EVTOPTA9485"
		random_country = {
			limit = {
				has_country_modifier = sought_after_bachelor
				religion_group = ROOT
				NOT = { marriage_with = ROOT }
			}
			random_list = {
				20 = { country_event = { id = 9486 } }
				80 = { country_event = { id = 9487 } }
			}
		}
		add_treasury = -15
		add_dip_power = -10
	}
	
	option = {
		name = "EVTOPTB9485"
		add_treasury = 10
		add_adm_power = 10
	}
}

# Wedding bells
country_event = {
	id = 9486
	title = "EVTNAME9486"
	desc = "EVTDESC9486"
	picture = GOOD_WITH_MONARCH_eventPicture
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA9486"
		if = {
			limit = {
				has_dlc = "Rights of Man"
			}
			define_consort = {
				country_of_origin = FROM
				culture = FROM
				religion = FROM
			}
		}
		create_marriage = FROM
		add_opinion = { who = FROM modifier = opinion_marriage_offer }
		remove_country_modifier = sought_after_bachelor
	}
	
	option = {
		name = "EVTOPTB9486"
		reverse_add_opinion = { who = FROM modifier = opinion_witchcraft }
	}
}

# Wedding bells
country_event = {
	id = 9487
	title = "EVTNAME9487"
	desc = "EVTDESC9487"
	picture = GOOD_WITH_MONARCH_eventPicture
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA9487"
		if = {
			limit = {
				has_dlc = "Rights of Man"
			}
			define_consort = {
				country_of_origin = FROM
				culture = FROM
				religion = FROM
			}
		}
		create_marriage = FROM
		add_opinion = { who = FROM modifier = opinion_united_dynasties }
		remove_country_modifier = sought_after_bachelor
	}
	
	option = {
		name = "EVTOPTB9487"
		reverse_add_opinion = { who = FROM modifier = opinion_refused_marriage }
	}
}

#Last war was a failure
country_event = {
	id = 9488
	title = "EVTNAME9488"
	desc = "EVTDESC9488"
	picture = {
		picture = ROYAL_STRESS_eventPicture
		trigger = {
			has_dlc = "Lions of the North"
			technology_group = western
		}
	}
	picture = {
		picture = MILITARY_CAMP_eventPicture
		trigger = {
			OR = {
				NOT = { has_dlc = "Lions of the North" }
				NOT = { technology_group = western }
			}
		}
	}
	
	trigger = {
		government = monarchy
		NOT = { has_reform = elective_monarchy }
		NOT = { has_reform = polish_elective_monarchy }
		has_heir = yes
		is_heir_leader = yes
		heir_age = 20
		any_known_country = {
			truce_with = ROOT
		}
		is_at_war = no
		is_lesser_in_union = no
		war_exhaustion = 12
	}
	
	mean_time_to_happen = {
		months = 300
	}
	
	option = {
		name = "EVTOPTA9488"
		kill_ruler = yes
		add_war_exhaustion = -4
		add_stability_or_adm_power = yes
	}
	
	option = {
		name = "EVTOPTB9488"
		kill_heir = {}
		add_war_exhaustion = -2
	}
}

# The Moon
country_event = {
	id = 9489
	title = "EVTNAME9489"
	desc = "EVTDESC9489"
	picture = IMPORTANT_STATUE_eventPicture
	
	trigger = {
		war_exhaustion = 4
		adm = 3
	}
	
	mean_time_to_happen = {
		months = 800
	}
	
	option = {
		name = "EVTOPTA9489"
		add_prestige = 5
	}
	
	option = {
		name = "EVTOPTB9489"
		add_mil_power = 25
	}
}

# Seeing the real you
country_event = {
	id = 9490
	title = "EVTNAME9490"
	desc = "EVTDESC9490"
	picture = NEW_HEIR_eventPicture
	
	trigger = {
		is_lesser_in_union = no
		government = monarchy
		NOT = { has_government_attribute = has_harem_events }
		NOT = { has_reform = mamluk_government }
		NOT = { has_reform = elective_monarchy }
		NOT = { has_reform = polish_elective_monarchy }
		has_heir = no
		is_female = no
		has_regency = no
		num_of_royal_marriages = 1
		has_government_attribute = heir
		if = {
			limit = {
				has_dlc = "Rights of Man"
			}
			has_consort = yes
		}
		NOT = {
			has_country_modifier = a_woman_scorned
		}
	}
	
	mean_time_to_happen = {
		months = 1400
	}
	
	option = {
		name = "EVTOPTA9490"
		define_heir = {
			dynasty = ROOT
		}
	}
	
	option = {
		name = "EVTOPTB9490"
		add_years_of_income = 0.5
		add_country_modifier = {
			name = "a_woman_scorned"
			duration = 1825
		}
	}
}

### Suggestions by Ex Mudder, scripted by Sara Wendel-�rtqvist

namespace = dynastic_events

# Starlight
country_event = {
	id = dynastic_events.1
	title = dynastic_events.1.t
	desc = dynastic_events.1.d
	picture = NEW_HEIR_eventPicture
	
	trigger = {
		has_heir = no
		ruler_age = 40
		government = monarchy
		religion_group = christian
		NOT = { has_government_attribute = has_harem_events }
		NOT = { has_reform = mamluk_government }
		NOT = { has_reform = elective_monarchy }
		NOT = { has_reform = polish_elective_monarchy }
		is_lesser_in_union = no
		has_government_attribute = heir
	}
	
	mean_time_to_happen = {
		months = 10000
		
		modifier = {
			factor = 0.5
			ruler_age = 50
		}
		modifier = {
			factor = 0.5
			ruler_age = 60
		}
		modifier = {
			factor = 0.5
			ruler_age = 70
		}
		modifier = {
			factor = 0.5
			ruler_age = 80
		}
		modifier = {
			factor = 0.5
			ruler_age = 90
		}
	}
	
	option = {
		name = dynastic_events.1.a
		define_heir = {
			name = "000000"
			dynasty = ROOT
			claim = 50
			female = yes
			adm = 4
			dip = 3
			mil = 3
		}
	}
	
	option = {
		name = dynastic_events.1.b
		define_heir = {
			dynasty = ROOT
			name = "Caterine"
			claim = 50
			adm = 3
			dip = 3
			mil = 4
			female = yes
		}
	}
	option = {
		name = dynastic_events.1.c
		define_heir = {
			dynasty = ROOT
			claim = 50
			adm = 3
			dip = 4
			mil = 3
			female = yes
		}
	}
	option = {
		name = dynastic_events.1.e
		define_heir = {
			dynasty = ROOT
			name = "00"
			claim = 50
			adm = 3
			dip = 3
			mil = 4
			female = yes
		}
	}
}

# Newborn Daughter
country_event = {
	id = dynastic_events.2
	title = dynastic_events.2.t
	desc = dynastic_events.2.d
	picture = NEW_HEIR_eventPicture
	
	trigger = {
		has_heir = no
		ruler_age = 20
		government = monarchy
		NOT = { religion_group = muslim }
		NOT = { has_government_attribute = has_harem_events }
		NOT = { has_reform = mamluk_government }
		NOT = { has_reform = elective_monarchy }
		NOT = { has_reform = polish_elective_monarchy }
		NOT = { has_reform = shogunate }
		is_lesser_in_union = no
		NOT = {
			has_country_modifier = dyn_newborn_daughter
		}
		has_government_attribute = heir
		OR = {
			has_regency = no 
			has_consort_regency = yes
		}
	}
	
	mean_time_to_happen = {
		months = 600
	}
	
	option = {
		name = dynastic_events.2.a
		add_horde_unity = 10
		add_legitimacy = -10
		if = {
			limit = {
				religion = catholic
			}
			add_papal_influence = -10
		}
		if = {
			limit = {
				religion_group = muslim
			}
			add_piety = -0.10
		}
		define_heir = {
			dynasty = ROOT
			female = yes
			claim = 50
		}
	}
	
	option = {
		name = dynastic_events.2.b
		add_country_modifier = {
			name = dyn_newborn_daughter
			duration = 365
		}
	}
}

# Talented and Ambitious Daughter
country_event = {
	id = dynastic_events.3
	title = dynastic_events.3.t
	desc = dynastic_events.3.d
	picture = NEW_HEIR_eventPicture
	
	trigger = {
		has_heir = no
		ruler_age = 40
		government = monarchy
		NOT = { has_reform = elective_monarchy }
		NOT = { has_reform = polish_elective_monarchy }
		NOT = { religion_group = muslim }
		NOT = { has_government_attribute = has_harem_events }
		NOT = { has_reform = mamluk_government }
		NOT = { has_reform = shogunate }
		has_government_attribute = heir
		is_lesser_in_union = no
		NOT = { has_ruler_flag = talented_daughter_happened }
	}
	
	immediate = {
		set_ruler_flag = talented_daughter_happened
	}
	
	mean_time_to_happen = {
		months = 500
		
		modifier = {
			factor = 0.9
			ruler_age = 50
		}
		
		modifier = {
			factor = 0.9
			ruler_age = 60
		}
		modifier = {
			factor = 0.9
			ruler_age = 70
		}
		modifier = {
			factor = 0.9
			ruler_age = 80
		}
		modifier = {
			factor = 0.9
			ruler_age = 90
		}
	}
	
	option = {
		name = dynastic_events.3.a
		add_horde_unity = -10
		add_legitimacy = -10
		if = {
			limit = {
				religion = catholic
			}
			add_papal_influence = -10
		}
		if = {
			limit = {
				religion_group = muslim
			}
			add_piety = -0.10
		}
		define_heir = {
			dynasty = ROOT
			age = 13
			change_adm = 3
			change_dip = 3
			change_mil = 3
			claim = 50
			female = yes
			no_consort_with_heir = yes
		}
	}
	
	option = {
		name = dynastic_events.3.b
		random_owned_province = {
			limit = {
				is_capital = yes
			}
			add_province_modifier = {
				name = add_unrest_5_modifier
				duration = 1825
			}
		}
	}
}

# The Ruler's Daughter
country_event = {
	id = dynastic_events.4
	title = dynastic_events.4.t
	desc = dynastic_events.4.d
	picture = NEW_HEIR_eventPicture
	
	is_triggered_only = yes
	
	trigger = {
		has_heir = no
		num_of_cities = 2
		has_regency = yes
		is_lesser_in_union = no
		government = monarchy
		NOT = { has_government_attribute = has_harem_events }
		NOT = { has_reform = elective_monarchy }
		NOT = { has_reform = polish_elective_monarchy }
		NOT = { has_reform = mamluk_government }
		religion_group = christian
		capital_scope = {
			continent = europe
		}
		any_known_country = {
			government = monarchy
			religion_group = christian
			NOT = { has_government_attribute = has_harem_events }
			NOT = { has_reform = elective_monarchy }
			NOT = { has_reform = polish_elective_monarchy }
			has_regency = no
			is_free_or_tributary_trigger = yes
			num_of_cities = ROOT
			is_female = no
			NOT = { has_country_flag = dyn_woman_pretender_flag }
			capital_scope = {
				continent = europe
			}
			NOT = {
				war_with = ROOT
			}
		}
	}
	
	mean_time_to_happen = {
		days = 1
	}
	
	immediate = {
		hidden_effect = {
			random_known_country = {
				limit = {
					government = monarchy
					NOT = { has_government_attribute = has_harem_events }
					NOT = { has_reform = elective_monarchy }
					NOT = { has_reform = polish_elective_monarchy }
					has_regency = no
					is_free_or_tributary_trigger = yes
					num_of_cities = ROOT
					is_female = no
					religion_group = christian
					capital_scope = {
						continent = europe
					}
					NOT = {
						war_with = ROOT
					}
				}
				set_country_flag = dyn_woman_pretender_flag
			}
		}
	}
	
	option = {
		name = dynastic_events.4.a
		if = {
			limit = {
				religion = catholic
			}
			add_papal_influence = -10
		}
		define_ruler = {
			dynasty = ROOT
			age = 20
			adm = 3
			dip = 3
			mil = 3
			claim = 50
			female = yes
		}
		if = {
			limit = {
				has_states_general_mechanic = yes
			}
			change_statists_vs_orangists = 1
		}
		random_known_country = {
			limit = {
				has_country_flag = dyn_woman_pretender_flag
			}
			add_casus_belli = {
				target = ROOT
				type = cb_restore_personal_union
				months = 12
			}
			add_opinion = {
				who = ROOT
				modifier = opinion_spurned_heir
			}
			clr_country_flag = dyn_woman_pretender_flag
		}
	}
	
	option = {
		name = dynastic_events.4.b
		random_known_country = {
			limit = {
				has_country_flag = dyn_woman_pretender_flag
			}
			clr_country_flag = dyn_woman_pretender_flag
			add_opinion = {
				who = ROOT
				modifier = opinion_choose_heir
			}
			ROOT = {
				define_ruler = {
					dynasty = PREV
					age = 20
				}
				if = {
					limit = {
						has_states_general_mechanic = yes
					}
					change_statists_vs_orangists = 1
				}
			}
		}
		random_owned_province = {
			limit = {
				is_capital = no
			}
			spawn_rebels = {
				type = pretender_rebels
				size = 2
				female = yes
			}
		}
	}
}

# Offer Personal Union
country_event = {
	id = dynastic_events.5
	title = dynastic_events.5.t
	desc = dynastic_events.5.d
	picture = DIPLOMACY_eventPicture
	
	is_triggered_only = yes 
	trigger = {
		has_heir = no
		government = monarchy
		NOT = { has_government_attribute = has_harem_events }
		NOT = { has_reform = mamluk_government }
		NOT = { has_reform = elective_monarchy }
		religion_group = christian
		is_free_or_tributary_trigger = yes
		has_consort = no
		ruler_age = 16
		NOT = {
			ruler_age = 40
		}
		any_neighbor_country = {
			government = monarchy
			NOT = { has_government_attribute = has_harem_events }
			NOT = { has_reform = elective_monarchy }
			religion_group = christian
			has_heir = no
			ruler_age = 16
			NOT = {
				ruler_age = 40
			}
			NOT = {
				OR = {
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_spurned_pu
					}
					reverse_has_opinion_modifier = {
						who = ROOT
						modifier = opinion_spurned_pu
					}
				}
			}
			OR = {
				AND = {
					is_female = no
					ROOT = {
						is_female = yes
					}
				}
				AND = {
					is_female = yes
					ROOT = {
						is_female = no
					}
				}
			}
			OR = {
				dynasty = ROOT
				culture_group = ROOT
			}
			has_opinion = { who = ROOT value = 75 }
			reverse_has_opinion = { who = ROOT value = 75 }
			is_free_or_tributary_trigger = yes
		}
	}

	mean_time_to_happen = {
		days = 1 
	}
	
	immediate = {
		random_neighbor_country = {
			limit = {
				government = monarchy
				NOT = { has_government_attribute = has_harem_events }
				NOT = { has_reform = elective_monarchy }
				NOT = { has_reform = polish_elective_monarchy }
				NOT = { has_reform = mamluk_government }
				religion_group = christian
				has_heir = no
				ruler_age = 16
				NOT = {
					ruler_age = 40
				}
				NOT = {
					OR = {
						has_opinion_modifier = {
							who = ROOT
							modifier = opinion_spurned_pu
						}
						reverse_has_opinion_modifier = {
							who = ROOT
							modifier = opinion_spurned_pu
						}
					}
				}
				OR = {
					AND = {
						is_female = no
						ROOT = {
							is_female = yes
						}
					}
					AND = {
						is_female = yes
						ROOT = {
							is_female = no
						}
					}
				}
				OR = {
					dynasty = ROOT
					culture_group = ROOT
				}
				has_opinion = { who = ROOT value = 75 }
				reverse_has_opinion = { who = ROOT value = 75 }
				is_free_or_tributary_trigger = yes
			}
			hidden_effect = {
				save_event_target_as = nameless_neighbor_no_more
			}
		}
	}
	
	option = {
		name = dynastic_events.5.a
		event_target:nameless_neighbor_no_more = {
			country_event = {
				id = dynastic_events.6
				tooltip = dynastic_events.6.t
			}
		}
	}
	
	option = {
		name = dynastic_events.5.b
		add_legitimacy = 10
	}
}

# Personal Union Offered
country_event = {
	id = dynastic_events.6
	title = dynastic_events.6.t
	desc = dynastic_events.6.d
	picture = DIPLOMACY_eventPicture
	
	is_triggered_only = yes
	
	option = {
		name = dynastic_events.6.a
		add_prestige = 20
		FROM = {
			set_country_flag = dyn_pu_accepted_flag
			tooltip = {
				create_union = ROOT
			}
			country_event = {
				id = dynastic_events.7
				tooltip = dynastic_events.7.t
			}
		}
		ai_chance = {
			factor = 20
			modifier = {
				factor = 4
				NOT = { total_development = FROM }
			}
		}
	}
	
	option = {
		name = dynastic_events.6.b
		FROM = {
			set_country_flag = dyn_pu_refused_flag
			add_opinion = {
				modifier = opinion_spurned_pu
				who = ROOT
			}
			add_casus_belli = {
				target = ROOT
				type = cb_insult
				months = 12
			}
			country_event = {
				id = dynastic_events.7
				tooltip = dynastic_events.7.t
			}
		}
		ai_chance = {
			factor = 20
			modifier = {
				factor = 4
				total_development = FROM
			}
		}
	}
}

# A Political Marriage - Accepted or Not?
country_event = {
	id = dynastic_events.7
	title = dynastic_events.7.t
	desc = dynastic_events.7.d
	picture = DIPLOMACY_eventPicture
	
	is_triggered_only = yes
	
	option = {
		name = dynastic_events.7.a
		trigger = {
			has_country_flag = dyn_pu_accepted_flag
		}
		add_legitimacy = 20
		define_consort = {
			country_of_origin = FROM
			dynasty = FROM
			culture = FROM
			religion = FROM
		}
		create_union = FROM		
	}
	
	option = {
		name = dynastic_events.7.b
		trigger = {
			has_country_flag = dyn_pu_refused_flag
		}
		tooltip = {
			add_opinion = {
				modifier = opinion_spurned_pu
				who = FROM
			}
			add_casus_belli = {
				target = FROM
				type = cb_insult
				months = 12
			}
		}
	}
	
	after = {
		hidden_effect = {
			clr_country_flag = dyn_pu_accepted_flag
			clr_country_flag = dyn_pu_refused_flag
		}
	}
}

# Marriage Policies paid off
country_event = {
	id = dynastic_events.8
	title = dynastic_events.8.t
	desc = dynastic_events.8.d
	picture = COURT_eventPicture
	
	is_triggered_only = yes
	
	trigger = {
		has_states_general_mechanic = no
		has_government_attribute = heir
	}
	
	option = {
		name = dynastic_events.8.a
		trigger = {
			FROM = {
				NOT = { dynasty = "0000000000" }
			}
		}
		custom_tooltip = dynastic_events.8.a.tt
	}
	option = {
		name = dynastic_events.8.b
		trigger = {
			FROM = {
				dynasty = "0000000000"
			}
		}
		custom_tooltip = dynastic_events.8.a.tt
	}
}