namespace = Plus

#reserved: Plus.2000 to Plus.2099

#######################################
# CHRISTIAN HERESY EVENTS
# Adapted from Heretic Pride by Rylock
#######################################

### CATHAR EVENTS

# Cathar child gains chaste
character_event = {
	id = Plus.2000
	desc = EVTDESC_Plus_2000
	picture = GFX_evt_child_talking
	
	is_triggered_only = yes
	
	min_age = 6
	max_age = 16
	religion = cathar

	trigger = {
		educator = { always = yes }
		NOT = { personality_traits = 5 }
		NOT = { trait = lustful }
		NOT = { trait = chaste }
	}
	
	weight_multiplier = {
		days = 1
		modifier = {
			factor = 0.1
			educator = { trait = lustful }
		}
		modifier = {
			factor = 2.0
			educator = { trait = chaste }
		}
	}
	
	option = {
		name = EVTOPTA_Plus_2000
		add_trait = chaste
	}
}

# Cathar male child becomes homosexual
character_event = {
	id = Plus.2001
	desc = EVTDESC_Plus_2001
	picture = GFX_evt_brothel
	
	min_age = 13
	max_age = 18
	only_men = yes
	religion = cathar
	is_married = no
	
	trigger = {
		NOR = {
			trait = homosexual
			trait = celibate
		}
	}

	mean_time_to_happen = {
		months = 960
		modifier = {
			factor = 1.25
			trait = chaste
		}
		modifier = {
			factor = 0.75
			martial = 10
			trait = fair
		}
		modifier = {
			factor = 0.75
			trait = shy
			learning = 10
		}
		modifier = {
			factor = 0.75
			trait = trusting
			any_courtier = {
				age = 13
				NOT = { age = 18 }
				trait = homosexual
				reverse_opinion = { who = ROOT value = 25 }
			}
		}
	}
	
	option = {
		name = EVTOPTA_Plus_2001
		add_trait = homosexual
	}
}

# Cathar female child becomes homosexual
character_event = {
	id = Plus.2002
	desc = EVTDESC_Plus_2002
	picture = GFX_evt_garden
	
	min_age = 12
	max_age = 17
	only_women = yes
	religion = cathar
	is_married = no
	
	trigger = {
		NOR = {
			trait = homosexual
			trait = celibate
		}		
	}

	mean_time_to_happen = {
		months = 960
		modifier = {
			factor = 0.5
			trait = zealous
		}
		modifier = {
			factor = 0.5
			trait = chaste
		}
	}
	
	option = {
		name = EVTOPTA_Plus_2001
		add_trait = homosexual
	}
}

# Adult Cathar becomes celibate
character_event = {
	id = Plus.2003
	desc = EVTDESC_Plus_2003
	picture = GFX_evt_brothel
	
	min_age = 25
	religion = cathar
	
	is_triggered_only = yes
	
	trigger = {
		trait = zealous
		NOR = {
			trait = celibate
			trait = hedonist
		}
	}
	
	weight_multiplier = {
		days = 1
		modifier = {
			factor = 2
			trait = chaste
		}
		modifier = {
			factor = 0.5
			trait = lustful
		}
	}
	
	option = {
		name = EVTOPTA_Plus_2003
		add_trait = celibate
	}
}

#[on_birth] Cathar child malus
character_event = {
	id = Plus.2004
	
	hide_window = yes
	is_triggered_only = yes
	
	trigger = {
		OR = {
			father = { religion = cathar }
			mother = { religion = cathar }
		}
	}
	
	immediate = {
		if = {
			limit = {
				father = { religion = cathar }
			}
			father = {
				character_event = {
					id = Plus.2005
					days = 2
				}
			}
		}
		if = {
			limit = {
				mother = { religion = cathar }
			}
			mother = {
				character_event = {
					id = Plus.2005
					days = 2
				}
			}
		}
	}
}

# Cathars lose piety and prestige for having children
character_event = {
	id = Plus.2005
	desc = EVTDESC_Plus_2005
	picture = GFX_evt_lovers
	
	is_triggered_only = yes
	
	trigger = {
		religion = cathar
	}
	
	option = {
		name = EVTOPTA_Plus_2005
		piety = -25
	}
}

# Cathar/Bogomilist ruler adopts a child (fired from decision)
character_event = {
	id = Plus.2006
	desc = EVTDESC_Plus_2006
	picture = GFX_evt_child_talking
	
	is_triggered_only = yes
	
	immediate = {
		random_realm_province = {
			limit = { religion = ROOT }
			save_event_target_as = adopted_province
		}
	}

	option = {
		name = EVTOPTA_Plus_2006
		piety = 20
		create_character = {
			dynasty = ROOT
			religion = ROOT
			culture = ROOT
			female = no
			age = 5
			health = 6.5
			fertility = 0.4
			attributes = {
				learning = 2
				diplomacy = 2
				martial = 2
				stewardship = 2
				intrigue = 2
			}
		}
		new_character = {
			if = {
				limit = { ROOT = { is_female = no } }
				set_father = ROOT
			}
			if = {
				limit = { ROOT = { is_female = yes } }
				set_mother = ROOT
			}
			random_list = {
				1 = { add_trait = genius }
				3 = { add_trait = quick }
				3 = { add_trait = strong }
				3 = { add_trait = tall }
				4 = { change_diplomacy = 2 }
				4 = { change_learning = 2 }
				4 = { change_martial = 2 }
				4 = { change_stewardship = 2 }
				4 = { change_intrigue = 2 }
				10 = { }
			}
			random_list = {
				3 = { add_trait = shy }
				1 = { add_trait = humble }
				1 = { add_trait = trusting }
			}
			add_trait = adopted
		}
		recalc_succession = yes
	}
}

# Council of Saint-Félix
narrative_event = {
	id = Plus.2010
	title = EVTTITLE_Plus_2010
	desc = EVTDESC_Plus_2010
	picture = GFX_evt_ecumenical_council
	border = GFX_event_narrative_frame_religion

	major = yes
	only_rulers = yes
	religion = catholic
	war = no
	
	trigger = {
		year = 1165
		has_landed_title = c_carcassonne
		213 = { religion = catholic }
		NOR = {
			any_independent_ruler = { religion = cathar }
			has_global_flag = rise_cathar
		}
	}
	
	major_trigger = {
		OR = {
			has_landed_title = c_carcassonne
			has_landed_title = c_toulouse
			has_landed_title = c_foix
			has_landed_title = c_narbonne
			religion = cathar
			religion = bogomilist
			capital_scope = {
				NOT = {
					distance = {
						where = 213 # Carcassone
						value = 600	# Same part of the world
					}
				}
			}
		}
	}
	
	mean_time_to_happen = {
		months = 24
		modifier = {
			factor = 0.5
			year = 1167
		}
	}
	
	immediate = {
		set_global_flag = rise_cathar
		213 = { #Carcassone
			religion = cathar
			add_province_modifier = {
				name = heretic_stronghold
				duration = 3650
			}
		}
		214 = { #Toulouse
			if = {
				limit = { religion = catholic }
				religion = cathar
				add_province_modifier = {
					name = heretic_stronghold
					duration = 3650
				}
			}
		}
		210 = { #Foix
			if = {
				limit = { religion = catholic }
				religion = cathar
				add_province_modifier = {
					name = heretic_stronghold
					duration = 3650
				}
			}
		}
		212 = { #Narbonne
			if = {
				limit = { religion = catholic }
				religion = cathar
				add_province_modifier = {
					name = heretic_stronghold
					duration = 3650
				}
			}
		}
	}
	
	option = {
		name = EVTOPTA_Plus_2010
		trigger = {
			religion = catholic
			OR = {
				has_landed_title = c_carcassonne
				has_landed_title = c_toulouse
				has_landed_title = c_foix
				has_landed_title = c_narbonne
			}
		}
		piety = -100
		hidden_tooltip = {
			create_character = {
				random_traits = yes
				dynasty = random
				religion = cathar
				culture = ROOT
				female = no
				age = 35
				trait = mastermind_theologian
				trait = perfecti
				trait = zealous
				trait = gregarious
				trait = scholar
				attributes = {
					learning = 5
					diplomacy = 5
				}
			}
		}
	}
	option = {
		name = EVTOPTB_Plus_2010
		trigger = {
			religion = catholic
			NOR = {
				has_landed_title = c_carcassonne
				has_landed_title = c_toulouse
				has_landed_title = c_foix
				has_landed_title = c_narbonne
			}
		}
	}
	option = {
		name = I_SEE
		trigger = {
			NOR = {
				religion = catholic
				religion = bogomilist
			}
		}
	}
	option = {
		name = EVTOPTC_Plus_2010
		trigger = {
			religion = bogomilist
		}
#		hidden_tooltip = {
#			character_event = { id = HPbogomilist.10210 days = 2 }
#		}
	}
}

