##################################################################
#
# ANCIENT RELIGIONS
# - Celtic changelings
#
# Event IDs celtic.211-0241 is reserved
#
##################################################################

namespace = celtic

### Druidic warnings

# Druid Warns About Child (AI Spouse)
character_event = {
	id = celtic.211
	hide_window = yes

	only_women = yes
	min_age = 16
	prisoner = no
	has_dlc = "The Old Gods"

	trigger = {
		is_pregnant = yes
		spouse = {
			supernatural_events_trigger = yes
			any_courtier = {
				is_celtic_clergy_in_good_standing_trigger = yes
			}
		}
		NOT = { has_character_flag = child_stolen_sidhe }
	}

	mean_time_to_happen = {
		months = 550

		modifier = { # way more likely if the mother is a wicked dryad
			factor = 0.5
			is_celtic_clergy_in_bad_standing_trigger = yes
		}
		
		modifier = { # Unseelie Mother
			factor = 0.75
			society_member_of = unseelie_petitioners
		}
		
		modifier = { # Unseelie Father
			factor = 0.75
			spouse = { society_member_of = unseelie_petitioners }
		}
	}

	immediate = {
		set_character_flag = child_stolen_sidhe
		spouse = {
			random_courtier = {
				limit = { is_celtic_clergy_in_good_standing_trigger = yes }
				character_event = { id = celtic.212 }
			}
		}
	}
}

# Druid/Dryad Warns About Child (AI Druid)
character_event = {
	id = celtic.212
	hide_window = yes

	is_triggered_only = yes

	immediate = {
		liege = {
			character_event = { id = celtic.213 }
		}
	}
}

# Druid Warns About Child
character_event = {
	id = celtic.213
	desc = celtic.213.desc
	picture = GFX_evt_pregnancy
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = celtic.213.a
		FROM = {
			opinion = {
				modifier = opinion_disappointed
				years = 1
				who = ROOT
			}
		}
	}
	option = {
		name = celtic.213.b
		FROMFROM = {
			opinion = {
				modifier = opinion_disappointed
				years = 1
				who = ROOT
			}
		}
	}
}

### Changeling events

# Child is stolen by Sidhe
character_event = {
	id = celtic.215
	hide_window = yes

	is_triggered_only = yes

	has_dlc = "The Old Gods"

	trigger = {
		mother = { has_character_flag = child_stolen_sidhe }
	}

	immediate = {
		random_list = {
			50 = {
				mult_modifier = {
					factor = 3
					OR = {
						mother = { society_member_of = unseelie_petitioners }
						father = { society_member_of = unseelie_petitioners }
					}
				}
				set_character_flag = changeling_child
			}
			50 = {
				mult_modifier = {
					factor = 0
					mother = { society_member_of = unseelie_petitioners }
					father = { society_member_of = unseelie_petitioners }
				}
				set_character_flag = changeling_child_fake
			}
		}
		mother = { clr_character_flag = child_stolen_sidhe }
	}
}

# Child acts strange I (AI)
character_event = {
	id = celtic.216
	hide_window = yes

	ai = yes
	has_dlc = "The Old Gods"
	min_age = 4
	max_age = 15
	has_character_flag = changeling_child

	trigger = {
		NOT = { has_character_flag = changeling_child_strange_1 }
		father = { is_alive = yes }
	}

	mean_time_to_happen = {
		months = 220
	}

	immediate = {
		set_character_flag = changeling_child_strange_1
		father = { character_event = { id = celtic.217 } }
	}
}

# Child acts strange I
character_event = {
	id = celtic.217
	desc = celtic.217.desc
	picture = GFX_evt_child_play
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = celtic.217.a
		custom_tooltip = { text = changeling_child_acts_strange }
	}
}

# Child acts strange II (AI)
character_event = {
	id = celtic.218
	hide_window = yes

	ai = yes
	has_dlc = "The Old Gods"
	min_age = 4
	max_age = 15
	has_character_flag = changeling_child

	trigger = {
		NOT = { has_character_flag = changeling_child_strange_2 }
		father = { is_alive = yes }
	}

	mean_time_to_happen = {
		months = 220
	}

	immediate = {
		set_character_flag = changeling_child_strange_2
		father = { character_event = { id = celtic.219 } }
	}
}

# Child acts strange II
character_event = {
	id = celtic.219
	desc = celtic.219.desc
	picture = GFX_evt_child_play
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = celtic.219.a
		custom_tooltip = { text = changeling_child_acts_strange }
	}
}

