# ASK_FOR_MONEY_INTERACTION_ACCEPT_EVENT
diploresponse_event = {
	id = SoA.3100
	desc = EVTDESC_SOA_3100

	is_triggered_only = yes
	is_friendly = yes

	ai = no

	option = {
		name = OK
	}
}

# ASK_FOR_MONEY_INTERACTION_DECLINE_EVENT
diploresponse_event = {
	id = SoA.3101
	desc = EVTDESC_SOA_3101

	is_triggered_only = yes
	is_hostile = yes

	ai = no

	option = {
		name = OK
	}
}

# NOMINATE_BISHOP_TO_POPE_INTERACTION_ACCEPT_EVENT
diploresponse_event = {
	id = SoA.3102
	desc = EVTDESC_SOA_3102

	is_triggered_only = yes
	is_friendly = yes

	ai = no

	option = {
		name = OK
	}
}

# NOMINATE_BISHOP_TO_POPE_INTERACTION_DECLINE_EVENT
diploresponse_event = {
	id = SoA.3103
	desc = EVTDESC_SOA_3103

	is_triggered_only = yes
	is_hostile = yes

	ai = no

	option = {
		name = OK
	}
}

# ASK_FOR_CLAIM_INTERACTION_ACCEPT_EVENT
diploresponse_event = {
	id = SoA.3104
	desc = EVTDESC_SOA_3104

	is_triggered_only = yes
	is_friendly = yes

	ai = no

	option = {
		name = OK
	}
}

# ASK_FOR_MONEY_INTERACTION_DECLINE_EVENT
diploresponse_event = {
	id = SoA.3105
	desc = EVTDESC_SOA_3105

	is_triggered_only = yes
	is_hostile = yes

	ai = no

	option = {
		name = OK
	}
}

###########################################
# Demon Child Narrative Event Chain
###########################################
# by Henrik Fhraeus
###########################################

# Apart from these events, other events have been modified to make sure the Demon character is very likely to start adventures and is hard to kill

# Newborn is a demon child
character_event = {
	id = SoA.3001

	is_triggered_only = yes # on_post_birth, random_events, demon_child_chance
	hide_window = yes

	trigger = {
		is_ill = no

		OR = {
			has_dlc = "Sons of Abraham"
			has_dlc = "Mystics"
		}

		NOR = {
			trait = inbred
			has_global_flag = demon_child_born
			event_target:demon_child_non_pagan = { is_alive = yes }

			has_game_rule = {
				name = supernatural_events
				value = off
			}
		}

		any_close_relative = {
			is_parent_of = ROOT
			is_playable = yes

			OR = {
				religion_group = christian
				religion_group = muslim
				religion_group = zoroastrian_group
				religion_group = jewish_group
			}

			trigger_if = {
				limit = { ai = yes }

				has_game_rule = {
					name = supernatural_events
					value = unrestricted
				}
			}
		}
	}

	weight_multiplier = {
		factor = 1

		mult_modifier = {
			factor = 2

			any_close_relative = {
				is_parent_of = ROOT
				is_playable = yes
				trait = possessed
			}
		}

		mult_modifier = {
			factor = 1.33

			any_close_relative = {
				is_parent_of = ROOT
				is_playable = yes
				trait = lunatic
			}
		}

		mult_modifier = {
			factor = 1.33

			any_close_relative = {
				is_parent_of = ROOT
				is_playable = yes
				trait = cruel
			}
		}

		mult_modifier = {
			factor = 1.33

			any_close_relative = {
				is_parent_of = ROOT
				is_playable = yes
				trait = impaler
			}
		}

		mult_modifier = {
			factor = 4

			any_close_relative = {
				is_parent_of = ROOT
				is_playable = yes
				society_member_of = the_satanists
			}
		}
	}

	immediate = {
		save_global_event_target_as = demon_child_non_pagan

		random_close_relative = {
			limit = {
				is_parent_of = ROOT
				is_playable = yes

				OR = {
					religion_group = christian
					religion_group = muslim
					religion_group = zoroastrian_group
					religion_group = jewish_group
				}
			}

			preferred_limit = { ai = no }

			narrative_event = {
				id = SoA.3002 # Demon child
				years = 2
			}
		}
	}
}

# Event triggers for a player
# Can also be fired from event MNM.20005

# First narrative event
narrative_event = {
	id = SoA.3002
	title = EVTTITLE_SOA_3002
	desc = EVTDESC_SOA_3002
	picture = GFX_evt_birth
	border = GFX_event_narrative_frame_religion

	is_triggered_only = yes

	only_playable = yes

	trigger = {
		OR = {
			religion_group = christian
			religion_group = muslim
			religion_group = zoroastrian_group
			religion_group = jewish_group
		}

		OR = {
			has_dlc = "Sons of Abraham"
			has_dlc = "Mystics"
		}

		trigger_if = {
			limit = { ai = yes }

			has_game_rule = {
				name = supernatural_events
				value = unrestricted
			}
		}

		any_child = {
			character = event_target:demon_child_non_pagan
		}

		NOR = {
			has_game_rule = {
				name = supernatural_events
				value = off
			}

			has_global_flag = demon_child_born
		}
	}

	immediate = {
		event_target:demon_child_non_pagan = {
			save_global_event_target_as = demon_child_non_pagan
			set_character_flag = demon_child_non_pagan
			set_global_flag = demon_child_born

			add_character_modifier = {
				name = demon_child_non_pagan
				duration = -1
				hidden = yes
			}

			remove_trait = sickly

			mother = {
				save_event_target_as = demon_child_mother
			}

			character_event = {
				id = SoA.3019 # Demon child tombola
				months = 3
				random = 90
			}
		}
	}

	fail_trigger_effect = {
		if = {
			limit = {
				NOT = { has_global_flag = demon_child_born }
			}

			clear_global_event_target = demon_child_non_pagan
		}
	}

	option = {
		name = {
			text = EVTOPTA_SOA_3002 # Pray and fast, father
			trigger = {
				is_female = no
				NOT = { society_member_of = the_satanists }
			}
		}
		name = {
			text = EVTOPTA_SOA_3002_SATANIST # Rejoice, father
			trigger = {
				is_female = no
				society_member_of = the_satanists
			}
		}
		name = {
			text = EVTOPTB_SOA_3002 # Pray and fast, mother
			trigger = {
				is_female = yes
				NOT = { society_member_of = the_satanists }
			}
		}
		name = {
			text = EVTOPTB_SOA_3002_SATANIST # Rejoice, mother
			trigger = {
				is_female = yes
				society_member_of = the_satanists
			}
		}

		if = {
			limit = { society_member_of = the_satanists }

			if = {
				limit = { is_female = yes }
				add_society_currency_massive_effect = yes
			}
			else = {
				add_society_currency_major_effect = yes
			}
		}

		random = {
			chance = 50

			event_target:demon_child_non_pagan = {
				show_scope_change = no

				add_character_modifier = {
					name = suspected_demon_spawn
					duration = -1
				}
			}
		}

		random = {
			chance = 50

			event_target:demon_child_mother = {
				show_scope_change = no

				add_character_modifier = {
					name = suspected_witch
					duration = -1
				}
			}
		}

		ai_chance = { factor = 100 }
	}

	option = {
		name = EVTOPTC_SOA_3002 # Consult the Court Chaplain

		trigger = {
			religion = job_spiritual
			NOT = { society_member_of = the_satanists }
		}

		job_spiritual = {
			show_scope_change = no

			character_event = {
				id = SoA.3003
				days = 2
				tooltip = EVTTOOLTIP_SOA_3003
			}
		}
	}
}

