﻿###########################
# These triggers are designed for use in generic event content:
# They are very restrictive, and designed to, as much as possible, not break immersion.
# Use them where you can, but be aware that they will make event triggers very strict
###########################

###### LOVER TRIGGERS #####

######
# are_characters_sensible_and_appropriate_open_lovers_trigger = { INSTIGATING_LOVER = scope:something TARGET_OF_LOVE = scope:something_else }
# This is the most restrictive form of lover trigger,
# use it when you need a couple of innocent lovers

######
# are_characters_sensible_and_appropriate_lovers_trigger = { INSTIGATING_LOVER = scope:something TARGET_OF_LOVE = scope:something_else }
# Is the pairing both sensible from an attraction standpoint,
# and appropriate from a social standpoint?

######
# are_characters_sensible_lovers_trigger = { INSTIGATING_LOVER = scope:something TARGET_OF_LOVE = scope:something_else }
# Is the pairing sensible from an attraction standpoint?
# Does not restrict based on genetic bad looks,
# this is about the _lover_ status, not attraction-based sex 


# Would two characters fancy each other somewhat?
are_characters_sensible_lovers_trigger = {
	$INSTIGATING_LOVER$ = { save_temporary_scope_as = instigating_character }
	$TARGET_OF_LOVE$ = { save_temporary_scope_as = target_of_love }
	
	scope:instigating_character = {
		NOT = { this = scope:target_of_love }
		is_physically_able_adult = yes
		might_cheat_on_every_partner_trigger = yes
		can_set_relation_lover_trigger = { CHARACTER = scope:target_of_love }
		is_attracted_to_gender_of = scope:target_of_love
		NOR = {
			has_trait = chaste
			has_trait = celibate
			has_sexuality = asexual
			has_trait = beardless_eunuch
			has_trait = leper
			has_trait = great_pox
			has_trait = bubonic_plague
			has_trait = smallpox
			has_trait = measles
			has_trait = ergotism
			has_trait = dysentery
			has_trait = consumption
			has_trait = typhus
			has_trait = pneumonic
		}
		# These three only need to be checked on one char
		age <= scope:target_of_love.age_plus_10
		age >= scope:target_of_love.age_minus_10
		trait_compatibility = {
			target = scope:target_of_love
			value >= low_positive_trait_compatibility
		}
	}
	
	scope:target_of_love = {
		NOT = { this = scope:instigating_character }
		might_cheat_on_every_partner_trigger = yes
		can_set_relation_lover_trigger = { CHARACTER = scope:instigating_character }
		is_attracted_to_gender_of = scope:instigating_character
		NOR = {
			has_trait = chaste
			has_trait = celibate
			has_sexuality = asexual
			has_trait = beardless_eunuch
			has_trait = leper
			has_trait = great_pox
			has_trait = bubonic_plague
			has_trait = smallpox
			has_trait = measles
			has_trait = ergotism
			has_trait = dysentery
			has_trait = consumption
			has_trait = typhus
			has_trait = pneumonic
		}
	}
	
	accepts_incest_with_each_other_trigger = {
		CHARACTER_1 = scope:instigating_character
		CHARACTER_2 = scope:target_of_love
	}
}

# Various social blockers - what would you, interpreting society, think of having a lover
are_characters_sensible_and_appropriate_lovers_trigger = {
	$INSTIGATING_LOVER$ = { save_temporary_scope_as = instigating_character }
	$TARGET_OF_LOVE$ = { save_temporary_scope_as = target_of_love }
	
	are_characters_sensible_lovers_trigger = {
		INSTIGATING_LOVER = scope:instigating_character
		TARGET_OF_LOVE = scope:target_of_love
	}
	
	scope:instigating_character = {
		OR = {
			has_trait = lustful
			any_relation = {
				type = lover
				count < 1
			}
		}
		trigger_if = {
			limit = {
				is_clergy = yes
			}
			faith = {
				has_doctrine_parameter = clergy_can_marry
			}
		}
		trigger_if = {
			limit = {
				is_courtier = yes
				is_close_or_extended_family_of = liege
				has_no_particular_noble_roots_trigger = no
			}
			OR = {
				scope:target_of_love = { has_no_particular_noble_roots_trigger = no }
				is_deviant_trigger = yes
				has_trait = lustful
				trait_compatibility = {
					target = scope:target_of_love
					value >= high_positive_trait_compatibility
				}
			}
		}
		trigger_if = {
			limit = {
				OR = {
					faith = { 
						has_doctrine_parameter = homosexuality_shunned
					}
					liege.faith ?= {
						has_doctrine_parameter = homosexuality_shunned
					}
					faith = { 
						has_doctrine_parameter = homosexuality_illegal
					}
					liege.faith ?= {
						has_doctrine_parameter = homosexuality_illegal
					}
				}
			}
			NOR = {
				AND = {
					is_female = yes
					scope:target_of_love = { is_female = yes }
				}
				AND = {
					is_male = yes
					scope:target_of_love = { is_male = yes }
				}
			}
		}
	}
	
	scope:target_of_love = {
		OR = {
			has_trait = lustful
			any_relation = {
				type = lover
				count < 1
			}
		}
		trigger_if = {
			limit = {
				is_clergy = yes
			}
			faith = {
				has_doctrine_parameter = clergy_can_marry
			}
		}
		trigger_if = {
			limit = {
				is_courtier = yes
				is_close_or_extended_family_of = liege
				has_no_particular_noble_roots_trigger = no
			}
			OR = {
				scope:instigating_character = { has_no_particular_noble_roots_trigger = no }
				is_deviant_trigger = yes
				has_trait = lustful
				trait_compatibility = {
					target = scope:instigating_character
					value >= high_positive_trait_compatibility
				}
			}
		}
		trigger_if = {
			limit = {
				OR = {
					faith = { 
						has_doctrine_parameter = homosexuality_shunned
					}
					liege.faith ?= {
						has_doctrine_parameter = homosexuality_shunned
					}
					faith = { 
						has_doctrine_parameter = homosexuality_illegal
					}
					liege.faith ?= {
						has_doctrine_parameter = homosexuality_illegal
					}
				}
			}
			NOR = {
				AND = {
					is_female = yes
					scope:target_of_love = { is_female = yes }
				}
				AND = {
					is_male = yes
					scope:target_of_love = { is_male = yes }
				}
			}
		}
	}
}

# Would the characters make sense as lovers within the context of their social situation
are_characters_sensible_and_appropriate_open_lovers_trigger = {
	$INSTIGATING_LOVER$ = { save_temporary_scope_as = instigating_character }
	$TARGET_OF_LOVE$ = { save_temporary_scope_as = target_of_love }
	
	scope:instigating_character = {
		trigger_if = {
			limit = {
				NOT = {
					is_consort_of = scope:target_of_love
				}
			}
			is_married = no
			is_concubine = no
		}
	}
	
	scope:target_of_love = {
		trigger_if = {
			limit = {
				NOT = {
					is_consort_of = scope:instigating_character
				}
			}
			is_married = no
			is_concubine = no
		}
	}
	
	are_characters_sensible_and_appropriate_lovers_trigger = {
		INSTIGATING_LOVER = scope:instigating_character
		TARGET_OF_LOVE = scope:target_of_love
	}
}