﻿namespace = jeanne_event

jeanne_event.0001 = {
	type = character_event

	hidden = yes
	
	trigger = {
		NOT = {
			OR = {
				has_game_rule = full_gender_equality
				has_game_rule = inversed_gender_equality
			}
			faith = {
				OR = {
					has_doctrine = doctrine_gender_female_dominated
					has_doctrine = doctrine_gender_equal
				}
			}
		}
		# current_date >= 1000.1.1
		highest_held_title_tier >= tier_kingdom
		is_ai = no
		is_ruler = yes
		is_independent_ruler = yes
		is_imprisoned = no
		is_adult = yes
		religion = religion:christianity_religion

		is_at_war = yes
		
		NOT = { exists = global_var:jeanne_darc_spawned }
	}

	# Insert time offset

	immediate = {
		set_global_variable = {
			name = jeanne_darc_spawned
			value = yes
		}
		create_character = {
			
			age = 17
			gender = female

			random_traits = no

			trait = education_martial_4
			trait = unyielding_defender
			trait = aggressive_attacker
			trait = zealous
			trait = chaste
			trait = honest
			trait = brave
			trait = celibate
			
			faith = root.faith
			culture = root.culture
			dynasty = none

			employer = root

			diplomacy = {
				min_template_decent_skill
				max_template_decent_skill
			}
			martial = 20
			prowess = {
				min_template_high_skill
				max_template_high_skill
			}
			# historical = yes
			save_scope_as = jeanne_the_maid

			after_creation = {
				add_character_flag = is_jeanne_the_maid
				add_character_flag = special_marshal
				if = {		
					limit = { culture = culture:french }
					change_first_name = Jeanne
					give_nickname = nick_darc
					
				}
				if = {
					limit = { NOT = { culture = culture:french } }
					give_nickname = nick_the_maid
				}
				add_character_modifier = {
					modifier = voice_of_jesus_modifier
				}
				add_character_modifier = {
					modifier = ignores_gender_army_rules
				}
				add_opinion = {
					modifier = loyal_servant
					target = root
					opinion = 50
				}
				trigger_event = jeanne_event.0002
			}
		}
	}
}

# Jeanne event
jeanne_event.0002 = {
	type = character_event
	hidden = yes

	immediate = {
		liege = {
			save_scope_as = jeanne_liege
			add_character_flag = is_jeanne_liege
			if = {
				limit = {
					any_realm_county = {
						this = title:c_orleans
					}
				}
				random_list = {
					85 = {
						title:c_orleans.county = {
							save_scope_as = home_of_jeanne_darc
						}
					}
					15 = {
						random_realm_county = {
							save_scope_as = home_of_jeanne_darc
						}
					}
				}
			}
			else = {
				random_realm_county = {
					save_scope_as = home_of_jeanne_darc
					add_county_modifier = home_of_jeanne_darc_modifier
				}
			}
			trigger_event = { id = jeanne_event.0004 }
			trigger_event = {
				id = jeanne_event.0003
				months = { 3 5 }
			}
		}
	}
}

# Jeanne finds Charles Martel's sword 
jeanne_event.0003 = {
	type = character_event
	title = jeanne_event.0003.t
	desc = jeanne_event.0003.desc
	theme = realm
	left_portrait = {
		character = scope:jeanne_the_maid
		animation = throne_room_one_handed_passive_1
	}
	artifact = {
		target = scope:newly_created_artifact
		position = lower_right_portrait
	}

	trigger = {
		scope:jeanne_the_maid = {
			AND = {
				is_imprisoned = no
				is_alive = yes
			}
		}
	}

	immediate = {
		hidden_effect = {
			scope:jeanne_the_maid = {
				if = {
					limit = { culture = culture:french }
					character:131721 = { save_scope_as = first_owner }
					set_artifact_rarity_famed = yes
					create_artifact = {
						name = jeanne_sword_name
						description = jeanne_sword_french_description
						visuals = sword
						type = sword
						wealth = scope:wealth
						quality = scope:quality
						
						history = {
							type = created
							date = 721.1.1
							recipient = scope:first_owner
							location = province:2274 #Tours
						}
						modifier = artifact_prowess_11_modifier
						decaying = no
						save_scope_as = newly_created_artifact
					}
					scope:newly_created_artifact = {
						add_scaled_artifact_modifier_prowess_effect = yes
						add_scaled_artifact_modifier_piety_effect = yes
						add_artifact_modifier = artifact_knight_effectiveness_10_modifier
						add_artifact_modifier = jeanne_sword_public_opinion
					}
				}
				else = {
					set_artifact_rarity_famed = yes
					random_realm_province = {
						save_scope_as = jeanne_sword_location
					}
					create_artifact = {
						name = jeanne_sword_name
						description = jeanne_sword_description
						visuals = sword
						type = sword
						wealth = scope:wealth
						quality = scope:quality

						history = {
							type = created_before_history
							location = scope:jeanne_sword_location
						}
						
						modifier = artifact_prowess_1_modifier
						decaying = no
						save_scope_as = newly_created_artifact
					}
					scope:newly_created_artifact = {
						add_scaled_artifact_modifier_prowess_effect = yes
						add_scaled_artifact_modifier_piety_effect = yes
						add_artifact_modifier = artifact_knight_effectiveness_10_modifier
						add_artifact_modifier = jeanne_sword_public_opinion
					}
				}
			}
		}
	}
	
	option = {
		name = jeanne_event.0003.a

		scope:newly_created_artifact = {
			set_owner = scope:jeanne_the_maid
			equip_artifact_to_owner = yes
		}
		hidden_effect = {
			trigger_event = {
				id = jeanne_event.0023
				months = { 4 6 }
			}
		}
	}
}