# Court Chaplain Consulted triggers for the child
character_event = {
	id = SoA.3003
	desc = EVTDESC_SOA_3003
	picture = GFX_evt_birth
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA_SOA_3003 # Tell not to worry

		FROM = {
			character_event = {
				id = SoA.3007
				days = 2
			}
		}

		ai_chance = {
			factor = 100

			trigger = {
				trigger_if = {
					limit = { trait = zealous }
					society_member_of = the_satanists
				}
			}

			mult_modifier = {
				factor = 2

				FROM = {
					is_female = yes
					trait = kind
				}
			}

			mult_modifier = {
				factor = 2

				FROM = {
					is_female = yes
					trait = chaste
				}
			}

			mult_modifier = {
				factor = 2

				FROM = {
					is_female = yes
					trait = zealous
				}
			}

			mult_modifier = {
				factor = 2

				opinion = {
					who = FROM
					value >= 50
				}
			}
		}
	}

	option = {
		name = EVTOPTB_SOA_3003 # Accuse of witchcraft

		trigger = {
			FROM = { is_female = yes }
		}

		FROM = {
			show_scope_change = no

			character_event = {
				id = SoA.3008
				days = 2
				tooltip = EVTTOOLTIP_SOA_3005
			}
		}

		ai_chance = {
			factor = 100

			trigger = {
				NOR = {
					trait = cynical
					society_member_of = the_satanists
				}
			}

			mult_modifier = {
				factor = 2
				trait = cruel
			}

			mult_modifier = {
				factor = 2
				trait = arbitrary
			}

			mult_modifier = {
				factor = 2
				FROM = { trait = possessed }
			}

			mult_modifier = {
				factor = 2
				FROM = { trait = lunatic }
			}

			mult_modifier = {
				factor = 2
				FROM = { trait = cruel }
			}

			mult_modifier = {
				factor = 4
				FROM = { trait = impaler }
			}

			mult_modifier = {
				factor = 2
				FROM = { trait = mystic }
			}

			mult_modifier = {
				factor = 2
				FROM = { trait = lustful }
			}

			mult_modifier = {
				factor = 2

				opinion = {
					who = FROM
					value < 0
				}
			}

			mult_modifier = {
				factor = 2

				opinion = {
					who = FROM
					value < -50
				}
			}
		}
	}

	option = {
		name = EVTOPTB_SOA_3003 # Accuse mother of witchcraft

		trigger = {
			FROM = { is_female = no }

			event_target:demon_child_mother = {
				is_alive = yes
			}
		}

		FROM = {
			show_scope_change = no

			character_event = {
				id = SoA.3009
				days = 2
				tooltip = EVTTOOLTIP_SOA_3006
			}
		}

		ai_chance = {
			factor = 100

			trigger = {
				NOR = {
					trait = cynical
					society_member_of = the_satanists
				}
			}

			mult_modifier = {
				factor = 2
				trait = arbitrary
			}

			mult_modifier = {
				factor = 2
				event_target:demon_child_mother = { trait = possessed }
			}

			mult_modifier = {
				factor = 2
				event_target:demon_child_mother = { trait = lunatic }
			}

			mult_modifier = {
				factor = 2
				event_target:demon_child_mother = { trait = cruel }
			}

			mult_modifier = {
				factor = 4
				event_target:demon_child_mother = { trait = impaler }
			}

			mult_modifier = {
				factor = 2
				event_target:demon_child_mother = { trait = mystic }
			}

			mult_modifier = {
				factor = 2
				event_target:demon_child_mother = { trait = lustful }
			}

			mult_modifier = {
				factor = 5
				NOT = { religion = event_target:demon_child_mother }
			}

			mult_modifier = {
				factor = 2

				opinion = {
					who = FROM
					value < 0
				}
			}

			mult_modifier = {
				factor = 2

				opinion = {
					who = event_target:demon_child_mother
					value < 0
				}
			}

			mult_modifier = {
				factor = 2

				opinion = {
					who = event_target:demon_child_mother
					value < -50
				}
			}
		}
	}
}

# I should not worry about the child
character_event = {
	id = SoA.3007
	desc = EVTDESC_SOA_3007
	picture = GFX_evt_family
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA_SOA_3007 # What a relief!

		piety = 100
	}
}

# I am accused of witchcraft!
character_event = {
	id = SoA.3008
	desc = EVTDESC_SOA_3008
	picture = GFX_evt_shadowy_cabal
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA_SOA_3008 # Deny these ridiculous charges!

		add_character_modifier = {
			name = suspected_witch
			duration = -1
		}

		event_target:demon_child_non_pagan = {
			show_scope_change = no

			add_character_modifier = {
				name = suspected_demon_spawn
				duration = -1
			}
		}

		piety = -500

		FROM = {
			character_event = {
				id = SoA.3010
				days = 2
			}
		}
	}

	option = {
		name = EVTOPTB_SOA_3008 # Tell of lurid dreams

		FROM = {
			show_scope_change = no

			character_event = {
				id = SoA.3011
				days = 2
				tooltip = EVTTOOLTIP_SOA_3011
			}
		}
	}

	option = {
		name = EVTOPTC_SOA_3008 # Get rid of the court chaplain
		tooltip_info = intrigue

		trigger = { intrigue >= 10 }

		wealth = -50

		job_spiritual = {
			show_scope_change = no

			death = {
				death_reason = death_murder
				killer = ROOT
			}
		}
	}
}