# Cathars are allowed to use holy wars once Catholic holy war is used against them
character_event = {
	id = Plus.2011
	title = EVTTITLE_Plus_2011
	desc = EVTDESC_Plus_2011
	picture = GFX_evt_heresy_defeated
	border = GFX_event_normal_frame_war
	
	is_triggered_only = yes
	
	major = yes
	only_rulers = yes
	religion = cathar
	war = yes
	
	trigger = {
		is_heretic = yes
		is_primary_war_defender = yes
		any_war = {
			attacker = { is_parent_religion = ROOT }
			defender = { character = ROOT }
			OR = {
				using_cb = crusade
				using_cb = holy_war
			}
		}
		NOT = { has_global_flag = cathar_war }
	}
	
	major_trigger = {
		religion = cathar
	}

	immediate = {
		set_global_flag = cathar_war
	}
	
	option = {
		name = EVTOPTA_Plus_2011
	}
}

# A Cathar Pope is elected (fired from decision)
character_event = {
	id = Plus.2012
	
	is_triggered_only = yes
	hide_window = yes

	immediate = {
		activate_title = { title = d_cathar status = yes }
		if = {
			limit = {
				any_realm_lord = {
					in_revolt = no
					religion = cathar
					is_theocracy = yes
					capital_holding = { is_holy_site = ROOT }
					prisoner = no
					trait = perfecti
					NOT = { trait = incapable }
				}
			}
			random_realm_lord = {
				limit = {
					in_revolt = no
					religion = cathar
					is_theocracy = yes
					capital_holding = { is_holy_site = ROOT }
					prisoner = no
					trait = perfecti
					NOT = { trait = incapable }
				}
				d_cathar = { grant_title = PREV }
				set_defacto_liege = ROOT
				pf_liege_change_effect = yes
				save_event_target_as = new_cathar_pope
			}
		}
		if = {
			limit = {
				NOT = {
					any_realm_lord = {
						religion = cathar
						is_theocracy = yes
						capital_holding = { is_holy_site = ROOT }
						prisoner = no
						trait = perfecti
						NOT = { trait = incapable }
					}
				}
			}
			create_random_priest = {
				random_traits = yes
				dynasty = random
				religion = cathar
				culture = ROOT
				age = 40
				health = 7
				trait = quick
				trait = zealous
				trait = perfecti
				trait = scholar
				trait = mastermind_theologian
				attributes = {
					learning = 5
					diplomacy = 5
					martial = 2
					stewardship = 5
					intrigue = 5
				}
			}
			new_character = {
				d_cathar = { grant_title = PREV }
				set_defacto_liege = ROOT
				save_event_target_as = new_cathar_pope
				ROOT = {
					random_realm_title = {
						limit = { is_holy_site = ROOT }
						gain_title = PREVPREV
					}
				}
			}
		}
		narrative_event = { id = Plus.2013 }
	}
}

# The rest of the world is told about the new Cathar Pope
narrative_event = {
	id = Plus.2013
	title = EVTTITLE_Plus_2013
	desc = EVTDESC_Plus_2013
	picture = GFX_evt_pope
	border = GFX_event_narrative_frame_religion

	major = yes

	is_triggered_only = yes

	option = {
		name = EVTOPTA_Plus_2013
		trigger = {
			NOT = { religion = cathar }
			religion_group = christian
		}
	}
	option = {
		name = EVTOPTB_Plus_2013
		trigger = { NOT = { religion_group = christian } }
	}
	option = {
		name = EVTOPTC_Plus_2013
		trigger = { religion = cathar }
	}
}

### LOLLARD EVENTS

# John Wycliff appears in England
narrative_event = {
	id = Plus.2015
	title = EVTNAME_Plus_2015
	desc = EVTDESC_Plus_2015
	picture = GFX_evt_lollard_heresy
	border = GFX_event_narrative_frame_religion

	major = yes
	only_rulers = yes
	religion = catholic
	war = no
	
	trigger = {
		year = 1370
		has_landed_title = k_england
		any_realm_province = {
			region = custom_england
			religion = catholic
		}
		NOR = {
			any_realm_province = {
				region = custom_england
				religion = lollard
			}
			religion_authority = 0.60
			any_independent_ruler = { religion = lollard }
			has_global_flag = wycliff
		}
	}

	major_trigger = {
		OR = {
			has_landed_title = k_england
			religion = lollard
			capital_scope = {
				NOT = {
					distance = {
						where = 32 # Middlesex
						value = 600	# Same part of the world
					}
				}
			}
		}
	}

	mean_time_to_happen = {
		months = 12
	}
	
	immediate = {
		random_realm_province = {
			limit = {
				region = custom_england
				religion = catholic 
			}
			save_event_target_as = new_lollard_stronghold
		}
	}
	
	option = {
		name = EVTOPTA_Plus_2015
		trigger = { has_landed_title = k_england }
		set_global_flag = wycliff
		piety = -100
		event_target:new_lollard_stronghold = {
			religion = lollard
			add_province_modifier = {
				name = heretic_stronghold
				duration = 3650
            }
			hidden_tooltip = {
				owner = {
					create_character = {
						name = "John"
						random_traits = yes
						dynasty = 1000124390 #Wycliff
						religion = lollard
						culture = PREV
						female = no
						age = 39
						trait = mastermind_theologian
						trait = humble
						trait = zealous
						trait = gregarious
						trait = scholar
						trait = monk
						attributes = {
							learning = 5
							diplomacy = 5
						}
					}
				}
			}
		}
	}
	option = {
		name = EVTOPTB_Plus_2015
		trigger = {
			NOT = { has_landed_title = k_england }
			religion = catholic
		}
	}
	option = {
		name = EVTOPTC_Plus_2015
		trigger = {
			NOT = { has_landed_title = k_england }
			NOT = { religion = catholic }
			religion_group = christian
		}
	}
	option = {
		name = EVTOPTD_Plus_2015
		trigger = {
			NOT = { has_landed_title = k_england }
			NOT = { religion_group = christian }
		}
	}
}

# Lollard/Paulician/Iconoclast wins siege over a Christian temple
character_event = { 
	id = Plus.2016
	desc = EVTDESC_Plus_2016
	picture = GFX_evt_siege
	border = GFX_event_normal_frame_war
	
	is_triggered_only = yes
	
	trigger = {
		mercenary = no
		OR = {
			religion = lollard
			religion = paulician
			religion = iconoclast
			religion = bogomilist
		}
		FROM = { 
			holding_type = temple
			owner = {
				wealth = 50
				religion_group = christian
				NOR = {
					religion = lollard
					religion = paulician
					religion = iconoclast
					religion = bogomilist
				}
			}
		}
	}
	
	option = {
		name = EVTOPTA_Plus_2016
		ai_chance = {
			factor = 50
			modifier = {
				factor = 2
				religion = iconoclast
			}
			modifier = {
				factor = 5
				trait = zealous
			}
			modifier = {
				factor = 1.5
				trait = greedy
			}
			modifier = {
				factor = 1.5
				trait = wroth
			}
		}
		if = {
			limit = { NOT = { trait = iconoclast_trait } }
			add_trait = iconoclast_trait
		}
		wealth = 50
		piety = -25
		hidden_tooltip = {
			FROM = {
				owner = {
					wealth = -50
					opinion = { who = ROOT modifier = opinion_outraged years = 20 }
				}
			}
		}
	}
	option = {
		name = EVTOPTB_Plus_2016
		ai_chance = {
			factor = 50
			modifier = {
				factor = 0
				trait = iconoclast_trait
			}
			modifier = {
				factor = 0
				NOT = { piety = 0 }
			}
			modifier = {
				factor = 2
				trait = cynical
			}
			modifier = {
				factor = 1.5
				trait = kind
			}
			modifier = {
				factor = 1.5
				trait = humble
			}
		}
		piety = 10
	}
}

# Bible translation is well-received
narrative_event = { 
	id = Plus.2017
	title = EVTNAME_Plus_2017
	desc = EVTDESC_Plus_2017
	picture = GFX_evt_lollard_heresy
	border = GFX_event_narrative_frame_religion
	
	is_triggered_only = yes
	major = yes
	
	trigger = {
		OR = {
			religion = lollard
			religion = waldensian
		}
		higher_tier_than = DUKE
		has_character_flag = bible_translation_begun
		NOT = { has_global_flag = bible_translation_finished }
	}
	
	major_trigger = {
		religion_group = christian
	}
	
	option = {
		name = EVTOPTA_Plus_2017
		trigger = {
			character = ROOT
			has_character_flag = bible_translation_begun
			NOT = { has_global_flag = bible_translation_finished }
		}
		clr_character_flag = bible_translation_begun
		set_global_flag = bible_translation_finished
		piety = 500
		prestige = 500
		religion_authority = {
			modifier = bible_translated_lollard
			years = 25
		}
		random_independent_ruler = {
			limit = {
				religion = catholic
				 is_parent_religion = ROOT
			}
			religion_authority = {
				modifier = bible_translated
				years = 25
			}
		}
		random_independent_ruler = {
			limit = {
				religion = chalcedonian
				 is_parent_religion = ROOT
			}
			religion_authority = {
				modifier = bible_translated
				years = 25
			}
		}
	}
	option = {
		name = EVTOPTA_Plus_2017
		trigger = {
			NOT = { character = ROOT }
			religion = ROOT
		}
	}
	option = {
		name = EVTOPTB_Plus_2017
		trigger = {
			NOT = { character = ROOT }
			NOT = { religion = ROOT }
		}
	}
}

