﻿namespace = regula_tradition
# 0000-0999: Eligibility events
# 1000-1999: Magister events
# 2000-2999: Generic events
######################################################
# ELIGIBILITY EVENTS
# 0000-0999
######################################################
# Famuli Combat Pillar and Famuli Warriors tradition
regula_tradition.1001 = {
	type = character_event
	title = regula_tradition.1001.t
	desc = {
		desc = regula_tradition.1001.desc_intro
		first_valid = {
			triggered_desc = {
				trigger = {
					character_has_regula_holy_effect_female_offspring = yes
				}
				desc = regula_tradition.1001.desc_few_women
			}
			desc = regula_tradition.1001.desc_many_women
		}
		desc = regula_tradition.1001.desc_end
	}
	theme = regula_theme
	override_background = {
		reference = army_camp
	}
	left_portrait = {
		character = global_var:magister_character
		animation = personality_bold
	}
	right_portrait = {
		character = scope:knight_1
		outfit_tags = { military_outfit }
		animation = marshal_wooden_sword
	}

	lower_left_portrait = {
		character = scope:knight_2
		outfit_tags = { military_outfit }
		animation = idle
	}

	lower_right_portrait = {
		character = scope:knight_3
		outfit_tags = { military_outfit }
		animation = idle	
	}

	immediate = {
		global_var:magister_character.culture = {
			custom_tooltip = {
				text = "regula_adopt_martial_custom_decision_tooltip_effect_pillar"
				set_culture_pillar = martial_custom_regula
			}
			add_culture_tradition = tradition_famuli_warriors
		}
		global_var:magister_character = {
			convert_all_maa_into_famuli_maa = yes
			regula_deplete_famuli_maa_due_to_lack_of_women = yes
			add_character_modifier = {
				modifier = martial_custom_regula_implemented
				years = 10
			}
		}
		# Create bonus knights for player
		regula_create_initiate_effect = {
			WHO = root
			initiate_type = 1
			initiate_rarity = 2
		}
		scope:created_character = {
			save_scope_as = knight_1
		}
		# We only need to show armour for first knight as they are they only one "seen" in event
		scope:knight_1 = {
			add_to_list = new_knights
		}
		regula_create_initiate_effect = {
			WHO = root
			initiate_type = 1
			initiate_rarity = 1
		}
		scope:created_character = {
			save_scope_as = knight_2
			add_to_list = new_knights
		}
		regula_create_initiate_effect = {
			WHO = root
			initiate_type = 1
			initiate_rarity = 1
		}
		scope:created_character = {
			save_scope_as = knight_3
			add_to_list = new_knights
		}
		if = {
			limit = {
				regula_female_blessing_active_trigger = yes
			}
			regula_create_initiate_effect = {
				WHO = root
				initiate_type = 1
				initiate_rarity = 3
			}
			scope:created_character = {
				add_to_list = new_knights
			}
			regula_create_initiate_effect = {
				WHO = root
				initiate_type = 1
				initiate_rarity = 2
			}
			scope:created_character = {
				add_to_list = new_knights
			}
			regula_create_initiate_effect = {
				WHO = root
				initiate_type = 1
				initiate_rarity = 1
			}
			scope:created_character = {
				add_to_list = new_knights
			}
		}
	}
	option = {
		name = regula_tradition.1001.a
		every_in_list = {
			list = new_knights
			root = {
				add_courtier = prev
			}
		}
	}
}

# Famuli Enslavers
regula_tradition.1002 = {
	type = character_event
	title = regula_tradition.1002.t
	desc = regula_tradition.1002.desc
	theme = regula_theme
	override_background = {
		reference = regula_cell
	}

	left_portrait = {
		character = global_var:magister_character
		animation = flirtation
	}

	right_portrait = {
		character = scope:prisoner
		animation = beg
	}

	immediate = {
		random_prisoner = {
			limit = {
				is_female = yes
				age > 17
				age < 30
			}
			save_scope_as = prisoner
		}

		if = {
			limit = { NOT = {exists = scope:prisoner} }
			# If there are no young female prisoners
			# Just make one
			create_character = {
				save_temporary_scope_as = created_character
				location = root.capital_province
				culture = root.culture
				faith = root.faith
				gender = female
				dynasty = none
				template = regula_generated_temple_gardener_character
			}
			scope:created_character = { save_scope_as = prisoner }
			hidden_effect = {
				add_character_flag = {
					flag = block_imprisonment_event
					days = 1
				}
				prisoner_of_war_capture_effect = {
					TARGET = scope:prisoner
					IMPRISONER = root
				}
			}
		}
	}
	option = {
		name = regula_tradition.1002.a
		culture = {
			add_culture_tradition = tradition_famuli_enslavers
		}
		add_character_modifier = {
			years = 15
			modifier = regula_enslavement_bonus_chance
		}
		add_perk = kidnapper_perk
		every_prisoner = {
			limit = {
				is_female = yes
				is_adult = yes
			}
			fascinare_success_effect = { CHARACTER = root }
			create_memory_enchanted_in_prison = { CHARACTER = root }
		}
	}
}

