﻿

#####################################################################
# 00_councillor_effects
#####################################################################

councillor_spouse_learning_2601_tutoring_effect = {
	$STUDENT$ = { save_scope_as = tutoring_student }
	scope:tutoring_student = {
		random_list = {
			20 = { #Critical success
				modifier = {
					has_education_rank_trigger = { RANK = 3 OPERATOR = equals }
					factor = 0.6
				}
				modifier = {
					has_education_rank_trigger = { RANK = 4 OPERATOR = equals }
					factor = 0.6
				}
				modifier = {
					root = { spouse_learning_tier_3_trigger = yes }
					factor = 1.5
				}
				desc = councillor_spouse_learning_2601_tutoring_effect.critical_success
				root = {
					send_interface_toast = {
						type = event_toast_effect_good
						title = councillor_spouse_learning_2601_tutoring_effect.critical_success
						left_icon = scope:tutoring_student
						right_icon = scope:councillor
						scope:tutoring_student = {
							rank_up_education_effect = yes
						}
					}	
					add_character_flag = {
						flag = had_councillor_spouse_learning_2601_event
						days = 7300
					}
				}

				hidden_effect = {
					if = {
						limit = { scope:councillor != scope:tutoring_student } #Since the effect can be used on yourself.
						scope:tutoring_student = {
							add_opinion = {
								target = scope:councillor
								modifier = grateful_opinion
								opinion = 15
							}
						}
					}
					scope:councillor = {
						if = {
							limit = { scope:tutoring_student = { has_trait = education_diplomacy } }
							add_character_modifier = {
								modifier = studying_diplomacy
								years = 10
							}
						}
						else_if = {
							limit = { scope:tutoring_student = { has_trait = education_martial } }
							add_character_modifier = {
								modifier = studying_martial
								years = 10
							}
						}
						else_if = {
							limit = { scope:tutoring_student = { has_trait = education_stewardship } }
							add_character_modifier = {
								modifier = studying_stewardship
								years = 10
							}
						}
						else_if = {
							limit = { scope:tutoring_student = { has_trait = education_intrigue } }
							add_character_modifier = {
								modifier = studying_intrigue
								years = 10
							}
						}
						else_if = {
							limit = { scope:tutoring_student = { has_trait = education_learning } }
							add_character_modifier = {
								modifier = studying_learning
								years = 10
							}
						}
						else_if = {
							limit = { scope:tutoring_student = { has_trait = education_nht_prowess } }
							add_character_modifier = {
								modifier = studying_nht_prowess
								years = 10
							}
						}
						else_if = {
							limit = { scope:tutoring_student = { has_trait = education_nht_leadership } }
							add_character_modifier = {
								modifier = studying_nht_leadership
								years = 10
							}
						}
						random_list = {
							1 = { set_nickname_effect = { NICKNAME = nick_the_scholar } }
							1 = { set_nickname_effect = { NICKNAME = nick_the_wise } }
							10 = { }
						}
					}
				}
			}
			55 = { #Success
				desc = councillor_spouse_learning_2601_tutoring_effect.success
				root = {
					send_interface_toast = {
						type = event_toast_effect_good
						title = councillor_spouse_learning_2601_tutoring_effect.success
						left_icon = scope:tutoring_student
						right_icon = scope:councillor
						scope:tutoring_student = {
							if = {
								limit = { has_trait = education_diplomacy }
								add_character_modifier = {
									modifier = studying_diplomacy
									years = 10
								}
							}
							else_if = {
								limit = { has_trait = education_martial }
								add_character_modifier = {
									modifier = studying_martial
									years = 10
								}
							}
							else_if = {
								limit = { has_trait = education_stewardship }
								add_character_modifier = {
									modifier = studying_stewardship
									years = 10
								}
							}
							else_if = {
								limit = { has_trait = education_intrigue }
								add_character_modifier = {
									modifier = studying_intrigue
									years = 10
								}
							}
							else_if = {
								limit = { has_trait = education_learning }
								add_character_modifier = {
									modifier = studying_learning
									years = 10
								}
							}
							else_if = {
								limit = { has_trait = education_nht_prowess }
								add_character_modifier = {
									modifier = studying_nht_prowess
									years = 10
								}
							}
							else_if = {
								limit = { has_trait = education_nht_leadership }
								add_character_modifier = {
									modifier = studying_nht_leadership
									years = 10
								}
							}
							add_character_flag = {
								flag = had_councillor_spouse_learning_2601_event
								days = 3650
							}
						}
					}
				}
				hidden_effect = {
					if = {
						limit = {
							scope:tutoring_student != scope:councillor #Since the effect can be used on yourself.
						}
						scope:tutoring_student = {
							add_opinion = {
								target = scope:councillor
								modifier = grateful_opinion
								opinion = 10
							}
						}
					}
				}
			}
		}
	}
}


results_of_patronage_spouse_education_points_effect = {
	if = {
		limit = { has_variable = patronage_spouse_tutor }

		var:patronage_spouse_tutor = {
			save_scope_as = patronage_spouse_tutor
		}

		#Checks their current level
		if = {
			limit = { education_points_equals_education_rank = { RANK = 1 } }
			save_scope_value_as = {
				name = education_rank_before_patronage
				value = 1
			}
		}
		else_if = {
			limit = { education_points_equals_education_rank = { RANK = 2 } }
			save_scope_value_as = {
				name = education_rank_before_patronage
				value = 2
			}
		}
		else_if = {
			limit = { education_points_equals_education_rank = { RANK = 3 } }
			save_scope_value_as = {
				name = education_rank_before_patronage
				value = 3
			}
		}
		else_if = {
			limit = { education_points_equals_education_rank = { RANK = 4 } }
			save_scope_value_as = {
				name = education_rank_before_patronage
				value = 4
			}
		}
		#Adding the points to the current education
		if = {
			limit = { has_focus = education_diplomacy }
			change_variable = {
				name = education_diplomacy_variable
				add = var:patronage_spouse_tutor_points
			}
		}
		else_if = {
			limit = { has_focus = education_martial }
			change_variable = {
				name = education_martial_variable
				add = var:patronage_spouse_tutor_points
			}
		}
		else_if = {
			limit = { has_focus = education_stewardship }
			change_variable = {
				name = education_stewardship_variable
				add = var:patronage_spouse_tutor_points
			}
		}
		else_if = {
			limit = { has_focus = education_intrigue }
			change_variable = {
				name = education_intrigue_variable
				add = var:patronage_spouse_tutor_points
			}
		}
		else_if = {
			limit = { has_focus = education_learning }
			change_variable = {
				name = education_learning_variable
				add = var:patronage_spouse_tutor_points
			}
		}
		### Start More Lifestyles Submod Modifications
		else_if = {
			limit = { 
				has_focus = education_nht_prowess 
				exists = var:education_nht_prowess_variable 
			}
			change_variable = {
				name = education_nht_prowess_variable
				add = var:patronage_spouse_tutor_points
			}
		}
		else_if = {
			limit = { 
				has_focus = education_nht_leadership 
				exists = var:education_nht_leadership_variable
			}
			change_variable = {
				name = education_nht_leadership_variable
				add = var:patronage_spouse_tutor_points
			}
		}
		### End More Lifestyles Submod Modifications
		#Checks their new level
		if = {
			limit = { education_points_equals_education_rank = { RANK = 1 } }
			save_scope_value_as = {
				name = education_rank_after_patronage
				value = 1
			}
		}
		else_if = {
			limit = { education_points_equals_education_rank = { RANK = 2 } }
			save_scope_value_as = {
				name = education_rank_after_patronage
				value = 2
			}
		}
		else_if = {
			limit = { education_points_equals_education_rank = { RANK = 3 } }
			save_scope_value_as = {
				name = education_rank_after_patronage
				value = 3
			}
		}
		else_if = {
			limit = { education_points_equals_education_rank = { RANK = 4 } }
			save_scope_value_as = {
				name = education_rank_after_patronage
				value = 4
			}
		}

		#Sets flag for result
		if = {
			limit = {
				exists = scope:education_rank_before_patronage
				exists = scope:education_rank_after_patronage
			}
			if = {
				limit = { #+1
					OR = {
						AND = {
							scope:education_rank_before_patronage = 1
							scope:education_rank_after_patronage = 2
						}
						AND = {
							scope:education_rank_before_patronage = 2
							scope:education_rank_after_patronage = 3
						}
						AND = {
							scope:education_rank_before_patronage = 3
							scope:education_rank_after_patronage = 4
						}
					}
				}
				save_scope_value_as = {
					name = education_rank_patronage_bonus
					value = flag:1
				}
			}
			else_if = { #+2 or more
				limit = { scope:education_rank_after_patronage != scope:education_rank_before_patronage }
				save_scope_value_as = {
					name = education_rank_patronage_bonus
					value = flag:2_or_more
				}
			}
		}

		if = {
			limit = {
				exists = scope:education_rank_patronage_bonus
				scope:education_rank_patronage_bonus = flag:1
				scope:education_rank_patronage_bonus = flag:2_or_more
			}
		}

		if = {
			limit = {
				has_variable = patronage_spouse_tutor_points
			}
			remove_variable = patronage_spouse_tutor_points
		}
		#Got to keep the tutor var for now, but it is automatically cleared with time
	}
}

#####################################################################
# 00_court_position_effect
#####################################################################