# Child acts strange III (AI)
character_event = {
	id = celtic.220
	hide_window = yes

	ai = yes
	has_dlc = "The Old Gods"
	min_age = 4
	max_age = 15
	has_character_flag = changeling_child

	trigger = {
		NOT = { has_character_flag = changeling_child_strange_3 }
		father = { is_alive = yes }
	}

	mean_time_to_happen = {
		months = 220
	}

	immediate = {
		set_character_flag = changeling_child_strange_3
		father = { character_event = { id = celtic.221 } }
	}
}

# Child acts strange III
character_event = {
	id = celtic.221
	desc = celtic.221.desc
	picture = GFX_evt_child_play
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = celtic.221.a
		custom_tooltip = { text = changeling_child_acts_strange }
	}
}

# Child kills Courtier I (AI Child)
character_event = {
	id = celtic.222
	hide_window = yes

	ai = yes
	has_dlc = "The Old Gods"
	min_age = 4
	max_age = 15
	has_character_flag = changeling_child

	trigger = {
		NOT = { has_character_flag = changeling_child_kills_1 }
		father = { is_alive = yes }
		OR = {
			has_character_flag = changeling_child_strange_1
			has_character_flag = changeling_child_strange_2
			has_character_flag = changeling_child_strange_3
		}
		father = {
			any_courtier = {
				NOT = {
					character = ROOT
					is_close_relative = ROOT
				}
				host = {
					character = liege
					prisoner = no
				}
				ai = yes
				is_primary_heir = no
				is_pretender = no
				prisoner = no
				age = 13
				in_command = no
				NOT = { spouse = { character = host } }
			}
		}
	}

	mean_time_to_happen = {
		months = 320
	}

	immediate = {
		set_character_flag = changeling_child_kills_1
		father = {
			random_courtier = {
				limit = {
					NOT = {
						character = ROOT
						is_close_relative = ROOT
					}
					host = {
						character = liege
						prisoner = no
					}
					ai = yes
					is_primary_heir = no
					is_pretender = no
					prisoner = no
					age = 13
					in_command = no
					NOT = { spouse = { character = host } }
				}
				character_event = { id = celtic.223 }
			}
		}
	}
}

# Child kills Courtier I (AI Courtier)
character_event = {
	id = celtic.223
	hide_window = yes

	is_triggered_only = yes

	immediate = {
		liege = { character_event = { id = celtic.224 } }
	}
}

#Child kills Courtier I
character_event = {
	id = celtic.224
	desc = celtic.224.desc
	picture = GFX_evt_viking_funeral_oldgods
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = celtic.224.a
		FROM = {
			death = {
				death_reason = death_murder_unknown
			}
		}
	}
}

# Child kills Courtier II (AI Child)
character_event = {
	id = celtic.225
	hide_window = yes

	ai = yes
	has_dlc = "The Old Gods"
	min_age = 4
	max_age = 15
	has_character_flag = changeling_child

	trigger = {
		NOT = { has_character_flag = changeling_child_kills_2 }
		father = { is_alive = yes }
		OR = {
			has_character_flag = changeling_child_strange_1
			has_character_flag = changeling_child_strange_2
			has_character_flag = changeling_child_strange_3
		}
		father = {
			any_courtier = {
				NOT = {
					character = ROOT
					is_close_relative = ROOT
				}
				host = {
					character = liege
					prisoner = no
				}
				ai = yes
				is_primary_heir = no
				is_pretender = no
				prisoner = no
				age = 13
				in_command = no
				NOT = { spouse = { character = host } }
			}
		}
	}

	mean_time_to_happen = {
		months = 320
	}

	immediate = {
		set_character_flag = changeling_child_kills_2
		father = {
			random_courtier = {
				limit = {
					NOT = {
						character = ROOT
						is_close_relative = ROOT
					}
					host = {
						character = liege
						prisoner = no
					}
					ai = yes
					is_primary_heir = no
					is_pretender = no
					prisoner = no
					age = 13
					in_command = no
					NOT = { spouse = { character = host } }
				}
				character_event = { id = celtic.226 }
			}
		}
	}
}

# Child kills Courtier II (AI Courtier)
character_event = {
	id = celtic.226
	hide_window = yes

	is_triggered_only = yes

	immediate = {
		liege = { character_event = { id = celtic.227 } }
	}
}