# The mother is accused of witchcraft!
character_event = {
	id = SoA.3009
	desc = EVTDESC_SOA_3009
	picture = GFX_evt_quarrel
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA_SOA_3009 # Deny these ridiculous charges!

		event_target:demon_child_non_pagan = {
			show_scope_change = no

			add_character_modifier = {
				name = suspected_demon_spawn
				duration = -1
			}
		}

		event_target:demon_child_mother = {
			show_scope_change = no

			add_character_modifier = {
				name = suspected_witch
				duration = -1
			}
		}

		piety = -200

		FROM = {
			character_event = {
				id = SoA.3015
				days = 2
			}
		}
	}

	option = {
		name = EVTOPTB_SOA_3009 # Seize the mother declare the child illegitimate!

		event_target:demon_child_non_pagan = {
			show_scope_change = no

			hidden_effect = {
				if = {
					limit = { is_father_real_father = yes }
					set_character_flag = real_father_check_set
				}

				set_father = 0

				if = {
					limit = { has_character_flag = real_father_check_set }
					set_real_father = ROOT
					clr_character_flag = real_father_check_set
				}
			}

			add_trait = bastard
			dynasty = mother
		}

		event_target:demon_child_mother = {
			show_scope_change = no

			remove_spouse = yes

			if = {
				limit = {
					employer = {
						character = ROOT
					}
				}

				imprison = ROOT

				reverse_opinion = {
					name = opinion_witch
					who = ROOT
				}

				if = {
					limit = { is_lover = ROOT }
					remove_lover = ROOT
				}
			}
		}
	}

	option = {
		name = EVTOPTC_SOA_3008 # Get rid of the court chaplain
		tooltip_info = intrigue

		trigger = { intrigue >= 10 }

		wealth = -50

		FROM = {
			show_scope_change = no

			death = {
				death_reason = death_murder
				killer = ROOT
			}
		}
	}
}

# Ruler assures Court Chaplain of innocence
character_event = {
	id = SoA.3010
	desc = EVTDESC_SOA_3010
	picture = GFX_evt_shadowy_cabal
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA_SOA_3010 # I must keep an eye on mother and child...
	}
}

# Ruler confesses to the Court Chaplain
character_event = {
	id = SoA.3011
	desc = EVTDESC_SOA_3011
	picture = GFX_evt_quarrel
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA_SOA_3011 # Demand her abdication and declare the child illegitimate

		opinion = {
			name = opinion_witch
			who = FROM
		}

		FROM = {
			show_scope_change = no

			character_event = {
				id = SoA.3014
				days = 2
				tooltip = EVTTOOLTIP_SOA_3012
			}
		}

		ai_chance = {
			factor = 70

			mult_modifier = {
				factor = 0.5
				FROM = { diplomacy >= 7 }
			}

			mult_modifier = {
				factor = 0.5
				FROM = { diplomacy >= 9 }
			}

			mult_modifier = {
				factor = 0.5
				FROM = { diplomacy >= 12 }
			}

			mult_modifier = {
				factor = 2.0
				FROM = { diplomacy < 4 }
			}
		}
	}

	option = {
		name = EVTOPTB_SOA_3011 # These are just normal dreams and nightmares

		FROM = {
			show_scope_change = no

			character_event = {
				id = SoA.3013
				days = 2
				tooltip = EVTTOOLTIP_SOA_3013
			}
		}

		ai_chance = { factor = 30 }
	}
}

# My dreams are normal
character_event = {
	id = SoA.3013
	desc = EVTDESC_SOA_3013
	picture = GFX_evt_child_play
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA_SOA_3007

		piety = 100
	}
}

# Accused publicly!
character_event = {
	id = SoA.3014
	desc = EVTDESC_SOA_3014
	picture = GFX_evt_heretic
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	immediate = {
		event_target:demon_child_non_pagan = {
			add_character_modifier = {
				name = suspected_demon_spawn
				duration = -1
			}
		}
	}

	option = {
		name = EVTOPTA_SOA_3014 # Abdicate

		add_character_modifier = {
			name = suspected_witch
			duration = -1
		}

		event_target:demon_child_non_pagan = {
			show_scope_change = no

			hidden_effect = {
				father_even_if_dead = {
					event_target:demon_child_non_pagan = {
						if = {
							limit = { is_father_real_father = yes }
							set_character_flag = real_father_check_set
						}

						set_father = 0

						if = {
							limit = { has_character_flag = real_father_check_set }
							set_real_father = PREV
							clr_character_flag = real_father_check_set
						}
					}
				}
			}

			add_trait = bastard
		}

		transfer_crown_on_abdication_effect = yes

		transfer_scaled_wealth = {
			to = current_heir
			value = all
		}

		abdicate = yes
		add_ascetic_trait_effect = yes
	}

	option = {
		name = EVTOPTB_SOA_3014 # Never!

		FROM = {
			show_scope_change = no

			remove_title = job_spiritual
			imprison = ROOT
		}

		add_character_modifier = {
			name = known_witch
			duration = -1
		}

		random_list = {
			50 = { }
			25 = { add_trait_depressed_effect = yes }
			25 = { add_trait_stressed_effect = yes }
		}
	}
}

# Male ruler assures Court Chaplain of the mother's innocence
character_event = {
	id = SoA.3015
	desc = EVTDESC_SOA_3015
	picture = GFX_evt_birth
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	ai = no

	option = {
		name = EVTOPTA_SOA_3015
	}
}

#############################
# Demon child tombola!
# Choose some new antics...
#############################
character_event = {
	id = SoA.3019

	is_triggered_only = yes
	hide_window = yes

	immediate = {
		# Witch nanny commits suicide for the demon child
		if = {
			limit = {
				has_character_flag = demon_child_non_pagan_got_nanny
				age >= 6

				NOT = { has_character_flag = demon_child_non_pagan_nanny_suicide }

				trigger_if = {
					limit = { ai = yes }
					liege = { ai = no }
				}
			}

			set_character_flag = demon_child_non_pagan_nanny_suicide

			character_event = {
				id = SoA.3075
				days = 1
				random = 4745 # 13 years, i.e. ~70% of occuring before demon child becomes an adult
			}
		}

		# Spawn the Witch Nanny
		if = {
			limit = {
				NOT = { has_character_flag = demon_child_non_pagan_got_nanny }
				prisoner = no
				is_incapable = no
			}

			character_event = { id = SoA.3070 }
		}

		# Try to murder a sibling (ahead in the line of succession) in bed?
		else_if = {
			limit = {
				age >= 3
				is_adult = no
				prisoner = no
				is_incapable = no
				is_ruler = no

				any_sibling = {
					NOT = { trait = bastard }
					is_incapable = no

					OR = {
						is_older_than = ROOT
						ROOT = { trait = bastard }

						trigger_if = {
							limit = { is_female = no }
							is_opposite_sex = ROOT
						}

						trigger_if = {
							limit = { trait = born_in_the_purple }
							ROOT = { NOT = { trait = born_in_the_purple } }
						}
					}
				}
			}

			random_sibling = {
				limit = {
					NOT = { trait = bastard }
					is_incapable = no

					OR = {
						is_older_than = ROOT
						ROOT = { trait = bastard }

						trigger_if = {
							limit = { is_female = no }
							is_opposite_sex = ROOT
						}

						trigger_if = {
							limit = { trait = born_in_the_purple }
							ROOT = { NOT = { trait = born_in_the_purple } }
						}
					}
				}

				save_event_target_as = target_sibling
			}

			random_list = {
				50 = { character_event = { id = SoA.3032 } } # Success
				25 = { character_event = { id = SoA.3033 } } # Failure
				25 = { character_event = { id = SoA.3034 } } # Brain Damage
			}
		}

		# Get some help during a war
		else_if = {
			limit = {
				is_ruler = yes
				war = yes

				OR = {
					is_primary_war_defender = yes
					is_primary_war_attacker = yes
				}

				NOT = { has_character_flag = demon_child_non_pagan_cultists }
				is_at_sea = no
			}

			character_event = { id = SoA.3065 }
		}

		# Trigger the Sunset Invasion?
		else_if = {
			limit = {
				has_dlc = "Sunset Invasion"
				prisoner = no
				is_incapable = no
				war = no

				trigger_if = {
					limit = { is_ruler = yes }
					lower_real_tier_than = DUKE
				}

				NOR = {
					has_global_flag = aztec_explorers
					has_global_flag = aztec_arrival

					has_game_rule = {
						name = aztec_invasion
						value = off
					}
				}

				trigger_if = {
					limit = {
						OR = {
							has_game_rule = {
								name = aztec_invasion
								value = historical
							}
							has_game_rule = {
								name = aztec_invasion
								value = plus
							}
						}

						year >= 1250
					}
				}
				trigger_else_if = {
					limit = {
						has_game_rule = {
							name = aztec_invasion
							value = random
						}
					}

					total_years_played >= 50
				}
				trigger_else = {
					has_game_rule = {
						name = aztec_invasion
						value = delayed_random
					}

					total_years_played >= 50
					year >= 1000
				}

				NOT = {
					any_close_relative = {
						is_parent_of = ROOT
						is_playable = yes
					}
				}

				random < 50 # 50% chance
			}

			character_event = { id = SoA.3080 }
		}

		character_event = {
			id = SoA.3019 # More fun next time!
			days = 400
			random = 400
		}
	}
}