# Giving out generic court positions
decide_court_position_to_give_effect = {
	$EMPLOYER$ = {
		if = {
			limit = { exists = $CANDIDATE$ }
			if = {
				limit = {
					$CANDIDATE$ = {
						OR = {
							has_trait = education_learning
							learning >= high_skill_rating
						}
					}
				}
				random_list = {
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = court_physician_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = physician_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = court_tutor_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = tutor_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = court_guru_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = tutor_flag } # reusing same flag as tutor for simplicity later on
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = high_almoner_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = almoner_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = antiquarian_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = antiquarian_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = chief_qadi_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = qadi_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = fire_dragon_engineer_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = fire_dragon_engineer_flag }
					}
				}
			}
			else_if = {
				limit = {
					$CANDIDATE$ = {
						OR = {
							has_trait = education_intrigue
							intrigue >= high_skill_rating
						}
					}
				}
				random_list = {
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = food_taster_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = taster_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = executioner_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = executioner_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$ 
								COURT_POS = court_tutor_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = tutor_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$ 
								COURT_POS = court_guru_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = tutor_flag } # reusing flag as tutor for simplicity later on
					}
				}
			}
			else_if = {
				limit = {
					$CANDIDATE$ = {
						OR = {
							has_trait = education_diplomacy
							diplomacy >= high_skill_rating
						}
					}
				}
				random_list = {
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = cupbearer_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = cupbearer_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = lady_in_waiting_court_position
							}
							$CANDIDATE$ = { is_female = yes }
						}
						$CANDIDATE$ = { add_character_flag = lady_in_waiting_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = court_tutor_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = tutor_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = court_guru_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = tutor_flag } # reusing same flag as tutor for simplicity later on
					}
					20 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = court_jester_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = jester_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = court_poet_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = poet_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = court_musician_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = musician_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = wet_nurse_court_position
							}
							$CANDIDATE$ = { is_female = yes }
						}
						$CANDIDATE$ = { add_character_flag = wet_nurse_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = grand_preceptor_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = grand_preceptor_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = grand_guardian_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = grand_guardian_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = grand_mentor_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = grand_mentor_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = keeper_of_the_harem_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = keeper_of_the_harem_flag }
					}
				}
			}
			else_if = {
				limit = {
					$CANDIDATE$ = {
						OR = {
							has_trait = education_stewardship
							stewardship >= high_skill_rating
							has_trait = education_nht_leadership
						}
					}
				}
				random_list = {
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = court_gardener_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = gardener_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = royal_architect_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = architect_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = court_tutor_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = tutor_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = court_guru_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = tutor_flag } # reusing same flag as tutor for simplicity later on
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = keeper_of_swans_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = swan_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = seneschal_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = seneschal_flag }
					}
				}
			}
			else_if = {
				limit = {
					$CANDIDATE$ = {
						OR = {
							has_trait = education_martial
							has_trait = education_nht_prowess
							martial >= high_skill_rating
						}
					}
				}
				random_list = {
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = master_of_horse_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = horse_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = garuda_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = garuda_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = court_tutor_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = tutor_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = court_guru_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = tutor_flag } # reusing tutor flag for simplicity later on
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = master_of_hunt_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = hunt_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = bodyguard_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = bodyguard_flag }
					}
					10 = {
						trigger = {
							can_appoint_char_to_court_position = {
								CHAR = $CANDIDATE$
								COURT_POS = champion_court_position
							}
						}
						$CANDIDATE$ = { add_character_flag = champion_flag }
					}
				}
			}
		}
	}
}

#####################################################################
# 01_ep1_court_artifact_creation_effect
#####################################################################

set_book_subject_effect = {
	save_temporary_scope_value_as = {
		name = allow_no_subject_option
		value = $NO_SUBJECT$
	}
	hidden_effect = { #If they haven't specified what they're gonna write about we decide it here (might still leave it up to the sponsor if allow_no_subject_option = yes!)
		$BASE_SCOPE$ = {
			if = {
				limit = {
					NOT = { exists = var:book_subject }
				}
				random_list = { #What do they want to write about?
					1 = {
						modifier = {
							add = 60
							has_education_martial_trigger = yes
						}
						modifier = {
							add = 60
							has_education_nht_prowess_trigger = yes
						}
						modifier = {
							add = 40
							book_subject_martial_trigger = yes
						}
						modifier = {
							add = { #If they're good you get +, if they're shit you get -
								value = average_skill_rating
								subtract = martial
								multiply = -5
							}
						}
						set_variable = {
							name = book_subject
							value = flag:martial
						}
					}
					1 = {
						modifier = {
							add = 60
							has_education_diplomacy_trigger = yes
						}
						modifier = {
							add = { #If they're good you get +, if they're shit you get -
								value = average_skill_rating
								subtract = diplomacy
								multiply = -5
							}
						}
						set_variable = {
							name = book_subject
							value = flag:diplomacy
						}
					}
					1 = {
						modifier = {
							add = 60
							has_education_stewardship_trigger = yes
						}
						modifier = {
							add = 60
							has_education_nht_leadership_trigger = yes
						}
						modifier = {
							add = { #If they're good you get +, if they're shit you get -
								value = average_skill_rating
								subtract = stewardship
								multiply = -5
							}
						}
						set_variable = {
							name = book_subject
							value = flag:stewardship
						}
					}
					1 = {
						modifier = {
							add = 60
							has_education_intrigue_trigger = yes
						}
						modifier = {
							add = { #If they're good you get +, if they're shit you get -
								value = average_skill_rating
								subtract = intrigue
								multiply = -5
							}
						}
						set_variable = {
							name = book_subject
							value = flag:intrigue
						}
					}
					1 = {
						modifier = {
							add = 60
							has_education_learning_trigger = yes
						}
						modifier = {
							add = { #If they're good you get +, if they're shit you get -
								value = average_skill_rating
								subtract = learning
								multiply = -5
							}
						}
						set_variable = {
							name = book_subject
							value = flag:learning
						}
					}
					1 = {
						modifier = {
							add = 50
							book_subject_medicine_trigger = yes
						}
						modifier = {
							add = 20
							is_witch_trigger = yes
						}
						modifier = {
							add = {
								value = learning
								multiply = 2
							}
						}
						ai_value_modifier = {
							ai_rationality = 0.25
						}
						set_variable = {
							name = book_subject
							value = flag:medicine
						}
					}
					1 = {
						trigger = {
							is_witch_trigger = yes
						}
						modifier = {
							add = 20
							book_subject_witch_trigger = yes
						}
						ai_value_modifier = {
							ai_boldness = 0.75
						}
						set_variable = {
							name = book_subject
							value = flag:witch
						}
						set_variable = {
							name = book_subject_witch_scope
							value = this
						}
					}
					40 = {
						trigger = {
							has_trait = lifestyle_reveler
						}
						ai_value_modifier = {
							ai_compassion = 0.25
						}
						set_variable = {
							name = book_subject
							value = flag:reveler
						}
					}
					40 = {
						trigger = {
							has_trait = lifestyle_blademaster
						}
						modifier = {
							add = {
								value = martial
								multiply = 2
							}
						}
						set_variable = {
							name = book_subject
							value = flag:blademaster
						}
					}
					40 = {
						trigger = {
							has_trait = lifestyle_hunter
						}
						set_variable = {
							name = book_subject
							value = flag:hunter
						}
					}
					40 = {
						trigger = {
							has_trait = lifestyle_mystic
						}
						modifier = {
							add = {
								value = learning
								multiply = 2
							}
						}
						set_variable = {
							name = book_subject
							value = flag:mystic
						}
					}
					40 = {
						trigger = {
							has_trait = lifestyle_herbalist
						}
						modifier = {
							add = {
								value = learning
								multiply = 2
							}
						}
						set_variable = {
							name = book_subject
							value = flag:herbalist
						}
					}
					40 = {
						trigger = {
							has_trait = legend
						}
						modifier = {
							add = {
								value = martial
								multiply = 2
							}
						}
						set_variable = {
							name = book_subject
							value = flag:legend
						}
					}
					1 = {
						trigger = {
							is_cannibal_trigger = yes
						}
						modifier = {
							add = 30
							book_subject_cannibal_trigger = yes
						}
						ai_value_modifier = {
							ai_boldness = 0.75
						}
						set_variable = {
							name = book_subject
							value = flag:cannibal
						}
					}
					1 = {
						modifier = {
							add = 50
							book_subject_torturer_trigger = yes
						}
						compare_modifier = {
							value = intrigue
							multiplier = 0.5
						}
						set_variable = {
							name = book_subject
							value = flag:torturer
						}
					}
					1 = {
						trigger = {
							is_deviant_trigger = yes
						}
						modifier = {
							add = 30
							OR = {
								has_trait = arrogant
								has_trait = deviant
							}
						}
						ai_value_modifier = {
							ai_boldness = 0.75
						}
						set_variable = {
							name = book_subject
							value = flag:deviant
						}
					}
					50 = {
						trigger = {
							has_trait = lunatic
						}
						ai_value_modifier = {
							ai_boldness = 0.75
						}
						set_variable = {
							name = book_subject
							value = flag:lunatic
						}
					}
					400 = {
						trigger = { #Why are you sponsoring a kid to write??
							is_adult = no
						}
						set_variable = {
							name = book_subject
							value = flag:childhood
						}
						set_favorite_toy_effect = yes
					}
					50 = {
						trigger = {
							book_subject_animals_trigger = yes
						}
						modifier = { #If a kid has a pet they're gonna wanna to write about it
							add = 800
							is_adult = no
						}
						modifier = {
							add = 75
							has_trait = lunatic
						}
						modifier = {
							add = 50
							has_trait = intellect_bad
						}
						set_variable = {
							name = book_subject
							value = flag:animals
						}
					}
					50 = { #They don't care and you can decide!
						trigger = {
							scope:allow_no_subject_option = yes
						}
						modifier = {
							add = 30
							has_personality_submissive_trigger = yes
						}
						ai_value_modifier = {
							ai_boldness = -0.25
							ai_energy = -0.25
						}
					}
				}

				# FALLBACK: The previous list can return nothing if you're bad at all skills and have nothing special going on
				if = {
					limit = {
						NOT = { exists = var:book_subject }
						scope:allow_no_subject_option = no
					}
					random_list = {
						1 = {
							modifier = {
								add = 60
								has_education_martial_trigger = yes
							}
							modifier = {
								add = 60
								has_education_nht_prowess_trigger = yes
							}
							modifier = {
								add = 40
								OR = {
									prowess >= high_skill_rating
									has_trait = faith_warrior
									has_trait = crusader_king
									has_trait = viking
									number_of_commander_traits >= 1
								}
							}
							modifier = {
								add = {
									value = martial
									multiply = 2
								}
							}
							set_variable = {
								name = book_subject
								value = flag:martial
							}
						}
						1 = {
							modifier = {
								add = 60
								has_education_diplomacy_trigger = yes
							}
							modifier = {
								add = {
									value = diplomacy
									multiply = 2
								}
							}
							set_variable = {
								name = book_subject
								value = flag:diplomacy
							}
						}
						1 = {
							modifier = {
								add = 60
								has_education_stewardship_trigger = yes
							}
							modifier = {
								add = 60
								has_education_nht_leadership_trigger = yes
							}
							modifier = {
								add = {
									value = stewardship
									multiply = 2
								}
							}
							set_variable = {
								name = book_subject
								value = flag:stewardship
							}
						}
						1 = {
							modifier = {
								add = 60
								has_education_intrigue_trigger = yes
							}
							modifier = {
								add = {
									value = intrigue
									multiply = 2
								}
							}
							set_variable = {
								name = book_subject
								value = flag:intrigue
							}
						}
						1 = {
							modifier = {
								add = 60
								has_education_learning_trigger = yes
							}
							modifier = {
								add = {
									value = learning
									multiply = 2
								}
							}
							set_variable = {
								name = book_subject
								value = flag:learning
							}
						}
					}
				}
			}
		}
	}
}

