﻿#Events for Mystics

namespace = mystic_lifestyle

### Successful communion message
mystic_lifestyle.0001 = {
	hidden = yes

	immediate = {
		send_interface_toast = {
			title = held_mystical_communion_title
			right_icon = root
			mystical_communion_outcome_effect = yes
		}
	}
}

#################################
# Mystical Communion Outcomes
# 1001 - 1999
#################################

scripted_trigger mystic_lifestyle_not_a_virtue = {
	faith = {
		NOT = { trait_is_virtue = lifestyle_mystic }
	}
}

### Your Court Chaplain disapproves
# by Petter Vilberg
mystic_lifestyle.1001 = {
	type = character_event
	title = mystic_lifestyle.1001.t
	desc = mystic_lifestyle.1001.desc
	theme = learning_theology_focus
	left_portrait = {
		character = scope:priest
		animation = personality_zealous
	}
	right_portrait = {
		character = scope:priest
		animation = disapproval
	}
	
	trigger = {
		mystic_lifestyle_not_a_virtue = yes
		OR = {
			AND = {
				exists = cp:councillor_court_chaplain
				cp:councillor_court_chaplain = {
					is_available = yes
					NOT = {
						has_trait = lifestyle_mystic
					}
				}
			}
			AND = {
				employs_court_position = camp_priest_camp_officer
				any_court_position_holder = {
					type = camp_priest_camp_officer	
					NOT = {
						has_trait = lifestyle_mystic
					}			
				}
			}
		}
	}

	immediate = {
		if = {
			limit = {
				exists = cp:councillor_court_chaplain
			}
			cp:councillor_court_chaplain = {
				save_scope_as = priest
			}
		}
		else = {
			random_court_position_holder = {
				type = camp_priest_camp_officer	
				limit = {
					NOT = {
						has_trait = lifestyle_mystic
					}
				}	
				save_scope_as = priest	
			}
		}
	}

	option = { # Go through with it
		name = mystic_lifestyle.1001.a
		mystical_communion_outcome_effect = yes
		scope:priest = {
			add_opinion = {
				target = root
				modifier = impious_opinion
				opinion = -20
			}
		}
		ai_chance = {
			base = 100
		}
	}

	option = { # Back out
		name = mystic_lifestyle.1001.b
		flavor = mystic_lifestyle.1001.b.flavor
		scope:priest = {
			add_opinion = {
				target = root
				modifier = pious_opinion
				opinion = 10
			}
		}
		ai_chance = {
			base = 30
		}
	}
}

### The Religious Head takes notice
# by Petter Vilberg
mystic_lifestyle.1002 = {
	type = letter_event
	opening = mystic_lifestyle.1002.opening
	desc = mystic_lifestyle.1002.desc
	sender = {
		character = scope:religious_head
		animation = disapproval
	}
	
	trigger = {
		mystic_lifestyle_not_a_virtue = yes
		highest_held_title_tier >= tier_kingdom
		exists = faith.religious_head
		faith.religious_head != root
		faith.religious_head = {
			is_available = yes
			NOT = { has_trait = lifestyle_mystic }
		}
	}

	immediate = {
		faith.religious_head = {
			save_scope_as = religious_head
		}
	}

	option = { # Go through with it
		name = mystic_lifestyle.1002.a
		mystical_communion_outcome_effect = yes
		add_piety_level = -1
		scope:religious_head = {
			add_opinion = {
				target = root
				modifier = impious_opinion
				opinion = -30
			}
		}
		ai_chance = {
			base = 100
		}
	}

	option = { # Back out
		name = mystic_lifestyle.1001.b

		add_piety = minor_piety_gain
		scope:religious_head = {
			add_opinion = {
				target = root
				modifier = pious_opinion
				opinion = 30
			}
		}
		ai_chance = {
			base = 30
		}
	}
}

### A Zealous vassal disapproves
# by Petter Vilberg
scripted_trigger mystic_lifestyle_1003_vassal_trigger = {
	is_available = yes
	faith = root.faith
	has_trait = zealous
	NOT = {
		has_trait = lifestyle_mystic
	}
}