# The Demon child's true nature asserts itself
# Fired from on_adulthood
character_event = {
	id = SoA.3020
	desc = EVTDESC_SOA_3020
	picture = GFX_evt_lunatic
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes # on_adulthood

	trigger = { has_character_flag = demon_child_non_pagan }

	immediate = {
		remove_trait = chaste
		remove_trait = kind
		remove_trait = honest
		remove_trait = content
		remove_trait = charitable
		remove_trait = just
		remove_trait = humble
		remove_trait = quick
		remove_trait = shrewd
		remove_trait = slow
		remove_trait = imbecile
		remove_trait = weak
		remove_trait = frail
		remove_trait = dull
		remove_trait = shy
		remove_trait = trusting
		add_trait = lustful
		add_trait = deceitful
		add_trait = ambitious
		add_trait = cruel
		add_trait = genius
		add_trait = possessed
		add_trait = strong
		change_diplomacy = 5
		change_martial = 5
		change_stewardship = 5
		change_intrigue = 10
		change_learning = 5

		if = {
			limit = {
				OR = {
					trait = naive_appeaser
					trait = underhanded_rogue
					trait = charismatic_negotiator
				}
			}

			clear_education_trait = yes
			add_trait = grey_eminence
		}
		else_if = {
			limit = {
				OR = {
					trait = amateurish_plotter
					trait = flamboyant_schemer
					trait = intricate_webweaver
				}
			}

			clear_education_trait = yes
			add_trait = elusive_shadow
		}
		else_if = {
			limit = {
				OR = {
					trait = indulgent_wastrel
					trait = thrifty_clerk
					trait = fortune_builder
				}
			}

			clear_education_trait = yes
			add_trait = midas_touched
		}
		else_if = {
			limit = {
				OR = {
					trait = misguided_warrior
					trait = tough_soldier
					trait = skilled_tactician
				}
			}

			clear_education_trait = yes
			add_trait = brilliant_strategist
		}
		else_if = {
			limit = {
				OR = {
					trait = detached_priest
					trait = dutiful_cleric
					trait = scholarly_theologian
				}
			}

			clear_education_trait = yes
			add_trait = mastermind_theologian
		}

		if = {
			limit = { has_dlc = "Mystics" }

			trigger_switch = {
				on_trigger = has_character_flag

				demonspawn_will_join_satanists = {
					join_society = the_satanists
					clr_character_flag = demonspawn_will_join_satanists
				}

				demonspawn_will_join_cold_ones = {
					join_society = the_cold_ones
					clr_character_flag = demonspawn_will_join_cold_ones
				}

				demonspawn_will_join_plaguebringers = {
					join_society = the_plaguebringers
					clr_character_flag = demonspawn_will_join_plaguebringers
				}

				demonspawn_will_join_cult_of_kali = {
					join_society = the_cult_of_kali
					clr_character_flag = demonspawn_will_join_cult_of_kali
				}

				demonspawn_will_join_trollcrafters = {
					join_society = the_trollcrafters
					clr_character_flag = demonspawn_will_join_trollcrafters
				}

				demonspawn_will_join_bacchants = {
					join_society = the_bacchants
					clr_character_flag = demonspawn_will_join_bacchants
				}

				demonspawn_will_join_vodouns = {
					join_society = the_vodouns
					clr_character_flag = demonspawn_will_join_vodouns
				}

				# TODO: Needs Plus devil worshiper societies?
			}

			add_society_currency_massive_effect = yes
			set_society_grandmaster = yes

			any_player = {
				limit = {
					same_society_as = ROOT
					NOT = { character = ROOT }
				}

				narrative_event = {
					id = SoA.3090
					days = 3
				}
			}
		}

		add_character_modifier = {
			name = voice_of_satan
			duration = -1
		}

		any_player = {
			limit = {
				is_close_relative = ROOT
				NOT = { character = ROOT }
			}

			narrative_event = { id = SoA.3021 }
		}
	}

	option = {
		name = EVTOPTZ_SOA_3020

		trigger = {
			has_game_rule = {
				name = supernatural_events
				value = unrestricted
			}
		}

		add_character_modifier = {
			name = demon_horns
			duration = -1
		}

		ai_chance = { factor = 80 }
	}

	option = {
		name = EVTOPTA_SOA_3020

		ai_chance = { factor = 20 }
	}
}

narrative_event = {
	id = SoA.3021
	title = EVTTITLE_SOA_3021
	desc = EVTDESC_SOA_3021
	picture = GFX_evt_lunatic
	border = GFX_event_narrative_frame_religion

	is_triggered_only = yes

	option = {
		name = {
			text = EVTOPTA_SOA_3021
			trigger = {
				NOT = { society_member_of = the_satanists }
			}
		}
		name = {
			text = EVTOPTA_SOA_3021_SATANIST
			trigger = { society_member_of = the_satanists }
		}
	}
}