#Child kills Courtier II
character_event = {
	id = celtic.227
	desc = celtic.227.desc
	picture = GFX_evt_viking_funeral_oldgods
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = celtic.227.a
		FROM = {
			death = {
				death_reason = death_murder_unknown
			}
		}
	}
}

# Child kills Courtier III (AI Child)
character_event = {
	id = celtic.228
	hide_window = yes

	ai = yes
	has_dlc = "The Old Gods"
	min_age = 4
	max_age = 15
	has_character_flag = changeling_child

	trigger = {
		NOT = { has_character_flag = changeling_child_kills_3 }
		father = { is_alive = yes }
		OR = {
			has_character_flag = changeling_child_strange_1
			has_character_flag = changeling_child_strange_2
			has_character_flag = changeling_child_strange_3
		}
		father = {
			any_courtier = {
				NOT = {
					character = ROOT
					is_close_relative = ROOT
				}
				host = {
					character = liege
					prisoner = no
				}
				ai = yes
				is_primary_heir = no
				is_pretender = no
				prisoner = no
				age = 13
				in_command = no
				NOT = { spouse = { character = host } }
			}
		}
	}

	mean_time_to_happen = {
		months = 320
	}

	immediate = {
		set_character_flag = changeling_child_kills_3
		father = {
			random_courtier = {
				limit = {
					NOT = {
						character = ROOT
						is_close_relative = ROOT
					}
					host = {
						character = liege
						prisoner = no
					}
					ai = yes
					is_primary_heir = no
					is_pretender = no
					prisoner = no
					age = 13
					in_command = no
					NOT = { spouse = { character = host } }
				}
				character_event = { id = celtic.229 }
			}
		}
	}
}

# Child kills Courtier III (AI Courtier)
character_event = {
	id = celtic.229
	hide_window = yes

	is_triggered_only = yes

	immediate = {
		liege = { character_event = { id = celtic.230 } }
	}
}

#Child kills Courtier III
character_event = {
	id = celtic.230
	desc = celtic.230.desc
	picture = GFX_evt_viking_funeral_oldgods
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = celtic.230.a
		FROM = {
			death = {
				death_reason = death_murder_unknown
			}
		}
	}
}

# Druid offers to save child (AI Child)
character_event = {
	id = celtic.231
	hide_window = yes

	ai = yes
	has_dlc = "The Old Gods"
	min_age = 4
	max_age = 15

	trigger = {
		NOT = { has_character_flag = changeling_trade }
		father = { is_alive = yes }
		OR = {
			has_character_flag = changeling_child
			has_character_flag = changeling_child_fake
		}
		father = {
			any_courtier = {
				is_celtic_clergy_in_good_standing_trigger = yes
			}
		}
	}

	mean_time_to_happen = {
		months = 680
	}

	immediate = {
		set_character_flag = changeling_trade
		father = {
			random_courtier = {
				limit = { is_celtic_clergy_in_good_standing_trigger = yes }
				character_event = { id = celtic.232 }
			}
		}
	}
}

# Druid offers to save child (AI Druid)
character_event = {
	id = celtic.232
	hide_window = yes

	is_triggered_only = yes

	immediate = {
		liege = {
			character_event = { id = celtic.233 }
		}
	}
}

# Druid offers to save child
character_event = {
	id = celtic.233
	desc = celtic.233.desc
	picture = GFX_evt_viking_throneroom_oldgods
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = celtic.233.a
		hidden_tooltip = {
			character_event = { id = celtic.234 days = 7 }
		}
		custom_tooltip = { text = changeling_trade_approved }
	}
	option = {
		name = celtic.233.b
		FROM = {
			opinion = {
				modifier = opinion_very_disappointed
				years = 2
				who = ROOT
			}
		}
		custom_tooltip = { text = changeling_trade_denied }
	}
}

# Changeling Trade Begins
character_event = {
	id = celtic.234
	desc = celtic.234.desc
	picture = GFX_evt_pagan
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	hide_from = yes

	option = {
		name = celtic.234.a

		custom_tooltip = {
			text = changeling_trade_begins
			hidden_tooltip = {
				random_child = {
					limit = { has_character_flag = changeling_trade }
					character_event = { id = celtic.235 days = 3 }
				}
			}
		}
	}
}