# Here we save the content quality of the book; how well does the author understand/know the subject? This is separate from the artifact quality value since that's about the quality of the artifact itself, not the content of the text
get_book_content_quality_effect = {
	$SKILL_BASE$ = { save_scope_as = skill_base }
	save_scope_value_as = {
		name = book_content_quality
		value = {
			# Choices in events etc. will affect the quality of the artifact you get
			if = {
				limit = {
					exists = scope:skill_base.var:book_content_quality
				}
				add = {
					value = scope:skill_base.var:book_content_quality
					multiply = 10
				}
			}
			# Is it a lifestyle subject? Then it's good if the inspiration owner shares the lifestyle
			if = { # medicine
				limit = {
					has_artifact_feature = book_subject_medicine
				}
				if = {
					limit = {
						scope:skill_base = {
							has_trait = lifestyle_physician
						}
					}
					add = 30
				}
				if = {
					limit = {
						scope:skill_base = {
							has_trait = lifestyle_mystic
						}
					}
					add = 20
				}
				if = {
					limit = {
						scope:skill_base = {
							has_trait = lifestyle_herbalist
						}
					}
					add = 20
				}
				if = {
					limit = {
						scope:skill_base = {
							is_witch_trigger = yes
						}
					}
					add = 10
				}
			}
			if = { # reveler
				limit = {
					has_artifact_feature = book_subject_reveler
					scope:skill_base = {
						has_trait = lifestyle_reveler
					}
				}
				add = 30
			}
			if = { # blademaster
				limit = {
					has_artifact_feature = book_subject_blademaster
					scope:skill_base = {
						has_trait = lifestyle_blademaster
					}
				}
				add = 30
			}
			if = { # hunter
				limit = {
					has_artifact_feature = book_subject_hunter
					scope:skill_base = {
						has_trait = lifestyle_hunter
					}
				}
				add = 30
			}
			if = { # mystic
				limit = {
					has_artifact_feature = book_subject_mystic
					scope:skill_base = {
						has_trait = lifestyle_mystic
					}
				}
				add = 30
			}
			if = { # herbalist
				limit = {
					has_artifact_feature = book_subject_herbalist
					scope:skill_base = {
						has_trait = lifestyle_herbalist
					}
				}
				add = 30
			}
			if = { # cannibal
				limit = {
					has_artifact_feature = book_subject_cannibal
					scope:skill_base = {
						is_cannibal_trigger = yes
					}
				}
				add = 30
			}
			if = { # witch
				limit = {
					has_artifact_feature = book_subject_witch
					scope:skill_base = {
						is_witch_trigger = yes
					}
				}
				add = 30
			}
			if = { # deviant
				limit = {
					has_artifact_feature = book_subject_deviant
					scope:skill_base = {
						is_deviant_trigger = yes
					}
				}
				add = 30
			}
			if = { # lunatic
				limit = {
					has_artifact_feature = book_subject_lunatic
					scope:skill_base = {
						has_trait = lunatic
					}
				}
				add = 30
			}
			if = { # relationship - score based on the authors opinion of the subject
				limit = {
					has_artifact_feature = book_subject_relationship
					scope:skill_base = {
						save_temporary_opinion_value_as = {
							name = opinion_of_subject
							target = scope:owner.var:book_topic_relationship
						}
					}
				}
				add = {
					value = scope:opinion_of_subject
					min = 0
					max = 75
				}
			}
			if = { # relationship - boost if you're socially savvy
				limit = {
					has_artifact_feature = book_subject_relationship
					scope:skill_base = { has_trait = gregarious }
				}
				add = 10
			}
			# If it's about your actions related to unification/creation/restoration of a title then it's just naturally easier to make you look good
			if = {
				limit = {
					OR = {
						has_artifact_feature = book_subject_kingdom
						has_artifact_feature = book_subject_empire
					}
				}
				add = 50
			}
			# The owner and inspiration owner's skills in the relevant subject, and education trait, affects the outcome
			if = {
				limit = {
					has_artifact_feature = book_subject_martial
				}
				add = { #If they're good you get +, if they're shit you get -
					value = average_skill_rating
					subtract = scope:skill_base.martial
					multiply = -6
				}
				add = scope:owner.martial
				scope:skill_base = {
					if = {
						limit = {
							has_trait = education_martial_1
						}
						add = 20
					}
					else_if = {
						limit = {
							has_trait = education_martial_2
						}
						add = 40
					}
					else_if = {
						limit = {
							has_trait = education_martial_3
						}
						add = 60
					}
				}
			}
			else_if = {
				limit = {
					has_artifact_feature = book_subject_diplomacy
				}
				add = { #If they're good you get +, if they're shit you get -
					value = average_skill_rating
					subtract = scope:skill_base.diplomacy
					multiply = -6
				}
				add = scope:owner.diplomacy
				scope:skill_base = {
					if = {
						limit = {
							has_trait = education_diplomacy_1
						}
						add = 20
					}
					else_if = {
						limit = {
							has_trait = education_diplomacy_2
						}
						add = 40
					}
					else_if = {
						limit = {
							has_trait = education_diplomacy_3
						}
						add = 60
					}
				}
			}
			else_if = {
				limit = {
					has_artifact_feature = book_subject_stewardship
				}
				add = { #If they're good you get +, if they're shit you get -
					value = average_skill_rating
					subtract = scope:skill_base.stewardship
					multiply = -6
				}
				add = scope:owner.stewardship
				scope:skill_base = {
					if = {
						limit = {
							has_trait = education_stewardship_1
						}
						add = 20
					}
					else_if = {
						limit = {
							has_trait = education_stewardship_2
						}
						add = 40
					}
					else_if = {
						limit = {
							has_trait = education_stewardship_3
						}
						add = 60
					}
				}
			}
			else_if = {
				limit = {
					OR = {
						has_artifact_feature = book_subject_intrigue
						has_artifact_feature = book_subject_torturer
					}
				}
				add = { #If they're good you get +, if they're shit you get -
					value = average_skill_rating
					subtract = scope:skill_base.intrigue
					multiply = -6
				}
				add = scope:owner.intrigue
				scope:skill_base = {
					if = {
						limit = {
							has_trait = education_intrigue_1
						}
						add = 20
					}
					else_if = {
						limit = {
							has_trait = education_intrigue_2
						}
						add = 40
					}
					else_if = {
						limit = {
							has_trait = education_intrigue_3
						}
						add = 60
					}
				}
			}
			else_if = {
				limit = {
					has_artifact_feature = book_subject_learning
				}
				add = { #If they're good you get +, if they're shit you get -
					value = average_skill_rating
					subtract = scope:skill_base.learning
					multiply = -6
				}
				add = scope:owner.learning
				scope:skill_base = {
					if = {
						limit = {
							has_trait = education_learning_1
						}
						add = 20
					}
					else_if = {
						limit = {
							has_trait = education_learning_2
						}
						add = 40
					}
					else_if = {
						limit = {
							has_trait = education_learning_3
						}
						add = 60
					}
				}
			}
			# The overall quality has an impact as well
			add = {
				value = scope:quality
				multiply = 0.25
			}
		}
	}
}