# scope:jeanne_the_maid = {
# 	create_artifact = {
# 		name = jeanne_wall_banner_name
# 		description = jeanne_wall_banner_description
# 		visuals = banner
# 		visuals_source = title:k_jeanne_banner
# 		type = wall_big
# 		modifier = artifact_placeholder_modifier
# 		save_scope_as = newly_created_artifact
# 		wealth = scope:wealth
# 		quality = scope:quality
# 		history = {
# 			type = created
# 			recipient = this
# 			location = this.location
# 		}
# 	}
# }

# Notify monarch of this new servant of the crown
jeanne_event.0004 = {
	type = character_event
	title = jeanne_event.0004.t
	desc = jeanne_event.0004.desc
	theme = realm
	left_portrait = {
		character = scope:jeanne_the_maid
		animation = personality_zealous
	}
	
	trigger = {
		scope:jeanne_the_maid = {
			is_alive = yes
		}
	}

	option = {
		name = jeanne_event.0004.a
		custom_tooltip = jeanne_event.0004.a.tt

		hidden_effect = {
			trigger_event = {
				id = jeanne_event.0005
				months = { 1 2 }
			}
		}
	}
}

# Jeanne d'Arc - Nobles react
jeanne_event.0005 = {
	type = character_event
	title = jeanne_event.0005.t
	desc = jeanne_event.0005.desc
	theme = realm
	left_portrait = {
		character = scope:jeanne_the_maid
		animation = personality_honorable
	}

	trigger = {
		scope:jeanne_the_maid = {
			is_alive = yes
		}
	}

	option = {
		name = jeanne_event.0005.a

		every_vassal_or_below = {
			limit = {
				NOR = {
					has_government = theocracy_government
					has_council_position = councillor_court_chaplain
					has_government = republic_government
				}
				NOR = {
					has_trait = generous
					has_trait = compassionate
					has_trait = content
				}
			}
			add_opinion = {
				target = root #scope:jeanne_liege
				modifier = hate_opinion
				opinion = -15
			}
		}
		hidden_effect = {
			trigger_event = {
				id = jeanne_event.0006
				months = { 1 2 }
			}
		}
		custom_tooltip = jeanne_event.0005.a.tt
		# scope:jeanne_the_maid = {
		# 	hidden_effect = {
		# 		trigger_event = {
		# 			id = jeanne_event.0006
		# 			days = { 9 15 }
		# 		}
		# 	}
		# }
	}
	option = {
		name = jeanne_event.0005.b
		trigger = {
			diplomacy >= 10
		}
		skill = diplomacy
		add_prestige = minor_prestige_gain
		hidden_effect = {
			trigger_event = {
				id = jeanne_event.0006
				months = { 1 2 }
			}
		}
	}
	option = {
		name = jeanne_event.0005.c

		imprison = {
			target = scope:jeanne_the_maid
			type = dungeon
		}
		scope:jeanne_the_maid = { remove_character_flag = special_marshal }

		hidden_effect = {
			trigger_event = {
				id = jeanne_event.0030 # Trial for heresy!
				days = { 9 15 }
			}
		}
	}
}