# Demon Child tries to murder sibling in bed - Success
character_event = {
	id = SoA.3032
	desc = EVTDESC_SOA_3032
	picture = GFX_evt_shadow
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA_SOA_3032

		event_target:target_sibling = {
			show_scope_change = no

			character_event = {
				id = SoA.3035
				tooltip = EVTTOOLTIP_SOA_3035
			}
		}
	}
}

# Demon Child tries to murder sibling in bed - Failure
character_event = {
	id = SoA.3033
	desc = EVTDESC_SOA_3032
	picture = GFX_evt_shadow
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA_SOA_3032

		event_target:target_sibling = {
			show_scope_change = no

			character_event = {
				id = SoA.3036
				tooltip = EVTTOOLTIP_SOA_3035
			}
		}
	}
}

# Demon Child tries to murder sibling in bed - Brain Damage
character_event = {
	id = SoA.3034
	desc = EVTDESC_SOA_3032
	picture = GFX_evt_shadow
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA_SOA_3032

		event_target:target_sibling = {
			show_scope_change = no

			character_event = {
				id = SoA.3037
				tooltip = EVTTOOLTIP_SOA_3035
			}
		}
	}
}

# Demon Child murders sibling in bed
character_event = {
	id = SoA.3035
	desc = EVTDESC_SOA_3035
	picture = GFX_evt_shadow
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA_SOA_3035

		death = {
			death_reason = death_murder_unknown
			killer = FROM
		}
	}

	after = {
		any_player = {
			limit = {
				OR = {
					is_liege_or_above_of = ROOT
					is_parent_of = ROOT
				}
			}

			narrative_event = { id = SoA.3039 }
		}
	}
}

# Demon Child fails to murder sibling in bed
character_event = {
	id = SoA.3036
	desc = EVTDESC_SOA_3036
	picture = GFX_evt_shadow
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA_SOA_3036
	}

	after = {
		any_player = {
			limit = {
				OR = {
					is_liege_or_above_of = ROOT
					is_parent_of = ROOT
				}
			}

			narrative_event = { id = SoA.3040 }
		}
	}
}

# Demon Child fails to murder sibling in bed, but causes brain damage
character_event = {
	id = SoA.3037
	desc = EVTDESC_SOA_3037
	picture = GFX_evt_shadow
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA_SOA_3037

		add_trait = incapable
	}

	after = {
		any_player = {
			limit = {
				OR = {
					is_liege_or_above_of = ROOT
					is_parent_of = ROOT
				}
			}

			narrative_event = { id = SoA.3041 }
		}
	}
}

# Notification, murder succeeded
narrative_event = {
	id = SoA.3039
	title = EVTTITLE_SOA_3039
	desc = EVTDESC_SOA_3039
	picture = GFX_evt_death
	border = GFX_event_narrative_frame_religion

	is_triggered_only = yes

	option = {
		name = {
			text = EVTOPTA_SOA_3039
			trigger = {
				NOT = { society_member_of = the_satanists }
			}
		}
		name = {
			text = EVTOPTA_SOA_3039_SATANIST
			trigger = { society_member_of = the_satanists }
		}
	}
}

# Notification, murder failed
narrative_event = {
	id = SoA.3040
	title = EVTTITLE_SOA_3040
	desc = EVTDESC_SOA_3040
	picture = GFX_evt_shadow
	border = GFX_event_narrative_frame_religion

	is_triggered_only = yes

	option = {
		name = {
			text = EVTOPTA_SOA_3040
			trigger = {
				NOT = { society_member_of = the_satanists }
			}
		}
		name = {
			text = EVTOPTA_SOA_3039_SATANIST
			trigger = { society_member_of = the_satanists }
		}
	}
}

# Notification, murder failed, but brain damaged
narrative_event = {
	id = SoA.3041
	title = EVTTITLE_SOA_3041
	desc = EVTDESC_SOA_3041
	picture = GFX_evt_shadow
	border = GFX_event_narrative_frame_religion

	is_triggered_only = yes

	option = {
		name = {
			text = EVTOPTA_SOA_3041
			trigger = {
				NOT = { society_member_of = the_satanists }
			}
		}
		name = {
			text = EVTOPTA_SOA_3039_SATANIST
			trigger = { society_member_of = the_satanists }
		}
	}
}

# Demon Child recovers from maiming
character_event = {
	id = SoA.3050
	desc = EVTDESC_SOA_3050
	picture = GFX_evt_lunatic
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes # on_yearly_pulse, random_events, demon_child_magic

	has_dlc = "Sons of Abraham"

	trigger = {
		is_maimed_trigger = yes

		OR = {
			has_character_modifier = voice_of_satan
			has_character_flag = demon_child_non_pagan
		}
	}

	weight_multiplier = {
		factor = 1

		mult_modifier = {
			factor = 0.05
			NOT = { has_character_flag = demon_child_non_pagan }
		}
	}

	option = {
		name = EVTOPTA_SOA_3050

		if = {
			limit = { trait = maimed }
			remove_trait = maimed
		}

		if = {
			limit = { trait = one_eyed }
			remove_trait = one_eyed
		}

		if = {
			limit = { trait = one_handed }
			remove_trait = one_handed
		}

		if = {
			limit = { trait = one_legged }
			remove_trait = one_legged
		}

		if = {
			limit = { trait = disfigured }
			remove_trait = disfigured
		}

		if = {
			limit = { trait = mangled }
			remove_trait = mangled
		}

		if = {
			limit = { has_character_modifier = phantom_pain }
			remove_character_modifier = phantom_pain
		}
	}
}

# Demon Child recovers from blinding
character_event = {
	id = SoA.3051
	desc = EVTDESC_SOA_3051
	picture = GFX_evt_lunatic
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes # on_yearly_pulse, random_events, demon_child_magic

	has_dlc = "Sons of Abraham"

	trigger = {
		trait = blinded

		OR = {
			has_character_modifier = voice_of_satan
			has_character_flag = demon_child_non_pagan
		}
	}

	weight_multiplier = {
		factor = 1

		mult_modifier = {
			factor = 0.05
			NOT = { has_character_flag = demon_child_non_pagan }
		}
	}

	option = {
		name = EVTOPTA_SOA_3051

		remove_trait = blinded
	}
}

# Demon Child recovers from castration
character_event = {
	id = SoA.3052
	desc = EVTDESC_SOA_3052
	picture = GFX_evt_lunatic
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes # on_yearly_pulse, random_events, demon_child_magic

	has_dlc = "Sons of Abraham"

	trigger = {
		trait = eunuch

		OR = {
			has_character_modifier = voice_of_satan
			has_character_flag = demon_child_non_pagan
		}
	}

	weight_multiplier = {
		factor = 1

		mult_modifier = {
			factor = 0.05
			NOT = { has_character_flag = demon_child_non_pagan }
		}
	}

	option = {
		name = EVTOPTA_SOA_3052

		remove_trait = eunuch
	}
}