#####################################################################
# EFFECT LIST
#####################################################################
# !!! Remember to add all new effects with a short description here !!!

#education_point_acquisition_effect - Rolls a random chance for assigning education points based on a number of factors. Run in a pulse event every half year of childhood.

#education_point_acquisition_additional_points_effect - Effect to award more education points through one-offs like events etc.

#education_complete_notification_effect - Identifies characters for the "Education Completed" notification events and sends the events.

#save_childhood_trait_as_variable_effect - Saves childhood trait as a variable flag

#assign_commander_trait_effect - To assign a commander trait to a child with a martial education

#wrap_up_education_effect - Additional effects run to wrap up education

#rank_up_education_effect - Increases your education by 1 rank unless it's at 4 (or you don't have any)

######################################################################
# EFFECTS
######################################################################


#Education point acquisition

education_point_acquisition_effect = {
	if = {
		limit = { has_focus = education_diplomacy }
		education_point_acquisition_support_effect = { SKILL = diplomacy }
	}
	else_if = {
		limit = { has_focus = education_martial }
		education_point_acquisition_support_effect = { SKILL = martial }
	}
	else_if = {
		limit = { has_focus = education_stewardship }
		education_point_acquisition_support_effect = { SKILL = stewardship }
	}
	else_if = {
		limit = { has_focus = education_intrigue }
		education_point_acquisition_support_effect = { SKILL = intrigue }
	}
	else_if = {
		limit = { has_focus = education_learning }
		education_point_acquisition_support_effect = { SKILL = learning }
	}
	####### Start More Lifestyles Submod Modifications	
	else_if = {
		limit = { has_focus = education_nht_prowess }
		education_point_acquisition_support_effect = { SKILL = prowess }
	}
	else_if = {
		limit = { has_focus = education_nht_leadership }
		education_point_acquisition_support_effect = { SKILL = stewardship }
	}
	####### End More Lifestyles Submod Modifications
}

#Effect to award more education points through one-offs like events etc
#Takes argument LEVEL low/mid
education_point_acquisition_additional_points_effect = {
	save_temporary_scope_value_as = {
		name = point_level
		value = flag:$LEVEL$
	}
	#Mid
	if = {
		limit = { scope:point_level = flag:mid }
		if = {
			limit = { has_focus = education_diplomacy }
			#Set variables if they don't exist
			if = {
				limit = {
					NOT = { has_variable = education_diplomacy_variable }
				}
				set_variable = {
					name = education_diplomacy_variable
					value = 0
				}
			}
			#Award more points
			change_variable = {
				name = education_diplomacy_variable
				add = 6
			}
		}
		else_if = {
			limit = { has_focus = education_martial }
			#Set variables if they don't exist
			if = {
				limit = {
					NOT = { has_variable = education_martial_variable }
				}
				set_variable = {
					name = education_martial_variable
					value = 0
				}
			}
			#Award more points
			change_variable = {
				name = education_martial_variable
				add = 6
			}
		}
		else_if = {
			limit = { has_focus = education_stewardship }
			#Set variables if they don't exist
			if = {
				limit = {
					NOT = { has_variable = education_stewardship_variable }
				}
				set_variable = {
					name = education_stewardship_variable
					value = 0
				}
			}
			#Award more points
			change_variable = {
				name = education_stewardship_variable
				add = 6
			}
		}
		else_if = {
			limit = { has_focus = education_intrigue }
			#Set variables if they don't exist
			if = {
				limit = {
					NOT = { has_variable = education_intrigue_variable }
				}
				set_variable = {
					name = education_intrigue_variable
					value = 0
				}
			}
			#Award more points
			change_variable = {
				name = education_intrigue_variable
				add = 6
			}
		}
		else_if = {
			limit = { has_focus = education_learning }
			#Set variables if they don't exist
			if = {
				limit = {
					NOT = { has_variable = education_learning_variable }
				}
				set_variable = {
					name = education_learning_variable
					value = 0
				}
			}
			#Award more points
			change_variable = {
				name = education_learning_variable
				add = 6
			}
		}
		####### Start More Lifestyles Submod Modifications		
		else_if = {
			limit = { has_focus = education_nht_prowess }
			#Set variables if they don't exist
			if = {
				limit = {
					NOT = { has_variable = education_nht_prowess_variable }
				}
				set_variable = {
					name = education_nht_prowess_variable
					value = 0
				}
			}
			#Award more points
			change_variable = {
				name = education_nht_prowess_variable
				add = 6
			}
		}
		else_if = {
			limit = { has_focus = education_nht_leadership }
			#Set variables if they don't exist
			if = {
				limit = {
					NOT = { has_variable = education_nht_leadership_variable }
				}
				set_variable = {
					name = education_nht_leadership_variable
					value = 0
				}
			}
			#Award more points
			change_variable = {
				name = education_nht_leadership_variable
				add = 6
			}
		}
		####### End More Lifestyles Submod Modifications
	}
	#Low
	else_if = {
		limit = { scope:point_level = flag:low }
		if = {
			limit = { has_focus = education_diplomacy }
			#Set variables if they don't exist
			if = {
				limit = {
					NOT = { has_variable = education_diplomacy_variable }
				}
				set_variable = {
					name = education_diplomacy_variable
					value = 0
				}
			}
			#Award more points
			change_variable = {
				name = education_diplomacy_variable
				add = 4
			}
		}
		else_if = {
			limit = { has_focus = education_martial }
			#Set variables if they don't exist
			if = {
				limit = {
					NOT = { has_variable = education_martial_variable }
				}
				set_variable = {
					name = education_martial_variable
					value = 0
				}
			}
			#Award more points
			change_variable = {
				name = education_martial_variable
				add = 4
			}
		}
		else_if = {
			limit = { has_focus = education_stewardship }
			#Set variables if they don't exist
			if = {
				limit = {
					NOT = { has_variable = education_stewardship_variable }
				}
				set_variable = {
					name = education_stewardship_variable
					value = 0
				}
			}
			#Award more points
			change_variable = {
				name = education_stewardship_variable
				add = 4
			}
		}
		else_if = {
			limit = { has_focus = education_intrigue }
			#Set variables if they don't exist
			if = {
				limit = {
					NOT = { has_variable = education_intrigue_variable }
				}
				set_variable = {
					name = education_intrigue_variable
					value = 0
				}
			}
			#Award more points
			change_variable = {
				name = education_intrigue_variable
				add = 4
			}
		}
		else_if = {
			limit = { has_focus = education_learning }
			#Set variables if they don't exist
			if = {
				limit = {
					NOT = { has_variable = education_learning_variable }
				}
				set_variable = {
					name = education_learning_variable
					value = 0
				}
			}
			#Award more points
			change_variable = {
				name = education_learning_variable
				add = 4
			}
		}
		####### Start More Lifestyles Submod Modifications
		else_if = {
			limit = { has_focus = education_nht_prowess }
			#Set variables if they don't exist
			if = {
				limit = {
					NOT = { has_variable = education_nht_prowess_variable }
				}
				set_variable = {
					name = education_nht_prowess_variable
					value = 0
				}
			}
			#Award more points
			change_variable = {
				name = education_nht_prowess_variable
				add = 4
			}
		}
		else_if = {
			limit = { has_focus = education_nht_leadership }
			#Set variables if they don't exist
			if = {
				limit = {
					NOT = { has_variable = education_nht_leadership_variable }
				}
				set_variable = {
					name = education_nht_leadership_variable
					value = 0
				}
			}
			#Award more points
			change_variable = {
				name = education_nht_leadership_variable
				add = 4
			}
		}
		####### End More Lifestyles Submod Modifications
	}
}

remove_variables_and_trait_coming_of_age_effect = {
	if = {
		limit = {
			exists = var:had_childhood_crush_variable
		}
		remove_variable = had_childhood_crush_variable
	}
	if = {
		limit = {
			exists = var:unrequited_crush
		}
		remove_variable = unrequited_crush
	}
	if = {
		limit = {
			exists = var:had_childhood_victim_variable
		}
		remove_variable = had_childhood_victim_variable
	}
	if = {
		limit = {
			exists = var:had_childhood_bully_variable
		}
		remove_variable = had_childhood_bully_variable
	}
	if = {
		limit = { has_trait = curious }
		remove_trait = curious
	}
	if = {
		limit = { has_trait = rowdy }
		remove_trait = rowdy
	}
	if = {
		limit = { has_trait = bossy }
		remove_trait = bossy
	}
	if = {
		limit = { has_trait = charming }
		remove_trait = charming
	}
	if = {
		limit = { has_trait = pensive }
		remove_trait = pensive
	}
	if = {
		limit = {
			has_character_flag = bully_destroyed_toy
		}
		remove_character_flag = bully_destroyed_toy
	}
	if = {
		limit = {
			has_character_flag = natural_education_progression
		}
		remove_character_flag = natural_education_progression
	}
	if = {
		limit = {
			has_variable = education_point_gain_variable
		}
		remove_variable = education_point_gain_variable
	}
	if = {
		limit = {
			has_variable = childhood_trait_type
		}
		remove_variable = childhood_trait_type
	}
	if = {
		limit = {
			exists = var:education_diplomacy_variable
		}
		remove_variable = education_diplomacy_variable
	}
	if = {
		limit = {
			exists = var:education_martial_variable
		}
		remove_variable = education_martial_variable
	}
	if = {
		limit = {
			exists = var:education_stewardship_variable
		}
		remove_variable = education_stewardship_variable
	}
	if = {
		limit = {
			exists = var:education_intrigue_variable
		}
		remove_variable = education_intrigue_variable
	}
	if = {
		limit = {
			exists = var:education_learning_variable
		}
		remove_variable = education_learning_variable
	}
	####### Start More Lifestyles Submod Modifications
	if = {
		limit = {
			exists = var:education_nht_prowess_variable
		}
		remove_variable = education_nht_prowess_variable
	}
	if = {
		limit = {
			exists = var:education_nht_leadership_variable
		}
		remove_variable = education_nht_leadership_variable
	}
	####### End More Lifestyles Submod Modifications
}

