﻿@infant_upper_age_threshold_value = 2
@teen_lower_threshold_value = 13
@teen_upper_threshold_value = 19

child_is_infant_trigger = {
	age <= @infant_upper_age_threshold_value
	is_adult = no
}

# Duplicated because there were some weird edge case OR uses where "child_is_infant_trigger = no" read _extremely_ confusingly.
child_not_infant_trigger = {
	age > @infant_upper_age_threshold_value
	is_adult = no
}

# At what point is it not weird to hear a child using (relatively) advanced reasoning & so able to hold an extended conversation?
child_can_have_full_conversations_trigger = {
	age >= 6
	is_adult = no
}

child_not_teen_trigger = {
	child_not_infant_trigger = yes
	age < @teen_lower_threshold_value
	is_adult = no
}

# Duplicated because there were some weird edge case OR uses where "child_not_teen_trigger = no" read _extremely_ confusingly.
child_is_teen_trigger = {
	age >= @teen_lower_threshold_value
	is_adult = no
}

child_old_enough_for_responsibility_trigger = {
	age >= 8
	is_adult = no
}

# Note: we don't want to say that children below this definitely can't read, that's a lot of edge cases to account for, but it's convenient to roughly unified trigger we can check for whether pensive characters are more likely to read or be read to.
child_likely_reader_trigger = { age >= 7 }

character_is_teen_trigger = {
	age >= @teen_lower_threshold_value
	age <= @teen_upper_threshold_value
}

character_is_teen_or_older_trigger = {
	age > @teen_lower_threshold_value
}

save_good_friend_character_trigger_check = {
	is_adult = no
	age >= root.age_dif_child_down_friend
	age <= root.age_dif_child_up_friend
	NOT = { this = root }
	is_imprisoned = no
	opinion = {
		target = root
		value > -10
	}
	NOR = {
		has_relation_friend = root
		has_any_bad_relationship_with_root_trigger = yes
	}
}


save_good_crush_character_trigger_check = {
	is_adult = no
	age >= root.age_dif_child_down
	age <= root.age_dif_child_up
	age > childhood_education_start_age
	NOT = { this = root }
	is_imprisoned = no
	is_close_family_of_root_trigger = no
	NOR = {
		root = { has_relation_crush = prev }
		has_relation_victim = root
	}
	OR = {
		has_sexuality = heterosexual
		has_sexuality = bisexual
		has_sexuality = homosexual
	}
	is_attracted_to_gender_of = root
	root = { is_attracted_to_gender_of = prev }
	OR = {
		num_of_relation_crush <= 2
		has_trait = lustful
	}
}

save_good_bully_character_trigger_check = {
	is_adult = no
	age >= 6
	age >= root.age
	NOT = { this = root }
	is_imprisoned = no
	OR = {
		has_trait_malicious_trigger = yes
		has_trait_dominant_trigger = yes
		has_trait_emotional_trigger = yes
	}
	NOR = {
		has_trait = compassionate
		has_trait_submissive_trigger = yes
	}
	opinion = {
		target = root
		value < 0
	}
	NOR = {
		has_any_bad_relationship_with_root_trigger = yes
		has_relation_victim = root
		has_relation_friend = root
		has_relation_crush = root
	}
}

save_good_victim_character_trigger_check = {
	is_adult = no
	age >= 6
	age <= root.age
	NOT = { this = root }
	is_imprisoned = no
	reverse_opinion = {
		target = root
		value < 0
	}
	NOR = {
		has_any_bad_relationship_with_root_trigger = yes
		has_relation_victim = root
		has_relation_friend = root
		has_relation_crush = root
	}
}

child_suitable_to_play_with_character = {
	# Is available for events at $CHARACTER$'s locale.
	is_available_child = yes
	exists = location
	location = $CHARACTER$.location
	# Of a suitable age range.
	child_not_infant_trigger = yes
	# Doesn't have a bad relationship with $CHARACTER$.
	NOT = {
		has_any_bad_relationship_with_character_trigger = { CHARACTER = $CHARACTER$ }
	}
}

child_suitable_to_play_with_character_one_sided = {
	child_suitable_to_play_with_character = { CHARACTER = $CHARACTER$ }
	is_ai = yes
}



childhood_mean_child_trigger = {
	OR = {
		has_trait = rowdy
		has_personality_malicious_trigger = yes
		has_personality_dominant_trigger = yes
		ai_compassion <= low_negative_ai_value
	}
}