# Changeling Trade Begins (AI Child)
character_event = {
	id = celtic.235
	hide_window = yes

	is_triggered_only = yes

	immediate = {
		father = {
			random_courtier = {
				limit = { is_celtic_clergy_in_good_standing_trigger = yes }
				character_event = { id = celtic.236 }
			}
		}
	}
}

# Changeling Trade Begins (AI Druid)
character_event = {
	id = celtic.236
	hide_window = yes

	is_triggered_only = yes

	immediate = {
		liege = {
			random_list = {
				20 = { character_event = { id = celtic.237 days = 3 } }
				20 = { character_event = { id = celtic.238 days = 3 } }
				40 = { character_event = { id = celtic.239 days = 3 } }
				20 = { character_event = { id = celtic.240 days = 3 } }
			}
		}
	}
}

# Changeling Trade Completed - Druid Dies
character_event = {
	id = celtic.237
	desc = celtic.237.desc
	picture = GFX_evt_child_play
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = celtic.237.a
		FROM = {
			death = {
				death_reason = death_murder_unknown
			}
		}
		FROMFROM = { # Flags removed, no more events
			clr_character_flag = changeling_trade
		}
	}
}

# Changeling Trade Completed - Child Dies
character_event = {
	id = celtic.238
	desc = celtic.238.desc
	picture = GFX_evt_viking_funeral_oldgods
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = celtic.238.a
		FROMFROM = {
			death = {
				death_reason = death_sacrificed
			}
		}
		FROM = {
			death = {
				death_reason = death_execution
				killer = ROOT
			}
		}
	}
	option = {
		name = celtic.238.b
		FROMFROM = {
			death = {
				death_reason = death_sacrificed
			}
		}
		FROM = {
			banish = yes
		}
	}
	option = {
		name = celtic.238.c
		FROMFROM = {
			death = {
				death_reason = death_sacrificed
			}
		}
	}
}

# Changeling Trade Completed - Child is Unharmed
character_event = {
	id = celtic.239
	desc = celtic.239.desc
	picture = GFX_evt_pagan
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = celtic.239.a
		FROMFROM = {
			clr_character_flag = changeling_child
			clr_character_flag = changeling_child_fake
			clr_character_flag = changeling_trade
			remove_trait = possessed
		}
	}
}

# Changeling Trade Completed - Child is Hurt
character_event = {
	id = celtic.240
	desc = celtic.240.desc
	picture = GFX_evt_pagan
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = celtic.238.b
		FROMFROM = {
			clr_character_flag = changeling_child
			clr_character_flag = changeling_child_fake
			clr_character_flag = changeling_trade
			remove_trait = possessed
		}
		FROM = {
			banish = yes
		}
	}
	option = {
		name = celtic.238.c
		FROMFROM = {
			clr_character_flag = changeling_child
			clr_character_flag = changeling_child_fake
			clr_character_flag = changeling_trade
			remove_trait = possessed
		}
	}
}

#[on_adulthood] Changeling child becomes and adult (Trait makes character more keen to go on adventures and harder to kill)
character_event = {
	id = celtic.241
	desc = celtic.241.desc
	picture = GFX_evt_the_changeling_fuseli
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	has_character_flag = changeling_child

	immediate = {
		clr_character_flag = changeling_child
		clr_character_flag = changeling_child_fake
		clr_character_flag = changeling_trade
	}

	option = {
		name = celtic.241.a
		add_trait = changeling
		hidden_tooltip = {
			random_list = {
				50 = {    # Born from Fomorian
					remove_trait = chaste
					remove_trait = kind
					remove_trait = honest
					remove_trait = content
					remove_trait = charitable
					remove_trait = just
					remove_trait = humble
					remove_trait = slow
					remove_trait = dull
					remove_trait = imbecile
					remove_trait = weak
					remove_trait = frail
					remove_trait = shy
					remove_trait = trusting
					add_trait = lustful
					add_trait = envious
					add_trait = deceitful
					add_trait = ambitious
					add_trait = cruel
					add_trait = wroth
					add_trait = lunatic
				}
				50 = { 		# Born from Sidhe
					remove_trait = cruel
					remove_trait = wroth
					remove_trait = envious
					remove_trait = content
					remove_trait = slow
					remove_trait = dull
					remove_trait = imbecile
					remove_trait = weak
					remove_trait = frail
					remove_trait = shy
					remove_trait = trusting
					add_trait = kind
					add_trait = patient
					add_trait = lunatic
					add_trait = charitable
					add_trait = lustful
					add_trait = deceitful
				}
			}
		}
	}
}
