﻿namespace = regula_start_cult_event

# Start your journey as Magister, meet with Magisterian cult
# This start event is purely for flavour, and to give player a chance to "back out"
regula_start_cult_event.0001 = {
	type = character_event
	title = regula_start_cult_event.0001.t
	desc = regula_start_cult_event.0001.desc

	theme = regula_theme

	override_background = {
		reference = ep2_hunt_forest_hut
	}

	override_effect_2d = {
		reference = fog	
	}

	left_portrait = {
		character = root
		animation = idle
	}

	option = {
		name = regula_start_cult_event.0001.a

		trigger_event = regula_start_cult_event.0002
	}

	option = {

		# Coward!
		stress_impact = {
			base = minor_stress_impact_gain
		}

		remove_character_flag = regula_decision_taken

		name = regula_start_cult_event.0001.b	# Back out.
	}

	# Debug choice to skip this decision
	option = {
		name = regula_start_cult_event.0001.debug

		trigger = {
			debug_only = yes
		}

		add_secret = {
			type = regula_covert_conversion
		}

		set_global_variable = {
			name = regula_covert_initialized
			value = yes
		}

		remove_character_flag = regula_decision_taken
	}
}

# This event is purely a basic lore dump
# This event also gives you a big dump of stress, which is basically the "cost" of starting the RM chain
# Being lustful lets you avoid the stress!
regula_start_cult_event.0002 = {
	type = character_event
	title = regula_start_cult_event.0002.t
	desc = regula_start_cult_event.0002.desc

	theme = regula_theme

	override_background = {
		reference = regula_magister_cult_home
	}

	left_portrait = {
		character = root
		animation = idle
	}

	right_portrait = {
		character = scope:cultist_priestess
		animation = flirtation_left
	}

	lower_left_portrait = {
		character = scope:cultist_warrior
		animation = idle
	}

	lower_center_portrait = {
		character = scope:cultist_maiden
		animation = idle
	}

	immediate = {
		# Create our Magi cultist family
		# "Mother" (who is dead)
		create_character = {
			save_temporary_scope_as = created_character
			age = { 42 45 }
			location = root.location
			culture = root.location.culture
			faith = faith:regula_no_holy_sites
			gender = female
			dynasty = generate
			template = regula_commander_character
		}
		scope:created_character = {
			save_scope_as = orphan_mother
			death = { death_reason = death_childbirth }
		}

		create_character = {
			save_temporary_scope_as = created_character
			location = root.location
			culture = root.location.culture
			faith = faith:regula_no_holy_sites
			gender = female
			dynasty = none
			template = regula_cultist_priestess_character
		}
		scope:created_character = {
			hidden_effect = {
				set_mother = scope:orphan_mother
				set_house = scope:orphan_mother.house
			}
			save_scope_as = cultist_priestess
		}

		create_character = {
			save_temporary_scope_as = created_character
			location = root.location
			culture = root.location.culture
			faith = faith:regula_no_holy_sites
			gender = female
			dynasty = none
			template = regula_cultist_warrior_character
		}
		scope:created_character = {
			hidden_effect = {
				set_mother = scope:orphan_mother
				set_house = scope:orphan_mother.house
				add_character_flag = wear_armor
			}
			save_scope_as = cultist_warrior
		}

		create_character = {
			save_temporary_scope_as = created_character
			location = root.location
			culture = root.location.culture
			faith = faith:regula_no_holy_sites
			gender = female
			dynasty = none
			template = regula_cultist_maiden_character
		}
		scope:created_character = {
			hidden_effect = {
				set_mother = scope:orphan_mother
				set_house = scope:orphan_mother.house
			}
			save_scope_as = cultist_maiden
		}
	}

	# Default, just in case
	option = {
		name = regula_start_cult_event.0002.default

		trigger = {
			always = no
		}

		fallback = yes

		stress_impact = {
			base = massive_stress_impact_gain
		}

		trigger_event = regula_start_cult_event.0003
	}

	# Lustful bonus, no stress gain
	option = {
		name = regula_start_cult_event.0002.lustful

		trigger = {
			has_trait = lustful
		}

		trait = lustful

		stress_impact = {
			lustful = minor_stress_impact_loss
		}

		trigger_event = regula_start_cult_event.0003
	}

	# Craven - Paranoid - Zealous - Shy - Humble
	option = {
		name = regula_start_cult_event.0002.craven_paranoid_zealous_shy_humble
		flavor = regula_start_cult_event.0002.craven_paranoid_zealous_shy_humble.tt

		trigger = {
			OR = {
				has_trait = craven
				has_trait = paranoid
				has_trait = zealous
				has_trait = shy
				has_trait = humble
			}
		}

		trait = craven
		trait = paranoid
		trait = zealous
		trait = shy
		trait = humble

		stress_impact = {
			base = massive_stress_impact_gain

			craven = minor_stress_impact_loss
			paranoid = minor_stress_impact_loss
			zealous = minor_stress_impact_loss
			shy = minor_stress_impact_loss
			humble = minor_stress_impact_loss
		}

		trigger_event = regula_start_cult_event.0003
	}

	# Just - Brave - Wrathful - Vengeful - Zealous
	option = {
		name = regula_start_cult_event.0002.just_brave_wrathful_vengeful_zealous
		flavor = regula_start_cult_event.0002.just_brave_wrathful_vengeful_zealous.tt

		trigger = {
			OR = {
				has_trait = just
				has_trait = brave
				has_trait = wrathful
				has_trait = vengeful
				has_trait = zealous
			}
		}

		trait = just
		trait = brave
		trait = wrathful
		trait = vengeful
		trait = zealous

		stress_impact = {
			base = massive_stress_impact_gain

			just = minor_stress_impact_loss
			brave = minor_stress_impact_loss
			wrathful = minor_stress_impact_loss
			vengeful = minor_stress_impact_loss
			zealous = minor_stress_impact_loss
		}

		trigger_event = regula_start_cult_event.0003
	}

	# Eccentric - Trusting - Arbitary - Gregarious - Calm
	option = {
		name = regula_start_cult_event.0002.eccentric_trusting_arbitary_gregarious_calm
		flavor = regula_start_cult_event.0002.eccentric_trusting_arbitary_gregarious_calm.tt

		trigger = {
			OR = {
				has_trait = eccentric
				has_trait = trusting
				has_trait = arbitrary
				has_trait = gregarious
				has_trait = calm
			}
		}

		trait = eccentric
		trait = trusting
		trait = arbitrary
		trait = gregarious
		trait = calm

		stress_impact = {
			base = massive_stress_impact_gain

			eccentric = minor_stress_impact_loss
			trusting = minor_stress_impact_loss
			arbitrary = minor_stress_impact_loss
			gregarious = minor_stress_impact_loss
			calm = minor_stress_impact_loss
		}

		trigger_event = regula_start_cult_event.0003
	}

	# Compassionate - Trusting - Patient - Honest - Generous
	option = {
		name = regula_start_cult_event.0002.compassionate_trusting_patient_honest_generous
		flavor = regula_start_cult_event.0002.compassionate_trusting_patient_honest_generous.tt

		trigger = {
			OR = {
				has_trait = compassionate
				has_trait = trusting
				has_trait = patient
				has_trait = honest
				has_trait = generous
			}
		}

		trait = compassionate
		trait = trusting
		trait = patient
		trait = honest
		trait = generous

		stress_impact = {
			base = massive_stress_impact_gain

			compassionate = minor_stress_impact_loss
			trusting = minor_stress_impact_loss
			patient = minor_stress_impact_loss
			honest = minor_stress_impact_loss
			generous = minor_stress_impact_loss
		}

		trigger_event = regula_start_cult_event.0003
	}

	# Callous - Sadistic - Arrogant - Deceitful - Greedy
	option = {
		name = regula_start_cult_event.0002.callous_sadistic_arrogant_deceitful_greedy
		flavor = regula_start_cult_event.0002.callous_sadistic_arrogant_deceitful_greedy.tt

		trigger = {
			OR = {
				has_trait = callous
				has_trait = sadistic
				has_trait = arrogant
				has_trait = deceitful
				has_trait = greedy
			}
		}

		trait = callous
		trait = sadistic
		trait = arrogant
		trait = deceitful
		trait = greedy

		stress_impact = {
			base = massive_stress_impact_gain

			callous = minor_stress_impact_loss
			sadistic = minor_stress_impact_loss
			arrogant = minor_stress_impact_loss
			deceitful = minor_stress_impact_loss
			greedy = minor_stress_impact_loss
		}

		trigger_event = regula_start_cult_event.0003
	}
}