# Jeanne d'Arc approaches liege to talk of God and life
jeanne_event.0006 = {
	type = character_event
	title = jeanne_event.0006.t
	desc = jeanne_event.0006.desc
	theme = realm
	left_portrait = {
		character = scope:jeanne_the_maid
		animation = personality_honorable
	}

	trigger = {
		scope:jeanne_the_maid = {
			is_alive = yes
		}
	}

	option = {
		name = jeanne_event.0006.a
		hidden_effect = { trigger_event = jeanne_event.0007 }
	}
	option = {
		name = jeanne_event.0006.b
		add_piety = 30
		if = { 
			limit = { has_trait = cynical }
			remove_trait = cynical
		}
		add_trait = zealous
		hidden_effect = { trigger_event = jeanne_event.0008 }
	}
	option = {
		name = jeanne_event.0006.c
		add_prestige = 30
		scope:jeanne_the_maid = {
			add_prestige = -30
		}
		hidden_effect = { trigger_event = jeanne_event.0009 }
	}
	option = {
		name = jeanne_event.0006.d
		trigger = {
			OR= {
				AND = {
					has_trait = lustful
					has_trait = cynical
					intrigue >= 10
				}
				AND = {
					OR = {
						has_trait = lustful
						has_trait = cynical
					}
					has_game_rule = jda_loosened_chastity_belt
				}
				# intrigue >= 5
				has_game_rule = jda_unlocked_chastity_belt
			}
			is_female = no
		}
		if = {
			limit = {
				has_game_rule = jda_tight_chastity_belt
			}
			custom_tooltip = jeanne_event.0006.d.tt.1
		}
		if = {
			limit = {
				has_game_rule = jda_loosened_chastity_belt
			}
			custom_tooltip = jeanne_event.0006.d.tt.2
		}
		if = {
			limit = {
				has_game_rule = jda_unlocked_chastity_belt
			}
			custom_tooltip = jeanne_event.0006.d.tt.3
		}
		random_list = {
			20 = {
				set_relation_lover = scope:jeanne_the_maid
				scope:jeanne_the_maid = {
					# remove_trait = celibate
					add_prestige = -50
					if = {
						limit = { has_nickname = nick_the_maid }
						give_nickname = nick_the_bold
					}
				}
				modifier = {
					has_game_rule = jda_loosened_chastity_belt
					add = 60
				}
				modifier = {
					has_game_rule = jda_unlocked_chastity_belt
					factor = 1
				}
				hidden_effect = { trigger_event = jeanne_event.0010 }
			}
			80 = {
				hidden_effect = { trigger_event = jeanne_event.0011 }
				modifier = {
					has_game_rule = jda_loosened_chastity_belt
					add = -60
				}
				modifier = {
					has_game_rule = jda_unlocked_chastity_belt
					factor = 0
				}
			}
		}
	}
}

jeanne_event.0007 = {
	type = character_event
	title = jeanne_event.0007.t
	desc = jeanne_event.0007.desc
	theme = realm
	left_portrait = {
		character = scope:jeanne_the_maid
		animation = personality_zealous
	}

	trigger = {
		scope:jeanne_the_maid = {
			is_alive = yes
		}
	}
	
	option = {
		name = jeanne_event.0007.a

		hidden_effect = {
			trigger_event = {
				id = jeanne_event.0012
				months = { 1 2 }
			}
		}
	}
}

jeanne_event.0008 = {
	type = character_event
	title = jeanne_event.0008.t
	desc = jeanne_event.0008.desc
	theme = realm
	left_portrait = {
		character = scope:jeanne_the_maid
		animation = personality_zealous
	}

	trigger = {
		scope:jeanne_the_maid = {
			is_alive = yes
		}
	}
	
	option = {
		name = jeanne_event.0008.a

		hidden_effect = {
			trigger_event = {
				id = jeanne_event.0012
				months = { 1 2 }
			}
		}
	}
}

jeanne_event.0009 = {
	type = character_event
	title = jeanne_event.0009.t
	desc = jeanne_event.0009.desc
	theme = realm
	left_portrait = {
		character = scope:jeanne_the_maid
		animation = personality_zealous
	}

	trigger = {
		scope:jeanne_the_maid = {
			is_alive = yes
		}
	}
	
	option = {
		name = jeanne_event.0009.a

		hidden_effect = {
			trigger_event = {
				id = jeanne_event.0012
				months = { 1 2 }
			}
		}
	}
}

jeanne_event.0010 = {
	type = character_event
	title = jeanne_event.0010.t
	desc = jeanne_event.0010.desc
	theme = realm
	left_portrait = {
		character = scope:jeanne_the_maid
		animation = flirtation
	}

	trigger = {
		scope:jeanne_the_maid = {
			is_alive = yes
		}
	}
	
	option = {
		name = jeanne_event.0010.a
		scope:jeanne_the_maid = {
			remove_trait = celibate
			had_sex_with_effect = {
				CHARACTER = scope:jeanne_liege
				PREGNANCY_CHANCE = seduce_pregnancy_chance
			}
		}
		trigger_event = {
			id = jeanne_event.0012
			months = { 1 2 }
		}
	}
}

