﻿# List
#
# St_Saint.0001 # Someone who becomes a Saint : trigger by on_death
# St_Saint.0002 # Religious head hidden event
# St_Saint.0003 # Notify player that there is a new Saint
#
# St_Saint.1001 # The enemies found the tomb of Saint in the occupied land : trigger by on_siege_completion
# St_Saint.1002 # Notify holder of county that the tomb of Saint had been pillaged
#
# St_Saint.2001 # The pagans found the tomb of Saint in the occupied land : trigger by three_year_playable_pulse
# St_Saint.2002 # Reconstruct the Tomb of Saint of Christianity : trigger by three_year_playable_pulse


namespace = St_Saint


# Someone who becomes a Saint : trigger by on_death
St_Saint.0001 = {
	type = character_event
	hidden = yes

	trigger = {
		is_adult = yes
		is_landed = yes
		faith = {
			exists = religious_head
			religious_head = { NOT = { this = root } }
			religion_tag = christianity_religion
		}
		OR = {
			AND = {
				highest_held_title_tier = tier_empire
				piety_level >= high_piety_level
			}
			AND = {
				highest_held_title_tier = tier_kingdom
				piety_level >= high_piety_level
			}
			AND = {
				highest_held_title_tier = tier_duchy
				piety_level >= medium_piety_level
			}
			AND = {
				highest_held_title_tier = tier_county
				piety_level >= low_piety_level
			}
			AND = {
				highest_held_title_tier = tier_county
				has_trait = zealous
			}
		}
		NOT = { faith = faith:waldensian }
		NOT = {
			has_trait = cynical
			has_trait = excommunicated
			has_trait = saint
		}
		NOT = {
			title:k_papal_state = {
				any_claimant = { this = root }
			}
		}
		num_sinful_traits < 1
		num_virtuous_traits >= 1
		Si_has_bad_traits_trigger = no
		Si_has_unsuitable_doctrine_traits_trigger = no
		Si_has_sin_traits_faith_trigger = no
		Si_has_virtue_traits_faith_trigger = yes
	}

	immediate = {
		save_scope_as = saint_person
		capital_county = { save_scope_as = saint_capital }
		faith.religious_head = {
			save_scope_as = saint_religious_head
			trigger_event = { id = St_Saint.0002 days = 1000 }
		}
	}
}

# Religious head hidden event
St_Saint.0002 = {
	type = character_event
	hidden = yes

	trigger = {
		scope:saint_religious_head = {
			is_alive = yes
			num_sinful_traits < 1
			Si_has_bad_traits_trigger = no
			Si_has_unsuitable_doctrine_traits_trigger = no
			Si_has_sin_traits_faith_trigger = no
		}
	}

	immediate = {
		scope:saint_person = {
			add_trait = saint
			give_nickname = nick_the_saint
			dynasty = {
				if = {
					limit = { dynasty_prestige_level < max_dynasty_prestige_level }
					add_dynasty_prestige_level = 1
				}
			}
		}
		scope:saint_capital = {
			remove_county_modifier = St_pillaged_tomb_of_saint_of_christianity_modifier
			add_county_modifier = { modifier = St_tomb_of_saint_of_christianity_modifier }
		}
		every_player = {
			limit = {
				OR = {
					dynasty = scope:saint_person.dynasty
					faith = scope:saint_person.faith
				}
			}
			trigger_event = St_Saint.0003
		}
	}
}

# Notify player that there is a new Saint
St_Saint.0003 = {
	type = character_event
	title = St_Saint.0003.title
	desc = St_Saint.0003.desc
	theme = faith
	left_portrait = scope:saint_person
	right_portrait = scope:saint_religious_head

	trigger = { is_ai = no }

	immediate = {
		show_as_tooltip = {
			scope:saint_person = {
				add_trait_force_tooltip = saint
				give_nickname = nick_the_saint
				dynasty = {
					if = {
						limit = { dynasty_prestige_level < max_dynasty_prestige_level }
						add_dynasty_prestige_level = 1
					}
				}
			}
			scope:saint_capital = {
				add_county_modifier = { modifier = St_tomb_of_saint_of_christianity_modifier }
			}
		}
	}

	option = {
		name = St_Saint.0003.a
	}
}