# Prove your worthiness
# Each option gives a small bonus
regula_start_cult_event.0003 = {
	type = character_event
	title = regula_start_cult_event.0003.t
	desc = regula_start_cult_event.0003.desc

	theme = regula_theme

	override_background = {
		reference = regula_bedchamber
	}

	left_portrait = {
		character = root
		animation = shock
	}

	right_portrait = {
		character = scope:cultist_priestess
		animation = reading
		outfit_tags = { no_clothes }
	}

	lower_left_portrait = {
		character = scope:cultist_warrior
		animation = idle
		outfit_tags = { no_clothes }
	}

	lower_center_portrait = {
		character = scope:cultist_maiden
		animation = idle
		outfit_tags = { no_clothes }
	}

	immediate = {
		add_secret = {
			type = regula_covert_conversion
		}
	}

	# Fallback option, gain stress but you get through
	option = {
		name = regula_start_cult_event.0003.lame
		flavor = regula_start_cult_event.0003.lame.tt

		trigger = { always = no }
		fallback = yes

		stress_impact = {
			base = minor_stress_impact_gain
		}

		save_scope_value_as = {
			name = worthy_response
			value = flag:lame
		}

		trigger_event = regula_start_cult_event.0004
	}

	# Being lustful is an automatic pass
	option = {
		name = regula_start_cult_event.0003.lustful
		flavor = regula_start_cult_event.0003.lustful.tt

		trigger = {
			has_trait = lustful
		}

		trait = lustful

		add_character_modifier = {
			modifier = alluring_confidence
			years = 10
		}

		save_scope_value_as = {
			name = worthy_response
			value = flag:lustful
		}

		trigger_event = regula_start_cult_event.0004
	}

	# Being ambitious is also an automatic pass
	option = {
		name = regula_start_cult_event.0003.ambitious
		flavor = regula_start_cult_event.0003.ambitious.tt

		trigger = {
			has_trait = ambitious
		}

		trait = ambitious

		add_character_modifier = {
			modifier = focused_modifier
			years = 10
		}

		save_scope_value_as = {
			name = worthy_response
			value = flag:ambitious
		}

		trigger_event = regula_start_cult_event.0004
	}

	# Duchy Landed
	option = {
		name = regula_start_cult_event.0003.landed
		flavor = regula_start_cult_event.0003.landed.tt

		trigger = {
			is_landed = yes
			highest_held_title_tier >= tier_duchy
		}

		add_prestige = medium_prestige_gain

		save_scope_value_as = {
			name = worthy_response
			value = flag:landed
		}

		trigger_event = regula_start_cult_event.0004
	}

	# Having good genetic traits
	option = {
		name = regula_start_cult_event.0003.genetic
		flavor = regula_start_cult_event.0003.genetic.tt

		trigger = {
			OR = {
				has_trait = physique_good
				has_trait = intellect_good
				has_trait = beauty_good
				has_trait = fecund
				has_trait = pure_blooded

			}
		}

		add_character_modifier = {
			modifier = invigorated_modifier
			years = 10
		}

		save_scope_value_as = {
			name = worthy_response
			value = flag:genetic
		}

		trigger_event = regula_start_cult_event.0004
	}

	# Famous Dynasty
	option = {
		name = regula_start_cult_event.0003.dynasty
		flavor = regula_start_cult_event.0003.dynasty.tt

		trigger = {
			dynasty = {
				dynasty_prestige_level >= 3
			}
		}

		dynasty = {
			add_dynasty_prestige = minor_prestige_gain
		}

		save_scope_value_as = {
			name = worthy_response
			value = flag:dynasty
		}

		trigger_event = regula_start_cult_event.0004
	}

	# Prestige Level
	option = {
		name = regula_start_cult_event.0003.prestige
		flavor = regula_start_cult_event.0003.prestige.tt

		trigger = {
			prestige_level >= 3
		}

		add_prestige = medium_prestige_gain

		save_scope_value_as = {
			name = worthy_response
			value = flag:prestige
		}

		trigger_event = regula_start_cult_event.0004
	}

	# Gold!
	option = {
		name = regula_start_cult_event.0003.gold
		flavor = regula_start_cult_event.0003.gold.tt

		trigger = {
			gold >= major_gold_value
		}

		show_as_unavailable = {
			always = yes
		}

		add_character_modifier = {
			modifier = focused_modifier
			years = 10
		}

		save_scope_value_as = {
			name = worthy_response
			value = flag:gold
		}

		trigger_event = regula_start_cult_event.0004
	}
}