#Display correct trait tooltip
display_correct_education_trait_gain_tooltip_effect = {
	if = {
		limit = { has_trait = education_diplomacy_1 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_diplomacy_1
		}
	}
	if = {
		limit = { has_trait = education_diplomacy_2 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_diplomacy_2
		}
	}
	if = {
		limit = { has_trait = education_diplomacy_3 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_diplomacy_3
		}
	}
	if = {
		limit = { has_trait = education_diplomacy_4 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_diplomacy_4
		}
	}
	if = {
		limit = { has_trait = education_diplomacy_5 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_diplomacy_5
		}
	}
	if = {
		limit = { has_trait = education_martial_1 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_martial_1
		}
	}
	if = {
		limit = { has_trait = education_martial_2 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_martial_2
		}
	}
	if = {
		limit = { has_trait = education_martial_3 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_martial_3
		}
	}
	if = {
		limit = { has_trait = education_martial_4 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_martial_4
		}
	}
	if = {
		limit = { has_trait = education_martial_5 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_martial_5
		}
	}
	if = {
		limit = { has_trait = education_stewardship_1 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_stewardship_1
		}
	}
	if = {
		limit = { has_trait = education_stewardship_2 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_stewardship_2
		}
	}
	if = {
		limit = { has_trait = education_stewardship_3 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_stewardship_3
		}
	}
	if = {
		limit = { has_trait = education_stewardship_4 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_stewardship_4
		}
	}
	if = {
		limit = { has_trait = education_stewardship_5 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_stewardship_5
		}
	}
	if = {
		limit = { has_trait = education_intrigue_1 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_intrigue_1
		}
	}
	if = {
		limit = { has_trait = education_intrigue_2 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_intrigue_2
		}
	}
	if = {
		limit = { has_trait = education_intrigue_3 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_intrigue_3
		}
	}
	if = {
		limit = { has_trait = education_intrigue_4 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_intrigue_4
		}
	}
	if = {
		limit = { has_trait = education_intrigue_5 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_intrigue_5
		}
	}
	if = {
		limit = { has_trait = education_learning_1 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_learning_1
		}
	}
	if = {
		limit = { has_trait = education_learning_2 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_learning_2
		}
	}
	if = {
		limit = { has_trait = education_learning_3 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_learning_3
		}
	}
	if = {
		limit = { has_trait = education_learning_4 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_learning_4
		}
	}
	if = {
		limit = { has_trait = education_learning_5 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_learning_5
		}
	}
	if = { # Knighthood innovation
		limit = { has_trait = education_martial_prowess_1 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_martial_prowess_1
		}
	}
	if = {
		limit = { has_trait = education_martial_prowess_2 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_martial_prowess_2
		}
	}
	if = {
		limit = { has_trait = education_martial_prowess_3 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_martial_prowess_3
		}
	}
	if = {
		limit = { has_trait = education_martial_prowess_4 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_martial_prowess_4
		}
	}
	##### Start More Lifestyles Submod Modifications
	if = {
		limit = { has_trait = education_nht_prowess_1 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_nht_prowess_1
		}
	}
	if = {
		limit = { has_trait = education_nht_prowess_2 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_nht_prowess_2
		}
	}
	if = {
		limit = { has_trait = education_nht_prowess_3 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_nht_prowess_3
		}
	}
	if = {
		limit = { has_trait = education_nht_prowess_4 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_nht_prowess_4
		}
	}
	if = {
		limit = { has_trait = education_nht_prowess_5 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_nht_prowess_5
		}
	}
	if = {
		limit = { has_trait = education_nht_leadership_1 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_nht_leadership_1
		}
	}
	if = {
		limit = { has_trait = education_nht_leadership_2 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_nht_leadership_2
		}
	}
	if = {
		limit = { has_trait = education_nht_leadership_3 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_nht_leadership_3
		}
	}
	if = {
		limit = { has_trait = education_nht_leadership_4 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_nht_leadership_4
		}
	}
	if = {
		limit = { has_trait = education_nht_leadership_5 }
		show_as_tooltip = {
			add_trait_force_tooltip = education_nht_leadership_5
		}
	}	
	##### End More Lifestyles Submod Modifications	
	
	if = { # Esotericism Tenet
		limit = { has_trait = lifestyle_mystic }
		show_as_tooltip = {
			add_trait_force_tooltip = lifestyle_mystic
		}
	}
	if = {
		limit = {
			has_trait = logistician
		}
		show_as_tooltip = {
			add_trait_force_tooltip = logistician
		}
	}
	if = {
		limit = {
			has_trait = military_engineer
		}
		show_as_tooltip = {
			add_trait_force_tooltip = military_engineer
		}
	}
	if = {
		limit = {
			has_trait = aggressive_attacker
		}
		show_as_tooltip = {
			add_trait_force_tooltip = aggressive_attacker
		}
	}
	if = {
		limit = {
			has_trait = unyielding_defender
		}
		show_as_tooltip = {
			add_trait_force_tooltip = unyielding_defender
		}
	}
	if = {
		limit = {
			has_trait = forder
		}
		show_as_tooltip = {
			add_trait_force_tooltip = forder
		}
	}
	if = {
		limit = {
			has_trait = flexible_leader
		}
		show_as_tooltip = {
			add_trait_force_tooltip = flexible_leader
		}
	}
	if = {
		limit = {
			has_trait = desert_warrior
		}
		show_as_tooltip = {
			add_trait_force_tooltip = desert_warrior
		}
	}
	if = {
		limit = {
			has_trait = jungle_stalker
		}
		show_as_tooltip = {
			add_trait_force_tooltip = jungle_stalker
		}
	}
	if = {
		limit = {
			has_trait = winter_soldier
		}
		show_as_tooltip = {
			add_trait_force_tooltip = winter_soldier
		}
	}
	if = {
		limit = {
			has_trait = reaver
		}
		show_as_tooltip = {
			add_trait_force_tooltip = reaver
		}
	}
	if = {
		limit = {
			has_trait = reckless
		}
		show_as_tooltip = {
			add_trait_force_tooltip = reckless
		}
	}
	if = {
		limit = {
			has_trait = holy_warrior
		}
		show_as_tooltip = {
			add_trait_force_tooltip = holy_warrior
		}
	}
	if = {
		limit = {
			has_trait = rough_terrain_expert
		}
		show_as_tooltip = {
			add_trait_force_tooltip = rough_terrain_expert
		}
	}
	if = {
		limit = { has_trait = organizer }
		show_as_tooltip = { add_trait_force_tooltip = organizer }
	}
	if = {
		limit = { has_trait = forest_fighter }
		show_as_tooltip = { add_trait_force_tooltip = forest_fighter }
	}
	if = {
		limit = { has_trait = cautious_leader }
		show_as_tooltip = { add_trait_force_tooltip = cautious_leader }
	}
	if = {
		limit = { has_trait = open_terrain_expert }
		show_as_tooltip = { add_trait_force_tooltip = open_terrain_expert }
	}
	if = {
		limit = { has_trait = education_republican_knowledge_1 }
		show_as_tooltip = { add_trait_force_tooltip = education_republican_knowledge_1 }
	}
	if = {
		limit = { has_trait = education_republican_knowledge_2 }
		show_as_tooltip = { add_trait_force_tooltip = education_republican_knowledge_2 }
	}
	if = {
		limit = { has_trait = education_republican_knowledge_3 }
		show_as_tooltip = { add_trait_force_tooltip = education_republican_knowledge_3 }
	}
	if = {
		limit = { has_trait = education_republican_knowledge_4 }
		show_as_tooltip = { add_trait_force_tooltip = education_republican_knowledge_4 }
	}
}

rank_up_education_effect = {
	if = {
		limit = { has_education_rank_4_trigger = no }
		if = {
			limit = { has_trait = education_diplomacy }
			change_trait_rank = {
				trait = education_diplomacy
				rank = 1
			}
		}
		else_if = {
			limit = { has_trait = education_martial }
			change_trait_rank = {
				trait = education_martial
				rank = 1
			}
		}
		else_if = {
			limit = { has_trait = education_stewardship }
			change_trait_rank = {
				trait = education_stewardship
				rank = 1
			}
		}
		else_if = {
			limit = { has_trait = education_intrigue }
			change_trait_rank = {
				trait = education_intrigue
				rank = 1
			}
		}
		else_if = {
			limit = { has_trait = education_learning }
			change_trait_rank = {
				trait = education_learning
				rank = 1
			}
		}
		####### Start More Lifestyles Submod Modifications
		else_if = {
			limit = { has_trait = education_nht_prowess }
			change_trait_rank = {
				trait = education_nht_prowess
				rank = 1
			}
		}
		else_if = {
			limit = { has_trait = education_nht_leadership }
			change_trait_rank = {
				trait = education_nht_leadership
				rank = 1
			}
		}
		####### End More Lifestyles Submod Modifications
	}
}