jeanne_event.0011 = {
	type = character_event
	title = jeanne_event.0011.t
	desc = jeanne_event.0011.desc
	theme = realm
	left_portrait = {
		character = scope:jeanne_the_maid
		animation = shock
	}

	trigger = {
		scope:jeanne_the_maid = {
			is_alive = yes
		}
	}
	
	option = {
		name = jeanne_event.0011.a

		hidden_effect = {
			trigger_event = {
				id = jeanne_event.0012
				months = { 1 2 }
			}
		}
	}
}

# Peasants like Jeanne
jeanne_event.0012 = {
	type = character_event
	title = jeanne_event.0012.t
	desc = jeanne_event.0012.desc
	theme = realm
	left_portrait = {
		character = scope:jeanne_the_maid
		animation = happiness
	}

	trigger = {
		scope:jeanne_the_maid = {
			is_alive = yes
		}
	}

	option = {
		name = jeanne_event.0012.a

		# Gives a modifier that lowers peasant rebellion chance
		add_character_modifier = {
			modifier = realm_religious_fervor_modifier
			years = 5
		}
		hidden_effect = {
			trigger_event = {
				id = jeanne_event.0013
				months = { 1 2 }
			}
		}
	}
}

# Jeanne comes with advice to liege
jeanne_event.0013 = {
	type = character_event
	title = jeanne_event.0013.t
	desc = jeanne_event.0013.desc
	theme = realm
	left_portrait = {
		character = scope:jeanne_the_maid
		animation = personality_bold
	}

	trigger = {
		scope:jeanne_the_maid = {
			is_alive = yes
		}
	}
	
	immediate = {
		scope:jeanne_liege.realm_priest = {
			save_scope_as = jeanne_court_chaplain
		}
	}

	option = {
		name = jeanne_event.0013.a
		add_piety = 30
		scope:jeanne_liege.culture = { add_random_innovation = culture_group_military }
		custom_tooltip = jeanne_event.0005.a.tt
		every_vassal_or_below = {
			limit = {
				NOR = {
					has_government = theocracy_government
					has_council_position = councillor_court_chaplain
					has_government = republic_government
				}
				NOR = {
					has_trait = education_martial_4
					has_trait = education_martial_3
					has_trait = content
				}
			}
			add_opinion = {
				target = scope:jeanne_liege #root
				modifier = hate_opinion
				opinion = -15
			}
		}
		hidden_effect = {
			trigger_event = {
				id = jeanne_event.0014
				months = { 1 2 }
			}
		}
	}
	option = {
		name = jeanne_event.0013.b
		add_prestige = 30
		scope:jeanne_the_maid = { add_prestige = -30 }
		hidden_effect = {
			trigger_event = {
				id = jeanne_event.0014
				months = { 1 2 }
			}
		}
	}
	option = {
		name = jeanne_event.0013.c
		
		imprison = {
			target = scope:jeanne_the_maid
			type = dungeon
		}
		scope:jeanne_the_maid = { remove_character_flag = special_marshal }

		hidden_effect = {
			trigger_event = {
				id = jeanne_event.0030 # Trial for heresy!
				days = { 9 15 }
			}
		}
	}
}

# Jeanne d'Arc - Church Reacts
jeanne_event.0014 = {
	type = character_event
	title = jeanne_event.0014.t
	desc = jeanne_event.0014.desc
	theme = realm
	left_portrait = {
		character = scope:jeanne_liege.realm_priest
		animation = anger
	}

	trigger = {
		scope:jeanne_the_maid = {
			is_alive = yes
		}
	}

	option = {
		name = jeanne_event.0014.a
		custom_tooltip = jeanne_event.0014.a.tt
		hidden_effect = {
			every_vassal_or_below = {
				limit = {
					OR = {
						has_government = theocracy_government
						has_council_position = councillor_court_chaplain
					}
					NOR = {
						has_trait = education_martial_4
						has_trait = education_martial_3
						has_trait = content
					}
				}
				add_opinion = {
					target = scope:jeanne_liege #root
					modifier = hate_opinion
					opinion = -15
				}
			}
			trigger_event = {
				id = jeanne_event.0015
				months = { 1 2 }
			}
		}
	}
	option = {
		name = jeanne_event.0014.b
		trigger = {
			diplomacy >= 10
		}
		skill = diplomacy
		add_prestige = 20
		hidden_effect = {
			trigger_event = {
				id = jeanne_event.0015
				months = { 1 2 }
			}
		}
	}
	option = {
		name = jeanne_event.0014.c
		
		imprison = {
			target = scope:jeanne_the_maid
			type = dungeon
		}
		scope:jeanne_the_maid = { remove_character_flag = special_marshal }

		hidden_effect = {
			trigger_event = {
				id = jeanne_event.0030 # Trial for heresy!
				days = { 9 15 }
			}
			remove_character_modifier = realm_religious_fervor_modifier
		}
	}
}

