﻿
# This trigger is used when offering the player a choice between two stress outlets for a stress threshold event.
# The stress threshold event will add character flags from this list, based on a character's personality and relevance to the event, until two have been selected.
has_two_stress_threshold_options = {
	calc_true_if = {
		amount >= 2

		has_character_flag = stress_threshold_option_drunkard
		has_character_flag = stress_threshold_option_hashishiyah
		has_character_flag = stress_threshold_option_rakish
		has_character_flag = stress_threshold_option_reclusive
		has_character_flag = stress_threshold_option_irritable
		has_character_flag = stress_threshold_option_flagellant
		has_character_flag = stress_threshold_option_profligate
		has_character_flag = stress_threshold_option_improvident
		has_character_flag = stress_threshold_option_contrite
		has_character_flag = stress_threshold_option_comfort_eater
		has_character_flag = stress_threshold_option_inappetetic
		has_character_flag = stress_threshold_option_journaller
		has_character_flag = stress_threshold_option_confider
		has_character_flag = stress_threshold_option_athletic
		has_character_flag = stress_threshold_option_conversion
		has_character_flag = stress_threshold_option_depression
	}
}

# Check if the player already has two stress coping traits ( we don't want to give any more than that! )
has_two_stress_coping_traits_trigger = {
	calc_true_if = {
		amount >= 2
		has_trait = drunkard
		has_trait = hashishiyah
		has_trait = rakish
		has_trait = reclusive
		has_trait = irritable
		has_trait = flagellant
		has_trait = profligate
		has_trait = improvident
		has_trait = contrite
		has_trait = comfort_eater
		has_trait = inappetetic
		has_trait = journaller
		has_trait = confider
		has_trait = athletic
	}
}

has_a_stress_coping_trait_trigger = {
	OR = {
		has_trait = drunkard
		has_trait = hashishiyah
		has_trait = rakish
		has_trait = reclusive
		has_trait = irritable
		has_trait = flagellant
		has_trait = profligate
		has_trait = improvident
		has_trait = contrite
		has_trait = comfort_eater
		has_trait = inappetetic
		has_trait = journaller
		has_trait = confider
		has_trait = athletic
	}
}

has_a_bad_stress_coping_trait_trigger = {
	OR = {
		has_trait = drunkard
		has_trait = hashishiyah
		has_trait = rakish
		has_trait = irritable
		has_trait = flagellant
		has_trait = profligate
		has_trait = contrite
		has_trait = comfort_eater
		has_trait = inappetetic
	}
}

can_be_drunkard = {
	is_adult = yes
	NOR = { # Cannot be Temperate or already have a Substance Abuse trait.
		has_trait = drunkard
		has_trait = hashishiyah
		has_trait = temperate
	}
	faith = { # Cannot be Muslim ( some Muslims did actually drink, but ideally we want Muslims to be Hashishiyahs instead of Drunkards because it is more thematic).
		NOT = {
			religion_tag = islam_religion
		}
	}
}

can_be_hashishiyah = {
	is_adult = yes
	NOR = { # Cannot be Temperate or already have a Substance Abuse trait.
		has_trait = drunkard
		has_trait = hashishiyah
		has_trait = temperate
	}

	NAND = { # Cannot be Zealous if faith views hashish as sinful
		faith = { trait_is_sin = hashishiyah }
		has_trait = zealous
	}

	OR = {
		# Muslims always have access to Hashish...
		faith = {
			religion_tag = islam_religion
		}
		# Otherwise you must not be located in Europe (where Hashish was relatively unknown until modern times.)
		AND = {
			OR = {
				capital_province ?= {
					save_temporary_scope_as = my_home_province
				}
				liege.capital_province ?= {
					save_temporary_scope_as = my_home_province
				}
			}
			scope:my_home_province = {
				NOR = {
					geographical_region = world_europe
					geographical_region = world_asia
				}
			}
		}
	}
}

can_be_rakish = { # Must have a fitting personality or lifestyle
	is_adult = yes
	NOR = {
		has_trait = rakish
		has_sexuality = asexual
		has_trait = celibate
		has_trait = chaste
	}
	OR = {
		has_trait = lustful
		has_trait = arrogant
		has_trait = deceitful
		has_trait = gallant
		has_trait = seducer
	}
}

can_be_reclusive = { # Must have a fitting personality or lifestyle
	NOT = { has_trait = reclusive }
	OR = {
		has_trait = shy
		has_trait = lazy
		has_trait = paranoid
		has_trait = craven
		has_trait = cynical
		has_trait = just # Does this make sense here?
	}
}