childhood_loud_child_trigger = {
	OR = {
		has_trait = curious
		has_trait = bossy
		has_personality_extroverted_trigger = yes
		has_personality_emotional_trigger = yes
		ai_energy >= low_positive_ai_value
		ai_boldness >= low_positive_ai_value
	}
}

childhood_quiet_child_trigger = {
	OR = {
		has_trait = pensive
		has_personality_submissive_trigger = yes
		has_personality_introverted_trigger = yes
		ai_energy <= low_negative_ai_value
		ai_boldness <= low_negative_ai_value
	}
}

childhood_nice_child_trigger = {
	OR = {
		has_trait = charming
		has_trait = curious
		has_personality_benevolent_trigger = yes
		has_personality_levelheaded_trigger = yes
		ai_compassion >= low_positive_ai_value
	}
}

suitable_same_realm_child = {
	exists = location.county.holder # Scoping like this allows children in the pool to also get this event
	location.county.holder = {
		OR = {
			AND = {
				is_ai = yes
				is_available_child = yes
				NOT = { this = root }
				age >= 6
			}
			any_courtier_or_guest = {
				is_ai = yes
				is_available_child = yes
				NOT = { this = root }
				age >= 6
			}
			any_warden_hostage = {
				is_ai = yes
				is_available_child = yes
				NOT = { this = root }
				age >= 6
			}
			any_vassal = {
				is_ai = yes
				is_available_child = yes
				NOT = { this = root }
				age >= 6
			}
			any_vassal = {
				any_courtier_or_guest = {
					is_ai = yes
					is_available_child = yes
					NOT = { this = root }
					age >= 6
				}
			}
		}
	}
}

similar_age_same_court_child = {
	exists = location.county.holder # Scoping like this allows children in the pool to also get this event
	location.county.holder = {
		OR = {
			AND = {
				is_ai = yes
				is_available_child = yes
				NOT = { this = root }
				age <= root.age_plus_3
				age >= age_minus_3
			}
			any_courtier_or_guest = {
				is_ai = yes
				is_available_child = yes
				NOT = { this = root }
				age <= root.age_plus_3
				age >= age_minus_3
			}
			any_warden_hostage = {
				is_ai = yes
				is_available_child = yes
				NOT = { this = root }
				age <= root.age_plus_3
				age >= age_minus_3
			}
		}
	}
}

suitable_crush_trigger = {
	AND = {
		save_temporary_scope_as = temp_crush
		is_ai = yes
		is_available_child = yes
		NOT = { this = root }
		child_not_infant_trigger = yes
		age <= root.age_plus_3
		age >= root.age_minus_3
		location = root.location
		OR = {
			matching_gender_and_sexuality_trigger = {
				CHARACTER_1 = root
				CHARACTER_2 = scope:temp_crush
			}
			AND = {
				has_sexuality = asexual
				root = {
					OR = {
						is_attracted_to_gender_of = scope:temp_crush
						has_sexuality = asexual
					}
				}
			}
			AND = {
				root = { has_sexuality = asexual }
				OR = {
					is_attracted_to_gender_of = root
					has_sexuality = asexual
				}
			}
		}
		NOT = {
			relation_with_character_is_incestuous_in_my_faith_trigger = { CHARACTER = root }
		}
	}
}

suitable_crush_same_court_child = {
	exists = location.county.holder # Scoping like this allows children in the pool to also get this event
	location.county.holder = {
		OR = {
			save_good_crush_character_trigger_check = yes
			any_courtier_or_guest = {
				save_good_crush_character_trigger_check = yes
			}
			any_warden_hostage = {
				save_good_crush_character_trigger_check = yes
			}
		}
	}
}

guardian_or_court_tutor_trait = {
	trigger_if = {
		limit = {
			any_relation = {
				type = guardian
			}
		}
		any_relation = {
			type = guardian
			has_trait = $TRAIT$
		}
	}
	trigger_else = {
		court_owner.court_position:court_tutor_court_position ?= {
			has_trait = $TRAIT$
		}
	}
}

guardian_or_court_tutor_2_trait = {
	trigger_if = {
		limit = {
			any_relation = {
				type = guardian
			}
		}
		any_relation = {
			type = guardian
			OR = {
				has_trait = $TRAIT$
				has_trait = $TRAIT_2$
			}
		}
	}
	trigger_else = {
		court_owner.court_position:court_tutor_court_position ?= {
			OR = {
				has_trait = $TRAIT$
				has_trait = $TRAIT_2$
			}
		}
	}
}
