﻿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
	}
	## mr_mod replace
	remove_childhoood_traits_effect = yes
	## end
	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
	}
}

remove_childhoood_traits_effect = {
	## mr_mod replace
	if = {
		limit = { has_game_rule = keep_childhood_trait_disabled }
		mr_QOL_remove_childhoood_traits_effect = yes
	}
	## end
}

### from 05_dlc_bp2_effects ###

adult_education_completed_log_entry_effect = {
	involved_activity = {
		add_activity_log_entry = {
			key = adult_education_studies_completed_log
			tags = { completed }
			score = 100
			show_in_conclusion = yes
			character = root
			#Effects
			root = {
				## mr_mod
				if = {
					limit = {
						has_game_rule = keep_childhood_trait_enabled
						OR = {
							has_trait = rowdy
							has_trait = charming
							has_trait = curious
							has_trait = pensive
							has_trait = bossy
						}
					}
					switch = {
						trigger = has_character_flag
						perfect_studies_reward = {
							while_improve_childhoood_traits_effect = { COUNT = 4 }
						}
						high_studies_reward = {
							while_improve_childhoood_traits_effect = { COUNT = 3 }
						}
						mid_studies_reward = {
							while_improve_childhoood_traits_effect = { COUNT = 2 }
						}
						low_studies_reward = {
							while_improve_childhoood_traits_effect = { COUNT = 1 }
						}
					}
				}
				## end

				disburse_adult_education_reward_effect = yes
			}
		}
	}
}

# MOD Effects #

mr_QOL_remove_childhoood_traits_effect = {
	remove_childhoood_trait = { TRAIT = rowdy }
	remove_childhoood_trait = { TRAIT = charming }
	remove_childhoood_trait = { TRAIT = curious }
	remove_childhoood_trait = { TRAIT = pensive }
	remove_childhoood_trait = { TRAIT = bossy }
}

remove_childhoood_trait = {
	if = {
		limit = { has_trait = $TRAIT$ }
		add_trait_xp = {
			trait = $TRAIT$
			value = {
				value = age
				multiply = -0.2
				floor = yes
			}
		}
		if = {
			limit = { has_trait_xp = { trait = $TRAIT$ value <= 0 } }
			remove_trait = $TRAIT$
		}
	}
}

mr_QOL_improve_childhoood_traits_effect = {
	improve_childhoood_trait = { TRAIT = rowdy }
	improve_childhoood_trait = { TRAIT = charming }
	improve_childhoood_trait = { TRAIT = curious }
	improve_childhoood_trait = { TRAIT = pensive }
	improve_childhoood_trait = { TRAIT = bossy }
}

improve_childhoood_trait = {
	if = {
		limit = {
			has_trait = $TRAIT$
			has_trait_xp = { trait = $TRAIT$ value <= 100 }
		}
		add_trait_xp = {
			trait = $TRAIT$
			value = {
				value = age
				multiply = 0.15
				ceiling = yes
			}
		}
	}
}

while_improve_childhoood_traits_effect = {
	while = {
		count = $COUNT$
		mr_QOL_improve_childhoood_traits_effect = yes
	}
}

#while_random_childhoood_traits_effect = {
#	while = {
#		count = $COUNT$
#		random_list = {
#			1 = { mr_QOL_improve_childhoood_traits_effect = yes }
#			1 = { mr_QOL_remove_childhoood_traits_effect = yes }
#		}
#	}
#}