# Bible translation is poorly-received
narrative_event = { 
	id = Plus.2018
	title = EVTNAME_Plus_2017
	desc = EVTDESC_Plus_2018
	picture = GFX_evt_lollard_heresy
	border = GFX_event_narrative_frame_religion
	
	is_triggered_only = yes
	major = yes
	
	religion_group = christian
	has_character_flag = bible_translation_begun
	
	trigger = {
		OR = {
			religion = lollard
			religion = waldensian
		}
		higher_tier_than = DUKE
		NOT = { has_global_flag = bible_translation_finished }
	}
	
	major_trigger = {
		religion_group = christian
	}
	
	option = {
		name = EVTOPTA_Plus_2018
		trigger = {
			character = ROOT
			has_character_flag = bible_translation_begun
			NOT = { has_global_flag = bible_translation_finished }
		}
		clr_character_flag = bible_translation_begun
		set_global_flag = bible_translation_finished
		piety = 250
		prestige = -250
		religion_authority = {
			modifier = bible_translated_poor_lollard
			years = 25
		}
		random_independent_ruler = {
			limit = { 
				religion = catholic
				is_parent_religion = ROOT
			}
			religion_authority = {
				modifier = bible_translated_poor
				years = 25
			}
		}
		random_independent_ruler = {
			limit = { 
				religion = chalcedonian
				is_parent_religion = ROOT
			}
			religion_authority = {
				modifier = bible_translated_poor
				years = 25
			}
		}
	}
	option = {
		name = EVTOPTA_Plus_2017
		trigger = {
			NOT = { character = ROOT }
			religion = ROOT
		}
	}
	option = {
		name = EVTOPTB_Plus_2017
		trigger = {
			NOT = { character = ROOT }
			NOT = { religion = ROOT }
		}
	}
}

# Ruler dies while Bible is being translated
character_event = {
	id = Plus.2019
	
	hide_window = yes
	is_triggered_only = yes
	
	has_character_flag = bible_translation_begun
	
	trigger = {
		NOT = { has_global_flag = bible_translation_finished }
	}
	
	immediate = {
		current_heir = {
			character_event = { id = Plus.2020 days = 3 }
		}
	}
}

# Ruler's heir decides whether to continue work on Bible translation
character_event = {
	id = Plus.2020
	desc = EVTDESC_Plus_2020
	picture = GFX_evt_book_carolingian_script
	border = GFX_event_normal_frame_religion	
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_Plus_2020 # Continue his work
		trigger = {
			has_regent = no
			higher_tier_than = DUKE
			OR = {
				religion = lollard
				religion = waldensian
			}
			wealth = 0
		}
		set_character_flag = bible_translation_begun
		scaled_wealth = -0.5
		random_list = {
			50 = {
				modifier = {
					factor = 1.1
					learning = 12
				}
				modifier = {
					factor = 1.1
					learning = 14
				}
				modifier = {
					factor = 1.2
					learning = 16
				}
				modifier = {
					factor = 1.2
					learning = 18
				}
				modifier = {
					factor = 1.2
					learning = 20
				}
				narrative_event = { id = Plus.2017 days = 150 random = 250 tooltip = BIBLE_TRANSLATION_GOOD }
			}
			50 = {
				modifier = {
					factor = 0.8
					NOT = { learning = 8 }
				}
				modifier = {
					factor = 0.8
					NOT = { learning = 6 }
				}
				modifier = {
					factor = 0.8
					NOT = { learning = 4 }
				}
				narrative_event = { id = Plus.2018 days = 150 random = 250 tooltip = BIBLE_TRANSLATION_POOR }
			}
		}
	}
	option = {
		name = EVTOPTB_Plus_2020 # His efforts die with him
		scaled_wealth = 1.5
		if = {
			limit = {
				OR = {
					religion = lollard
					religion = waldensian
				}
			}
			piety = -100
		}
	}
}

# Lollard ruler attempts to revoke/claim religious titles (fired from decision)
letter_event = {
	id = Plus.2021
	border = GFX_event_letter_frame_religion
	
	desc = {
		text = EVTDESC_Plus_2021_not_lollard
		trigger = {
			NOT = { religion = lollard }
		}
	}
	desc = {
		text = EVTDESC_Plus_2021_wicked
		trigger = {
			religion = lollard
			trait = bad_priest_christian
		}
	}
	desc = {
		text = EVTDESC_Plus_2021_high_tier
		trigger = {
			religion = lollard
			NOT = { trait = bad_priest_christian }
			higher_tier_than = COUNT
		}
	}
	
	is_triggered_only = yes
	
	trigger = {
		is_ruler = yes
		holy_order = no
		vassal_of = FROMFROM
		capital_holding = { holding_type = temple }
		NOR = {
			any_demesne_title = { temporary = yes }
			reverse_has_truce = FROMFROM
			has_non_aggression_pact_with = FROMFROM
		}
	}
	
	immediate = {
		clr_character_flag = lollard_revoking_titles
	}
	
	option = {
		name = EVTOPTA_Plus_2021 # I have no choice
		prestige = -100
		if = {
			limit = {
				OR = {
					NOT = { religion = lollard }
					trait = bad_priest_christian
				}
			}
			any_demesne_title = {
				limit = {
					OR = {
						is_theocracy = yes
						higher_tier_than = BARON
					}
				}
				usurp_title_plus_barony_if_unlanded = FROMFROM
			}
			set_defacto_liege = FROMFROM
			pf_liege_change_effect = yes
			hidden_tooltip = {
				FROMFROM = { letter_event = { id = Plus.2022 } }
			}
		}
		if = {
			limit = {
				religion = lollard
				NOT = { trait = bad_priest_christian }
			}
			any_demesne_title = {
				limit = { higher_tier_than = COUNT }
				tooltip = { add_claim = FROMFROM }
			}
			hidden_tooltip = {
				FROMFROM = { letter_event = { id = Plus.2023 } }
			}
		}
	}
	option = {
		name = EVTOPTB_Plus_2021 # How dare he!
		trigger = {
			higher_tier_than = BARON
			OR = {
				NOT = { religion = lollard }
				trait = bad_priest_christian
			}
		}
		FROMFROM = {
			opinion = { who = ROOT modifier = opinion_rebel_traitor years = 20 }
			hidden_tooltip = { letter_event = { id = Plus.2024 } }
		}
		tooltip = {
			war = {
				target = FROMFROM
				casus_belli = overthrow_ruler
			}
		}
	}
}

# Priest accepts titles being revoked
letter_event = {
	id = Plus.2022
	desc = EVTDESC_Plus_2022
	border = GFX_event_letter_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EXCELLENT
		FROM = {
			any_demesne_title = {
				limit = {
					OR = {
						is_theocracy = yes
						higher_tier_than = BARON
					}
				}
				usurp_title_plus_barony_if_unlanded = ROOT
			}
			set_defacto_liege = FROM
			pf_liege_change_effect = yes
		}
	}
}

# Lollard ruler gains claims to titles
letter_event = {
	id = Plus.2023
	desc = EVTDESC_Plus_2023
	border = GFX_event_letter_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EXCELLENT
		FROM = {
			opinion = { who = ROOT modifier = opinion_outraged years = 10 }
			any_demesne_title = {
				limit = { higher_tier_than = COUNT }
				add_claim = ROOT
			}
		}
	}
}

# Priest refuses titles being revoked
letter_event = {
	id = Plus.2024
	desc = EVTDESC_Plus_2024
	border = GFX_event_letter_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_Plus_2024
		FROM = { opinion = { who = ROOT modifier = opinion_outraged years = 20 } }
		reverse_war = {
			target = FROM
			casus_belli = overthrow_ruler
		}
	}
}

### FRATICELLI EVENTS

# Brother Angelo criticizes the Pope
narrative_event = {
	id = Plus.2025
	title = EVTNAME_Plus_2025
	desc = EVTDESC_Plus_2025
	picture = GFX_evt_lollard_heresy
	border = GFX_event_narrative_frame_religion
	
	is_triggered_only = yes

	major = yes
	only_rulers = yes
	religion = catholic
	
	trigger = {
		war = no
		year = 1250
		has_landed_title = k_papal_state
		OR = {
			trait = bad_priest_christian
			NOT = { religion_authority = 0.60 }
		}
		NOT = { has_global_flag = fraticelli_reform }
	}
	
	major_trigger = {
		OR = {
			has_landed_title = k_papal_state
			religion_group = christian
		}
	}
	
	option = {
		name = EVTDESC_Plus_2025
		trigger = { has_landed_title = k_papal_state }
		set_global_flag = fraticelli_reform
		piety = -200
		religion_authority = {
			modifier = fraticelli_reforms
			years = 15
		}
		hidden_tooltip = {
			any_character = {
				limit = {
					ai = yes
					religion = catholic
					is_theocracy = yes
					trait = mastermind_theologian
					is_within_diplo_range = ROOT
					NOT = { character = ROOT }
				}
				character_event = { id = Plus.2026 days = 7 }
			}
			capital_scope = {
				ROOT = {
					create_character = {
						name = "Angelo"
						random_traits = yes
						dynasty = random
						religion = fraticelli
						culture = PREV
						female = no
						age = 40
						trait = monk
						trait = mastermind_theologian
						trait = zealous
						trait = gregarious
						trait = scholar
						attributes = {
							learning = 5
							diplomacy = 5
						}
					}
				}
			}
		}
	}
	option = {
		name = EVTOPTB_Plus_2025
		trigger = {
			NOT = { has_landed_title = k_papal_state }
			is_heretic = yes
		}
	}
	option = {
		name = EVTOPTC_Plus_2025
		trigger = {
			NOT = { has_landed_title = k_papal_state }
			is_heretic = no
		}
	}
}