# The enemies found the tomb of Saint in the occupied land : trigger by on_siege_completion
St_Saint.1001 = {
	type = character_event
	title = St_Saint.1001.title
	desc = St_Saint.1001.desc
	theme = war
	left_portrait = root

	trigger = {
		scope:county.title_capital_county = {
			has_county_modifier = St_tomb_of_saint_of_christianity_modifier
		}
		NOT = { root.faith = { religion_tag = christianity_religion } }
	}

	immediate = {
		save_scope_as = occupant
	}

	option = {
		name = St_Saint.1001.a
		ai_chance = {
			base = 100
			modifier = {
				add = 100
				has_trait = greedy
			}
			modifier = {
				add = 50
				has_trait = brave
			}
			modifier = {
				add = 50
				has_trait = arbitrary
			}
			modifier = {
				add = 100
				has_trait = cynical
			}
			modifier = {
				add = 10000
				has_trait = zealous
			}
			modifier = {
				add = 100
				has_trait = trusting
			}
		}
		add_dread = 10
		add_gold = {
			add = scope:county.development_level
			multiply = 10
		}
		add_piety = 250
		scope:county.title_capital_county = {
			remove_county_modifier = St_tomb_of_saint_of_christianity_modifier
			add_county_modifier = { modifier = St_pillaged_tomb_of_saint_of_christianity_modifier }
		}
		stress_impact = {
			greedy = minor_stress_loss
			craven = medium_stress_gain
			cynical = minor_stress_loss
			zealous = monumental_stress_loss
			compassionate = minor_stress_gain
			devoted = monumental_stress_gain
		}
		scope:previous_controller = { trigger_event = St_Saint.1002 }
	}
	option = {
		name = St_Saint.1001.b
		ai_chance = {
			base = 10
			modifier = {
				add = 1000
				has_trait = temperate
			}
			modifier = {
				add = 1000
				has_trait = craven
			}
			modifier = {
				add = 1000
				has_trait = paranoid
			}
			modifier = {
				add = 1000
				has_trait = compassionate
			}
		}
		if = {
			limit = { has_trait = zealous }
			add_piety = -250
		}
		stress_impact = {
			greedy = minor_stress_gain
			cynical = minor_stress_gain
			zealous = monumental_stress_gain
			compassionate = minor_stress_loss
		}
	}
}

# Notify holder of county that the tomb of Saint had been pillaged
St_Saint.1002 = {
	type = character_event
	title = St_Saint.1002.title
	desc = St_Saint.1002.desc
	theme = war
	left_portrait = root
	right_portrait = scope:occupant

	trigger = { is_ai = no }

	immediate = {
		show_as_tooltip = {
			scope:county.title_capital_county = {
				remove_county_modifier = St_tomb_of_saint_of_christianity_modifier
				add_county_modifier = { modifier = St_pillaged_tomb_of_saint_of_christianity_modifier }
			}
		}
	}

	option = {
		name = St_Saint.1002.a
		trigger = {
			has_trait = zealous
			faith = { religion_tag = christianity_religion }
		}
		stress_impact = {
			wrathful = minor_stress_gain
			zealous = major_stress_gain
			compassionate = minor_stress_gain
			vengeful = major_stress_gain
		}
	}
	option = {
		name = St_Saint.1002.b
		trigger = {
			NOT = { has_trait = zealous }
			faith = { religion_tag = christianity_religion }
		}
		stress_impact = {
			greedy = minor_stress_gain
			just = medium_stress_gain
			compassionate = minor_stress_gain
			vengeful = major_stress_gain
		}
	}
	option = {
		name = St_Saint.1002.c
		trigger = {
			NOT = { faith = { religion_tag = christianity_religion } }
		}
		stress_impact = {
			greedy = minor_stress_gain
			compassionate = minor_stress_gain
		}
	}
}