# Demon Child recovers from brain damage
character_event = {
	id = SoA.3053
	desc = EVTDESC_SOA_3053
	picture = GFX_evt_lunatic
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes # on_yearly_pulse, random_events, demon_child_magic

	max_age = 75
	has_dlc = "Sons of Abraham"

	trigger = {
		OR = {
			trait = incapable
			trait = infirm
		}

		OR = {
			has_character_modifier = voice_of_satan
			has_character_flag = demon_child_non_pagan
		}
	}

	weight_multiplier = {
		factor = 1

		mult_modifier = {
			factor = 0.05
			NOT = { has_character_flag = demon_child_non_pagan }
		}
	}

	option = {
		name = EVTOPTA_SOA_3053

		if = {
			limit = { trait = incapable }
			remove_trait = incapable
		}

		if = {
			limit = { trait = infirm }
			remove_trait = infirm
		}
	}
}

# Demon Child recovers from epidemic
character_event = {
	id = SoA.3054
	desc = EVTDESC_SOA_3054
	picture = GFX_evt_lunatic
	border = GFX_event_normal_frame_religion

	is_sick = yes
	has_dlc = "Sons of Abraham"

	trigger = {
		has_epidemic = yes

		OR = {
			has_character_modifier = voice_of_satan
			has_character_flag = demon_child_non_pagan
		}
	}

	mean_time_to_happen = {
		months = 1

		mult_modifier = {
			factor = 12
			NOT = { has_character_flag = demon_child_non_pagan }
		}
	}

	option = {
		name = EVTOPTA_SOA_3054

		if = {
			limit = { trait = bubonic_plague }

			remove_trait = bubonic_plague
			set_character_flag = achievement_i_got_better
		}

		cure_illness = yes
		clear_disease_level_effect = yes
	}
}

# Demon Child escapes from prison
character_event = {
	id = SoA.3060
	desc = EVTDESC_SOA_3060
	picture = GFX_evt_courier
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes # on_yearly_pulse, random_events, demon_child_magic

	prisoner = yes
	has_dlc = "Sons of Abraham"

	trigger = {
		OR = {
			has_character_modifier = voice_of_satan
			has_character_flag = demon_child_non_pagan
		}
	}

	weight_multiplier = {
		factor = 1

		mult_modifier = {
			factor = 0.05
			NOT = { has_character_flag = demon_child_non_pagan }
		}
	}

	option = {
		name = EVTOPTA_SOA_3060

		host = {
			character_event = { id = SoA.3061 }
		}

		imprison = no
	}
}

# Demon Child escapes from prison
character_event = {
	id = SoA.3061
	desc = EVTDESC_SOA_3061
	picture = GFX_evt_courier
	border = GFX_event_normal_frame_intrigue

	is_triggered_only = yes

	ai = no

	option = {
		name = EVTOPTA_SOA_3061
	}
}

# Demon Child receives troop reinforcements
character_event = {
	id = SoA.3065
	desc = EVTDESC_SOA_3065
	picture = GFX_evt_burning_house
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	hide_new = yes
	hide_from = yes

	immediate = {
		set_character_flag = demon_child_non_pagan_cultists

		while = {
			count = 3

			spawn_unit = {
				province = location
				home = location
				owner = ROOT
				attrition = 0.0

				troops = {
					archers = { 150 150 }
					knights = { 100 100 }
					heavy_infantry = { 250 250 }
				}
			}
		}

		create_character = {
			dynasty = none
			religion = hellenic_pagan
			culture = greek
			female = yes
			name = "Circe"
			age = 25
			dna = bdlhexmbcai
			add_trait = ambitious
			add_trait = cruel
			add_trait = envious
			add_trait = cynical
			add_trait = deceitful
			add_trait = attractive
			add_trait = mystic
			add_trait = brilliant_strategist
			add_trait = flanker

			attributes = {
				intrigue = 12
				martial = 7
				diplomacy = 10
				stewardship = 4
				learning = 10
			}
		}

		new_character = {
			save_event_target_as = first_witch

			add_character_modifier = {
				name = known_witch
				duration = -1
			}

			if = {
				limit = { has_dlc = "Mystics" }

				religion = ROOT
				join_society = the_satanists
			}

			opinion = {
				name = opinion_the_chosen_one
				who = ROOT
			}

			set_character_flag = special_marshal
			set_character_flag = special_treasurer
			set_character_flag = special_chancellor
			set_character_flag = special_spiritual
			set_character_flag = special_spymaster
		}

		create_character = {
			dynasty = none
			religion = zun_pagan
			culture = levantine_arabic
			female = yes
			name = "Jezebel"
			age = 24
			dna = dhmfgmabaaz
			add_trait = ambitious
			add_trait = cruel
			add_trait = envious
			add_trait = lustful
			add_trait = deceitful
			add_trait = attractive
			add_trait = hedonist
			add_trait = grey_eminence
			add_trait = inspiring_leader

			attributes = {
				intrigue = 9
				martial = 7
				diplomacy = 12
				stewardship = 3
				learning = 8
			}
		}

		new_character = {
			save_event_target_as = second_witch

			add_character_modifier = {
				name = known_witch
				duration = -1
			}

			if = {
				limit = { has_dlc = "Mystics" }

				religion = ROOT
				join_society = the_satanists
			}

			opinion = {
				name = opinion_the_chosen_one
				who = ROOT
			}

			set_character_flag = special_marshal
			set_character_flag = special_treasurer
			set_character_flag = special_chancellor
			set_character_flag = special_spiritual
			set_character_flag = special_spymaster
		}

		create_character = {
			dynasty = none
			religion = norse_pagan
			culture = welsh
			female = yes
			name = "Morgana"
			age = 27
			dna = aefccojcgbd
			add_trait = ambitious
			add_trait = cruel
			add_trait = lustful
			add_trait = envious
			add_trait = genius
			add_trait = deceitful
			add_trait = attractive
			add_trait = mystic
			add_trait = elusive_shadow
			add_trait = defensive_leader

			attributes = {
				intrigue = 15
				martial = 7
				diplomacy = 10
				stewardship = 8
				learning = 12
			}
		}

		new_character = {
			save_event_target_as = third_witch

			add_character_modifier = {
				name = known_witch
				duration = -1
			}

			if = {
				limit = { has_dlc = "Mystics" }

				religion = ROOT
				join_society = the_satanists
			}

			opinion = {
				name = opinion_the_chosen_one
				who = ROOT
			}

			set_character_flag = special_marshal
			set_character_flag = special_treasurer
			set_character_flag = special_chancellor
			set_character_flag = special_spiritual
			set_character_flag = special_spymaster
		}
	}

	option = {
		name = EVTOPTA_SOA_3065

		show_portrait = event_target:first_witch
		show_portrait = event_target:second_witch
		show_portrait = event_target:third_witch
	}
}

