﻿#	Example:
#
#	example_trigger = {
#		is_country_type = default
#		free_leader_slots > 0
#	}
#
#
#	In a script file:
#
#	trigger = {
#		example_trigger = yes
#	}
#

minor_gold_value_trigger = {
	short_term_gold >= minor_gold_value
}

medium_gold_value_trigger = {
	short_term_gold >= medium_gold_value
}

major_gold_value_trigger = {
	short_term_gold >= major_gold_value
}

has_chosen_murder_execution_type = {
	exists = scope:murder_method
}

seduction_target_is_close_trigger = {
	scope:target = { is_in_the_same_court_as = scope:owner }
}


scope_is_close_to_root_trigger = {
	OR = {
		is_in_the_same_court_as = root
		is_courtier_of = root
	}
}

#Education triggers
has_education_martial_trigger = {
	OR = {
		has_trait = education_martial_1
		has_trait = education_martial_2
		has_trait = education_martial_3
		has_trait = education_martial_4
		has_trait = education_martial_5
	}
}

has_education_diplomacy_trigger = {
	OR = {
		has_trait = education_diplomacy_1
		has_trait = education_diplomacy_2
		has_trait = education_diplomacy_3
		has_trait = education_diplomacy_4
		has_trait = education_diplomacy_5
	}
}

has_education_learning_trigger = {
	OR = {
		has_trait = education_learning_1
		has_trait = education_learning_2
		has_trait = education_learning_3
		has_trait = education_learning_4
		has_trait = education_learning_5
	}
}

has_education_stewardship_trigger = {
	OR = {
		has_trait = education_stewardship_1
		has_trait = education_stewardship_2
		has_trait = education_stewardship_3
		has_trait = education_stewardship_4
		has_trait = education_stewardship_5
	}
}

has_education_intrigue_trigger = {
	OR = {
		has_trait = education_intrigue_1
		has_trait = education_intrigue_2
		has_trait = education_intrigue_3
		has_trait = education_intrigue_4
		has_trait = education_intrigue_5
	}
}

is_cannibal_trigger = {
	OR = {
		has_trait = cannibal
		any_secret = {
			secret_type = secret_cannibal
		}
	}
}

is_murderer_trigger = {
	OR = {
		has_trait = murderer
		any_secret = {
			secret_type = secret_murder
		}
	}
}


likes_target_trigger = {
	opinion = {
		target = $CHARACTER$
		value > 10
	}
}



has_any_lifestyle_focus_trigger = {
	OR = {
		has_lifestyle = diplomacy_lifestyle
		has_lifestyle = martial_lifestyle
		has_lifestyle = stewardship_lifestyle
		has_lifestyle = intrigue_lifestyle
		has_lifestyle = learning_lifestyle
	}
}

has_any_lifestyle_trait_trigger = {
	OR = {
		has_diplomacy_lifestyle_trait_trigger = yes
		has_martial_lifestyle_trait_trigger = yes
		has_stewardship_lifestyle_trait_trigger = yes
		has_intrigue_lifestyle_trait_trigger = yes
		has_learning_lifestyle_trait_trigger = yes
	}
}

tier_or_related_liege_tier_equal_trigger = {
	OR = {
		highest_held_title_tier = $TIER$
		AND = {
			exists = liege
			liege = { highest_held_title_tier = $TIER$ }
			OR = {
				is_close_family_of = this.liege
				is_spouse_of = this.liege
			}
		}
	}
}

tier_or_related_liege_tier_greater_or_equal_trigger = {
	OR = {
		highest_held_title_tier >= $TIER$
		AND = {
			exists = liege
			liege = { highest_held_title_tier >= $TIER$ }
			OR = {
				is_close_family_of = this.liege
				is_spouse_of = this.liege
			}
		}
	}
}

torture_secret_trigger = {
	NOT = { is_known_by = scope:actor }
	OR = {
		is_blackmailable_secret_trigger = { BLACKMAILER = scope:actor PARTICIPANT = $PARTICIPANT$ }
		secret_is_always_interesting_trigger = yes
	}
	NAND = {
		exists = secret_target
		secret_target = scope:recipient
	}
}

has_interesting_portrait_altering_trait_trigger = {
	OR = {
		has_trait = scarred
		has_trait = blind
		has_trait = beauty_bad
		has_trait = beauty_good
		has_trait = hunchbacked
		has_trait = dwarf
		has_trait = giant
		has_trait = spindly
		has_trait = scaly
		has_trait = albino
		has_trait = one_eyed
	}
}

