###########################################
#                                         #
# Way of Life theology events             #
#                                         #
# ID WoL.7000-WoL.7999                    #
#                                         #
###########################################

# Written by Tobias Bodlund

namespace = WoL


# Study religious myths?
character_event = {
	id = WoL.7000
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	only_playable = yes
	min_age =  16
	capable_only = yes
	prisoner = no

	trigger = {
		is_priest = no
		holy_order = no
		has_focus = focus_theology
		NOT = { trait = in_hiding }
		NOT = { has_character_flag = studied_religious_myths }
		OR = {
			NOT = { has_character_flag = religious_studies_timer }
			had_character_flag = { flag = religious_studies_timer days = 1800 }
		}
	}

	desc = {
		trigger = {
			OR = {
				NOT = { religion_group = pagan_group } # Scriptures
				is_reformed_religion = yes
			}
		}
		text = EVTDESC_WoL_7000_non_unref_pagan
	}
	desc = {
		trigger = {
			religion_group = pagan_group # Stories
			is_reformed_religion = no
		}
		text = EVTDESC_WoL_7000_unref_pagan
	}
	
	immediate = {
		set_character_flag = studied_religious_myths
	}
	
	option = {
		name = EVTOPTA_WoL_7000 # Yes, study scriptures
		trigger = {
			OR = {
				NOT = { religion_group = pagan_group }
				is_reformed_religion = yes
			}
		}
		piety = 20
		hidden_tooltip = { character_event = { id = WoL.7001 days = 90 } }
	}
	option = {
		name = EVTOPTB_WoL_7000 # Yes, listen to stories
		trigger = {
			religion_group = pagan_group
			is_reformed_religion = no
		}
		piety = 20
		hidden_tooltip = { character_event = { id = WoL.7001 days = 90 } }
	}
	option = {
		name = EVTOPTC_WoL_7000  # I have no time
		piety = -5
		if = {
			limit = {
				has_character_modifier = religious_studies
			}
			remove_character_modifier = religious_studies
		}
	}
}

# Results of studying religous scriptures or stories
character_event = {
	id = WoL.7001
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes

	desc = {
		trigger = {
			OR = {
				NOT = { religion_group = pagan_group } # Scriptures
				is_reformed_religion = yes
			}
		}
		text = EVTDESC_WoL_7001_non_unref_pagan
	}
	desc = {
		trigger = {
			religion_group = pagan_group # Stories
			is_reformed_religion = no
		}
		text = EVTDESC_WoL_7001_unref_pagan
	}

	option = {
		name = EVTOPTA_WoL_7001 # Scriptures
		trigger = {
			OR = {
				NOT = { religion_group = pagan_group }
				is_reformed_religion = yes
			}
		}
		piety = 20
		add_character_modifier = {
			name = ancient_wisdom
			years = 3
		}
		if = {
			limit = {
				NOT = { has_character_modifier = religious_studies }
				NOT = { has_character_modifier = religious_philosopher }
				NOT = { trait = theologian }
			}
			add_character_modifier = {
				name = religious_studies
				duration = -1
			}
			set_character_flag = religious_studies_timer
			break = yes
		}
		if = {
			limit = {
				has_character_modifier = religious_studies
				NOT = { has_character_modifier = religious_philosopher }
				NOT = { trait = theologian }
				had_character_flag = { flag = religious_studies_timer days = 1800 }
			}
			clr_character_flag = religious_studies_timer
			remove_character_modifier = religious_studies
			add_character_modifier = {
				name = religious_philosopher
				duration = -1
			}
		}
	}
	option = {
		name = EVTOPTB_WoL_7001 # Stories
		trigger = {
			religion_group = pagan_group # Stories
			is_reformed_religion = no
		}
		piety = 20
		add_character_modifier = {
			name = ancient_wisdom
			years = 3
		}
		if = {
			limit = {
				NOT = { has_character_modifier = religious_studies }
				NOT = { has_character_modifier = religious_philosopher }
				NOT = { trait = theologian }
			}
			add_character_modifier = {
				name = religious_studies
				duration = -1
			}
			set_character_flag = religious_studies_timer
			break = yes
		}
		if = {
			limit = {
				has_character_modifier = religious_studies
				NOT = { has_character_modifier = religious_philosopher }
				NOT = { trait = theologian }
				had_character_flag = { flag = religious_studies_timer days = 1800 }
			}
			clr_character_flag = religious_studies_timer
			remove_character_modifier = religious_studies
			add_character_modifier = {
				name = religious_philosopher
				duration = -1
			}
		}
	}
}