# A witch nanny arrives at court
character_event = {
	id = SoA.3070

	is_triggered_only = yes
	hide_window = yes

	immediate = {
		set_character_flag = demon_child_non_pagan_got_nanny

		if = {
			limit = { is_ruler = yes }
			character_event = { id = SoA.3072 }
		}
		else = {
			host = {
				character_event = { id = SoA.3071 }
			}
		}
	}
}

# A witch nanny arrives at court
character_event = {
	id = SoA.3071
	desc = EVTDESC_SOA_3071
	picture = GFX_evt_princess_byzantine
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	hide_new = yes

	immediate = {
		create_character = {
			dynasty = none
			religion = ROOT
			culture = french
			female = yes
			age = 20
			dna = dkkdfdgibbe
			add_trait = cruel
			add_trait = envious
			add_trait = quick
			add_trait = diligent
			add_trait = patient
			add_trait = scholar
			add_trait = mastermind_theologian

			attributes = {
				intrigue = 10
				martial = 4
				diplomacy = 5
				stewardship = 6
				learning = 10
			}
		}

		new_character = {
			save_global_event_target_as = demon_child_non_pagan_nanny
			set_character_flag = special_treasurer
			set_character_flag = special_chancellor
			set_character_flag = special_spymaster
			set_character_flag = witch_nanny

			add_character_modifier = {
				name = suspected_witch
				duration = -1
			}

			if = {
				limit = { has_dlc = "Mystics" }
				join_society = the_satanists
			}

			add_ascetic_trait_effect = yes

			opinion = {
				name = opinion_the_chosen_one
				who = event_target:demon_child_non_pagan
			}
		}
	}

	option = {
		name = EVTOPTA_SOA_3071
	}
}

# A witch nanny arrives at court
character_event = {
	id = SoA.3072
	desc = EVTDESC_SOA_3072
	picture = GFX_evt_princess_byzantine
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	hide_new = yes

	immediate = {
		create_character = {
			dynasty = none
			religion = ROOT
			culture = french
			female = yes
			age = 20
			dna = dkkdfdgibbe
			add_trait = cruel
			add_trait = envious
			add_trait = quick
			add_trait = diligent
			add_trait = patient
			add_trait = scholar
			add_trait = mastermind_theologian

			attributes = {
				intrigue = 10
				martial = 4
				diplomacy = 5
				stewardship = 6
				learning = 10
			}
		}

		new_character = {
			save_global_event_target_as = demon_child_non_pagan_nanny
			set_character_flag = special_treasurer
			set_character_flag = special_chancellor
			set_character_flag = special_spymaster
			set_character_flag = witch_nanny

			add_character_modifier = {
				name = suspected_witch
				duration = -1
			}

			if = {
				limit = { has_dlc = "Mystics" }
				join_society = the_satanists
			}

			add_ascetic_trait_effect = yes

			opinion = {
				name = opinion_the_chosen_one
				who = event_target:demon_child_non_pagan
			}
		}
	}

	option = {
		name = EVTOPTA_SOA_3072
	}
}

# Witch nanny moves with her charge

# Witch nanny moves with her charge - Demon child
character_event = {
	id = SoA.3079

	is_triggered_only = yes # on_employer_change
	hide_window = yes

	has_dlc = "Sons of Abraham"
	has_character_flag = demon_child_non_pagan_got_nanny
	prisoner = no

	trigger = {
		has_character_flag = demon_child_non_pagan

		event_target:demon_child_non_pagan_nanny = {
			same_realm = ROOT
			is_ruler = no
			is_consort = no
			is_married = no
			is_incapable = no
			prisoner = no

			NOR = {
				religion_group = pagan_group

				trigger_if = {
					limit = {
						ROOT = { is_ruler = yes }
					}

					vassal_of = ROOT
				}
				trigger_else = {
					same_liege = ROOT
				}
			}
		}
	}

	immediate = {
		if = {
			limit = { is_ruler = yes }

			event_target:demon_child_non_pagan_nanny = {
				move_character = ROOT
			}
		}
		else = {
			liege = {
				event_target:demon_child_non_pagan_nanny = {
					move_character = PREV
				}
			}
		}

		event_target:demon_child_non_pagan_nanny = {
			liege = {
				character_event = { id = SoA.3074 }
			}
		}
	}
}

character_event = {
	id = SoA.3073

	is_triggered_only = yes # on_employer_change
	hide_window = yes

	has_character_flag = witch_nanny
	has_dlc = "Sons of Abraham"
	is_married = no
	only_capable = yes
	prisoner = no

	trigger = {
		is_ruler = no
		is_consort = no
		NOT = { religion_group = pagan_group }

		event_target:demon_child_non_pagan = {
			same_realm = ROOT
			prisoner = no
			has_character_flag = demon_child_non_pagan

			NOT = {
				trigger_if = {
					limit = { is_ruler = yes }
					is_liege_of = ROOT
				}
				trigger_else = {
					same_liege = ROOT
				}
			}
		}
	}

	immediate = {
		liege = {
			character_event = { id = SoA.3074 }
		}

		event_target:demon_child_non_pagan = {
			if = {
				limit = { is_ruler = yes }

				ROOT = {
					move_character = PREV
				}
			}
			else = {
				liege = {
					ROOT = {
						move_character = PREV
					}
				}
			}
		}
	}
}

# A witch nanny moves with her charge
character_event = {
	id = SoA.3074
	desc = EVTDESC_SOA_3074
	picture = GFX_evt_princess_byzantine
	border = GFX_event_normal_frame_religion
	portrait = event_target:demon_child_non_pagan_nanny

	is_triggered_only = yes

	ai = no

	option = {
		name = EVTOPTA_SOA_3074
	}
}

# Witch nanny commits suicide for the demon child
character_event = {
	id = SoA.3075

	is_triggered_only = yes
	hide_window = yes

	has_character_flag = demon_child_non_pagan_got_nanny
	max_age = 15
	prisoner = no

	trigger = {
		has_character_flag = demon_child_non_pagan

		trigger_if = {
			limit = { ai = yes }
			liege = { ai = no }
		}

		OR = {
			ai = no

			liege = {
				ai = no
			}
		}

		event_target:demon_child_non_pagan_nanny = {
			at_location = ROOT
			prisoner = no
			is_incapable = no
		}
	}

	fail_trigger_effect = {
		if = {
			limit = {
				is_adult = no
				has_character_flag = demon_child_non_pagan_got_nanny
				has_character_flag = demon_child_non_pagan
				event_target:demon_child_non_pagan_nanny = { is_alive = yes }
			}

			repeat_event = {
				id = SoA.3075
				months = 3
			}
		}
	}

	immediate = {
		event_target:demon_child_non_pagan_nanny = {
			liege = {
				if = {
					limit = { has_character_flag = demon_child_non_pagan }
					narrative_event = { id = SoA.3078 }
				}
				else = {
					narrative_event = { id = SoA.3077 }
				}
			}

			death = { death_reason = death_suicide_fall }
		}
	}
}