# Catholic bishops react to the words of Brother Angelo
character_event = { 
	id = Plus.2026
	
	is_triggered_only = yes
	hide_window = yes
	
	immediate = {
		random_list = {
			90 = {
				# Does not convert
			}
			10 = {
				# Chance of converting
				character_event = { id = Plus.2027 }
			}
		}
	}
}

# The Catholic faithful consider the Fraticelli heresy
character_event = {
	id = Plus.2027
	desc = EVTDESC_Plus_2027
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	religion = catholic
	
	trigger = {
		controls_religion = no
		OR = {
			trait = mastermind_theologian
			has_focus = focus_theology
			trait = monk
			trait = nun
			is_theocracy = yes
		}
		OR = {
			trait = cynical
			trait = humble
			trait = temperate
			trait = charitable
		}
		NOR = {
			rightful_religious_head = ROOT
			has_claim = k_papal_state
			religion_authority = 0.60
			trait = zealous
			trait = greedy
			trait = gluttonous
			trait = proud
			trait = bad_priest_christian
			has_character_flag = considered_fraticelli
		}
		has_global_flag = fraticelli_reform
	}
	
	immediate = {
		set_character_flag = considered_fraticelli
	}
	
	option = {
		name = EVTOPTA_Plus_2027
		ai_chance = {
			factor = 25
			modifier = {
				factor = 3
				OR = {
					any_liege = { is_heretic = yes }
					father_even_if_dead = { is_heretic = yes }
					mother_even_if_dead = { is_heretic = yes }
					any_sibling = { is_heretic = yes }
					any_child = { is_heretic = yes }
				}
			}
			modifier = {
				factor = 0.5
				is_ruler = yes
			}
			modifier = {
				factor = 0.5
				is_councillor = yes
				NOT = { any_liege = { is_heretic = yes } }
			}
			modifier = {
				factor = 2
				trait = cynical
			}
			modifier = {
				factor = 1.5
				trait = just
			}
			modifier = {
				factor = 1.5
				trait = wroth
			}
			modifier = {
				factor = 0.75
				trait = arbitrary
			}
			modifier = {
				factor = 0.75
				trait = trusting
			}
			modifier = {
				factor = 0.75
				trait = patient
			}
			modifier = {
				factor = 0.5
				trait = content
			}
			modifier = {
				factor = 0.5
				trait = craven
			}
			modifier = {
				factor = 0.5
				trait = slothful
			}
		}
		if = {
			limit = { NOT = { trait = cynical } }
			random = {
				chance = 50
				add_trait = zealous
			}
		}
		if = {
			limit = { trait = cynical }
			remove_trait = cynical
		}
		if = {
			limit = { higher_tier_than = BARON }
			religion_authority = {
				modifier = ruler_converted_from
			}
		}
		religion = fraticelli
		add_character_modifier = { name = recently_converted duration = 730}
		if = {
			limit = { higher_tier_than = BARON }
			hidden_tooltip = {
				religion_authority = {
					modifier = ruler_converted_to
				}
			}
		}
		piety = 100
	}
	option = {
		name = EVTOPTB_Plus_2027
		ai_chance = {
			factor = 75
		}
	}
}

### WALDENSIAN EVENTS

# The Poor of Lyons appear
narrative_event = {
	id = Plus.2030
	title = EVTTITLE_Plus_2030
	desc = EVTDESC_Plus_2030
	picture = GFX_evt_heretic
	border = GFX_event_narrative_frame_religion
	
	is_triggered_only = yes
	major = yes

	only_playable = yes
	religion = catholic
	
	trigger = {
		war = no
		year = 1150
		has_landed_title = c_lyon
		227 = { religion = catholic }
		NOR = {
			any_independent_ruler = { religion = waldensian }
			religion_authority = 0.80
			has_global_flag = poor_lyons
		}
	}
	
	major_trigger = {
		OR = {
			has_landed_title = c_lyon
			has_landed_title = d_susa
			religion = waldensian
			capital_scope = {
				NOT = {
					distance = {
						where = 227 # Lyons
						value = 600	# Same part of the world
					}
				}
			}
		}
	}

	option = {
		name = EVTOPTA_Plus_2030
		trigger = {
			has_landed_title = c_lyon
		}
		set_global_flag = poor_lyons
		piety = -100
		227 = { #Lyons
			religion = waldensian
			add_province_modifier = {
				name = heretic_stronghold
				duration = 3650
			}
			hidden_tooltip = {
				ROOT = {
					create_character = {
						name = "Pierre"
						random_traits = yes
						dynasty = 1000124391 #Valdes
						religion = waldensian
						culture = PREV
						female = no
						age = 40
						trait = grey_eminence
						trait = possessed
						trait = zealous
						trait = gregarious
						trait = charitable
						trait = humble
						trait = novellani
						attributes = {
							learning = 5
							diplomacy = 5
						}
					}
					new_character = {
						add_character_modifier = {
							name = voice_of_jesus
							duration = -1
						}
					}
				}
			}
		}
		hidden_tooltip = {
			d_susa = {
				holder_scope = {
					random_realm_province = {
						limit = {
							duchy = { title = d_susa }
							religion = catholic
						}
						religion = waldensian
						add_province_modifier = {
							name = heretic_stronghold
							duration = 3650
						}
					}
				}
			}
		}
	}
	option = {
		name = EVTOPTB_Plus_2030
		trigger = {
			NOT = { has_landed_title = c_lyon }
			religion = catholic
		}
	}
	option = {
		name = EVTOPTC_Plus_2030
		trigger = {
			NOT = { has_landed_title = c_lyon }
			NOT = { religion = catholic }
		}
	}
}

# Waldensian chooses their path (fired from decision)
character_event = { 
	id = Plus.2031
	desc = EVTDESC_Plus_2031
	picture = GFX_evt_heretic_pride
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_Plus_2031
		trigger = {
			OR = { 
				is_ruler = yes
				intrigue = 7
			}		
		}
		add_trait = sandaliati
	}
	option = {
		name = EVTOPTB_Plus_2031
		trigger = {
			OR = { 
				is_priest = yes
				learning = 9
			}		
		}
		add_trait = doctores
	}
	option = {
		name = EVTOPTC_Plus_2031
		trigger = {
			OR = {
				is_ruler = no
				tier = BARON
			}
		}
		add_trait = novellani
	}
}

# The first Waldensian king
character_event = { 
	id = Plus.2032
	desc = EVTDESC_Plus_2032
	picture = GFX_evt_heretic_pride
	border = GFX_event_normal_frame_religion
	
	only_independent = yes
	religion = waldensian
	min_age = 16
	capable_only = yes
	prisoner = no
	
	trigger = {
		higher_real_tier_than = DUKE
		piety = 200
		trait = charitable
		any_realm_province = { religion = waldensian }
		NOT = { has_global_flag = waldensian_king }
	}
	
	mean_time_to_happen = {
		years = 10
	}
	
	option = {
		name = EVTOPTA_Plus_2032
		set_global_flag = waldensian_king
		religion_authority = {
			modifier = wald_king
			years = 10
		}
	}
}

# Hospital removed from province if non-Waldensian
province_event = {
	id = Plus.2033
	
	hide_window = yes
	
	trigger = {
		has_province_modifier = wald_hospital
		owner = { NOT = { religion = waldensian } }
	}
	
	mean_time_to_happen = {
		months = 1
	}
	
	immediate = {
		remove_province_modifier = wald_hospital
	}
}

