﻿
###TRIGGER LIST

###SEDUCE SCHEME##
# use_seduce_secrecy_trigger


###SEXUAL ORITENTATION###
# attracted_to_same_gender_trigger_trigger
# attracted_to_opposite_gender_trigger_trigger
# attracted_to_all_genders_trigger
# matching_gender_and_sexuality_trigger

###INCEST###
# accepts_incest_with_trigger
# accepts_incest_with_each_other_trigger

###ATTRACTION###
# possibly_interested_in_root_trigger
# possible_mutual_interest_trigger
# object_of_importance_exist_trigger

### CHEATING ####
# might_cheat_on_partner_trigger - If scope would at all be willing to cheat, baseline that must be passed
# might_cheat_on_every_partner_trigger - checks might_cheat_on_partner_trigger on every partner
# dislikes_partner_cheating_trigger	




###SEDUCE SCHEME TRIGGERS###

use_seduce_secrecy_trigger = {
	scope:target = {
		NOR = {
			is_consort_of = scope:owner
			is_courtier_of = scope:owner
			is_ruler = yes
		}
		exists = liege
		OR = {
			is_consort_of = scope:target.liege
			is_close_family_of = scope:target.liege
			house = scope:target.house
		}
	}
}


court_allow_owner_opt_out_trigger = {
	NAND = {
		is_ai = yes
		scope:target = { is_ai = no }
	}
}

###SEXUAL ORIENTATION TRIGGERS###

attracted_to_same_gender_trigger = {
	OR = {
		has_sexuality = bisexual
		has_sexuality = homosexual
	}
}

attracted_to_opposite_gender_trigger = {
	OR = {
		has_sexuality = bisexual
		has_sexuality = heterosexual
	}
}

attracted_to_all_genders_trigger = {
	has_sexuality = bisexual
}


#Needs CHARACTER_1 and CHARACTER_2
matching_gender_and_sexuality_trigger = {
	$CHARACTER_1$ = { is_attracted_to_gender_of = $CHARACTER_2$ }
	$CHARACTER_2$ = { is_attracted_to_gender_of = $CHARACTER_1$ }	
}






###ATTRACTION###

possibly_interested_in_root_trigger = {
	OR = {
		AND = { #Is not related to Root, or has an indicator that they would be interested anyways
			NOR = {
				any_sibling = {
					this = root
				}
				any_parent = {
					this = root
				}
				any_child = {
					this = root
				}
			}
			OR = {
				has_relation_crush = root
				has_relation_lover = root
				has_relation_potential_lover = root
				AND = {
					is_attracted_to_men = yes
					root = { is_male = yes }
				}
				AND = {
					is_attracted_to_women = yes
					root = { is_female = yes }
				}
			}
		}
		AND = {
			OR = {
				any_sibling = {
					this = root
				}
				any_parent = {
					this = root
				}
				any_child = {
					this = root
				}
			}
			OR = {
				has_relation_crush = root
				has_relation_lover = root
				has_relation_potential_lover = root
			}
		}
	}
}

possibly_interested_in_character_trigger = {
	OR = {
		AND = { #Is not related to Root, or has an indicator that they would be interested anyways
			NOR = {
				any_sibling = {
					this = $CHARACTER$
				}
				any_parent = {
					this = $CHARACTER$
				}
				any_child = {
					this = $CHARACTER$
				}
			}
			OR = {
				has_relation_crush = $CHARACTER$
				has_relation_lover = $CHARACTER$
				has_relation_potential_lover = $CHARACTER$
				AND = {
					is_attracted_to_men = yes
					$CHARACTER$ = { is_male = yes }
				}
				AND = {
					is_attracted_to_women = yes
					$CHARACTER$ = { is_female = yes }
				}
			}
		}
		AND = {
			OR = {
				any_sibling = {
					this = $CHARACTER$
				}
				any_parent = {
					this = $CHARACTER$
				}
				any_child = {
					this = $CHARACTER$
				}
			}
			OR = {
				has_relation_crush = $CHARACTER$
				has_relation_lover = $CHARACTER$
				has_relation_potential_lover = $CHARACTER$
			}
		}
	}
}