mystic_lifestyle.1003 = {
	type = letter_event
	opening = mystic_lifestyle.1003.opening
	desc = mystic_lifestyle.1003.desc
	sender = {
		character = scope:vassal
		animation = disapproval
	}
	
	trigger = {
		mystic_lifestyle_not_a_virtue = yes
		OR = {
			any_vassal = {
				mystic_lifestyle_1003_vassal_trigger = yes
			}
			AND = {
				has_government = landless_adventurer_government
				any_courtier = {
					mystic_lifestyle_1003_vassal_trigger = yes
				}
			}
		}
	}

	immediate = {
		random_vassal = {
			limit = {
				NOR = {
					has_relation_rival = root
					has_relation_nemesis = root
				}
				mystic_lifestyle_1003_vassal_trigger = yes
			}
			alternative_limit = {
				mystic_lifestyle_1003_vassal_trigger = yes
			}
			weight = {
				base = 1
				modifier = {
					add = 10
					is_of_major_interest_to_root_trigger = yes
				}
				modifier = {
					add = 5
					is_of_minor_interest_to_root_trigger = yes
				}
			}
			save_scope_as = vassal
		}
		if = {
			limit = {
				NOT = { exists = scope:vassal }
			}
			random_courtier = {
				limit = {
					NOR = {
						has_relation_rival = root
						has_relation_nemesis = root
					}
					mystic_lifestyle_1003_vassal_trigger = yes
				}
				alternative_limit = {
					mystic_lifestyle_1003_vassal_trigger = yes
				}
				weight = {
					base = 1
					modifier = {
						add = 10
						is_of_major_interest_to_root_trigger = yes
					}
					modifier = {
						add = 5
						is_of_minor_interest_to_root_trigger = yes
					}
				}
				save_scope_as = vassal
			}
		}
	}

	option = { # Go through with it
		name = mystic_lifestyle.1003.a
		mystical_communion_outcome_effect = yes
		progress_towards_rival_effect = {
			REASON = rival_religious_secrets
			CHARACTER = scope:vassal
			OPINION = 0
		}
		scope:vassal = {
			add_opinion = {
				target = root
				modifier = impious_opinion
				opinion = -20
			}
		}
		ai_chance = {
			base = 100
		}
	}

	option = { # Back out
		name = mystic_lifestyle.1001.b
		scope:vassal = {
			add_opinion = {
				target = root
				modifier = pious_opinion
				opinion = 10
			}
		}
		ai_chance = {
			base = 30
		}
	}
}


### Your reputation makes it harder to scheme
# by Petter Vilberg
mystic_lifestyle.1004 = {
	type = character_event
	title = mystic_lifestyle.1004.t
	desc = mystic_lifestyle.1004.desc
	theme = learning_theology_focus
	left_portrait = {
		character = root
		animation = eyeroll
	}
	
	trigger = {
		mystic_lifestyle_not_a_virtue = yes
		NOR = {
			has_character_modifier = mystic_suspicious_reputation_modifier
			has_character_modifier = mystic_great_openness_modifier
		}
	}

	option = { # Let them think what they want
		name = mystic_lifestyle.1004.a
		mystical_communion_outcome_effect = yes
		add_character_modifier = {
			modifier = mystic_suspicious_reputation_modifier
			years = 5
		}
		ai_chance = {
			base = 100
		}
	}

	option = { # Perhaps I should do something else...
		name = mystic_lifestyle.1004.b
		mystical_communion_outcome_effect = yes
		add_character_modifier = {
			modifier = mystic_great_openness_modifier
			years = 5
		}
		ai_chance = {
			base = 100
		}
	}
}



### A Zealous vassal approves
# by Petter Vilberg
scripted_trigger mystic_lifestyle_1005_vassal_trigger = {
	is_available_ai = yes
	faith = root.faith
	has_trait = zealous
	NOT = { has_trait = lifestyle_mystic }
}

mystic_lifestyle.1005 = {
	type = letter_event
	opening = mystic_lifestyle.1005.opening
	desc = mystic_lifestyle.1005.desc
	sender = {
		character = scope:vassal
		animation = admiration
	}
	
	trigger = {
		OR = {
			any_vassal = {
				mystic_lifestyle_1005_vassal_trigger = yes
			}
			AND = {
				has_government = landless_adventurer_government
				any_courtier = {
					mystic_lifestyle_1005_vassal_trigger = yes
				}
			}
		}
	}

	immediate = {
		random_vassal = {
			limit = {
				mystic_lifestyle_1005_vassal_trigger = yes
			}
			weight = {
				base = 1
				modifier = {
					add = 10
					is_of_major_interest_to_root_trigger = yes
				}
				modifier = {
					add = 5
					is_of_minor_interest_to_root_trigger = yes
				}
			}
			save_scope_as = vassal
		}
		if = {
			limit = {
				NOT = { exists = scope:vassal }
			}
			random_courtier = {
				limit = {
					mystic_lifestyle_1005_vassal_trigger = yes
				}
				weight = {
					base = 1
					modifier = {
						add = 10
						is_of_major_interest_to_root_trigger = yes
					}
					modifier = {
						add = 5
						is_of_minor_interest_to_root_trigger = yes
					}
				}
				save_scope_as = vassal
			}
		}
	}

	option = { # Yes, I am very devout
		name = mystic_lifestyle.1005.a
		mystical_communion_outcome_effect = yes
		scope:vassal = {
			add_opinion = {
				target = root
				modifier = pious_opinion
				opinion = 30
			}
		}
		ai_chance = {
			base = 100
		}
	}

	option = { # Let me show you what I'm doing!
		name = mystic_lifestyle.1005.b
		mystical_communion_outcome_effect = yes
		progress_towards_friend_effect = {
			CHARACTER = scope:vassal
			OPINION = 0
			REASON = friend_shared_mysticism
		}
		scope:vassal = { add_trait = lifestyle_mystic }
		ai_chance = {
			base = 50
		}
	}
}