# Christian temple is sacked
character_event = { 
	id = Plus.2034
	desc = EVTDESC_Plus_2034
	picture = GFX_evt_siege
	border = GFX_event_normal_frame_war
	
	is_triggered_only = yes
	
	religion = waldensian
	
	trigger = {
		FROM = { 
			holding_type = temple
			NOT = { title = b_roma }
			OR = {
				NOT = { title = b_canterbury }
				NOT = { k_papal_state = { has_title_flag = schism_happened } }
			}
			OR = {
				NOT = { title = b_santiago }
				NOT = { k_papal_state = { has_title_flag = schism_happened } }
			}
			OR = {
				NOT = { title = b_koln }
				NOT = { k_papal_state = { has_title_flag = schism_happened } }
			}
			owner = {
				religion_group = christian
				NOT = { religion = waldensian }
			}
		}
	}
	
	option = {
		name = EVTOPTA_Plus_2034
		ai_chance = {
			factor = 75
			modifier = {
				factor = 0
				trait = greedy
			}
			modifier = {
				factor = 0.5
				trait = envious
			}
			modifier = {
				factor = 0.5
				trait = gluttonous
			}
			modifier = {
				factor = 0.5
				trait = humble
			}
			modifier = {
				factor = 0.5
				trait = cynical
			}
		}
		piety = 50
		if = {
			limit = { NOT = { trait = charitable } }
			random = {
				chance = 50
				add_trait = charitable
			}
		}
		FROM = {
			owner = {
				religion_authority = {
					modifier = relics_destroyed
					years = 5
				}
				piety = -100
			}
		}
		if = {
			limit = { is_ruler = no }
			liege = {
				random_realm_province = {
					limit = {
						religion = waldensian
						NOT = { has_province_modifier = wald_charity }
					}
					add_province_modifier = {
						name = wald_charity
						duration = 1000
					}
				}
			}
		}
		if = {
			limit = { is_ruler = yes }
			random_realm_province = {
				limit = {
					religion = waldensian
					NOT = { has_province_modifier = wald_charity }
				}
				add_province_modifier = {
					name = wald_charity
					duration = 1000
				}
			}
		}
	}
	option = {
		name = EVTOPTB_Plus_2034
		ai_chance = {
			factor = 25
			modifier = {
				factor = 0
				trait = charitable
			}
			modifier = {
				factor = 0.5
				trait = temperate
			}
			modifier = {
				factor = 0.5
				trait = proud
			}
			modifier = {
				factor = 0.5
				trait = zealous
			}
		}
		piety = -50
		wealth = 50
		if = {
			limit = { NOT = { trait = greedy } }
			random = {
				chance = 50
				add_trait = greedy
			}
		}
		FROM = {
			owner = {
				religion_authority = {
					modifier = relics_destroyed
					years = 5
				}
				piety = -100
			}
		}
	}
}

# Christian holy site is sacked
character_event = {
	id = Plus.2035
	picture = GFX_evt_heresy_defeated
	border = GFX_event_normal_frame_war
	
	desc = {
		text = EVTDESC_Plus_2035_rome
		trigger = {
			FROM = { title = b_roma }
		}
	}
	desc = {
		text = EVTDESC_Plus_2035_canterbury
		trigger = {
			FROM = { title = b_canterbury }
		}
	}
	desc = {
		text = EVTDESC_Plus_2035_santiago
		trigger = {
			FROM = { title = b_santiago }
		}
	}
	desc = {
		text = EVTDESC_Plus_2035_koln
		trigger = {
			FROM = { title = b_koln }
		}
	}
	
	is_triggered_only = yes
	
	religion = waldensian
	
	trigger = {
		OR = {
			AND = {
				FROM = { title = b_roma }
				NOT = { has_global_flag = wald_roma }
			}
			AND = {
				FROM = { title = b_canterbury }
				NOT = { has_global_flag = wald_canterbury }
				k_papal_state = { has_title_flag = schism_happened }
			}
			AND = {
				FROM = { title = b_santiago }
				NOT = { has_global_flag = wald_santiago }
				k_papal_state = { has_title_flag = schism_happened }
			}
			AND = {
				FROM = { title = b_koln }
				NOT = { has_global_flag = wald_koln }
				k_papal_state = { has_title_flag = schism_happened }
			}
		}
		FROM = {
			owner = {
				religion_group = christian
				NOT = { religion = waldensian }
			}
		}
	}
	
	option = {
		name = EVTOPTA_Plus_2035
		if = {
			limit = { is_ruler = yes }
			piety = 200
		}
		if = {
			limit = { is_ruler = no }
			piety = 100
			liege = { piety = 100 }
		}
		if = {
			limit = { FROM = { title = b_roma } }
			set_global_flag = wald_roma
		}
		if = {
			limit = { FROM = { title = b_canterbury } }
			set_global_flag = wald_canterbury
		}
		if = {
			limit = { FROM = { title = b_santiago } }
			set_global_flag = wald_santiago
		}
		if = {
			limit = { FROM = { title = b_koln } }
			set_global_flag = wald_koln
		}
		FROM = {
			owner = {
				religion_authority = {
					modifier = wald_sack
					years = 10
				}
				piety = -300
				hidden_tooltip = { narrative_event = { id = Plus.2036 days = 1 } }
			}
		}
		if = {
			limit = { has_nickname = no }
			give_nickname = nick_the_defiler
		}
		if = {
			limit = { is_ruler = no }
			liege = {
				random_realm_province = {
					limit = {
						religion = waldensian
						NOT = { has_province_modifier = wald_charity }
					}
					add_province_modifier = {
						name = wald_charity
						duration = 1000
					}
				}
			}
		}
		if = {
			limit = { is_ruler = yes }
			random_realm_province = {
				limit = {
					religion = waldensian
					NOT = { has_province_modifier = wald_charity }
				}
				add_province_modifier = {
					name = wald_charity
					duration = 1000
				}
			}
		}		
	}
}

# Christians informed that holy site was sacked
narrative_event = {
	id = Plus.2036
	title = EVTNAME_Plus_2036
	picture = GFX_evt_heresy_defeated
	border = GFX_event_narrative_frame_war
	
	desc = {
		text = EVTDESC_Plus_2036_rome
		trigger = {
			FROMFROM = { title = b_roma }
		}
	}
	desc = {
		text = EVTDESC_Plus_2036_canterbury
		trigger = {
			FROMFROM = { title = b_canterbury }
		}
	}
	desc = {
		text = EVTDESC_Plus_2036_santiago
		trigger = {
			FROMFROM = { title = b_santiago }
		}
	}
	desc = {
		text = EVTDESC_Plus_2036_koln
		trigger = {
			FROMFROM = { title = b_koln }
		}
	}
	
	major = yes
	is_triggered_only = yes
	
	major_trigger = {
		religion_group = christian
	}
	
	option = {
		name = EVTOPTA_Plus_2036
		trigger = { NOT = { religion = waldensian } }
	}
	option = {
		name = EVTOPTB_Plus_2036
		trigger = { religion = waldensian }
	}
}

# Refugees arrive at a Waldensian ruler's capital
character_event = { 
	id = Plus.2037
	desc = EVTDESC_Plus_2037
	picture = GFX_evt_pilgrims_epic_journey
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	only_rulers = yes
	religion = waldensian
	
	trigger = {
		war = yes
		demesne_size = 1
		OR = {
			NOT = { has_character_flag = wald_refugees }
			had_character_flag = { flag = wald_refugees days = 3650 }
		}
	}
	
	weight_multiplier = {
		days = 1
	}
	
	option = {
		name = EVTOPTA_Plus_2037
		set_character_flag = wald_refugees
		piety = 50
		scaled_wealth = -0.4
		if = {
			limit = { trait = greedy }
			remove_trait = greedy
		}
		if = {
			limit = {
				NOT = { trait = charitable }
				NOT = { trait = greedy }
			}
			random = {
				chance = 75
				add_trait = charitable
			}
		}
	}
	option = {
		name = EVTOPTB_Plus_2037
		set_character_flag = wald_refugees
		piety = -50
		if = {
			limit = { trait = charitable }
			remove_trait = charitable
		}
		if = {
			limit = {
				NOT = { trait = greedy }
				NOT = { trait = charitable }
			}
			random = {
				chance = 40
				add_trait = greedy
			}
		}
	}
}

# Waldensian ruler is greedy
character_event = { 
	id = Plus.2038
	desc = EVTDESC_Plus_2038
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	only_rulers = yes
	religion = waldensian
	
	trigger = {
		trait = greedy
		NOT = { has_character_modifier = the_greedy }
	}
	
	weight_multiplier = {
		days = 1
	}
	
	option = {
		name = EVTOPTA_Plus_2038
		piety = -50
		add_character_modifier = {
			name = the_greedy
			duration = 730
		}
	}
}

# Charitable Waldensian sees opportunity to help the poor
character_event = { 
	id = Plus.2039
	desc = EVTDESC_Plus_2039
	picture = GFX_evt_busy_trading_dock_republic
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	only_rulers = yes
	religion = waldensian
	
	trigger = {
		war = no
		trait = charitable
		OR = {
			trait = fortune_builder
			trait = thrifty_clerk
			trait = indulgent_wastrel
		}
		NOT = { has_character_flag = wald_steward }
	}
	
	weight_multiplier = {
		days = 1
	}
	
	option = {
		name = EVTOPTA_Plus_2039
		set_character_flag = wald_steward
		scaled_wealth = -0.5
		if = {
			limit = { trait = fortune_builder }
			remove_trait = fortune_builder
			add_trait = midas_touched
		}
		if = {
			limit = { trait = thrifty_clerk }
			remove_trait = thrifty_clerk
			add_trait = fortune_builder
		}
		if = {
			limit = { trait = indulgent_wastrel }
			remove_trait = indulgent_wastrel
			add_trait = thrifty_clerk
		}
	}
	option = {
		name = EVTOPTB_Plus_2039
		set_character_flag = wald_steward
		piety = -20
	}
}