can_be_irritable = { # Must have a fitting personality or lifestyle
	NOT = {
		has_trait = irritable
	}
	OR = {
		has_trait = wrathful
		has_trait = impatient
		has_trait = arrogant
		has_trait = stubborn
		has_trait = vengeful
		has_trait = callous
	}
}

can_be_flagellant = { # Must have a fitting personality or lifestyle
	NOR = { 
		has_trait = flagellant
		faith = { has_doctrine = special_doctrine_immaterial_harmony }
	}
	OR = {
		has_trait = zealous
		has_trait = chaste
		has_trait = temperate
		has_trait = humble
		has_trait = lifestyle_mystic
	}
}

can_be_profligate = { # Must have a fitting personality or lifestyle
	NOT = { has_trait = profligate }
	OR = {
		has_trait = greedy
		has_trait = ambitious
		has_trait = arbitrary
		has_trait = gregarious
		has_trait = cynical
	}
}

can_be_improvident = { # Must have a fitting personality or lifestyle
	NOT = { has_trait = improvident }
	OR = {	
		has_trait = generous
		has_trait = forgiving
		has_trait = compassionate
		has_trait = just
		has_trait = content
	}
}

can_be_contrite = {
	NOT = { has_trait = contrite }
	OR = { # Must have a fitting personality or lifestyle
		has_trait = deceitful
		has_trait = schemer
		has_trait = honest
		has_trait = trusting
		has_trait = humble
	}
	OR = { # Must have something to feel guilty about / confess to.
		num_sinful_traits >= 1
		any_secret = {
			exists = this
			can_be_exposed_by = root
		}
	}
}

can_be_comfort_eater = { # Must have a fitting personality.
	NOR = {
		has_trait = comfort_eater
		has_trait = inappetetic
		has_trait = temperate
	}
	OR = {
		has_trait = gluttonous
		has_trait = fickle
		has_trait = arbitrary
		has_trait = impatient
		has_trait = calm
	}
}

can_be_inappetetic = { # Must have a fitting personality.
	NOR = {
		has_trait = comfort_eater
		has_trait = inappetetic
		has_trait = gluttonous
	}
	OR = {	
		has_trait = temperate
		has_trait = content
		has_trait = arbitrary
		has_trait = patient
		has_trait = diligent
	}
}

can_be_journaller = { # Must be a learned character with the scholarship lifestyle.
	NOT = { has_trait = journaller }
	learning >= high_skill_rating
	OR = {
		has_trait = scholar
		has_trait = theologian
	}
}

can_be_confider = { # Must have a close friend they can confide in (and be willing to confide in!)
	NOR = {
		has_trait = confider
		has_trait = shy
		has_trait = arrogant
		has_trait = paranoid
	}
	any_relation = {
		type = friend
		is_available_ai_adult = yes
	}
}

can_be_athletic = { # Must be willing and interested in getting out and exercising.
	has_traits_that_negate_athletic_trigger = no #Are we already athletic or does any of our traits contradict athletic?
	OR = {
		has_trait = brave
		has_trait = diligent
	}
}


can_do_lustful_stress_conversion = {
	is_ai = no # AI picks this way too often and makes the map predominantly Paulician/Orthodox/Karite
	is_adult = yes

	# So you don't end up with Sapmi or African pagans or Indian kings going "Yeah let's worship Jesus now!" and everyone else goes "Who is Jesus?"
	religion = { is_in_family = rf_abrahamic }
		
	# So the Caliph doesn't just convert after a bad day
	this != faith.religious_head
}

can_inflict_torture = {
	OR = {
		has_trait = sadistic
		has_trait = vengeful
		has_trait = torturer
		has_trait = lifestyle_hunter
		has_trait = lifestyle_blademaster
	}
}

can_be_eccentric = {
	NOR = {
		has_trait = fickle
		has_trait = stubborn
		has_trait = eccentric
	}
}

has_witnessed_stress_coping_trait = {
	NOT = { has_trait = $TRAIT$ }
	var:witnessed_trait ?= flag:$TRAIT$	
}

can_be_burdened = {
	NOT = {
		has_trait = burdened
	}
	is_adult = no
	trigger_if = {
		limit = {
			faith = { has_doctrine = doctrine_gender_female_dominated }
		}
		is_female = yes
	}
	trigger_else_if = {
		limit = {
			faith = { has_doctrine = doctrine_gender_male_dominated }
		}
		is_female = no
	}
	trigger_else = { always = yes }
	# TGP flavor stress trait
	government_allows = merit
	OR = {
		# This stress trait is for children only, after all
		has_trait = bossy
		has_trait = pensive
		has_trait = rowdy
		# But kids get adult traits too
		has_trait = wrathful
		has_trait = impatient
		has_trait = arrogant
		has_trait = stubborn
		has_trait = vengeful
		has_trait = callous
	}
}