# Jeanne d'Arc - Jeanne's ways affect liege
jeanne_event.0015 = {
	type = character_event
	title = jeanne_event.0015.t
	desc = jeanne_event.0015.desc
	theme = realm
	left_portrait = {
		character = scope:jeanne_the_maid
		animation = personality_zealous
	}

	trigger = {
		scope:jeanne_the_maid = {
			is_alive = yes
		}
	}

	immediate = {
		scope:jeanne_liege.cp:councillor_chancellor = {
			save_scope_as = jeanne_chancellor
		}
	}

	option = {
		name = jeanne_event.0015.a
		add_piety = 30
		if = {
			limit = { NOT = { has_trait = zealous } }
			random_list = {
				20 = {
					remove_trait = cynical
					add_trait = zealous
				}
				80 = {
					
				}
			}
		}
		hidden_effect = {
			trigger_event = {
				id = jeanne_event.0016
				months = { 1 2 }
			}
		}
	}
	option = {
		name = jeanne_event.0015.b
		if = {
			limit = { NOT = { has_trait = cynical } }
			random_list = {
				30 = {
					remove_trait = zealous
					add_trait = cynical
				}
				70 = {

				}
			}
		}
		hidden_effect = {
			trigger_event = {
				id = jeanne_event.0016
				months = { 1 2 }
			}
		}
	}
}