is_dangerous_faction_trigger = {
	OR = {
		AND = {
			exists = faction_leader
			faction_leader = { is_ai = no } # For now human factions are always dangerous
		}

		AND = { 
			faction_is_type = peasant_faction
			months_until_max_discontent <= 12
		}
		AND = { 
			NOT = { faction_is_type = peasant_faction }
			discontent_per_month > 0
		}
	}
}

basic_allowed_to_imprison_character_trigger = { #Only to be used in is_shown for imprison interaction and similar
	save_temporary_scope_as = allowed_imprisoner
	$CHARACTER$ = {
		OR = {
			target_is_liege_or_above = scope:allowed_imprisoner
			is_foreign_court_or_pool_guest_of = scope:allowed_imprisoner
			AND = {
				# EP3 EVICTION
				is_landless_adventurer = yes
				reverse_has_opinion_modifier = {
					target = scope:allowed_imprisoner
					modifier = eviction_ignored_opinion
				}
			}
		}
		NOT = {
			is_imprisoned_by = scope:allowed_imprisoner
		}
	}
}

advanced_allowed_to_imprison_character_trigger = {
	save_temporary_scope_as = allowed_imprisoner
	$CHARACTER$ = {
		save_temporary_scope_as = allowed_prisoner
		is_imprisoned = no
		NOT = { is_at_war_with = scope:allowed_imprisoner }
		custom_description = {
			text = "character_interactions_imprison_recently_ransomed"
			object = scope:allowed_prisoner
			NOT = {
				has_opinion_modifier = {
					target = scope:allowed_imprisoner
					modifier = ransomed_from_prison
				}
			}
		}
		NOT = { has_strong_hook = scope:allowed_imprisoner }
		custom_tooltip = {
			text = hostage_travelling_tt
			NOT = { exists = var:hostage_travelling_to_warden }
		}
		trigger_if = {
			limit = { is_landless_adventurer = yes }
			scope:allowed_imprisoner = { is_landed = yes }
			reverse_has_opinion_modifier = {
				target = scope:allowed_imprisoner
				modifier = eviction_ignored_opinion
			}
			domicile.domicile_location.county ?= { target_is_de_facto_liege_or_above = scope:allowed_imprisoner.primary_title }
		}
	}
	scope:allowed_imprisoner = {
		custom_description = {
			text = "character_interactions_imprison_ally_without_reason"
			object = scope:allowed_prisoner
			OR = {
				NOT = { is_allied_to = scope:allowed_prisoner }
				has_imprisonment_reason = scope:allowed_prisoner
				is_spouse_of = scope:allowed_prisoner
			}
		}
	}
}

allowed_to_imprison_character_trigger = {
	# We separate these out so that diarchs can imprison characters they aren't liege over.
	advanced_allowed_to_imprison_character_trigger = { CHARACTER = $CHARACTER$ }
	basic_allowed_to_imprison_character_trigger = { CHARACTER = $CHARACTER$ }
}

can_be_granted_titles_by = { #This is set up with trigger-ifs to allow for nice tooltip printouts in grant title interaction
	save_temporary_scope_as = title_grantee
	#Gender check
	trigger_if = {
		limit = {
			is_ruler = no #Rulers can always get additional titles
			is_theocratic_lessee = no #Theocratic lessees use other gender checks
			NOT = { $RULER$ = { has_government = administrative_government } }
			NOT = {
				$RULER$.faith = {
					has_dominant_ruling_gender = scope:title_grantee
				}
			}
		}
		trigger_if = {
			limit = {
				$RULER$ = { government_allows = state_faith }
			}
			$RULER$.primary_title.state_faith = {
				has_dominant_ruling_gender = scope:title_grantee
			}
		}
		trigger_else = {
			$RULER$.faith = {
				has_dominant_ruling_gender = scope:title_grantee
			}
		}
	}
	trigger_if = {
		limit = {
			is_ruler = no #Rulers can always get additional titles
			is_theocratic_lessee = no #Theocratic lessees use other gender checks
			$RULER$ = {
				has_government = administrative_government
				NOT = { has_realm_law = equal_law }
			}
		}
		trigger_if = {
			limit = {
				$RULER$ = { has_realm_law = male_only_law }
			}
			scope:title_grantee = { is_female = no }
		}
		trigger_if = {
			limit = {
				$RULER$ = { has_realm_law = female_only_law }
			}
			scope:title_grantee = { is_female = yes }
		}
		#trigger_else = { always = yes }
	}
	trigger_else_if = {
		limit = {
			is_theocratic_lessee = yes
		}
		liege = $RULER$
		#If this is ever visible anywhere, we need to write a custom desc "Theocratic lessees cannot only be given titles by their ruler"
	}
	trigger_else = {
		always = yes
	}
}