# Befriend priest through your religious interest
character_event = {
	id = WoL.7010
	
	hide_window = yes
	
	is_triggered_only = yes

	only_playable = yes
	min_age =  16
	capable_only = yes
	prisoner = no

	trigger = {
		is_priest = no
		has_focus = focus_theology
		any_realm_character = {
			religion = ROOT
			is_priest = yes
			NOT = { trait = incapable }
			NOT = { trait = in_hiding }
			prisoner = no
		}
	}
	
	immediate = {
		random_realm_character = {
			limit = {
				religion = ROOT
				is_priest = yes
				NOT = { trait = incapable }
				NOT = { trait = in_hiding }
				prisoner = no
			}
			character_event = { id = WoL.7011 }
		}
	}
}

character_event = {
	id = WoL.7011

	hide_window = yes

	is_triggered_only = yes
	
	immediate = {
		FROM = { character_event = { id = WoL.7012 } }
	}
}

character_event = {
	id = WoL.7012
	desc = EVTDESC_WoL_7012
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes

	option = {
		name = EVTOPTA_WoL_7012
		add_friend = FROM
	}
}

# Visit holy site and speak with priests there (not Muslims, Christians, Jews or Indians)
character_event = {
	id = WoL.7020
	desc = EVTDESC_WoL_7020
	picture = GFX_evt_cathedral
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes

	only_playable = yes
	min_age =  16
	capable_only = yes
	prisoner = no

	trigger = {
		has_focus = focus_theology
		war = no
		in_command = no
		NOT = { religion_group = christian }
		NOT = { religion_group = muslim }
		NOT = { religion_group = jewish_group }
		NOT = { religion_group = indian_group }
		NOT = { trait = in_hiding }
		NOT = { has_character_flag = do_not_disturb }
		NOT = { has_character_flag = wol_theology_visited_holy_site }
		any_realm_title = {
			is_holy_site = ROOT
			holder_scope = { ai = yes }
		}
		OR = {
			NOT = { has_character_flag = religious_studies_timer }
			had_character_flag = { flag = religious_studies_timer days = 1800 }
		}
	}
	
	immediate = {
		set_character_flag = wol_theology_visited_holy_site
		random_realm_title = {
			limit = {
				is_holy_site = ROOT
				holder_scope = { ai = yes }
			}
			save_event_target_as = holy_site_visiting # For localization
		}
	}
	
	option = {
		name = EVTOPTA_WoL_7020  # Go
		piety = 20
		scaled_wealth = -0.2
		hidden_tooltip = { character_event = { id = WoL.7021 days = 20 } }
		set_character_flag = do_not_disturb
	}
	option = {
		name = EVTOPTB_WoL_7020 # Don't go
		piety = -5
	}
}

# Experience at holy site
character_event = {
	id = WoL.7021
	desc = EVTDESC_WoL_7021
	picture = GFX_evt_cathedral
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes

	option = {
		name = EVTOPTA_WoL_7021
		piety = 50
		if = {
			limit = {
				trait = cynical
			}
			random = {
				chance = 20
				remove_trait = cynical
			}
		}
		if = {
			limit = {
				NOT = { trait = cynical }
				NOT = { trait = zealous }
			}
			random = {
				chance = 20
				add_trait = zealous
			}
		}
		clr_character_flag = do_not_disturb
		clear_event_target = holy_site_visiting
		if = {
			limit = {
				NOT = { has_character_modifier = religious_studies }
				NOT = { has_character_modifier = religious_philosopher }
				NOT = { trait = theologian }
			}
			add_character_modifier = {
				name = religious_studies
				duration = -1
			}
			set_character_flag = religious_studies_timer
		}
		if = {
			limit = {
				has_character_modifier = religious_studies
				NOT = { has_character_modifier = religious_philosopher }
				NOT = { trait = theologian }
				had_character_flag = { flag = religious_studies_timer days = 1800 }
			}
			clr_character_flag = religious_studies_timer
			remove_character_modifier = religious_studies
			add_character_modifier = {
				name = religious_philosopher
				duration = -1
			}
		}
	}
}