### Your reputation makes people unwilling to scheme against you
# by Petter Vilberg
mystic_lifestyle.1006 = {
	type = character_event
	title = mystic_lifestyle.1006.t
	desc = mystic_lifestyle.1006.desc
	theme = learning_theology_focus
	left_portrait = {
		character = root
		animation = menacing
	}
	
	trigger = {
		mystic_lifestyle_not_a_virtue = yes
		NOR = {
			has_character_modifier = mystic_dangerous_to_know_modifier
			has_character_modifier = mystic_devout_protector_modifier
		}
	}

	option = { # Lean into your reputation
		name = mystic_lifestyle.1006.a
		mystical_communion_outcome_effect = yes
		add_character_modifier = {
			modifier = mystic_dangerous_to_know_modifier
			years = 5
		}
		ai_chance = {
			base = 100
		}
	}

	option = { # Let people know I wish no harm
		name = mystic_lifestyle.1006.b
		mystical_communion_outcome_effect = yes
		add_character_modifier = {
			modifier = mystic_devout_protector_modifier
			years = 5
		}
		ai_chance = {
			base = 100
		}
	}
}

### Your practice makes you ill
# by Petter Vilberg
mystic_lifestyle.1007 = {
	type = character_event
	title = mystic_lifestyle.1007.t
	desc = mystic_lifestyle.1007.desc
	theme = learning_theology_focus
	left_portrait = {
		character = root
		animation = sick
	}
	
	trigger = {
		can_contract_disease_trigger = { DISEASE = ill }
	}

	option = { # Oh no
		name = mystic_lifestyle.1007.a
		mystical_communion_outcome_effect = yes
		contract_disease_effect = {
			DISEASE = ill
			TREATMENT_EVENT = yes
		}
	}
}

### Your practice somehow cures you
# by Petter Vilberg
mystic_lifestyle.1008 = {
	type = character_event
	title = mystic_lifestyle.1008.t
	desc = mystic_lifestyle.1008.desc
	theme = learning_theology_focus
	left_portrait = {
		character = root
		animation = happiness
	}
	
	trigger = {
		OR = {
			has_trait = ill
			has_trait = pneumonic
		}
	}

	option = { # Phew!
		name = mystic_lifestyle.1008.a
		mystical_communion_outcome_effect = yes
		if = {
			limit = { has_trait = ill }
			recover_from_disease_effect = {
				DISEASE = ill
			}
		}
		if = {
			limit = { has_trait = pneumonic }
			recover_from_disease_effect = {
				DISEASE = pneumonic
			}
		}
	}
}


### A fellow mystic approves
# by Petter Vilberg
scripted_trigger mystic_lifestyle_1009_mystic_trigger = {
	is_available_ai = yes
	OR = {
		is_of_major_interest_to_root_trigger = yes
		is_of_minor_interest_to_root_trigger = yes
	}
	faith = root.faith
	has_trait = lifestyle_mystic
	NOR = {
		has_relation_rival = root
		has_relation_lover = root
	}
}

mystic_lifestyle.1009 = {
	type = letter_event
	opening = mystic_lifestyle.1009.opening
	desc = mystic_lifestyle.1009.desc
	sender = {
		character = scope:mystic
		animation = admiration
	}
	
	trigger = {
		OR = {
			any_vassal = {
				mystic_lifestyle_1009_mystic_trigger = yes
			}
			any_close_or_extended_family_member = {
				mystic_lifestyle_1009_mystic_trigger = yes
			}
			any_councillor = {
				mystic_lifestyle_1009_mystic_trigger = yes
			}
		}
	}

	immediate = {
		every_vassal = {
			limit = {
				mystic_lifestyle_1009_mystic_trigger = yes
			}
			add_to_list = potential_mystics
		}
		every_close_or_extended_family_member = {
			limit = {
				mystic_lifestyle_1009_mystic_trigger = yes
			}
			add_to_list = potential_mystics
		}
		every_councillor = {
			limit = {
				mystic_lifestyle_1009_mystic_trigger = yes
			}
			add_to_list = potential_mystics
		}
		random_in_list = {
			list = potential_mystics

			limit = {
				NOR = {
					has_relation_friend = root
					has_relation_best_friend = root
				}
			}
			alternative_limit = {
				always = yes
			}

			weight = {
				base = 1
				modifier = {
					factor = 2
					is_of_major_interest_to_root_trigger = yes
				}
				modifier = {
					factor = 5
					has_relation_potential_friend = root
				}
			}
			save_scope_as = mystic
		}
	}

	option = {
		name = mystic_lifestyle.1009.a
		mystical_communion_outcome_effect = yes
		progress_towards_friend_effect = {
			CHARACTER = scope:mystic
			OPINION = 0
			REASON = friend_shared_mysticism
		}
		scope:mystic = {
			add_opinion = {
				target = root
				modifier = respect_opinion
				opinion = 20
			}
		}
		ai_chance = {
			base = 100
		}
	}
}