results_of_university_education_points_effect = {
	if = {
		limit = {
			has_character_flag = studying_at_university
		}
		#Adding the points to the current education
		if = {
			limit = { has_focus = education_diplomacy }
			random_list = {
				60 = {
					change_variable = {
						name = education_diplomacy_variable
						add = 2
					}
				}
				40 = {
					change_variable = {
						name = education_diplomacy_variable
						add = 3
					}
				}
			}
		}
		else_if = {
			limit = { has_focus = education_martial }
			random_list = {
				60 = {
					change_variable = {
						name = education_martial_variable
						add = 2
					}
				}
				40 = {
					change_variable = {
						name = education_martial_variable
						add = 3
					}
				}
			}
		}
		else_if = {
			limit = { has_focus = education_stewardship }
			random_list = {
				60 = {
					change_variable = {
						name = education_stewardship_variable
						add = 2
					}
				}
				40 = {
					change_variable = {
						name = education_stewardship_variable
						add = 3
					}
				}
			}
		}
		else_if = {
			limit = { has_focus = education_intrigue }
			random_list = {
				60 = {
					change_variable = {
						name = education_intrigue_variable
						add = 2
					}
				}
				40 = {
					change_variable = {
						name = education_intrigue_variable
						add = 3
					}
				}
			}
		}
		else_if = {
			limit = { has_focus = education_learning }
			random_list = {
				60 = {
					change_variable = {
						name = education_learning_variable
						add = 2
					}
				}
				40 = {
					change_variable = {
						name = education_learning_variable
						add = 3
					}
				}
			}
		}
		else_if = {
			limit = { has_focus = education_nht_leadership }
			random_list = {
				60 = {
					change_variable = {
						name = education_nht_leadership_variable
						add = 2
					}
				}
				40 = {
					change_variable = {
						name = education_nht_leadership_variable
						add = 3
					}
				}
			}
		}
		else_if = {
			limit = { has_focus = education_nht_prowess }
			random_list = {
				60 = {
					change_variable = {
						name = education_nht_prowess_variable
						add = 2
					}
				}
				40 = {
					change_variable = {
						name = education_nht_prowess_variable
						add = 3
					}
				}
			}
		}
		remove_character_flag = studying_at_university
		add_character_flag = studied_at_university

		if = {
			limit = {
				NOT = {
					has_trait = drunkard
				}
			}
			hidden_effect = {
				random = {
					chance = 2
					add_trait = drunkard
				}
			}
		}
		if = {
			limit = {
				NOT = { has_character_flag = studying_confucian_education }
			}
			#Adding the points to the current education
			if = {
				limit = { has_trait = confucian_education }
				add_trait_xp = {
					trait = confucian_education
					value = {
						value = 20
						add = {
							value = "scope:educator.has_trait_xp(confucian_education)"
							multiply = 0.25
						}
						if = {
							limit = {
								has_religion = religion:confucianism_religion
							}
							add = 20 
						}
						round = yes
					}
				}
			}
			else = {
				add_trait = confucian_education
				add_trait_xp = {
					trait = confucian_education
					value = {
						value = 20
						add = {
							value = "scope:educator.has_trait_xp(confucian_education)"
							multiply = 0.1
						}
						if = {
							limit = {
								has_religion = religion:confucianism_religion
							}
							add = 10 
						}
						round = yes
					}
				}
			}
		}
	}
}

dynasty_legacy_education_boost_effect = {
	if = {
		limit = {
			has_dynasty = yes
			dynasty = { has_dynasty_perk = kin_legacy_2 }
		}

		if = {
			limit = { has_focus = education_diplomacy }
			random_list = {
				60 = {
					change_variable = {
						name = education_diplomacy_variable
						add = 2
					}
				}
				40 = {
					change_variable = {
						name = education_diplomacy_variable
						add = 3
					}
				}
			}
		}
		else_if = {
			limit = { has_focus = education_martial }
			random_list = {
				60 = {
					change_variable = {
						name = education_martial_variable
						add = 2
					}
				}
				40 = {
					change_variable = {
						name = education_martial_variable
						add = 3
					}
				}
			}
		}
		else_if = {
			limit = { has_focus = education_stewardship }
			random_list = {
				60 = {
					change_variable = {
						name = education_stewardship_variable
						add = 2
					}
				}
				40 = {
					change_variable = {
						name = education_stewardship_variable
						add = 3
					}
				}
			}
		}
		else_if = {
			limit = { has_focus = education_intrigue }
			random_list = {
				60 = {
					change_variable = {
						name = education_intrigue_variable
						add = 2
					}
				}
				40 = {
					change_variable = {
						name = education_intrigue_variable
						add = 3
					}
				}
			}
		}
		else_if = {
			limit = { has_focus = education_learning }
			random_list = {
				60 = {
					change_variable = {
						name = education_learning_variable
						add = 2
					}
				}
				40 = {
					change_variable = {
						name = education_learning_variable
						add = 3
					}
				}
			}
		}
		####### Start More Lifestyles Submod Modifications
		else_if = {
			limit = { has_focus = education_nht_prowess }
			random_list = {
				60 = {
					change_variable = {
						name = education_nht_prowess_variable
						add = 2
					}
				}
				40 = {
					change_variable = {
						name = education_nht_prowess_variable
						add = 3
					}
				}
			}
		}		
		else_if = {
			limit = { has_focus = education_nht_leadership }
			random_list = {
				60 = {
					change_variable = {
						name = education_nht_leadership_variable
						add = 2
					}
				}
				40 = {
					change_variable = {
						name = education_nht_leadership_variable
						add = 3
					}
				}
			}
		}
		####### End More Lifestyles Submod Modifications
	}
}

cultural_traditions_education_boost_effect = {
	# FP3 Beacon of Learning
	if = {
		limit = {
			any_relation = {
				type = guardian
				culture = { has_cultural_parameter = guardian_education_better_outcomes }
			}
		}
		if = {
			limit = { exists = var:education_diplomacy_variable }
			change_variable = {
				name = education_diplomacy_variable
				add = {
					value = var:education_diplomacy_variable
					divide = 4
					round = yes
					max = 3 # This effect shouldn't be better than a good court tutor
				}
			}
		}
		else_if = {
			limit = { exists = var:education_martial_variable }
			change_variable = {
				name = education_martial_variable
				add = {
					value = var:education_martial_variable
					divide = 4
					round = yes
					max = 3
				}
			}
		}
		else_if = {
			limit = { exists = var:education_intrigue_variable }
			change_variable = {
				name = education_intrigue_variable
				add = {
					value = var:education_intrigue_variable
					divide = 4
					round = yes
					max = 3
				}
			}
		}
		else_if = {
			limit = { exists = var:education_stewardship_variable }
			change_variable = {
				name = education_stewardship_variable
				add = {
					value = var:education_stewardship_variable
					divide = 4
					round = yes
					max = 3
				}
			}
		}
		else_if = {
			limit = { exists = var:education_learning_variable }
			change_variable = {
				name = education_learning_variable
				add = {
					value = var:education_learning_variable
					divide = 4
					round = yes
					max = 3
				}
			}
		}
		####### Start More Lifestyles Submod Modifications
		else_if = {
			limit = { exists = var:education_nht_prowess_variable }
			change_variable = {
				name = education_nht_prowess_variable
				add = {
					value = var:education_nht_prowess_variable
					divide = 4
					round = yes
					max = 3
				}
			}
		}
		else_if = {
			limit = { exists = var:education_nht_leadership_variable }
			change_variable = {
				name = education_nht_leadership_variable
				add = {
					value = var:education_nht_prowess_variable
					divide = 4
					round = yes
					max = 3
				}
			}
		}		
		####### End More Lifestyles Submod Modifications		
	}
	if = {
		limit = {
			culture = {
				has_cultural_parameter = diplomacy_education_better_outcomes
			}
			has_focus = education_diplomacy
		}

		random_list = {
			60 = {
				change_variable = {
					name = education_diplomacy_variable
					add = 1
				}
			}
			40 = {
				change_variable = {
					name = education_diplomacy_variable
					add = 0
				}
			}
		}
	}
	if = {
		limit = {
			culture = {
				has_cultural_parameter = martial_education_worse_outcomes
			}
			has_focus = education_martial
			exists = var:education_martial_variable
			var:education_martial_variable > 0
		}

		change_variable = {
			name = education_martial_variable
			add = -1
		}
	}
}


custom_tooltip_nht_leadership_coming_of_age_effect = {
	if = {
		limit = {
			has_trait = education_nht_leadership_1
		}
		custom_tooltip = coming_of_age.0001.tt.1
	}
	else_if = {
		limit = {
			has_trait = education_nht_leadership_2
		}
		custom_tooltip = coming_of_age.0001.tt.2
	}
	else_if = {
		limit = {
			has_trait = education_nht_leadership_3
		}
		custom_tooltip = coming_of_age.0001.tt.3
	}
	else_if = {
		limit = {
			has_trait = education_nht_leadership_4
		}
		custom_tooltip = coming_of_age.0001.tt.4
	}
	if = {
		limit = {
			exists = scope:crush
		}
		custom_tooltip = coming_of_age.0001.tt.5
	}
	if = {
		limit = {
			exists = scope:victim
		}
		custom_tooltip = coming_of_age.0001.tt.7
	}
	if = {
		limit = {
			exists = scope:bully
		}
		custom_tooltip = coming_of_age.0001.tt.9
	}
}