# Reflect on own life and how it relates to the gods.
character_event = {
	id = WoL.7030
	desc = EVTDESC_WoL_7030
	picture = GFX_evt_religious_exultation
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes

	only_playable = yes
	min_age =  16
	capable_only = yes

	trigger = {
		is_priest = no
		has_focus = focus_theology
		NOT = { has_character_flag = wol_theology_reflect_on_self_and_gods }
		NOT = { trait = possessed }
		NOT = { trait = theologian }
		NOT = { has_character_modifier = religious_philosopher }
		any_realm_character = {
			religion = ROOT
			is_priest = yes
			NOT = { trait = incapable }
			NOT = { trait = in_hiding }
		}
		OR = {
			NOT = { has_character_flag = religious_studies_timer }
			had_character_flag = { flag = religious_studies_timer days = 1800 }
		}
	}
	
	immediate = {
		set_character_flag = wol_theology_reflect_on_self_and_gods
	}
	
	option = {
		name = EVTOPTA_WoL_7030  # Indeed
		piety = 10
	}
	option = {
		name = EVTOPTB_WoL_7030  # Study more deeply
		piety = 30
		if = {
			limit = {
				NOT = { has_character_modifier = religious_studies }
				NOT = { has_character_modifier = religious_philosopher }
				NOT = { trait = theologian }
			}
			add_character_modifier = {
				name = religious_studies
				duration = -1
			}
			set_character_flag = religious_studies_timer
		}
		if = {
			limit = {
				has_character_modifier = religious_studies
				NOT = { has_character_modifier = religious_philosopher }
				NOT = { trait = theologian }
				had_character_flag = { flag = religious_studies_timer days = 1800 }
			}
			clr_character_flag = religious_studies_timer
			remove_character_modifier = religious_studies
			add_character_modifier = {
				name = religious_philosopher
				duration = -1
			}
		}
	}
	option = {
		name = EVTOPTC_WoL_7030  # Stop this
		piety = -10
		if = {
			limit = {
				has_character_modifier = religious_studies
			}
			remove_character_modifier = religious_studies
			add_trait = cynical
		}
		set_character_flag = religious_studies_timer
	}
}

# Theologian's view of other religions
character_event = {
	id = WoL.7040

	hide_window = yes
	
	is_triggered_only = yes

	only_playable = yes
	min_age =  16
	capable_only = yes

	trigger = {
		has_focus = focus_theology
		NOT = { trait = sympathy_christendom }
		NOT = { trait = sympathy_islam }
		NOT = { trait = sympathy_pagans }
		NOT = { trait = sympathy_zoroastrianism }
		NOT = { trait = sympathy_judaism }
		NOT = { trait = sympathy_indian }
		NOT = { has_character_flag = wol_theology_view_other_religions }
		any_realm_character = {
			NOT = { religion_group = ROOT }
		}
	}
	
	immediate = {
		set_character_flag = wol_theology_view_other_religions
		random_realm_character = {
			limit = {
				NOT = { religion_group = ROOT }
			}
			character_event = { id = WoL.7041 }
		}
	}
}

# Bounce
character_event = {
	id = WoL.7041
	
	hide_window = yes

	is_triggered_only = yes

	immediate = {
		FROM = { character_event = { id = WoL.7042 } }
	}
}

# Choose stance on other religion
character_event = {
	id = WoL.7042
	desc = EVTDESC_WoL_7042
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion
	
	hide_from = yes
	
	is_triggered_only = yes
	
	trigger = {
		is_priest = no
		NOT = { trait = zealous }
	}

	option = {
		name = EVTOPTA_WoL_7042  # Accept
		if = {
			limit = { FROM = { religion_group = christian } }
			add_trait = sympathy_christendom
		}
		if = {
			limit = { FROM = { religion_group = muslim } }
			add_trait = sympathy_islam
		}
		if = {
			limit = { FROM = { religion_group = pagan_group } }
			add_trait = sympathy_pagans
		}
		if = {
			limit = { FROM = { religion_group = zoroastrian_group } }
			add_trait = sympathy_zoroastrianism
		}
		if = {
			limit = { FROM = { religion_group = jewish_group } }
			add_trait = sympathy_judaism
		}
		if = {
			limit = { FROM = { religion_group = indian_group } }
			add_trait = sympathy_indian
		}
	}
	option = {
		name = EVTOPTB_WoL_7042  # Condemn
		piety = 50
	}
}
	