possible_mutual_interest_trigger = {
	NOT ={ $CHARACTER_1$ = $CHARACTER_2$ } #Cannot be an event target for yourself
	$CHARACTER_1$ = {	
		OR = { #Not related etc.
			AND = {
				NOT = {
					any_sibling = {
						this = $CHARACTER_2$
					}
				}
				NOT = {
					any_parent = {
						this = $CHARACTER_2$
					}
				}
				NOT = {
					any_child = {
						this = $CHARACTER_2$
					}
				}
			}
			has_relation_crush = $CHARACTER_2$
			has_relation_lover = $CHARACTER_2$
			has_opinion_modifier = {
				modifier = love_opinion
				target = $CHARACTER_2$
			}
		}
	}
	$CHARACTER_2$ = {	
		OR = {
			AND = { #Not related etc.
				NOT = {
					any_sibling = {
						this = $CHARACTER_1$
					}
				}
				NOT = {
					any_parent = {
						this = $CHARACTER_1$
					}
				}
				NOT = {
					any_child = {
						this = $CHARACTER_1$
					}
				}
			}
			has_relation_crush = $CHARACTER_1$
			has_relation_lover = $CHARACTER_1$
			has_opinion_modifier = {
				modifier = love_opinion
				target = $CHARACTER_1$
			}
		}
	}
	$CHARACTER_1$ = {	
		OR = {
			AND = {
				is_attracted_to_men = yes
				$CHARACTER_2$ = { is_male = yes }
			}
			AND = {
				is_attracted_to_women = yes
				$CHARACTER_2$ = { is_female = yes }
			}
		}
	}
	$CHARACTER_2$ = {	
		OR = {
			AND = {
				is_attracted_to_men = yes
				$CHARACTER_1$ = { is_male = yes }
			}
			AND = {
				is_attracted_to_women = yes
				$CHARACTER_1$ = { is_female = yes }
			}
		}
	}
}


#To check if either of two lovers have a object of importance saved
	#Use LOVER to slot in the non-scope character!
object_of_importance_exist_trigger = {
	save_temporary_scope_as = original_scope
	OR = {
		AND = {
			has_variable_list = lover_object_of_importance
			variable_list_size = {
				name = lover_object_of_importance
				value = 2
			}
			is_target_in_variable_list = {
				name = lover_object_of_importance
				target = $LOVER$
			}
		}
		AND = {
			has_variable_list = lover_object_of_importance_2
			variable_list_size = {
				name = lover_object_of_importance_2
				value = 2
			}
			is_target_in_variable_list = {
				name = lover_object_of_importance_2
				target = $LOVER$
			}
		}
		$LOVER$ = {
			has_variable_list = lover_object_of_importance
			variable_list_size = {
				name = lover_object_of_importance
				value = 2
			}
			is_target_in_variable_list = {
				name = lover_object_of_importance
				target = scope:original_scope
			}
		}
		$LOVER$ = {
			has_variable_list = lover_object_of_importance_2
			variable_list_size = {
				name = lover_object_of_importance_2
				value = 2
			}
			is_target_in_variable_list = {
				name = lover_object_of_importance_2
				target = scope:original_scope
			}
		}
	}
}


might_cheat_on_partner_trigger = {
	trigger_if = {
		limit = {
			OR = {
				has_game_rule = no_seduction
				AND = {
					has_game_rule = restricted_seduction
					NOR = {
						has_trait = lustful
						has_trait = deviant
						has_trait = seducer
						has_trait = reveler_1
						has_trait = reveler_2
						has_trait = reveler_3
						has_trait = rakish	
					}
				}
			}
		}
		always = no
	}
	trigger_else_if = {
		limit = {
			OR = {
				has_relation_lover = $PARTNER$
				is_consort_of = $PARTNER$
			}
		}
		OR = {
			NOR = { # Doesn't have any strong reason to like partner
				has_relation_soulmate = $PARTNER$
				AND = {
					is_consort_of = $PARTNER$
					opinion = {
						target =  $PARTNER$
						value >= high_positive_opinion
					}
				}
				opinion = {
					target = $PARTNER$
					value >= very_high_positive_opinion
				}
			}
			# Or has one of these things that make them always cheat:
			has_trait = lustful
			has_trait = seducer
			AND = {
				is_deviant_trigger = yes
				$PARTNER$ = { is_deviant_trigger = no }
			}
			ai_honor <= medium_negative_ai_value
		}
	}
	trigger_else = { always = yes } # Partner isn't my partner, so it's not even cheating
}