# Magistri Submission tradition
regula_tradition.1003 = {
	type = character_event
	title = regula_tradition.1003.t
	desc = {
		desc = regula_tradition.1003.desc
		triggered_desc = {
			trigger = {
				list_size = {
					name = convert_counties
					value >= 0
				}
			}
			desc = regula_tradition.1003.convert
		}
		desc = regula_tradition.1003.end
	}
	theme = regula_theme
	override_background = {
		reference = throne_room
	}
	right_portrait = {
		character = global_var:magister_character
		animation = personality_bold
	}
	immediate = {
		every_realm_county = {
			every_neighboring_county = {
				limit = {
					culture = root.culture
					NOT = { faith = root.faith }
				}
				add_to_list = convert_counties
			}
		}
		every_realm_county = {
			limit = {
				culture = root.culture
				NOT = { faith = root.faith }
			}
			add_to_list = convert_counties
		}
	}
	option = {
		name = regula_tradition.1003.a
		culture = {
			add_culture_tradition = tradition_magistri_submission
		}
		every_in_list = {
			list = convert_counties
			set_county_faith = root.faith
		}
	}
}

# Magister Bloodline tradition
regula_tradition.1004 = {
	type = character_event
	title = regula_tradition.1004.t
	desc = {
		triggered_desc = {
			trigger = {
				exists = scope:family_noble
			}
			desc = regula_tradition.1004.intro_family
		}
		desc = regula_tradition.1004.desc
	}
	theme = regula_theme
	override_background = {
		reference = throne_room
	}

	left_portrait = {
		character = global_var:magister_character
		animation = idle
	}

	right_portrait = {
		character = scope:family_noble
		animation = idle
	}

	immediate = {
		random_vassal_or_below = {
			limit = {
				is_female = yes
				dynasty = root.dynasty
				highest_held_title_tier >= tier_county
				is_adult = yes
				NOT = { this = root }
			}
			save_scope_as = family_noble
		}
	}

	option = {
		name = regula_tradition.1004.a
		culture = {
			add_culture_tradition = tradition_magister_bloodline
		}
		regula_bloodline_gain_renown_inital_effect = yes
	}
}

# Famuli Reavers
regula_tradition.1005 = {
	type = character_event
	title = regula_tradition.1005.t
	desc = regula_tradition.1005.desc
	theme = regula_theme
	override_background = {
		reference = docks
	}

	left_portrait = {
		character = global_var:magister_character
		animation = flirtation
	}

	right_portrait = {
		character = scope:prisoner
		animation = dead
	}

	immediate = {
		random_prisoner = {
			limit = {
				is_female = yes
				age > 17
				age < 30
			}
			save_scope_as = prisoner
		}

		scope:prisoner = {
			add_character_flag = {
				flag = is_naked
				days = 180
			}
		}
		if = {
			limit = { NOT = {exists = scope:prisoner} }
			# If there are no young female prisoners
			# Just make one
			create_character = {
				save_temporary_scope_as = created_character
				location = root.capital_province
				culture = root.culture
				faith = root.faith
				gender = female
				dynasty = none
				template = regula_generated_temple_gardener_character
			}
			scope:created_character = { save_scope_as = prisoner }
			hidden_effect = {
				add_character_flag = {
					flag = block_imprisonment_event
					days = 1
				}
				prisoner_of_war_capture_effect = {
					TARGET = scope:prisoner
					IMPRISONER = root
				}
			}
		}
	}
	option = {
		name = regula_tradition.1005.a
		culture = {
			add_culture_tradition = tradition_famuli_reavers
		}
		add_character_modifier = {
			years = 15
			modifier = regula_enslavement_bonus_chance
		}
		add_perk = kidnapper_perk
		scope:prisoner = {
			remove_character_flag = is_naked
		}
		every_prisoner = {
			limit = {
				is_female = yes
				is_adult = yes
			}
			fascinare_success_effect = { CHARACTER = root }
			create_memory_enchanted_in_prison = { CHARACTER = root }
		}
	}
}