﻿
###TRIGGER LIST

# is_close_family_of_root_trigger
# is_sibling_child_of_root_trigger
# is_parent_sibling_of_root_trigger
# is_cousin_of_root_trigger
# is_sibling_in_law_of_root_trigger
# is_mother_of_compare_character_trigger
# is_father_of_compare_character_trigger
# is_sibling_of_compare_character_trigger
# is_child_of_compare_character_trigger
# is_close_family_of_compare_character_trigger
# is_allowed_to_legitimize_children_trigger


is_close_family_of_root_trigger = {
	OR = {
		any_parent = { this = root }
		any_sibling = { this = root }
		any_child = { this = root }
	}
}

is_close_family_or_spouse_of_root_trigger = {
	OR = {
		any_parent = { this = root }
		any_sibling = { this = root }
		any_child = { this = root }
		any_spouse = { this = root }
	}
}

is_sibling_child_of_root_trigger = {
	any_parent = {
		even_if_dead = yes
		any_sibling = {
			this = root
		}
	}
}

is_parent_sibling_of_root_trigger = {
	any_sibling = {
		even_if_dead = yes
		any_child = {
			this = root
		}
	}
}

is_cousin_of_root_trigger = {
	any_parent = {
		even_if_dead = yes
		any_sibling = {
			even_if_dead = yes
			any_child = {
				this = root
			}
		}
	}
}

is_sibling_in_law_of_root_trigger = {
	NOT = {
		any_sibling = {
			this = root
		}
	}
	any_spouse = {
		any_sibling = {
			this = root
		}
	}
}

is_cousin_in_law_of_root_trigger = {
	any_spouse = {
		is_cousin_of = root
		this != root
	}
}

is_auntuncle_in_law_of_root_trigger = {
	any_spouse = {
		is_uncle_or_aunt_of = root
		this != root
	}
}

is_grandmotherfather_in_law_of_root_trigger = {
	any_spouse = {
		is_grandparent_of = root
		this != root
	}
}

is_great_grandmotherfather_in_law_of_root_trigger = {
	any_spouse = {
		is_great_grandparent_of = root
		this != root
	}
}

is_granddaughterson_in_law_of_root_trigger = {
	any_spouse = {
		is_grandchild_of = root
		this != root
	}
}

is_great_granddaughterson_in_law_of_root_trigger = {
	any_spouse = {
		is_great_grandchild_of = root
		this != root
	}
}

is_nibling_in_law_of_root_trigger = {
	any_spouse = {
		is_nibling_of = root
		this != root
	}
}

is_any_family_relation_or_spouse_of_root_trigger = {
	OR = {
		any_parent = { this = root }
		any_sibling = { this = root }
		any_child = { this = root }
		any_spouse = { this = root }
		any_parent = {
			even_if_dead = yes
			any_sibling = {
				this = root
			}
		}
		any_sibling = {
			even_if_dead = yes
			any_child = {
				this = root
			}
		}
		AND = {
			NOT = {
				any_sibling = {
					this = root
				}
			}
			any_parent = {
				even_if_dead = yes
				any_child = {
					this = root
				}
			}
		}
	}
}

is_mother_of_compare_character_trigger = {
	this = scope:compare_character.mother
}

is_father_of_compare_character_trigger = {
	this = scope:compare_character.father	
}

is_sibling_of_compare_character_trigger = {
	scope:compare_character = {
		any_sibling = {
			this = prev
		}
	}
}

is_child_of_compare_character_trigger = {
	scope:compare_character = {
		any_child = {
			this = prev
		}
	}
}

is_close_family_of_compare_character_trigger = {
	OR = {
		this = scope:compare_character.mother
		this = scope:compare_character.father	
		any_sibling = {
			this = scope:compare_character
		}
		father = scope:compare_character
		mother = scope:compare_character
	}
}

is_allowed_to_legitimize_children_trigger = {
	is_lowborn = no
	is_concubine = no
	is_ruler = yes
	custom_description = {
		text = faith_allows_legitimization_of_bastards
		faith = {
			has_doctrine_parameter = bastards_legitimize
		}
	}
}



###############################################
# Triggers that take an argument and NOT root
##############################################
is_close_family_trigger = {
	OR = {
		any_parent = { this = $CHARACTER$ }
		any_sibling = { this = $CHARACTER$ }
		any_child = { this = $CHARACTER$ }
	}
}

is_close_family_or_spouse_trigger = {
	OR = {
		any_parent = { this = $CHARACTER$ }
		any_sibling = { this = $CHARACTER$ }
		any_child = { this = $CHARACTER$ }
		any_spouse = { this = $CHARACTER$ }
	}
}

is_any_family_relation_or_spouse_trigger = {
	save_temporary_scope_as = root_character
	OR = {
		any_parent = { this = $CHARACTER$ }
		any_sibling = { this = $CHARACTER$ }
		any_child = { this = $CHARACTER$ }
		any_spouse = { this = $CHARACTER$ }
		any_parent = {
			even_if_dead = yes
			any_sibling = {
				this = $CHARACTER$
			}
		}
		any_parent = {
			even_if_dead = yes
			any_sibling = {
				even_if_dead = yes
				any_child = {
					this = $CHARACTER$
				}
			}
		}
		any_sibling = {
			even_if_dead = yes
			any_child = {
				this = $CHARACTER$
			}
		}
		AND = {
			NOT = {
				any_sibling = {
					this = $CHARACTER$
				}
			}
			any_parent = {
				even_if_dead = yes
				any_child = {
					this = $CHARACTER$
				}
			}
		}

		#child/parent/sibling/nephew/grandchild/grandparent/uncle/aunt/niece/nephew is married to the other
		any_spouse = {
			OR = {
				is_close_family_of = $CHARACTER$
				is_nibling_of = $CHARACTER$
				is_uncle_or_aunt_of = $CHARACTER$
			}
		}
		$CHARACTER$ = {
			any_spouse = {
				OR = {
					is_close_family_of = scope:root_character
					is_nibling_of = scope:root_character
					is_uncle_or_aunt_of = scope:root_character
				}
			}
		}
		#child/parent/sibling is married to other's child/parent/sibling
		any_close_family_member = {
			OR = {
				is_parent_of = scope:root_character
				is_child_of = scope:root_character
				is_sibling_of = scope:root_character
			}
			any_spouse = {
				OR = {
					is_parent_of = $CHARACTER$
					is_child_of = $CHARACTER$
					is_sibling_of = $CHARACTER$
				}
			}
		}
	}
}


house_head_would_approve_legitimization_trigger = {
	$LEGITIMIZER$ = {
		save_temporary_scope_as = the_legitimizer
	}
	$BASTARD$ = {
		save_temporary_scope_as = the_bastard
	}
	trigger_if = {
		limit = {
			exists = scope:legitimizer.house
		}
		scope:legitimizer.house.house_head = {
			save_temporary_scope_as = the_house_head
		}
			
		house_head_legitimize_approval_rating > 0
	}
}

is_allowed_to_legitimize_child_trigger = {
	is_allowed_to_legitimize_children_trigger = yes
	OR = {
		this = house.house_head
		house_head_would_approve_legitimization_trigger = {
			LEGITIMIZER = $LEGITIMIZER$
			BASTARD = $BASTARD$
		}
	}
}