# Become the Proto-Magister
# Choose between having the three sisters as courtiers or a stat bonus
regula_start_cult_event.0004 = {
	type = character_event
	title = regula_start_cult_event.0004.t

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:worthy_response = flag:lame }
				desc = regula_start_cult_event.0004.intro_response_lame
			}
			triggered_desc = {
				trigger = { scope:worthy_response = flag:lustful }
				desc = regula_start_cult_event.0004.intro_response_lustful
			}
			triggered_desc = {
				trigger = { scope:worthy_response = flag:ambitious }
				desc = regula_start_cult_event.0004.intro_response_ambitious
			}
			triggered_desc = {
				trigger = { scope:worthy_response = flag:landed }
				desc = regula_start_cult_event.0004.intro_response_landed
			}
			triggered_desc = {
				trigger = { scope:worthy_response = flag:genetic }
				desc = regula_start_cult_event.0004.intro_response_genetic
			}
			triggered_desc = {
				trigger = { scope:worthy_response = flag:dynasty }
				desc = regula_start_cult_event.0004.intro_response_dynasty
			}
			triggered_desc = {
				trigger = { scope:worthy_response = flag:prestige }
				desc = regula_start_cult_event.0004.intro_response_prestige
			}
			triggered_desc = {
				trigger = { scope:worthy_response = flag:gold }
				desc = regula_start_cult_event.0004.intro_response_gold
			}
		}
		desc = regula_start_cult_event.0004.desc_main
	}

	theme = regula_theme

	override_background = {
		reference = regula_bedchamber
	}

	left_portrait = {
		character = root
		animation = love
		outfit_tags = { no_clothes }
	}

	right_portrait = {
		character = scope:cultist_priestess
		animation = ecstasy
		outfit_tags = { no_clothes }
	}

	lower_left_portrait = {
		character = scope:cultist_warrior
		animation = idle
		outfit_tags = { no_clothes }
	}

	lower_center_portrait = {
		character = scope:cultist_maiden
		animation = idle
		outfit_tags = { no_clothes }
	}

	immediate = {
		play_music_cue = "mx_cue_sacredrite"

		set_global_variable = {
			name = regula_covert_initialized
			value = yes
		}

		regula_sex_with_target_no_stress_outside = { TARGET = scope:cultist_priestess }
		regula_sex_with_target_no_stress_outside = { TARGET = scope:cultist_warrior }
		regula_sex_with_target_no_stress_outside = { TARGET = scope:cultist_maiden }
	}

	# Take them
	option = {
		name = regula_start_cult_event.0004.all

		add_courtier = scope:cultist_priestess
		add_courtier = scope:cultist_warrior
		add_courtier = scope:cultist_maiden

		add_hook_no_toast = {
			type = loyalty_hook
			target = scope:cultist_priestess
		}
		add_hook_no_toast = {
			type = loyalty_hook
			target = scope:cultist_warrior
		}
		add_hook_no_toast = {
			type = loyalty_hook
			target = scope:cultist_maiden
		}

		scope:cultist_priestess = {
			set_character_faith = root.faith
			regula_secret_conversion = { CONVERTER = root }
		}
		scope:cultist_warrior = {
			set_character_faith = root.faith
			regula_secret_conversion = { CONVERTER = root }
		}
		scope:cultist_maiden = {
			set_character_faith = root.faith
			regula_secret_conversion = { CONVERTER = root }
		}
	}

	# Take knowledge
	option = {
		name = regula_start_cult_event.0004.none

		add_diplomacy_skill = 2
		add_martial_skill = 2
		add_stewardship_skill = 2
		add_intrigue_skill = 2
		add_learning_skill = 2
		add_prowess_skill = 3

		hidden_effect = {
			scope:cultist_priestess = {
				death = {
					death_reason = death_vanished
				}
			}
			scope:cultist_warrior = {
				death = {
					death_reason = death_vanished
				}
			}
			scope:cultist_maiden = {
				death = {
					death_reason = death_vanished
				}
			}
		}
	}

	# Take knowledge - Callous/Sadistic "drain" them
	# Evil bastard option
	option = {
		name = regula_start_cult_event.0004.none_drain

		trigger = {
			OR = {
				has_trait = callous
				has_trait = sadistic
			}
		}

		trait = callous
		trait = sadistic

		add_diplomacy_skill = 3
		add_martial_skill = 3
		add_stewardship_skill = 3
		add_intrigue_skill = 3
		add_learning_skill = 3
		add_prowess_skill = 5

		scope:cultist_priestess = {
			death = {
				death_reason = death_drained
				killer = root
			}
		}
		scope:cultist_warrior = {
			death = {
				death_reason = death_drained
				killer = root
			}
		}
		scope:cultist_maiden = {
			death = {
				death_reason = death_drained
				killer = root
			}
		}
	}

	after = {
		scope:cultist_warrior ?= {
			if = {
				limit = {
					is_alive = yes
				}
				remove_character_flag = wear_armor
			}
		}

		remove_character_flag = regula_decision_taken
	}
}