# The pagans found the tomb of Saint in the occupied land : trigger by three_year_playable_pulse
St_Saint.2001 = {
	type = character_event
	title = St_Saint.2001.title
	desc = St_Saint.2001.desc
	theme = faith
	left_portrait = root

	trigger = {
		is_landed = yes
		highest_held_title_tier >= tier_county
		NOT = { faith = { religion_tag = christianity_religion } }
		any_held_county = {
			has_county_modifier = St_tomb_of_saint_of_christianity_modifier
		}
	}

	immediate = {
		random_held_county = {
			limit = { has_county_modifier = St_tomb_of_saint_of_christianity_modifier }
			save_scope_as = saint_county
		}
	}

	option = {
		name = St_Saint.2001.a
		ai_chance = {
			base = 100
			modifier = {
				add = 100
				has_trait = greedy
			}
			modifier = {
				add = 50
				has_trait = brave
			}
			modifier = {
				add = 50
				has_trait = arbitrary
			}
			modifier = {
				add = 100
				has_trait = cynical
			}
			modifier = {
				add = 10000
				has_trait = zealous
			}
			modifier = {
				add = 100
				has_trait = trusting
			}
		}
		add_dread = 10
		add_gold = {
			add = scope:saint_county.development_level
			multiply = 10
		}
		add_piety = 250
		scope:saint_county = {
			remove_county_modifier = St_tomb_of_saint_of_christianity_modifier
			add_county_modifier = { modifier = St_pillaged_tomb_of_saint_of_christianity_modifier }
		}
		stress_impact = {
			greedy = minor_stress_loss
			craven = medium_stress_gain
			cynical = minor_stress_loss
			zealous = monumental_stress_loss
			compassionate = minor_stress_gain
			devoted = monumental_stress_gain
		}
	}
	option = {
		name = St_Saint.2001.b
		ai_chance = {
			base = 10
			modifier = {
				add = 1000
				has_trait = temperate
			}
			modifier = {
				add = 1000
				has_trait = craven
			}
			modifier = {
				add = 1000
				has_trait = paranoid
			}
			modifier = {
				add = 1000
				has_trait = compassionate
			}
		}
		if = {
			limit = { has_trait = zealous }
			add_piety = -250
		}
		stress_impact = {
			greedy = minor_stress_gain
			cynical = minor_stress_gain
			zealous = monumental_stress_gain
			compassionate = minor_stress_loss
		}
	}
}

# Reconstruct the Tomb of Saint of Christianity : trigger by three_year_playable_pulse
St_Saint.2002 = {
	type = character_event
	title = St_Saint.2002.title
	desc = St_Saint.2002.desc
	theme = faith
	left_portrait = root

	trigger = {
		is_landed = yes
		highest_held_title_tier >= tier_county
		gold >= 100
		faith = { religion_tag = christianity_religion }
		any_held_county = {
			has_county_modifier = St_pillaged_tomb_of_saint_of_christianity_modifier
		}
	}

	immediate = {
		random_held_county = {
			limit = { has_county_modifier = St_pillaged_tomb_of_saint_of_christianity_modifier }
			save_scope_as = saint_county
		}
	}

	option = {
		name = St_Saint.2002.a
		ai_chance = {
			base = 100
			modifier = {
				add = 1000
				has_trait = theologian
			}
			modifier = {
				add = 100
				has_trait = generous
			}
			modifier = {
				add = 100
				has_trait = humble
			}
			modifier = {
				add = 10000
				has_trait = zealous
			}
			modifier = {
				add = 1000
				has_trait = compassionate
			}
		}
		add_dread = -10
		add_piety = 250
		remove_short_term_gold = 100
		scope:saint_county = {
			remove_county_modifier = St_pillaged_tomb_of_saint_of_christianity_modifier
			add_county_modifier = { modifier = St_tomb_of_saint_of_christianity_modifier }
		}
		stress_impact = {
			generous = minor_stress_loss
			greedy = minor_stress_gain
			cynical = medium_stress_gain
			zealous = monumental_stress_loss
			compassionate = minor_stress_loss
		}
	}
	option = {
		name = St_Saint.2002.b
		ai_chance = {
			base = 10
			modifier = {
				add = 100
				has_trait = greedy
			}
			modifier = {
				add = 1000
				has_trait = arrogant
			}
			modifier = {
				add = 10000
				has_trait = cynical
			}
			modifier = {
				add = 1000
				has_trait = callous
			}
		}
		if = {
			limit = { has_trait = zealous }
			add_piety = -250
		}
		stress_impact = {
			generous = medium_stress_gain
			arbitrary = medium_stress_loss
			zealous = monumental_stress_gain
			compassionate = medium_stress_gain
		}
	}
}