custom_tooltip_nht_prowess_coming_of_age_effect = {
	if = {
		limit = {
			has_trait = education_nht_prowess_1
		}
		custom_tooltip = coming_of_age.0001.tt.1
	}
	else_if = {
		limit = {
			has_trait = education_nht_prowess_2
		}
		custom_tooltip = coming_of_age.0001.tt.2
	}
	else_if = {
		limit = {
			has_trait = education_nht_prowess_3
		}
		custom_tooltip = coming_of_age.0001.tt.3
	}
	else_if = {
		limit = {
			has_trait = education_nht_prowess_4
		}
		custom_tooltip = coming_of_age.0001.tt.4
	}
	if = {
		limit = {
			exists = scope:crush
		}
		custom_tooltip = coming_of_age.0001.tt.5
	}
	if = {
		limit = {
			exists = scope:victim
		}
		custom_tooltip = coming_of_age.0001.tt.7
	}
	if = {
		limit = {
			exists = scope:bully
		}
		custom_tooltip = coming_of_age.0001.tt.9
	}
}

court_tutor_education_boost_effect = {
	if = {
		limit = {
			court_owner ?= {
				OR = {
					AND = {
						employs_court_position = court_tutor_court_position
						any_court_position_holder = {
							type = court_tutor_court_position
						}
					}
					AND = {
						employs_court_position = court_guru_court_position
						any_court_position_holder = {
							type = court_guru_court_position
						}
					}
				}
			}
		}
		# Let's save the court tutor or guru with the highest aptitude
		# we can use the court tutor aptitude checks for Gurus because they are nearly identical for what matters in these calculations
		court_owner = {
			if = {
				limit = {
					employs_court_position = court_tutor_court_position
				}				
				random_court_position_holder = {
					type = court_tutor_court_position
					limit = { 
						var:booner_target ?= root
					}
					alternative_limit = { aptitude:court_tutor_court_position >= 4 }
					alternative_limit = { aptitude:court_tutor_court_position >= 3 }
					alternative_limit = { aptitude:court_tutor_court_position >= 2 }
					alternative_limit = { aptitude:court_tutor_court_position >= 1 }
					alternative_limit = { always = yes }
					save_scope_as = court_tutor
				}
			}
			else = {
				random_court_position_holder = {
					type = court_guru_court_position
					limit = { 
						var:booner_target ?= root
					}
					alternative_limit = { aptitude:court_guru_court_position >= 4 }
					alternative_limit = { aptitude:court_guru_court_position >= 3 }
					alternative_limit = { aptitude:court_guru_court_position >= 2 }
					alternative_limit = { aptitude:court_guru_court_position >= 1 }
					alternative_limit = { always = yes }
					save_scope_as = court_tutor
				}
			}
		}

		if = {
			limit = { has_focus = education_diplomacy }
			random_list = {
				10 = { # Small chance for a GREAT boost
					trigger = {
						OR = {
							scope:court_tutor.aptitude:court_tutor_court_position = 4
							scope:court_tutor.var:booner_target ?= root
						}
					}
					change_variable = {
						name = education_diplomacy_variable
						add = 4
					}
				}
				40 = {
					modifier = {
						add = 20
						scope:court_tutor.aptitude:court_tutor_court_position = 4
					}
					modifier = {
						add = 10
						scope:court_tutor.aptitude:court_tutor_court_position = 3
					}
					modifier = {
						add = 10
						scope:court_tutor.var:booner_target ?= root
					}
					change_variable = {
						name = education_diplomacy_variable
						add = 3
					}
				}
				50 = {
					modifier = {
						add = 10
						scope:court_tutor.aptitude:court_tutor_court_position = 2
					}
					modifier = {
						add = 20
						scope:court_tutor.aptitude:court_tutor_court_position = 1
					}
					change_variable = {
						name = education_diplomacy_variable
						add = 2
					}
				}
			}
		}
		else_if = {
			limit = { has_focus = education_martial }
			random_list = {
				10 = { # Small chance for a GREAT boost
					trigger = {
						scope:court_tutor.aptitude:court_tutor_court_position = 4
						scope:court_tutor.var:booner_target ?= root
					}
					change_variable = {
						name = education_martial_variable
						add = 4
					}
				}
				40 = {
					modifier = {
						add = 20
						scope:court_tutor.aptitude:court_tutor_court_position = 4
					}
					modifier = {
						add = 10
						scope:court_tutor.aptitude:court_tutor_court_position = 3
					}
					modifier = {
						add = 10
						scope:court_tutor.var:booner_target ?= root
					}
					change_variable = {
						name = education_martial_variable
						add = 3
					}
				}
				50 = {
					modifier = {
						add = 10
						scope:court_tutor.aptitude:court_tutor_court_position = 2
					}
					modifier = {
						add = 20
						scope:court_tutor.aptitude:court_tutor_court_position = 1
					}
					change_variable = {
						name = education_martial_variable
						add = 2
					}
				}
			}
		}
		else_if = {
			limit = { has_focus = education_stewardship }
			random_list = {
				10 = { # Small chance for a GREAT boost
					trigger = {
						scope:court_tutor.aptitude:court_tutor_court_position = 4
						scope:court_tutor.var:booner_target ?= root
						scope:court_tutor = { has_trait = confucian_education }
					}
					change_variable = {
						name = education_stewardship_variable
						add = 4
					}
				}
				40 = {
					modifier = {
						add = 20
						scope:court_tutor = { has_trait = confucian_education }
					}
					modifier = {
						add = 20
						scope:court_tutor.aptitude:court_tutor_court_position = 4
					}
					modifier = {
						add = 10
						scope:court_tutor.aptitude:court_tutor_court_position = 3
					}
					modifier = {
						add = 10
						scope:court_tutor.var:booner_target ?= root
					}
					change_variable = {
						name = education_stewardship_variable
						add = 3
					}
				}
				50 = {
					trigger = {
						NOT = {
							scope:court_tutor = { has_trait = confucian_education }
						}
					}
					modifier = {
						add = 10
						scope:court_tutor.aptitude:court_tutor_court_position = 2
					}
					modifier = {
						add = 20
						scope:court_tutor.aptitude:court_tutor_court_position = 1
					}
					change_variable = {
						name = education_stewardship_variable
						add = 2
					}
				}
			}
		}
		else_if = {
			limit = { has_focus = education_intrigue }
			random_list = {
				10 = { # Small chance for a GREAT boost
					trigger = {
						scope:court_tutor.aptitude:court_tutor_court_position = 4
						scope:court_tutor.var:booner_target ?= root
					}
					change_variable = {
						name = education_intrigue_variable
						add = 4
					}
				}
				40 = {
					modifier = {
						add = 20
						scope:court_tutor.aptitude:court_tutor_court_position = 4
					}
					modifier = {
						add = 10
						scope:court_tutor.aptitude:court_tutor_court_position = 3
					}
					modifier = {
						add = 10
						scope:court_tutor.var:booner_target ?= root
					}
					change_variable = {
						name = education_intrigue_variable
						add = 3
					}
				}
				50 = {
					modifier = {
						add = 10
						scope:court_tutor.aptitude:court_tutor_court_position = 2
					}
					modifier = {
						add = 20
						scope:court_tutor.aptitude:court_tutor_court_position = 1
					}
					change_variable = {
						name = education_intrigue_variable
						add = 2
					}
				}
			}
		}
		else_if = {
			limit = { has_focus = education_learning }
			random_list = {
				10 = { # Small chance for a GREAT boost
					trigger = {
						scope:court_tutor.aptitude:court_tutor_court_position = 4
						scope:court_tutor.var:booner_target ?= root
						scope:court_tutor = { has_trait = confucian_education }
					}
					change_variable = {
						name = education_learning_variable
						add = 4
					}
				}
				40 = {
					modifier = {
						add = 20
						scope:court_tutor = { has_trait = confucian_education }
					}
					modifier = {
						add = 20
						scope:court_tutor.aptitude:court_tutor_court_position = 4
					}
					modifier = {
						add = 10
						scope:court_tutor.aptitude:court_tutor_court_position = 3
					}
					modifier = {
						add = 10
						scope:court_tutor.var:booner_target ?= root
					}
					change_variable = {
						name = education_learning_variable
						add = 3
					}
				}
				50 = {
					trigger = {
						NOT = {
							scope:court_tutor = { has_trait = confucian_education }
						}
					}
					modifier = {
						add = 10
						scope:court_tutor.aptitude:court_tutor_court_position = 2
					}
					modifier = {
						add = 20
						scope:court_tutor.aptitude:court_tutor_court_position = 1
					}
					change_variable = {
						name = education_learning_variable
						add = 2
					}
				}
			}
		}
		####### Start More Lifestyles Submod Modifications
		else_if = {
			limit = { has_focus = education_nht_prowess }
			random_list = {
				10 = { # Small chance for a GREAT boost
					trigger = {
						scope:court_tutor.aptitude:court_tutor_court_position = 4
						scope:court_tutor.var:booner_target ?= root
						scope:court_tutor = { has_trait = confucian_education }
					}
					change_variable = {
						name = education_nht_prowess_variable
						add = 4
					}
				}
				40 = {
					modifier = {
						add = 20
						scope:court_tutor = { has_trait = confucian_education }
					}
					modifier = {
						add = 20
						scope:court_tutor.aptitude:court_tutor_court_position = 4
					}
					modifier = {
						add = 10
						scope:court_tutor.aptitude:court_tutor_court_position = 3
					}
					modifier = {
						add = 10
						scope:court_tutor.var:booner_target ?= root
					}
					change_variable = {
						name = education_nht_prowess_variable
						add = 3
					}
				}
				50 = {
					trigger = {
						NOT = {
							scope:court_tutor = { has_trait = confucian_education }
						}
					}
					modifier = {
						add = 10
						scope:court_tutor.aptitude:court_tutor_court_position = 2
					}
					modifier = {
						add = 20
						scope:court_tutor.aptitude:court_tutor_court_position = 1
					}
					change_variable = {
						name = education_nht_prowess_variable
						add = 2
					}
				}
			}
		}
		else_if = {
			limit = { has_focus = education_nht_leadership }
			random_list = {
				10 = { # Small chance for a GREAT boost
					trigger = {
						scope:court_tutor.aptitude:court_tutor_court_position = 4
						scope:court_tutor.var:booner_target ?= root
						scope:court_tutor = { has_trait = confucian_education }
					}
					change_variable = {
						name = education_nht_leadership_variable
						add = 4
					}
				}
				40 = {
					modifier = {
						add = 20
						scope:court_tutor = { has_trait = confucian_education }
					}
					modifier = {
						add = 20
						scope:court_tutor.aptitude:court_tutor_court_position = 4
					}
					modifier = {
						add = 10
						scope:court_tutor.aptitude:court_tutor_court_position = 3
					}
					modifier = {
						add = 10
						scope:court_tutor.var:booner_target ?= root
					}
					change_variable = {
						name = education_nht_leadership_variable
						add = 3
					}
				}
				50 = {
					trigger = {
						NOT = {
							scope:court_tutor = { has_trait = confucian_education }
						}
					}
					modifier = {
						add = 10
						scope:court_tutor.aptitude:court_tutor_court_position = 2
					}
					modifier = {
						add = 20
						scope:court_tutor.aptitude:court_tutor_court_position = 1
					}
					change_variable = {
						name = education_nht_leadership_variable
						add = 2
					}
				}
			}
		}
		####### End More Lifestyles Submod Modifications		
	}
}

