﻿# Called from code after history generation
# Empty scope
on_game_start = {
	on_actions = {
		on_assigning_childhood_trait
		#on_saving_faith_culture
	}
}

on_assigning_childhood_trait = {
	trigger = {
		has_game_rule = keep_childhood_trait_enabled
	}
	effect = {
		every_living_character = {
			limit = { # those without a childhood trait
				NOR = {
					has_trait = rowdy
					has_trait = charming
					has_trait = curious
					has_trait = pensive
					has_trait = bossy
				}
				is_adult = yes # they should be, but just in case
			}
			# distribute base on education
			switch = {
				trigger = has_trait
				education_diplomacy = {
					random_list = {
						1 = { add_trait = charming }
						1 = { add_trait = curious }
					}
				}
				education_martial = {
					random_list = {
						1 = { add_trait = rowdy }
						1 = { add_trait = bossy }
					}
				}
				education_stewardship = {
					random_list = {
						1 = { add_trait = pensive }
						1 = { add_trait = bossy }
					}
				}
				education_intrigue = {
					random_list = {
						1 = { add_trait = rowdy }
						1 = { add_trait = charming }
					}
				}
				education_learning = {
					random_list = {
						1 = { add_trait = curious }
						1 = { add_trait = pensive }
					}
				}
			}
			# simulate allignment for years being adult...
			set_variable = {
				name = start_age
				value = age
			}
			set_variable = {
				name = while_count
				value = {
					value = age
					divide = 2 # save some calculation time at loading
					min = 0
				}
			}
			set_age = 16
			while = {
				count = var:while_count
				trigger_event = { on_action = on_childhood_trait_change }
				set_age = {
					value = age
					add = 2
				}
			}
			set_age = var:start_age
			remove_variable = start_age
			remove_variable = while_count
		}
	}
}

#on_saving_faith_culture = {
#	trigger = {
#		NOT = { has_game_rule = static_faith_culture_disabled }
#	}
#	effect = {
#		every_county = {
#			switch = {
#				trigger = has_game_rule
#				static_faith = { save_county_faith = yes }
#				static_culture = { save_county_culture = yes }
#				static_faith_culture = {
#					save_county_faith = yes
#					save_county_culture = yes
#				}
#			}
#		}
#	}
#}