# Witch nanny commits suicide for the demon child
narrative_event = {
	id = SoA.3077
	title = EVTTITLE_SOA_3077
	desc = EVTDESC_SOA_3077
	picture = GFX_evt_family
	border = GFX_event_narrative_frame_religion

	is_triggered_only = yes

	option = {
		name = {
			text = EVTOPTA_SOA_3077
			trigger = {
				NOT = { society_member_of = the_satanists }
			}
		}
		name = {
			text = EVTOPTA_SOA_3078
			trigger = { society_member_of = the_satanists }
		}

		clear_global_event_target = demon_child_non_pagan_nanny
	}
}

# Witch nanny commits suicide for the demon child
narrative_event = {
	id = SoA.3078
	title = EVTTITLE_SOA_3078
	desc = EVTDESC_SOA_3078
	picture = GFX_evt_family
	border = GFX_event_narrative_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA_SOA_3078

		clear_global_event_target = demon_child_non_pagan_nanny
	}
}

# The Demon Child travels to the New World and returns as the Aztec Emperor (somewhat altered descriptions in the Sunset Invasion)
character_event = {
	id = SoA.3080

	is_triggered_only = yes
	hide_window = yes

	immediate = {
		set_global_flag = demon_child_to_aztecs

		any_player = {
			limit = {
				NOT = { character = ROOT }
			}

			if = {
				limit = {
					OR = {
						is_close_relative = ROOT
						dynasty = ROOT
					}
				}

				narrative_event = {
					id = SoA.3083
					days = 3
				}
			}
			else_if = {
				limit = { society_member_of = the_satanists }

				narrative_event = {
					id = SoA.3082
					days = 3
				}
			}
		}

		if = {
			limit = { is_ruler = yes }
			abdicate = yes
		}

		activate_title = {
			title = e_aztec_empire
			status = yes
		}

		culture = nahua
		religion = aztec_pagan

		e_aztec_empire = {
			grant_title = ROOT
		}

		set_government_type = feudal_government

		e_aztec_empire = {
			set_title_flag = non_manual_law_change # No prestige loss
			add_law = succ_primogeniture
			add_law = agnatic_succession

			if = {
				limit = { has_dlc = "Zeus" }
				add_law = revoke_title_law_2
			}
			else = {
				add_law = crown_authority_1
			}

			clr_title_flag = non_manual_law_change # No prestige loss
		}

		random_province = {
			limit = {
				OR = {
					province_id = c_vestisland
					province_id = c_west_connacht
					province_id = c_innse_gall
					province_id = c_cornwall
					province_id = c_cornouaille
					province_id = c_bordeaux
					province_id = c_coruna
					province_id = c_silves
					province_id = c_tangier
					province_id = c_safi
				}
			}

			save_event_target_as = target_province

			province_event = {
				id = SoA.3081
				days = 200
			}
		}
	}
}

# First Landing - Heralds of the Demon-led Aztecs
province_event = {
	id = SoA.3081
	desc = EVTDESC_SOA_3081
	picture = GFX_evt_aztec_explorers
	border = GFX_event_normal_frame_war

	is_triggered_only = yes

	trigger = {
		FROM = { is_alive = yes }
	}

	immediate = {
		log = "AZTEC INVASION IMMEDIATE SoA.3081"
		set_global_flag = aztec_explorers
		set_province_flag = aztec_explorers
		save_global_event_target_as = first_aztec_invasion_target

		FROM = {
			narrative_event = {
				id = SSI.2
				days = 7
			}
		}
	}

	option = {
		name = EVTOPTA_SSI_001
	}
}

# Satanists are notified about the departure of the Demon Child
narrative_event = {
	id = SoA.3082
	title = EVTTITLE_SOA_3082
	desc = EVTDESC_SOA_3082
	picture = GFX_evt_throne_room_mesoamerican
	border = GFX_event_narrative_frame_war

	is_triggered_only = yes

	trigger = {
		FROM = { is_alive = yes }
	}

	option = {
		name = {
			text = EVTOPTA_SOA_3082_MUSLIM
			trigger = { religion_group = muslim }
		}
		name = {
			text = EVTOPTA_SOA_3082
			trigger = {
				NOT = { religion_group = muslim }
			}
		}
	}
}

# Relatives are notified about the departure of the Demon Child
narrative_event = {
	id = SoA.3083
	title = EVTTITLE_SOA_3083
	desc = EVTDESC_SOA_3083
	picture = GFX_evt_throne_room_mesoamerican
	border = GFX_event_narrative_frame_war

	is_triggered_only = yes

	trigger = {
		FROM = { is_alive = yes }
	}

	option = {
		name = {
			text = EVTOPTA_SOA_3082
			trigger = { society_member_of = the_satanists }
		}
		name = {
			text = EVTOPTA_SOA_3083
			trigger = {
				NOT = { society_member_of = the_satanists }
			}
		}
	}
}

# Satanists are notified of the coming of age of the Demon Child
narrative_event = {
	id = SoA.3090
	title = EVTTITLE_SOA_3090
	desc = EVTDESC_SOA_3090
	picture = GFX_evt_shadowy_cabal
	border = GFX_event_narrative_frame_war

	is_triggered_only = yes

	trigger = {
		FROM = { is_alive = yes }
	}

	option = {
		name = {
			text = EVTOPTA_SOA_3082_MUSLIM
			trigger = {
				religion_group = muslim
				NOT = { is_parent_of = FROM }
			}
		}
		name = {
			text = EVTOPTA_SOA_3082
			trigger = {
				NOR = {
					religion_group = muslim
					is_parent_of = ROOT
				}
			}
		}
		name = {
			text = EVTOPTA_SOA_3090_CHILD
			trigger = { is_parent_of = FROM }
		}
	}
}

# Satanists are notified of the death of the Demon Child
# Fired from 'on_death'
character_event = {
	id = SoA.3091

	is_triggered_only = yes # on_death
	hide_window = yes

	trigger = {
		has_character_flag = demon_child_non_pagan
	}

	immediate = {
		if = {
			limit = { society_member_of = the_satanists }

			any_player = {
				limit = {
					same_society_as = ROOT
					NOT = { character = ROOT }
				}

				narrative_event = { id = SoA.3092 }
			}
		}
	}

	after = {
		clear_global_event_target = demon_child_non_pagan
		clear_global_event_target = demon_child_non_pagan_nanny
	}
}

narrative_event = {
	id = SoA.3092
	title = EVTTITLE_SOA_3092
	desc = EVTDESC_SOA_3092
	picture = GFX_evt_death
	border = GFX_event_narrative_frame_intrigue

	is_triggered_only = yes

	ai = no

	option = {
		name = EVTOPTA_SOA_3092
	}
}