replace_with_learning_trait_effect = {
	if = {
		limit = { has_trait = education_intrigue_1 }
		remove_trait = education_intrigue_1
	}
	else_if = {
		limit = { has_trait = education_intrigue_2 }
		remove_trait = education_intrigue_2
	}
	else_if = {
		limit = { has_trait = education_intrigue_3 }
		remove_trait = education_intrigue_3
	}
	else_if = {
		limit = { has_trait = education_intrigue_4 }
		remove_trait = education_intrigue_4
	}
	else_if = {
		limit = { has_trait = education_intrigue_5 }
		remove_trait = education_intrigue_5
	}
	else_if = {
		limit = { has_trait = education_diplomacy_1 }
		remove_trait = education_diplomacy_1
	}
	else_if = {
		limit = { has_trait = education_diplomacy_2 }
		remove_trait = education_diplomacy_2
	}
	else_if = {
		limit = { has_trait = education_diplomacy_3 }
		remove_trait = education_diplomacy_3
	}
	else_if = {
		limit = { has_trait = education_diplomacy_4 }
		remove_trait = education_diplomacy_4
	}
	else_if = {
		limit = { has_trait = education_diplomacy_5 }
		remove_trait = education_diplomacy_5
	}
	else_if = {
		limit = { has_trait = education_stewardship_1 }
		remove_trait = education_stewardship_1
	}
	else_if = {
		limit = { has_trait = education_stewardship_2 }
		remove_trait = education_stewardship_2
	}
	else_if = {
		limit = { has_trait = education_stewardship_3 }
		remove_trait = education_stewardship_3
	}
	else_if = {
		limit = { has_trait = education_stewardship_4 }
		remove_trait = education_stewardship_4
	}
	else_if = {
		limit = { has_trait = education_stewardship_5 }
		remove_trait = education_stewardship_5
	}
	else_if = {
		limit = { has_trait = education_martial_1 }
		remove_trait = education_martial_1
	}
	else_if = {
		limit = { has_trait = education_martial_2 }
		remove_trait = education_martial_2
	}
	else_if = {
		limit = { has_trait = education_martial_3 }
		remove_trait = education_martial_3
	}
	else_if = {
		limit = { has_trait = education_martial_4 }
		remove_trait = education_martial_4
	}
	else_if = {
		limit = { has_trait = education_martial_5 }
		remove_trait = education_martial_5
	}
	###### Start More Lifestyles Submod Modifications
	else_if = {
		limit = { has_trait = education_nht_prowess_1 }
		remove_trait = education_nht_prowess_1
	}
	else_if = {
		limit = { has_trait = education_nht_prowess_2 }
		remove_trait = education_nht_prowess_2
	}
	else_if = {
		limit = { has_trait = education_nht_prowess_3 }
		remove_trait = education_nht_prowess_3
	}
	else_if = {
		limit = { has_trait = education_nht_prowess_4 }
		remove_trait = education_nht_prowess_4
	}
	else_if = {
		limit = { has_trait = education_nht_prowess_5 }
		remove_trait = education_nht_prowess_5
	}	
	else_if = {
		limit = { has_trait = education_nht_leadership_1 }
		remove_trait = education_nht_leadership_1
	}
	else_if = {
		limit = { has_trait = education_nht_leadership_2 }
		remove_trait = education_nht_leadership_2
	}
	else_if = {
		limit = { has_trait = education_nht_leadership_3 }
		remove_trait = education_nht_leadership_3
	}
	else_if = {
		limit = { has_trait = education_nht_leadership_4 }
		remove_trait = education_nht_leadership_4
	}
	else_if = {
		limit = { has_trait = education_nht_leadership_5 }
		remove_trait = education_nht_leadership_5
	}
	###### End More Lifestyles Submod Modifications
	random_list = {
		2 = { add_trait = education_learning_2 }
		2 = { add_trait = education_learning_3 }
		1 = { add_trait = education_learning_4 }
	}
}

huntperson_camp_officer_education_boost_effect = {
	if = {
		limit = {
			court_owner ?= {
				employs_court_position = huntperson_camp_officer
				any_court_position_holder = {
					type = huntperson_camp_officer
				}
			}
		}
		#Let's save the huntperson with the highest aptitude
		court_owner = {
			random_court_position_holder = {
				type = huntperson_camp_officer
				limit = { aptitude:huntperson_camp_officer >= 5 }
				alternative_limit = { aptitude:huntperson_camp_officer >= 4 }
				alternative_limit = { aptitude:huntperson_camp_officer >= 3 }
				alternative_limit = { aptitude:huntperson_camp_officer >= 2 }
				alternative_limit = { always = yes }
				save_scope_as = huntperson
			}
		}
		if = {
			limit = { has_focus = education_martial }
			random_list = {
				10 = { # Small chance for a GREAT boost
					trigger = {
						scope:huntperson.aptitude:huntperson_camp_officer = 5
					}
					change_variable = {
						name = education_martial_variable
						add = 4
					}
				}
				40 = {
					modifier = {
						add = 20
						scope:huntperson.aptitude:huntperson_camp_officer = 5
					}
					modifier = {
						add = 10
						scope:huntperson.aptitude:huntperson_camp_officer = 4
					}
					change_variable = {
						name = education_martial_variable
						add = 3
					}
				}
				50 = {
					modifier = {
						add = 10
						scope:huntperson.aptitude:huntperson_camp_officer = 2
					}
					modifier = {
						add = 20
						scope:huntperson.aptitude:huntperson_camp_officer = 1
					}
					change_variable = {
						name = education_martial_variable
						add = 2
					}
				}
			}
		}
		else_if = {
			limit = { has_focus = education_nht_prowess }
			random_list = {
				10 = { # Small chance for a GREAT boost
					trigger = {
						scope:huntperson.aptitude:huntperson_camp_officer = 5
					}
					change_variable = {
						name = education_nht_prowess_variable
						add = 4
					}
				}
				40 = {
					modifier = {
						add = 20
						scope:huntperson.aptitude:huntperson_camp_officer = 5
					}
					modifier = {
						add = 10
						scope:huntperson.aptitude:huntperson_camp_officer = 4
					}
					change_variable = {
						name = education_nht_prowess_variable
						add = 3
					}
				}
				50 = {
					modifier = {
						add = 10
						scope:huntperson.aptitude:huntperson_camp_officer = 2
					}
					modifier = {
						add = 20
						scope:huntperson.aptitude:huntperson_camp_officer = 1
					}
					change_variable = {
						name = education_nht_prowess_variable
						add = 2
					}
				}
			}
		}
	}
}

education_point_add_general_effect = {
	switch = {
		trigger = has_focus
		education_diplomacy = {
			education_point_add_point_effect = { SKILL = diplomacy VALUE = $VALUE$ }
		}
		education_martial = {
			education_point_add_point_effect = { SKILL = martial VALUE = $VALUE$ }
		}
		education_stewardship = {
			education_point_add_point_effect = { SKILL = stewardship VALUE = $VALUE$ }
		}
		education_intrigue = {
			education_point_add_point_effect = { SKILL = intrigue VALUE = $VALUE$ }
		}
		education_learning = {
			education_point_add_point_effect = { SKILL = learning VALUE = $VALUE$ }
		}
		education_nht_prowess = {
			education_point_add_point_effect = { SKILL = nht_prowess VALUE = $VALUE$ }
		}
		education_nht_leadership = {
			education_point_add_point_effect = { SKILL = nht_leadership VALUE = $VALUE$ }
		}
	}
}