
# Override secret lover trigger to exlude mistress
secret_lover_is_valid_trigger = {
	$TARGET$ = {
		save_temporary_scope_as = target
	}
	$OWNER$ = {
		has_relation_lover = scope:target
		NOT = { is_consort_of = scope:target }
		NAND = {
		    has_court_position = mistress_court_position
		    is_courtier_of = scope:target
        }
	}
}

# Override adultery trigger to exclude paramours
adultery_0001_valid_partner_trigger = {
	is_imprisoned = no
	NOT = { has_character_flag = was_recently_suspected_of_adultery } # To avoid event spamming
	NOT = { has_court_position = mistress_court_position }
}

adultery_0001_unfaithful_trigger = {
	save_temporary_scope_as = unfaithful
	AND = {
		scope:unfaithful = {
			NOT = { has_court_position = mistress_court_position }
		}
		OR = {
			any_relation = {
				type = lover
				NOR = {
					any_consort = { this = scope:unfaithful }
					has_relation_soulmate = scope:unfaithful
				}
			}
			AND = {
				has_variable = had_recent_sex_with
				var:had_recent_sex_with = {
					NOR = {
						any_consort = { this = scope:unfaithful }
						has_relation_soulmate = scope:unfaithful
					}
				}
			}
			has_variable = had_recent_sex
		}
	}
}

# Can invite lover to court to become a mistress
can_recruit_lover_to_court_trigger = {
	$RECRUITER$ = { save_temporary_scope_as = recruiter }
	$RECRUITEE$ = { save_temporary_scope_as = recruitee }
	scope:recruitee = {
		is_adult = yes
		NOR = {
			is_imprisoned = yes
			is_theocratic_lessee = yes
			trigger_if = {
				limit = {
					exists = host
					NOT = { is_player_heir_of = scope:recruiter }
				}
				is_player_heir_of = host
			}
			trigger_if = {
				limit = { exists = host }
				host = {
					pressing_claim_of_character_trigger = { CHARACTER = scope:recruitee }
				}
			}
			
			custom_description = {
				text = "is_escaped_prisoner"
				subject = scope:recruitee
				OR = {
					has_opinion_modifier = {
						modifier = attempted_imprisonment_opinion
						target = scope:recruiter
					}
					has_opinion_modifier = {
						modifier = treasonous_imprison_refusal
						target = scope:recruiter
					}
					AND = {
						exists = var:escaped_imprisonment_from
						var:escaped_imprisonment_from = scope:recruiter
					}
				}
			}
		}
	}
}

mistress_position_valid_trigger = {
	highest_held_title_tier >= tier_kingdom
	OR = {
		faith = {
			NAND = {
				has_doctrine = doctrine_adultery_women_crime
				has_doctrine = doctrine_adultery_men_crime
			}
		}
		has_trait = lustful
		has_trait = arbitrary
		has_trait = brave
		has_trait = adulterer
		has_trait = fornicator
	}
	NOR = {
		has_trait = honest
		has_trait = chaste
	}
}

mistress_can_become_mistress_trigger = {
	is_adult = yes
	is_imprisoned = no
	is_ruler = no
	top_liege = $CHARACTER$
	NOT = { is_consort_of = $CHARACTER$ }
	NOT = { is_courtier_of = $CHARACTER$ }
	
	OR = {
		has_relation_lover = $CHARACTER$
		has_relation_soulmate = $CHARACTER$
	}
	
	trigger_if = {
		limit = {
			sex_same_as = $CHARACTER$
		}
		$CHARACTER$ = {
			OR = {
				faith = { has_doctrine_parameter = homosexuality_accepted }
				OR = {
					has_trait = arbitrary
					has_trait = lustful
					has_trait = brave
					has_trait = lunatic
				}
				
			}
		}
	}
}

# Override birth trigger to exclude mistresses
birth_will_happen_as_usual_trigger = {
	OR = {
		has_character_flag = birth_will_go_smoothly
		has_character_flag = birth_child_will_become_sickly
		has_character_flag = birth_mother_will_become_ill
	}
}