# Raise to noblity effect - I added this because the founder being glitched annoyed me. Unfortunately it doesn't work with dynasty prefixes
scripted_effect jeanne_raise_to_nobility_effect = {
	scope:jeanne_the_maid = {
		create_dynamic_title = {
			tier = duchy
			name = placeholder
		}
		create_title_and_vassal_change = {
			type = created
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:new_title = {
			set_capital_county = scope:jeanne_liege.capital_county
			set_landless_title = yes
			set_destroy_on_gain_same_tier = yes
			set_no_automatic_claims = yes
			set_can_be_named_after_dynasty = no
			change_title_holder = {
				holder = prev
				change = scope:change
			}
		}
		resolve_title_and_vassal_change = scope:change
		scope:new_title = {
			generate_coa = yes
		}
		destroy_title = scope:new_title
	}
	scope:jeanne_liege = {
		add_courtier = scope:jeanne_the_maid
	}
}

# Jeanne d'Arc - Nobles complain again - issue of low birth
jeanne_event.0016 = {
	type = character_event
	title = jeanne_event.0016.t
	desc = jeanne_event.0016.desc
	theme = realm
	left_portrait = {
		character = scope:jeanne_court_chaplain
		animation = worry
	}

	trigger = {
		scope:jeanne_the_maid = {
			is_alive = yes
			is_lowborn = yes
		}
	}

	option = {
		name = jeanne_event.0016.a
		hidden_effect = {
			every_vassal_or_below = {
				limit = {
					NOR = {
						has_government = theocracy_government
						has_council_position = councillor_court_chaplain
						has_government = republic_government
					}
					NOR = {
						has_trait = generous
						has_trait = compassionate
						has_trait = content
						is_lowborn = yes
					}
				}
				add_opinion = {
					target = root #scope:jeanne_liege
					modifier = hate_opinion
					opinion = -15
				}
			}
			trigger_event = {
				id = jeanne_event.0040 #Jeanne's story ends
				years = 4
			}
		}
		custom_tooltip = jeanne_event.0005.a.tt
	}
	option = {
		name = jeanne_event.0016.b
		scope:jeanne_the_maid = { add_prestige = -100 }
		hidden_effect = {
			trigger_event = {
				id = jeanne_event.0040 #Jeanne's story ends
				years = 4
			}
		}
	}
	option = {
		name = jeanne_event.0016.c
		hidden_effect = {
			trigger_event = {
				id = jeanne_event.0040 #Jeanne's story ends
				years = 4
			}
		}
		scope:jeanne_the_maid = {
			if = {
				limit = {
					NOR ={
						has_nickname = nick_darc
						culture = culture:french
					}
				}
				hidden_effect = {
					jeanne_raise_to_nobility_effect = yes
				}
				add_prestige = 200
				house = {
					set_coa = house:house_jeanne_ancilla
					set_house_name_from_house = house:house_jeanne_ancilla
				}
				dynasty = {
					set_coa = scope:jeanne_the_maid.house
					set_dynasty_name = dynn_Ancilla
				}
			}
			else_if = {
				limit = {
					OR = {
						has_nickname = nick_darc
						culture = culture:french
					}
				}
				give_nickname = nick_the_maid
				add_prestige = 100
				# Having the dynasty prefix is more satisfying than having a non-bugged dynasty founder
				set_house = house:house_jeanne_d'arc
			}
		}
	}
	option = {
		name = jeanne_event.0016.d
		
		imprison = {
			target = scope:jeanne_the_maid
			type = dungeon
		}
		scope:jeanne_the_maid = { remove_character_flag = special_marshal }

		hidden_effect = {
			trigger_event = {
				id = jeanne_event.0030 # Trial for heresy!
				days = { 9 15 }
			}
		}
	}
}

# Jeanne d'Arc marries trigger. Not the cleanest way of doing things, I know, but at least it works
jeanne_event.0019 = {
	type = character_event
	hidden = yes

	trigger = {
		OR = {
			root = { has_character_flag = is_jeanne_the_maid }
			scope:spouse = { has_character_flag = is_jeanne_the_maid }
		}
		exists = global_var:jeanne_darc_spawned
		NOT = { exists = global_var:jeanne_darc_married }
		# is_ai = no
		# religion = religion:christianity_religion
	}

	immediate = {
		if = {
			limit = { root = { has_character_flag = is_jeanne_the_maid } }
			save_scope_as = jeanne_the_maid
		}
		else_if = {
			limit = { scope:spouse = { has_character_flag = is_jeanne_the_maid } }
			scope:spouse = { save_scope_as = jeanne_the_maid }
		}
		scope:jeanne_the_maid.liege = {
			save_scope_as = jeanne_liege
		}
		every_ruler = { # Now informs every christian lord in range
			if = {
				limit = {
					AND = {
						in_diplomatic_range = scope:jeanne_liege
						religion = religion:christianity_religion
					}
				}
				trigger_event = { id = jeanne_event.0020 }
			}
		}
	}
}

# If Jeanne d'Arc marries
jeanne_event.0020 = {
	type = character_event
	title = jeanne_event.0020.t
	desc = jeanne_event.0020.desc
	theme = realm
	left_portrait = {
		character = scope:jeanne_the_maid
		animation = personality_bold
	}

	trigger = {
		# Making sure
		scope:jeanne_the_maid = {
			is_married = yes
			is_alive = yes
		}
		exists = global_var:jeanne_darc_spawned
		NOT = { exists = global_var:jeanne_darc_married }
		is_ai = no
		religion = religion:christianity_religion
	}

	immediate = {
		hidden_effect = {
			if = {
				limit = {
					OR = {
						has_game_rule = jda_loosened_chastity_belt
						has_game_rule = jda_unlocked_chastity_belt
					}
				}
				scope:jeanne_the_maid = { remove_trait = celibate }
			}
		}
		set_global_variable = {
			name = jeanne_darc_married
			value = yes
		}
	}
	
	option = { #CK2 removed the special marshal character flag here but I didn't. Doesn't make sense as future events reference her being martial
		name = jeanne_event.0020.a
		
		scope:jeanne_the_maid = {
			if = {
				limit = { has_nickname = nick_the_maid }
				give_nickname = nick_the_bold
			}
		}
	}
}

# If Jeanne d'Arc has a child
jeanne_event.0021 = {
	type = character_event
	hidden = yes

	trigger = {
		# scope:jeanne_the_maid = {
			# any_child = {
			# 	even_if_dead = yes
			# 	count >= 1
			# }
		# }
		is_alive = yes
		has_character_flag = is_jeanne_the_maid
		exists = global_var:jeanne_darc_spawned
		NOT = { exists = global_var:jeanne_darc_mother }
		# is_ai = no
		# religion = religion:christianity_religion
	}

	immediate = {
		root = { save_scope_as = jeanne_the_maid }
		every_ruler = { # Now informs every christian lord in range
			if = {
				limit = {
					AND = {
						in_diplomatic_range = scope:jeanne_the_maid.liege
						religion = religion:christianity_religion
					}
				}
				trigger_event = { id = jeanne_event.0022 }
			}
		}
	}
}

jeanne_event.0022 = {
	type = character_event
	title = jeanne_event.0022.t
	desc = jeanne_event.0022.desc
	theme = pregnancy
	
	left_portrait = {
		character = scope:jeanne_the_maid
		animation = newborn
	}
	
	immediate = {
		set_global_variable = {
			name = jeanne_darc_mother
			value = yes
		}
	}

	option = {
		name = jeanne_event.0022.a
		scope:jeanne_the_maid = {
			if = {
				limit = { has_nickname = nick_the_maid }
				give_nickname = nick_the_bold
			}
		}
	}
}

# Jeanne gains her Banner
jeanne_event.0023 = {
	type = character_event
	title = jeanne_event.0023.t
	desc = jeanne_event.0023.desc
	theme = realm
	left_portrait = {
		character = scope:jeanne_the_maid
		animation = personality_zealous
	}
	artifact = { # I know it's a non-combat banner but there are no other ways of showing banners. I might change it to be regalia or a trinket instead.
		target = scope:newly_created_artifact
		position = lower_right_portrait
	}

	trigger = {
		scope:jeanne_the_maid = {
			AND = {
				is_imprisoned = no
				is_alive = yes
			}
		}
	}

	immediate = {
		scope:jeanne_the_maid = {
			create_artifact = {
				name = jeanne_wall_banner_name
				description = jeanne_wall_banner_description
				visuals = banner
				visuals_source = title:k_jeanne_banner
				type = wall_big
				modifier = artifact_placeholder_modifier
				save_scope_as = newly_created_artifact
				wealth = scope:wealth
				quality = scope:quality
				history = {
					type = created
					recipient = scope:jeanne_the_maid
				}
			}
		}
		hidden_effect = {
			scope:newly_created_artifact = {
				add_scaled_artifact_modifier_piety_effect = yes
				add_artifact_modifier = artifact_knight_effectiveness_8_modifier
				add_artifact_modifier = jeanne_banner_opinion
			}
		}
	}
	
	option = {
		name = jeanne_event.0023.a
	}
}

# Trial of Jeanne d'Arc begins
jeanne_event.0030 = {
	type = character_event
	title = jeanne_event.0030.t
	desc = jeanne_event.0030.desc
	theme = unfriendly
	left_portrait = {
		character = scope:jeanne_the_maid
		animation = prison_dungeon
	}

	trigger = {
		scope:jeanne_the_maid = {
			is_alive = yes
		}
	}
	
	option = {
		name = jeanne_event.0030.a
		hidden_effect = {
			trigger_event = {
				id = jeanne_event.0031 # Give verdict
				months = { 2 3 }
			}
			set_global_variable = {
				name = jeanne_darc_on_trial
				value = yes
			}
		}
	}
}

# In hindsight I should have made the trial more interactive and engaged. Maybe an event two or three events about questioning her. Include that famous quote "If I am not, may God put me there; and if I am, may God so keep me. I should be the saddest creature in the world if I knew I were not in His grace."

# Trial of Jeanne d'Arc - give verdict
jeanne_event.0031 = {
	type = character_event
	title = jeanne_event.0031.t
	desc = jeanne_event.0031.desc
	theme = prison
	left_portrait = {
		character = scope:jeanne_the_maid
		animation = prison_dungeon
	}

	trigger = {
		scope:jeanne_the_maid = {
			is_alive = yes
		}
	}
	
	option = { #Guilty
		name = jeanne_event.0031.a
		hidden_effect = {
			trigger_event = {
				id = jeanne_event.0032
				days = { 3 5 }
			}
			scope:jeanne_the_maid = {
				add_character_flag = jeanne_guilty
			}
		}
	}
	option = { #Innocent
		name = jeanne_event.0031.b
		hidden_effect = {
			trigger_event = {
				id = jeanne_event.0033
				days = { 3 5 }
			}
			scope:jeanne_the_maid = {
				add_character_flag = jeanne_innocent
			}
		}
	}
}

# Jeanne d'Arc is burned at the stake
jeanne_event.0032 = {
	type = character_event
	title = jeanne_event.0032.t
	desc = jeanne_event.0032.desc
	theme = death
	override_background = {
		reference = gallows
	}
	left_portrait = {
		character = scope:jeanne_the_maid
		animation = schadenfreude	
	}
	artifact = { #This is not showing up is why I hate life
		target = scope:newly_created_ashes
		position = lower_right_portrait
	}

	immediate = {
		scope:jeanne_the_maid = {
			death = {
				death_reason = death_burned
			}
		}
		set_global_variable = {
			name = jeanne_darc_burned
			value = yes
		}
		remove_global_variable = jeanne_darc_on_trial
	}
	
	option = { #Collect her ashes
		name = jeanne_event.0032.a
		scope:jeanne_liege = {
			if = {
				limit = { has_royal_court = yes }
				create_artifact_ashes_effect = { # Mainly for Dom. Love you buddy. But in all seriousness collecting the ashes of saints was common however since Jeanne was a heretical peasant at the time of her death, and wasn't canonised until 1920, it's highly unlikely anyone collected her remains.
					OWNER = scope:jeanne_liege
					CREATOR = scope:jeanne_the_maid
				}
			}
		}
	}
	option = { #Good riddance
		name = jeanne_event.0032.b
		add_piety = 250
	}
}

# Jeanne d'Arc aquitted
jeanne_event.0033 = {
	type = character_event
	title = jeanne_event.0033.t
	desc = jeanne_event.0033.desc
	theme = death
	override_background = {
		reference = gallows
	}
	left_portrait = scope:jeanne_the_maid
	
	option = {
		name = jeanne_event.0033.a
		scope:jeanne_the_maid = {
			release_from_prison = yes
			add_trait = devoted
		}
		hidden_effect = {
			trigger_event = {
				id = jeanne_event.0040 #Jeanne's story ends
				years = 4
			}
			remove_global_variable = jeanne_darc_on_trial
		}
	}
}

# Stormy times over for Jeanne d'Arc
jeanne_event.0040 = {
	type = character_event
	title = jeanne_event.0040.t
	desc = jeanne_event.0040.desc
	theme = realm
	
	left_portrait = {
		character = scope:jeanne_the_maid
		animation = war_over_win
	}

	immediate = {
		set_global_variable = {
			name = jeanne_darc_peaceful
			value = yes
		}
	}

	option = {
		name = jeanne_event.0040.a
	}
}

# Jeanne dies early trigger
jeanne_event.0041 = {
	type = character_event
	hidden = yes

	trigger = {
		has_character_flag = is_jeanne_the_maid
		# exists = global_var:jeanne_darc_spawned
		# NOR = {
		# 	exists = global_var:jeanne_darc_early_death
		# 	exists = global_var:jeanne_darc_burned
		# }
		# is_ai = no
		# religion = religion:christianity_religion
	}

	immediate = {
		set_global_variable = {
			name = jeanne_darc_early_death
			value = yes
		}
		root = { save_scope_as = jeanne_the_maid }
		every_ruler = { # I'm lazy
			if = {
				limit = {
					has_character_flag = is_jeanne_liege
				}
				trigger_event = {
					id = jeanne_event.0042
					days = 3
				}
			}
		}
	}
}

# Jeanne dies early
jeanne_event.0042 = {
	type = character_event
	title = jeanne_event.0041.t
	desc = jeanne_event.0041.desc
	theme = realm
	
	# trigger = {
	# 	scope:jeanne_the_maid = {
	# 		is_alive = no
	# 	}
	# 	NOR = {
	# 		exists = global_var:jeanne_darc_peaceful
	# 		exists = global_var:jeanne_darc_spawned
	# 		AND = {
	# 			exists = scope:killer
	# 			scope:killer = root
	# 		}
	# 	}
	# }

	left_portrait = scope:jeanne_the_maid

	immediate = {
		every_ruler = {
			every_realm_county = {
				limit = {
					has_county_modifier = home_of_jeanne_darc_modifier
				}
				save_scope_as = home_of_jeanne_darc
			}
		}
	}

	option = { # Jeanne dies in battle/dungeon, bolsters country morale. Increased levy refresh rate
		name = jeanne_event.0041.a
		trigger = {
			scope:jeanne_the_maid = {
				OR = {
					death_killer_always_public_trigger = yes
					had_battle_death_trigger = yes
				}
			}
		}
		add_character_modifier = {
			modifier = jeanne_bolster_modifier
			years = 10
		}
	}
	option = { # Jeanne dies from an illness
		name = jeanne_event.0041.b
		trigger = {
			scope:jeanne_the_maid = { had_disease_death_trigger = yes }
		}
	}
	option = { # Jeanne is murdered/unknown causes
		name = jeanne_event.0041.c
		trigger = {
			OR = {
				scope:jeanne_the_maid = {
					death_reason = death_murder
				}
				scope:jeanne_the_maid = {
					death_reason = death_murder_known
				}
				scope:jeanne_the_maid = {
					death_reason = death_mysterious
				}
				scope:jeanne_the_maid = {
					death_reason = death_disappearance
				}
			}
		}
	}
	option = { # Jeanne dies from any other cause
		name = jeanne_event.0041.d
		trigger = {
			NOR = {
				exists = global_var:jeanne_darc_on_trial
				scope:jeanne_the_maid = {
					death_reason = death_murder
				}
				scope:jeanne_the_maid = {
					death_reason = death_mysterious
				}
				scope:jeanne_the_maid = { had_disease_death_trigger = yes }
				scope:jeanne_the_maid = {
					OR = {
						death_killer_always_public_trigger = yes
						had_battle_death_trigger = yes
					}
				}
			}
		}
	}
	option = { # Jeanne dies while on trial
		name = jeanne_event.0041.e
		trigger = {
			exists = global_var:jeanne_darc_on_trial
		}
	}
}