# Waldensian child learns charity
character_event = {
	id = Plus.2040
	desc = EVTDESC_Plus_2040
	picture = GFX_evt_child_talking
	
	is_triggered_only = yes
	
	religion = waldensian
	min_age = 6
	max_age = 16

	trigger = {
		NOT = { personality_traits = 5 }
		NOT = { trait = charitable }
		NOT = { trait = greedy }
		educator = { always = yes }
	}
	
	weight_multiplier = {
		days = 1
		modifier = {
			factor = 0.1
			educator = { trait = greedy }
		}
		modifier = {
			factor = 2.0
			educator = { trait = charitable }
		}
	}	
	
	option = {
		name = EVTOPTA_Plus_2040
		add_trait = charitable
		hidden_tooltip = {
			educator = {
				character_event = {
					id = 2030
					days = 3
				}
			}
		}
	}
}

### MESSALIAN EVENTS

# Attempting to drive out the demons
character_event = {
	id = Plus.2041
	desc = EVTDESC_Plus_2041
	picture = GFX_evt_ritual_scroll
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_Plus_2041
		set_character_flag = messalian_praying
		hidden_tooltip = {
			random_list = {
				10 = {
					modifier = {
						factor = 0
						NOR = {
							trait = lustful
							trait = hedonist
						}
					}
					set_character_flag = driving_out_lust
					character_event = { id = Plus.2045 days = 600 random = 400 } # check for success
					if = {
						limit = { NOT = { trait = homosexual } }
						random = {
							chance = 75
							character_event = { id = Plus.2046 days = 300 random = 200 } # Lustful temptation
						}
					}
					if = {
						limit = { trait = homosexual }
						random = {
							chance = 75
							character_event = { id = Plus.2047 days = 300 random = 200 } # Homosexual temptation
						}
					}
				}
				10 = {
					modifier = {
						factor = 0
						NOT = { trait = gluttonous }
					}
					set_character_flag = driving_out_gluttony
					character_event = { id = Plus.2045 days = 600 random = 400 } # check for success
					random = {
						chance = 75
						character_event = { id = Plus.2048 days = 300 random = 200 } # Gluttonous temptation
					}
				}
				10 = {
					modifier = {
						factor = 0
						NOT = { trait = greedy }
					}
					set_character_flag = driving_out_greed
					character_event = { id = Plus.2045 days = 600 random = 400 } # check for success
					random = {
						chance = 75
						character_event = { id = Plus.2049 days = 300 random = 200 } # Greed temptation
					}
				}
				10 = {
					modifier = {
						factor = 0
						NOT = { trait = slothful }
					}
					set_character_flag = driving_out_sloth
					character_event = { id = Plus.2045 days = 600 random = 400 } # check for success
					random = {
						chance = 75
						character_event = { id = Plus.2050 days = 300 random = 200 } # Slothful temptation
					}
				}
				10 = {
					modifier = {
						factor = 0
						NOT = { trait = wroth }
					}
					set_character_flag = driving_out_wrath
					character_event = { id = Plus.2045 days = 600 random = 400 } # check for success
					random = {
						chance = 75
						character_event = { id = Plus.2051 days = 300 random = 200 } # Wrathful temptation
					}
				}
				10 = {
					modifier = {
						factor = 0
						NOT = { trait = envious }
					}
					set_character_flag = driving_out_envy
					character_event = { id = Plus.2045 days = 600 random = 400 } # check for success
					random = {
						chance = 75
						character_event = { id = Plus.2052 days = 300 random = 200 } # Envious temptation
					}
				}
				10 = {
					modifier = {
						factor = 0
						NOT = { trait = proud }
					}
					set_character_flag = driving_out_pride
					character_event = { id = Plus.2045 days = 600 random = 400 } # check for success
					random = {
						chance = 75
						character_event = { id = Plus.2053 days = 300 random = 200 } # Pride temptation
					}
				}
				10 = {
					modifier = {
						factor = 0
						NOT = { trait = cruel }
					}
					set_character_flag = driving_out_cruelty
					character_event = { id = Plus.2045 days = 600 random = 400 } # check for success
					random = {
						chance = 75
						character_event = { id = Plus.2054 days = 300 random = 200 } # Cruelty temptation
					}
				}
				10 = {
					modifier = {
						factor = 0
						NOT = { trait = possessed }
					}
					set_character_flag = driving_out_possession
					character_event = { id = Plus.2045 days = 600 random = 400 } # check for success
				}
				10 = {
					modifier = {
						factor = 0
						NOT = { trait = lunatic }
					}
					set_character_flag = driving_out_lunacy
					character_event = { id = Plus.2045 days = 600 random = 400 } # check for success
				}
			}
		}
	}
}

# Failed to drive out the demons
character_event = {
	id = Plus.2042
	desc = EVTDESC_Plus_2042
	picture = GFX_evt_messalian_sin
	border = GFX_event_normal_frame_religion
	
	desc = {
		text = EVTDESC_Plus_2042
		trigger = {
			NOR = {
				has_character_flag = driving_out_lunacy
				has_character_flag = driving_out_possession
			}
		}
	}
	desc = {
		text = EVTDESC_Plus_2042_lunacy
		trigger = { has_character_flag = driving_out_lunacy }
	}
	desc = {
		text = EVTDESC_Plus_2042_possession
		trigger = { has_character_flag = driving_out_possession }
	}

	is_triggered_only = yes
	
	trigger = { has_character_modifier = messalian_prayer }

	option = {
		name = EVTOPTA_Plus_2042
		prestige = -50
		piety = -50
		clr_character_flag = messalian_praying
		remove_character_modifier = messalian_prayer
		if = {
			limit = { has_character_flag = driving_out_lust }
			add_trait = lustful
		}
		if = {
			limit = { has_character_flag = driving_out_gluttony }
			add_trait = gluttonous
		}
		if = {
			limit = { has_character_flag = driving_out_greed }
			add_trait = greedy
		}
		if = {
			limit = { has_character_flag = driving_out_sloth }
			add_trait = slothful
		}
		if = {
			limit = { has_character_flag = driving_out_wrath }
			add_trait = wroth
		}
		if = {
			limit = { has_character_flag = driving_out_envy }
			add_trait = envious
		}
		if = {
			limit = { has_character_flag = driving_out_pride }
			add_trait = proud
		}
		if = {
			limit = { has_character_flag = driving_out_cruelty }
			add_trait = cruel
		}
		if = {
			limit = { has_character_flag = driving_out_possession }
			add_trait = possessed
			add_character_modifier = {
				name = voice_of_satan
				duration = -1
			}
		}
		if = {
			limit = { has_character_flag = driving_out_lunacy }
			add_trait = lunatic
		}
		clr_character_flag = driving_out_lust
		clr_character_flag = driving_out_gluttony
		clr_character_flag = driving_out_greed
		clr_character_flag = driving_out_sloth
		clr_character_flag = driving_out_wrath
		clr_character_flag = driving_out_envy
		clr_character_flag = driving_out_pride
		clr_character_flag = driving_out_cruelty
		clr_character_flag = driving_out_possession
		clr_character_flag = driving_out_lunacy
		clr_character_flag = messalian_temptation
		random = {
			chance = 25
			add_trait = depressed
		}
		add_character_modifier = {
			name = messalian_prayer_timer
			duration = 1095
			hidden = yes
		}
	}
}