# Question own faith
character_event = {
	id = WoL.7050
	desc = EVTDESC_WoL_7050
	picture = GFX_evt_religious_exultation
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes

	only_playable = yes
	min_age =  16
	capable_only = yes

	trigger = {
		has_focus = focus_theology
		NOT = { trait = cynical }
		OR = {
			NOT = { religion_group = pagan_group }
			is_reformed_religion = yes
		}
		NOT = { has_character_flag = wol_theology_question_gods }
	}
	
	immediate = {
		set_character_flag = wol_theology_question_gods
	}
	
	option = {
		name = EVTOPTA_WoL_7050  # Become cynical (non-zealous)
		add_trait = cynical
	}
	option = {
		name = EVTOPTB_WoL_7050  # Stay true to faith
		piety = 30
		random = {
			chance = 30
			add_trait = stressed
		}
	}
}

# Embrace heresy?
character_event = {
	id = WoL.7060
	desc = EVTDESC_WoL_7060
	picture = GFX_evt_religious_exultation
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes

	only_playable = yes
	min_age =  16
	capable_only = yes

	trigger = {
		is_priest = no
		holy_order = no
		has_focus = focus_theology
		is_heretic = no
		trait = zealous
		OR = {
			religion_group = christian
			religion_group = muslim
			religion_group = zoroastrian_group
			religion_group = jewish_group
		}
		NOT = { has_character_flag = wol_theology_heretic }
		OR = {
			NOT = { has_character_flag = religious_studies_timer }
			had_character_flag = { flag = religious_studies_timer days = 1800 }
		}
	}
	
	immediate = {
		set_character_flag = wol_theology_heretic
	}
	
	option = {
		name = EVTOPTA_WoL_7060  # Settle firmly into orthodoxy
		piety = 30
	}
	option = {
		name = EVTOPTB_WoL_7060  # Take middle ground
		remove_trait = zealous
	}
	option = {
		name = EVTOPTC_WoL_7060  # Become heretic
		piety = 100
		become_heretic = yes
		if = {
			limit = {
				NOT = { has_character_modifier = religious_studies }
				NOT = { has_character_modifier = religious_philosopher }
				NOT = { trait = theologian }
			}
			add_character_modifier = {
				name = religious_studies
				duration = -1
			}
			set_character_flag = religious_studies_timer
		}
		if = {
			limit = {
				has_character_modifier = religious_studies
				NOT = { has_character_modifier = religious_philosopher }
				NOT = { trait = theologian }
				had_character_flag = { flag = religious_studies_timer days = 1800 }
			}
			clr_character_flag = religious_studies_timer
			remove_character_modifier = religious_studies
			add_character_modifier = {
				name = religious_philosopher
				duration = -1
			}
		}
	}
}

# Embrace theologian lifestyle?
character_event = {
	id = WoL.7070
	desc = EVTDESC_WoL_7070
	picture = GFX_evt_religious_exultation
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes

	only_playable = yes
	min_age =  16
	capable_only = yes

	trigger = {
		has_focus = focus_theology
		NOT = { lifestyle_traits = 1 }
		has_character_modifier = religious_philosopher
		NOT = { has_character_flag = wol_theology_lifestyle_question }
	}
	
	immediate = {
		set_character_flag = wol_theology_lifestyle_question
	}
	
	option = {
		name = EVTOPTA_WoL_7070  # Become theologian
		trigger = {
			NOT = { trait = cynical }
		}
		remove_character_modifier = religious_philosopher
		add_trait = theologian
		if = {
			limit = { has_nickname = no }
			random_list = {
				10 = {
					give_nickname = nick_the_pious
				}
				10 = {
					give_nickname = nick_the_holy
				}
				10 = {
					modifier = {
						factor = 0
						NOT = { religion_group = christian }
					}
					give_nickname = nick_the_apostle
				}
				10 = {
					modifier = {
						factor = 0
						NOT = { religion_group = christian }
					}
					give_nickname = nick_the_confessor
				}
				10 = {
					modifier = {
						factor = 0
						NOT = { religion_group = christian }
					}
					give_nickname = nick_the_blessed
				}
			}
		}
	}
	option = {
		name = EVTOPTB_WoL_7070  # Become cynical theologian
		trigger = {
			trait = cynical
		}
		remove_character_modifier = religious_philosopher
		add_trait = theologian
		if = {
			limit = { has_nickname = no }
			random_list = {
				10 = {
					give_nickname = nick_the_scholar
				}
				10 = {
					give_nickname = nick_the_wise
				}
			}
		}
	}
	option = {
		name = EVTOPTC_WoL_7070  # There are other paths in life
		if = {
			limit = { has_nickname = no }
			random_list = {
				10 = {
					give_nickname = nick_the_scholar
				}
				10 = {
					give_nickname = nick_the_wise
				}
			}
		}
	}
}
