﻿can_recruit_character_to_court_trigger = {
	$RECRUITER$ = { save_temporary_scope_as = recruiter }
	$RECRUITEE$ = { save_temporary_scope_as = recruitee }
	scope:recruitee = {
		bp2_valid_for_standard_interactions_trigger = yes
		trigger_if = {
			limit = { is_adult = no }
			custom_description = {
				text = is_not_wandering_child
				subject = scope:recruitee
				OR = {
					is_close_or_extended_family_of = scope:recruiter
					scope:recruiter = {
						any_spouse = {
							any_child = { this = scope:recruitee }
						}
					}
					trigger_if = {
						limit = {
							scope:recruiter.culture = { has_cultural_parameter = wider_adoption }
							scope:recruitee.culture = { has_cultural_parameter = wider_adoption }
						}
						NOT = {
							any_parent = {
								is_alive = yes
								can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = liege }
							}
						}
					}
				}
			}
		}
		NOR = {
			is_imprisoned = yes
			is_theocratic_lessee = yes
			is_diarch = yes
			trigger_if = {
				limit = {
					exists = host
					host = { is_ai = no }
					NOT = { is_player_heir_of = scope:recruiter }
				}
				is_player_heir_of = host
			}
			trigger_if = {
				limit = {
					exists = host
					host = { is_ai = yes }
					NOT = { is_player_heir_of = scope:recruiter }
				}
				is_primary_heir_of = host
			}
			trigger_if = {
				limit = { exists = host }
				is_consort_of = host
			}
			trigger_if = {
				limit = { exists = host }
				host = {
					pressing_claim_of_character_trigger = { CHARACTER = scope:recruitee }
				}
			}
			trigger_if = {
				limit = { exists = host }
				#Are they employed?
				OR = {
					is_councillor_of = scope:recruitee.host
					is_knight_of = scope:recruitee.host
					any_relation = {
						type = ward
						OR = {
							this = scope:recruitee.host
							is_close_family_of = scope:recruitee.host
						}
					}
					any_relation = {
						type = guardian
						OR = {
							this = scope:recruitee.host
							is_close_family_of = scope:recruitee.host
						}
					}
					any_relation = {
						type = mentor
						OR = {
							this = scope:recruitee.host
							is_close_family_of = scope:recruitee.host
						}
					}
					any_relation = {
						type = student
						OR = {
							this = scope:recruitee.host
							is_close_family_of = scope:recruitee.host
						}
					}
					any_court_position_employer = { this = scope:recruitee.host }
				}
			}
			trigger_if = {
				limit = {
					scope:recruiter = { has_government = landless_adventurer_government }
				}
				custom_tooltip = {
					text = can_recruit_character_to_court_trigger.tt.laamps_invitation_restrictions
					NOR = {
						is_player_heir_of = scope:recruiter
						has_relation_soulmate = scope:recruiter
						has_relation_best_friend = scope:recruiter
						has_relation_friend = scope:recruiter
						has_relation_lover = scope:recruiter
						is_consort_of = scope:recruiter
						AND = {
							is_pool_character = yes
							OR = {
								is_close_family_of = scope:recruiter
							}
						}
					}
				}
			}
			
			#Do they have the "wrong" marriage type and the spouse is employed?
			custom_description = {
				text = is_married_matrilineally_and_spouse_is_dominant_partner
				subject = scope:recruitee
				any_spouse = {
					is_female = yes
					matrilinear_marriage = yes
					host ?= scope:recruitee.host
					save_temporary_scope_as = spouse
					OR = { #Is employed in some way
						is_councillor_of = scope:recruitee.host
						is_knight_of = scope:recruitee.host
						any_relation = {
							type = ward
							OR = {
								this = scope:recruitee.host
								is_close_family_of = scope:recruitee.host
							}
						}
						any_relation = {
							type = guardian
							OR = {
								this = scope:recruitee.host
								is_close_family_of = scope:recruitee.host
							}
						}
						any_relation = {
							type = mentor
							OR = {
								this = scope:recruitee.host
								is_close_family_of = scope:recruitee.host
							}
						}
						any_relation = {
							type = student
							OR = {
								this = scope:recruitee.host
								is_close_family_of = scope:recruitee.host
							}
						}
						scope:spouse = {
							any_court_position_employer = { this = scope:recruitee.host }
						}
					}
				}
			}
			custom_description = {
				text = is_married_patrilineally_and_spouse_is_dominant_partner
				subject = scope:recruitee
				any_spouse = {
					is_male = yes
					patrilinear_marriage = yes
					host ?= scope:recruitee.host
					save_temporary_scope_as = spouse
					OR = { #Is employed in some way
						is_councillor_of = scope:recruitee.host
						is_knight_of = scope:recruitee.host
						any_relation = {
							type = ward
							OR = {
								this = scope:recruitee.host
								is_close_family_of = scope:recruitee.host
							}
						}
						any_relation = {
							type = guardian
							OR = {
								this = scope:recruitee.host
								is_close_family_of = scope:recruitee.host
							}
						}
						any_relation = {
							type = mentor
							OR = {
								this = scope:recruitee.host
								is_close_family_of = scope:recruitee.host
							}
						}
						any_relation = {
							type = student
							OR = {
								this = scope:recruitee.host
								is_close_family_of = scope:recruitee.host
							}
						}
						scope:spouse = {
							any_court_position_employer = { this = scope:recruitee.host }
						}
					}
				}
			}
			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
					}
				}
			}
			custom_description = {
				text = "is_paiza_merchant"
				subject = scope:recruitee
				scope:recruitee = {
					has_variable = merchant_var
				}
			}
		}
	}
}