# Succeeded in driving out a demon
character_event = {
	id = Plus.2043
	picture = GFX_evt_messalian_sin
	border = GFX_event_normal_frame_religion
	
	desc = {
		text = EVTDESC_Plus_2043_lust
		trigger = { has_character_flag = driving_out_lust }
	}
	desc = {
		text = EVTDESC_Plus_2043_gluttony
		trigger = { has_character_flag = driving_out_gluttony }
	}
	desc = {
		text = EVTDESC_Plus_2043_greed
		trigger = { has_character_flag = driving_out_greed }
	}
	desc = {
		text = EVTDESC_Plus_2043_sloth
		trigger = { has_character_flag = driving_out_sloth }
	}
	desc = {
		text = EVTDESC_Plus_2043_wrath
		trigger = { has_character_flag = driving_out_wrath }
	}
	desc = {
		text = EVTDESC_Plus_2043_envy
		trigger = { has_character_flag = driving_out_envy }
	}
	desc = {
		text = EVTDESC_Plus_2043_pride
		trigger = { has_character_flag = driving_out_pride }
	}
	desc = {
		text = EVTDESC_Plus_2043_cruelty
		trigger = { has_character_flag = driving_out_cruelty }
	}
	desc = {
		text = EVTDESC_Plus_2043_possession
		trigger = { has_character_flag = driving_out_possession }
	}
	desc = {
		text = EVTDESC_Plus_2043_lunacy
		trigger = { has_character_flag = driving_out_lunacy }
	}

	is_triggered_only = yes
	
	trigger = { has_character_modifier = messalian_prayer }

	option = {
		name = EVTOPTA_Plus_2043
		prestige = 50
		piety = 50
		if = {
			limit = { has_character_flag = driving_out_lust }
			remove_trait = lustful
			remove_trait = hedonist
			random = {
				chance = 20
				add_trait = chaste
			}
		}
		if = {
			limit = { has_character_flag = driving_out_gluttony }
			remove_trait = gluttonous
			random = {
				chance = 20
				add_trait = temperate
			}
		}
		if = {
			limit = { has_character_flag = driving_out_greed }
			remove_trait = greedy
			random = {
				chance = 20
				add_trait = charitable
			}
		}
		if = {
			limit = { has_character_flag = driving_out_sloth }
			remove_trait = slothful
			random = {
				chance = 20
				add_trait = diligent
			}
		}
		if = {
			limit = { has_character_flag = driving_out_wrath }
			remove_trait = wroth
			random = {
				chance = 20
				add_trait = patient
			}
		}
		if = {
			limit = { has_character_flag = driving_out_envy }
			remove_trait = envious
			random = {
				chance = 20
				add_trait = kind
			}
		}
		if = {
			limit = { has_character_flag = driving_out_pride }
			remove_trait = proud
			random = {
				chance = 20
				add_trait = humble
			}
		}
		if = {
			limit = { has_character_flag = driving_out_cruelty }
			remove_trait = cruel
			random = {
				chance = 20
				add_trait = kind
			}
		}
		if = {
			limit = { has_character_flag = driving_out_possession }
			remove_possessed_effect = yes
		}
		if = {
			limit = { has_character_flag = driving_out_lunacy }
			remove_trait = lunatic
		}
		clr_character_flag = driving_out_lust
		clr_character_flag = driving_out_gluttony
		clr_character_flag = driving_out_greed
		clr_character_flag = driving_out_sloth
		clr_character_flag = driving_out_wrath
		clr_character_flag = driving_out_envy
		clr_character_flag = driving_out_pride
		clr_character_flag = driving_out_cruelty
		clr_character_flag = driving_out_possession
		clr_character_flag = driving_out_lunacy
		clr_character_flag = messalian_temptation
		clr_character_flag = messalian_praying
		remove_character_modifier = messalian_prayer
	}
}

# Forced to abandon prayers
character_event = {
	id = Plus.2044
	picture = GFX_evt_ritual_scroll
	border = GFX_event_normal_frame_religion

	desc = {
		text = EVTDESC_Plus_2044_not_messalian
		trigger = { NOT = { religion = messalian } }
	}
	desc = {
		text = EVTDESC_Plus_2044_prisoner
		trigger = { prisoner = yes }
	}
	desc = {
		text = EVTDESC_Plus_2044_incapable
		trigger = { trait = incapable }
	}
	
	min_age = 16
	has_character_flag = messalian_praying
	
	trigger = {
		has_character_modifier = messalian_prayer
		OR = {
			NOT = { religion = messalian }
			prisoner = yes
			trait = incapable
		}
	}
	
	mean_time_to_happen = {
		days = 1
	}
	
	option = {
		name = OK
		remove_character_modifier = messalian_prayer
		clr_character_flag = driving_out_lust
		clr_character_flag = driving_out_gluttony
		clr_character_flag = driving_out_greed
		clr_character_flag = driving_out_sloth
		clr_character_flag = driving_out_wrath
		clr_character_flag = driving_out_envy
		clr_character_flag = driving_out_pride
		clr_character_flag = driving_out_cruelty
		clr_character_flag = driving_out_possession
		clr_character_flag = driving_out_lunacy
		clr_character_flag = messalian_temptation
		clr_character_flag = messalian_praying
		add_character_modifier = {
			name = messalian_prayer_timer
			duration = 1095
			hidden = yes
		}
	}
}

# Bounce event to determine success
character_event = {
	id = Plus.2045
	
	hide_window = yes
	is_triggered_only = yes
	
	trigger = { has_character_modifier = messalian_prayer }
	
	immediate = {
		random_list = {
			60 = {
				modifier = {
					factor = 0.25
					has_character_flag = messalian_temptation
				}
				modifier = {
					factor = 0.15
					OR = {
						has_character_flag = driving_out_possession
						has_character_flag = driving_out_lunacy
					}
				}
				character_event = { id = Plus.2043 } #Success
			}
			40 = {
				modifier = {
					factor = 2.125
					has_character_flag = messalian_temptation
				}
				modifier = {
					factor = 2.25
					OR = {
						has_character_flag = driving_out_possession
						has_character_flag = driving_out_lunacy
					}
				}
				character_event = { id = Plus.2042 } #Failure
			}
		}
	}
}

# Praying character receives lustful temptation
character_event = {
	id = Plus.2046
	desc = EVTDESC_Plus_2046
	picture = GFX_evt_lovers
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_Plus_2046 #I will surround myself only with those of my gender!
		any_lover = {
			tooltip = { remove_lover = ROOT }
			hidden_tooltip = { character_event = { id = WoL.1103 } }
		}
		hidden_tooltip = {
			character_event = { id = Plus.2047 days = 10 random = 20 }
		}
	}
	option = {
		name = EVTOPTB_Plus_2046 #I cannot resist the temptation
		set_character_flag = messalian_temptation
		piety = -25
	}
}

# Praying character receives homosexual temptation
character_event = {
	id = Plus.2047
	picture = GFX_evt_lovers
	border = GFX_event_normal_frame_religion
	
	desc = {
		text = EVTDESC_Plus_2047_male
		trigger = { is_female = no }
	}
	desc = {
		text = EVTDESC_Plus_2047_female
		trigger = { is_female = yes }
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_Plus_2047 #I must resist!
		trigger = { piety = 50 }
		any_lover = {
			tooltip = { remove_lover = ROOT }
			hidden_tooltip = { character_event = { id = WoL.1103 } }
		}
		piety = -50
	}
	option = {
		name = EVTOPTB_Plus_2047 #I have no choice but to give in
		set_character_flag = messalian_temptation
		if = {
			limit = { NOT = { trait = homosexual } }
			add_trait = homosexual
		}
	}
}

# Praying character receives gluttonous temptation
character_event = {
	id = Plus.2048
	desc = EVTDESC_Plus_2048
	picture = GFX_evt_knight_kneeling
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_Plus_2048 #I cannot surrender to the sins of the flesh!
		trigger = {
			piety = 50
		}
		piety = -50
		health = -1
	}
	option = {
		name = EVTOPTB_Plus_2047 #I have no choice but to give in
		set_character_flag = messalian_temptation
	}
}

# Praying character receives greed temptation
character_event = {
	id = Plus.2049
	desc = EVTDESC_Plus_2049
	picture = GFX_evt_knight_kneeling
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_Plus_2049 #No, gambling is sinful and greedy
		trigger = {
			piety = 50
		}
		piety = -50
	}
	option = {
		name = EVTOPTB_Plus_2049 #Perhaps just a few games won't hurt...
		set_character_flag = messalian_temptation
		scaled_wealth = 0.1
	}
}

# Praying character receives slothful temptation
character_event = {
	id = Plus.2050
	desc = EVTDESC_Plus_2050
	picture = GFX_evt_knight_kneeling
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_Plus_2050 #I will make a determined effort
		trigger = {
			NOT = { trait = content }
			OR = {
				piety = 50
				NOT = { trait = stressed }
			}
		}
		if = {
			limit = { trait = stressed }
			piety = -50
		}
		if = {
			limit = { NOT = { trait = stressed } }
			add_trait = stressed
		}
	}
	option = {
		name = EVTOPTB_Plus_2050 #Prayers can wait until tomorrow
		set_character_flag = messalian_temptation
		if = {
			limit = { NOT = { trait = content } }
			random = {
				chance = 30
				add_trait = content
			}
		}
	}
}

# Praying character receives wrathful temptation
character_event = {
	id = Plus.2051
	desc = EVTDESC_Plus_2051
	picture = GFX_evt_knight_kneeling
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_Plus_2051 #Slowly count to ten...
		trigger = {
			piety = 50
		}
		piety = -50
		prestige = -50
	}
	option = {
		name = EVTOPTB_Plus_2051 #Have that hat nailed to his head
		set_character_flag = messalian_temptation
		prestige = 50
	}
}

# Praying character receives envious temptation
character_event = {
	id = Plus.2052
	desc = EVTDESC_Plus_2052
	picture = GFX_evt_knight_kneeling
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_Plus_2052 #I can do without it
		trigger = {
			piety = 50
		}
		piety = -50
		if = {
			limit = { trait = ambitious }
			random = {
				chance = 50
				remove_trait = ambitious
			}
		}
	}
	option = {
		name = EVTOPTB_Plus_2052 #I will take it for myself
		set_character_flag = messalian_temptation
		prestige = 50
		if = {
			limit = { NOT = { trait = ambitious } }
			random = {
				chance = 50
				add_trait = ambitious
			}
		}
	}
}