can_be_granted_theocratic_titles_by = { #This is set up with trigger-ifs to allow for nice tooltip printouts in grant title interaction
	save_temporary_scope_as = title_grantee
	#Gender check
	trigger_if = {
		limit = {
			$RULER$.faith = { has_doctrine = doctrine_clerical_gender_female_only }
		}
		is_female = yes
	}
	trigger_else_if = {
		limit = {
			$RULER$.faith = { has_doctrine = doctrine_clerical_gender_male_only }
		}
		is_male = yes
	}
	trigger_else = { always = yes }
}

activate_disease_data_tracking_trigger = {
	always = no #Should be set to no, unless you're gathering data
}

vassal_contract_can_be_modified_trigger = {
	custom_description = {
		text = vassal_contract_can_be_modified
		vassal_contract_has_modifiable_obligations = yes
		vassal_contract_is_blocked_from_modification = no	
	}
}

has_changed_contract_obligation_trigger = {
	trigger_if = {
		limit = { 
			scope:recipient = { government_has_flag = government_is_feudal }
		}
		custom_description = {
			text = "modify_vassal_contract_select_different_obligation_level"
			list_size = {
				name = changed_obligations
				value > 0
			}
		}
	}
	trigger_else = {
		custom_description = {
			text = "modify_non_feudal_vassal_contract_select_different_obligation_level"
			list_size = {
				name = changed_obligations
				value > 0
			}
		}
	}
}

recently_converted_faith_trigger = {
	OR = {
		has_character_flag = converted_by_heresy_0011_event
		has_character_flag = converted_by_heresy_0010_event
		has_character_flag = converted_by_forced_conversion_interaction
	}
}

can_touch_someone_trigger = {
	#This is to check if someone is physically capable and not in risk of disease. Remember to always ask for consent!
	NOR = {
		has_trait = leper
		has_trait = scaly #people with eczema and other skin conditions often got the same treatment as lepers
		has_trait = smallpox
		has_trait = bubonic_plague
		has_trait = measles #people with eczema and other skin conditions often got the same treatment as lepers

		#circumstancial
		has_trait = incapable
		has_trait = wounded 
		has_trait = maimed
		has_trait = typhus 

		# gout happens mostly in the foot, but as someone with inflammatory arthritis, I hate handshakes when my fingers are aching
		has_trait = gout_ridden
	}
}

is_spouse_or_romantic_partner_of_root = {
	OR = {
		has_relation_lover = root
		is_consort_of = root
		has_relation_soulmate = root
	}
}
terrible_sum_of_all_skills_trigger = {
	sum_of_all_skills_value <= sum_of_all_skills_threshold_terrible
} 
poor_sum_of_all_skills_trigger = {
	sum_of_all_skills_value <= sum_of_all_skills_threshold_poor
} 
average_sum_of_all_skills_trigger = {
	sum_of_all_skills_value <= sum_of_all_skills_threshold_average
} 
good_sum_of_all_skills_trigger = {
	sum_of_all_skills_value <= sum_of_all_skills_threshold_good
} 
excellent_sum_of_all_skills_trigger = {
	sum_of_all_skills_value <= sum_of_all_skills_threshold_excellent
}

scarred_trait_activation_1 = {
	has_trait_xp = {
		trait = scarred
		track = scarred
		value < 50
	}
}

scarred_trait_activation_2 = {
	AND = {
		has_trait_xp = {
			trait = scarred
			track = scarred
			value >= 50
		}
		has_trait_xp = {
			trait = scarred
			track = scarred
			value < 100
		}
	}
}

scarred_trait_activation_3 = {
	has_trait_xp = {
		trait = scarred
		track = scarred
		value > 99
	}
}

has_purchased_truce_with_char = {
	has_variable_list = bought_truce_list
	any_in_list = {
		variable = bought_truce_list
		this = $TARGET$
	}
}