might_cheat_on_every_partner_trigger = {
	save_temporary_scope_as = potential_cheater
	any_spouse = {
		count = all
		save_temporary_scope_as = partner
		scope:potential_cheater = { might_cheat_on_partner_trigger = { PARTNER = scope:partner } }
	}
	any_relation = {
		type = lover
		count = all
		save_temporary_scope_as = partner
		scope:potential_cheater = { might_cheat_on_partner_trigger = { PARTNER = scope:partner } }
	}
}


dislikes_partner_cheating_trigger = {
	trigger_if = {
		limit = {
			OR = {
				has_relation_lover = $PARTNER$
				is_consort_of = $PARTNER$
			}
		}
		$PARTNER$ = { save_temporary_scope_as = cheating_trigger_partner }
		save_temporary_scope_as = cheating_trigger_root
		OR = {
			has_relation_soulmate = $PARTNER$ # Soulmates are exclusive
			AND = {  # Feels slighted
				is_consort_of = $PARTNER$
				trait_is_shunned_or_criminal_in_faith_trigger = {
					TRAIT = adulterer
					FAITH = scope:cheating_trigger_root.faith
					GENDER_CHARACTER = scope:cheating_trigger_partner
				}
				OR = {
					ai_honor >= 0
					ai_zeal >= 0
					has_trait = arrogant
					ai_vengefulness <= 0
				}
			}
			opinion = { # Loves partner
				target = $PARTNER$
				value >= high_positive_opinion
			}
		}
		NAND = { # Sexually liberal characters don't mind, unless you're exclusive
			sexually_liberal_trigger = yes
			NOT = { has_relation_soulmate = $PARTNER$ }
		}
	}
	trigger_else = { always = no } # Partner isn't my partner, so I don't care
}



sexually_liberal_trigger = {
	OR = {
		has_trait = deviant
		has_trait = lustful
		has_trait = seducer
	}
	NOR = {
		has_trait = chaste
		has_trait = celibate
	}
}

#Can this character ever have an affair? Counts both inability and whether sex outside marriage is counted as religiously problematic for them.
eligible_for_affairs_trigger = {
	mgr_can_seduce = yes
	NOR = {
		has_trait = celibate
		#Technically (and, historically, frequently) eunuchs can still have affairs, they just aren't able to impregnate.
		OR = {
			faith = { has_doctrine_parameter = no_unfaithfulness_penalty_active }
			trait_is_shunned_or_criminal_in_faith_trigger = {
				TRAIT = adulterer
				FAITH = root.faith
				GENDER_CHARACTER = root
			}
			trait_is_shunned_or_criminal_in_faith_trigger = {
				TRAIT = fornicator
				FAITH = root.faith
				GENDER_CHARACTER = root
			}
		}
	}
}


freely_accepts_sodomy_with_trigger = { #Will ignore sodomy consequences (because there are none or they have done this before)
	OR = {
		NOT = { relation_with_character_is_sodomy_in_my_or_lieges_faith_trigger = { CHARACTER = $CHARACTER$ } }
		has_trait = deviant
		has_trait = sodomite
		any_secret = { secret_type = secret_homosexual }
	}
}

# 100% fine with incest with CHARACTER. Important: There are also other factors to attraction! This isn't 100% acceptance of romantic/sexual relationship.
accepts_incest_with_trigger = {
	OR = {
		NOT = { is_close_or_extended_family_of = $CHARACTER$ } #Actually no incest here!
		is_incestuous_trigger = yes
		has_relation_potential_lover = $CHARACTER$
		has_relation_lover = $CHARACTER$
	}
	save_temporary_scope_as = incest_evaluation
	NOT = { #under 20 trigger is a HARD limit
		guaranteed_under_20_incest_rejection_trigger = {
			TARGET = scope:incest_evaluation
			SEDUCER = $CHARACTER$
		}
	}
}

accepts_incest_with_each_other_trigger = {
	$CHARACTER_2$ = {
		accepts_incest_with_trigger = {
			CHARACTER = $CHARACTER_1$
		}
	}
	$CHARACTER_1$ = {
		accepts_incest_with_trigger = {
			CHARACTER = $CHARACTER_2$
		}
	}
}

guaranteed_under_20_incest_rejection_trigger = {
	$TARGET$ = {
		NOT = { is_consort_of = $SEDUCER$ }
		is_close_or_extended_family_of = $SEDUCER$
		age < 20
		age < $SEDUCER$.age
		is_ai = yes #Players are allowed to choose
	}
}