# Praying character receives pride temptation
character_event = {
	id = Plus.2053
	desc = EVTDESC_Plus_2053
	picture = GFX_evt_knight_kneeling
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_Plus_2053 #Humbly ask him for help
		trigger = {
			piety = 50
		}
		prestige = -50
		piety = -50
	}
	option = {
		name = EVTOPTB_Plus_2053 #No, that's ridiculous! What could he do?
		set_character_flag = messalian_temptation
		prestige = 50
	}
}

# Praying character receives cruelty temptation
character_event = {
	id = Plus.2054
	desc = EVTDESC_Plus_2054
	picture = GFX_evt_knight_kneeling
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_Plus_2054 #Let him go free
		trigger = {
			piety = 50
		}
		prestige = -50 
		piety = -50
		if = {
			limit = { NOT = { trait = arbitrary } }
			random = {
				chance = 30
				add_trait = arbitrary
			}
		}
	}
	option = {
		name = EVTOPTB_Plus_2054 #Hang him as he deserves!
		set_character_flag = messalian_temptation
		prestige = 50
	}
}

# Messalian chooses a patron saint
character_event = {
	id = Plus.2055
	desc = EVTDESC_Plus_2055
	picture = GFX_evt_knight_kneeling
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_Plus_2055
		add_character_modifier = {
			name = patron_nestor
			duration = -1
		}
	}
	option = {
		name = EVTOPTB_Plus_2055
		add_character_modifier = {
			name = patron_addai
			duration = -1
		}
	}
	option = {
		name = EVTOPTC_Plus_2055
		add_character_modifier = {
			name = patron_lucifer
			duration = -1
		}
	}
	option = {
		name = EVTOPTD_Plus_2055
		add_character_modifier = {
			name = patron_adelphius 
			duration = -1
		}
	}
}

# Joining the Cult of Lucifer
character_event = { 
	id = Plus.2056
	desc = EVTDESC_Plus_2056
	picture = GFX_evt_cult_initiation
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_Plus_2056
		add_trait = cult_of_lucifer
	}
}

# The Army of Lucifer founded
narrative_event = {
	id = Plus.2057
	title = EVTNAME_Plus_2057
	desc = EVTDESC_Plus_2057
	picture = GFX_evt_crusaders
	border = GFX_event_narrative_frame_war
	
	is_triggered_only = yes
	major = yes
	hide_from = yes
	
	option = {
		name = EVTOPTA_Plus_2057
		trigger = {
			religion = manichean
		}
	}
	option = {
		name = I_SEE
		trigger = {
			NOT = { religion = manichean }
		}
	}
}

# Ping event when donating money to the Army of Light
character_event = {
	id = Plus.2058
	
	hide_window = yes
	is_triggered_only = yes
	
	immediate = {
		wealth = 300
		FROM = {
			letter_event = {
				id = Plus.2059
			}
		}
		opinion = {
			who = FROM
			modifier = opinion_generous_donation
		}
	}
}

# Notification event when donating money to the Army of Light
letter_event = {
	id = Plus.2059
	desc = EVTDESC_Plus_2059
	border = GFX_event_letter_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EXCELLENT
	}
}

# Ping event when expelling the Army of Light
character_event = {
	id = Plus.2060
	
	hide_window = yes
	is_triggered_only = yes
	
	immediate = {
		random_demesne_title = {
			limit = { holy_order = yes }
			save_event_target_as = holy_order_name
		}
		any_title_under = {
			limit = {
				tier = BARON
				location = {
					owner = {
						OR = {
							character = FROM
							is_liege_or_above = FROM
						}
					}
				}
			}
			usurp_title = FROM
		}
		if = {
			limit = { is_liege_or_above = FROM }
			set_defacto_liege = THIS
		}
		FROM = {
			letter_event = {
				id = Plus.2061
			}
		}
		opinion = {
			who = FROM
			modifier = opinion_expelled_from_realm
		}
	}
}

# Notification event when expelling the Army of Light
letter_event = {
	id = Plus.2061
	desc = EVTDESC_Plus_2061
	border = GFX_event_letter_frame_religion
	
	is_triggered_only = yes
	
	immediate = {
		remove_character_modifier = donated_to_holy_order
	}
	
	option = {
		name = EVTOPTB_SOA_1061
	}
}

### MONK/NUN EVENTS

# Adult christian asks to become a monk/nun
letter_event = {
	id = Plus.2062
	border = GFX_event_letter_frame_religion
	
	desc = {
		text = EVTDESC_Plus_2062_male
		trigger = { FROM = { is_female = no } }
	}
	desc = {
		text = EVTDESC_Plus_2062_female
		trigger = { FROM = { is_female = yes } }
	}
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_SoA_5218
		FROM = {
			any_spouse = { remove_spouse = PREV }
			if = {
				limit = { is_female = no }
				change_learning = 1
				add_trait = monk
				hidden_tooltip = {
					set_character_flag = title_monk
					set_special_character_title = MONK_BROTHER
				}
			}
			if = {
				limit = { is_female = yes }
				change_learning = 1
				add_trait = nun
				hidden_tooltip = {
					set_character_flag = title_nun
					set_special_character_title = NUN_SISTER
				}
			}
			opinion = {
				modifier = opinion_grateful
				who = ROOT
				years = 100
			}
		}
	}
	option = {
		name = EVTOPTB_SoA_5218
		FROM = {
			random_list = {
				50 = { add_trait = stressed }
				50 = { add_trait = depressed }
				20 = { add_trait = cynical }
			}
			set_character_flag = monk_refused
			opinion = {
				modifier = opinion_angry
				who = ROOT
				years = 10
			}
		}
	}
}

### MIAPHYSITE EVENTS

# Birth of the Order of Saint Blaise
narrative_event = {
	id = Plus.2063
	title = EVTNAME_Plus_2063
	desc = EVTDESC_Plus_2063
	picture = GFX_evt_knight_kneeling
	
	major = yes
	only_playable = yes
	religion_group = christian
	hide_from = yes
	
	trigger = {
		OR = {
			religion = apostolic
			religion = paulician
			religion = tondrakian
		}
		is_heretic = no
		NOT = { is_title_active = d_saint_blaise }
		has_global_flag = christian_crusades_unlocked
		OR = {
			year = 1191	# Historical
			672 = { # Dwin
				NOT = { owner = { religion_group = christian } }
			}
			k_jerusalem = {
				holder_scope = { religion_group = christian }
			}
		}
	}
	
	mean_time_to_happen = {
		months = 36
		modifier = {
			factor = 10
			k_jerusalem = {
				holder_scope = { religion_group = christian }
			}
		}
	}
	
	immediate = {
		activate_title = { title = d_saint_blaise status = yes }
		create_character = {
			random_traits = yes
			dynasty = random
			religion = ROOT
			culture = armenian
			female = no
			age = 35
		}
		new_character = {
			wealth = 500
			d_saint_blaise = {
				grant_title = PREV
			}
			create_random_soldier = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = armenian
				female = no
				age = 16
			}
			create_random_soldier = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = armenian
				female = no
				age = 18
			}
			create_random_soldier = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = armenian
				female = no
				age = 18
			}
			create_random_soldier = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = armenian
				female = no
				age = 20
			}
			create_random_priest = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = armenian
				female = no
				age = 25
			}
			create_random_priest = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = armenian
				female = no
				age = 26
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = coptic
				female = no
				age = 28
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = armenian
				female = yes
				age = 25
			}
		}
	}
	
	option = {
		name = EVTOPTA_Plus_2063
		trigger = {
			religion_group = christian
		}
	}
	option = {
		name = EVTOPTB39100
		trigger = {
			NOT = { religion_group = christian }
		}
	}
}

# Birth of the Order of Saint Mark
narrative_event = {
	id = Plus.2064
	title = EVTNAME_Plus_2064
	desc = EVTDESC_Plus_2064
	picture = GFX_evt_knight_kneeling
	
	major = yes
	hide_from = yes
	
	is_triggered_only = yes
	
	immediate = {
		create_character = {
			random_traits = yes
			dynasty = random
			religion = ROOT
			culture = ROOT
			female = no
			age = 35
		}
		new_character = {
			wealth = 500
			d_knights_saint_mark = {
				grant_title = PREV
			}
			create_random_soldier = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = ROOT
				female = no
				age = 16
			}
			create_random_soldier = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = ROOT
				female = no
				age = 18
			}
			create_random_soldier = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = ROOT
				female = no
				age = 18
			}
			create_random_soldier = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = ROOT
				female = no
				age = 20
			}
			create_random_priest = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = ROOT
				female = no
				age = 25
			}
			create_random_priest = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = ROOT
				female = no
				age = 26
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = ROOT
				female = no
				age = 28
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = ROOT
				female = yes
				age = 16
			}
		}
	}
	
	option = {
		name = EVTOPTA_Plus_2063
		trigger = {
			religion_group = ROOT
		}
	}
	option = {
		name = EVTOPTB39100
		trigger = {
			NOT = { religion_group = ROOT }
		}
	}
}

