ep3_should_use_byzantine_graphics_trigger = {
	OR = {
		culture = { has_building_gfx = byzantine_building_gfx }
		culture = { has_building_gfx = caucasian_building_gfx }
	}
}

is_roman_emperor_trigger = {
	OR = {
		has_title = title:e_byzantium
		has_title = title:h_roman_empire
		has_title = title:h_eastern_roman_empire
	}
}

is_roman_emperor_excluding_byzantium_trigger = {
	OR = {
		has_title = title:h_roman_empire
		has_title = title:h_eastern_roman_empire
	}
}

is_roman_emperor_primary_title_trigger = {
	OR = {
		primary_title ?= title:e_byzantium
		primary_title ?= title:h_roman_empire
		primary_title ?= title:h_eastern_roman_empire
	}
}

is_roman_emperor_primary_title_excluding_byzantium_trigger = {
	OR = {
		primary_title ?= title:h_roman_empire
		primary_title ?= title:h_eastern_roman_empire
	}
}

valid_for_byz_emperor_content_trigger = {
	has_ep3_dlc_trigger = yes
	culture = {
		OR = {
			has_cultural_pillar = heritage_byzantine
			has_cultural_pillar = heritage_caucasian
		}
	}
	OR = {
		is_roman_emperor_primary_title_trigger = yes
		AND = {
			culture = {
				OR = {
					this = culture:greek
					any_parent_culture_or_above = { this = culture:greek }
				}
			}
			highest_held_title_tier >= tier_empire
		}
	}
}

valid_for_byz_governor_content_trigger = {
	has_ep3_dlc_trigger = yes
	is_governor = yes
	top_liege.culture = {
		OR = {
			has_cultural_pillar = heritage_byzantine
			has_cultural_pillar = heritage_caucasian
		}
	}
	top_liege = {
		OR = {
			is_roman_emperor_primary_title_trigger = yes
			AND = {
				culture = {
					OR = {
						this = culture:greek
						any_parent_culture_or_above = { this = culture:greek }
					}
				}
				highest_held_title_tier >= tier_empire
			}
		}
	}
}

valid_for_byz_succession_trigger = {
	is_eunuch_trigger = no
	NOR = {
		has_trait = incapable
		has_trait = blind
		has_trait = disfigured
		has_trait = maimed
		has_trait = one_eyed
		has_trait = one_legged
		has_trait = clubfooted
		has_trait = hunchbacked
		has_trait = dwarf
	}
}

has_any_charioteer_trait = {
	OR = {
		has_trait = charioteer_blue
		has_trait = charioteer_green
		has_trait = charioteer_white
		has_trait = charioteer_red
	}
}

available_charioteers_spots_trigger = {
	scope:activity = {
		any_guest_subset = {
			name = charioteers
			has_trait = charioteer_$TEAM$
			count < scope:activity.var:num_$TEAM$s
		}
	}
}

ep3_varangian_trigger = {
	OR = {
		culture = {
			OR = {
				has_cultural_tradition = tradition_fp1_coastal_warriors
				has_cultural_tradition = tradition_hird
				has_cultural_tradition = tradition_fp1_performative_honour
				has_cultural_pillar = heritage_north_germanic
				has_cultural_pillar = heritage_west_germanic
			}
		}
		has_trait = varangian
	}
	can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
	is_physically_able_adult = yes
}

is_competing_for_same_title_as = {
	government_allows = administrative
	any_heir_title = {
		exists = this
		is_noble_family_title = no
		save_temporary_scope_as = temp_title
	}
	$CHARACTER$ = {
		government_allows = administrative
	}
	scope:temp_title = {
		any_title_heir = {
			this = $CHARACTER$
		}
	}
}

is_winning_competing_for_same_title_as = {
	$CHARACTER$ = { save_temporary_scope_as = target_char }
	is_competing_for_same_title_as = { CHARACTER = $CHARACTER$ }
	save_temporary_scope_as = root_scope
	any_heir_title = {
		exists = this
		is_noble_family_title = no
		save_temporary_scope_as = temp_title
	}
	scope:temp_title = {
		"place_in_line_of_succession(scope:root_scope)" > "place_in_line_of_succession(scope:target_char)"
	}
}

restore_greece_decision_county_trigger = {
	trigger_if = {
		limit = {
			holder.top_liege = root
			has_county_modifier = backwater_county_modifier
		}
		development_level >= 50
	}
}

any_valid_title_to_grant_trigger = {
	# IMPORTANT!
	# The is_valid_showing_failures_only of support_candidacy_interaction doesn't use this
	# It uses a cloned version that has been optimized for AI usage
	# Please update that one too if you're updating this one
	$CANDIDATE$ ?= {
		is_clergy = no
		save_temporary_scope_as = candidate_temp
		custom_tooltip = {
			text = support_candidacy_can_appoint_for_title_tt
			$TOP_LIEGE$.primary_title = {
				any_in_de_jure_hierarchy = {
					continue = {
						tier > tier_duchy
					}
					save_temporary_scope_as = title_temp
					scope:candidate_temp = { can_appoint_for_title = scope:title_temp }
				}
			}
		}
	}
}

any_valid_candidacy_trigger = {
	$CANDIDATE$ = {
		custom_tooltip = {
			text = any_valid_candidacy_tt
			trigger_if = {
				limit = {
					$TOP_LIEGE$ = {
						OR = {
							has_realm_law_flag = appointment_type_succession
							primary_title = {
								has_title_law_flag = appointment_type_succession
							}
						}
					}
					appointment_candidate_score = {
						target = $TOP_LIEGE$.primary_title
						value > 0
					}
				}
				always = yes
			}
			trigger_else = {
				$TOP_LIEGE$.primary_title ?= {
					any_in_de_jure_hierarchy = {
						exists = holder
						tier >= tier_duchy
						OR = {
							has_title_law_flag = appointment_type_succession
							holder = {
								has_realm_law_flag = appointment_type_succession
							}
						}
						save_temporary_scope_as = title_temp
						trigger_if = {
							limit = { exists = scope:title_temp }
							$CANDIDATE$ = {
								appointment_candidate_score = {
									target = scope:title_temp
									value > 0
								}
							}
						}
					}
				}
			}
		}
	}
}

is_candidate_for_title_trigger = {
	$CANDIDATE$ = {
		custom_tooltip = {
			text = is_candidate_for_title_tt
			$TITLE$ = {
				OR = {
					has_title_law = acclamation_succession_law
					has_title_law = appointment_succession_law
					holder ?= {
						OR = {
							has_realm_law = acclamation_succession_law
							has_realm_law = appointment_succession_law
						}
					}
				}
				holder = {
					NOT = { this = $CANDIDATE$ }
				}
			}
			appointment_candidate_score = {
				target = $TITLE$
				value > 0
			}
		}
	}
}

valid_governor_contract_trigger = {
	OR = {
		government_allows = administrative
		AND = {
			government_has_flag = government_is_landless_minority
			exists = liege
			liege = {
				government_allows = administrative
			}
		}
	}
	
	is_available_quick = {
		adult = yes
		alive = yes
		incapable = no
	}
}

valid_governor_contract_basic_trigger = {
	task_contract_taker = {
		#you have to be a governor
		OR = {
			trigger_if = {
				limit = {
					government_has_flag = government_is_celestial
				}
				is_governor_or_admin_count = yes
			}
			trigger_else = {
				is_governor = yes
			}
			#and the location has to be in your realm
			custom_tooltip = {
				text = task_contract_location_not_in_realm
				any_sub_realm_county = {
					any_county_province = {
						this = root.task_contract_location
					}
				}
			}
			AND = {
				government_has_flag = government_is_landless_minority
				exists = liege
				liege = {
					government_allows = administrative
				}
			}
		}
	}
}

governor_contract_invalidated_message_trigger = {
	task_contract_employer ?= {
		NOT = { root.task_contract_taker ?= this }
		OR = {
			is_incapable = yes
			is_imprisoned = yes
			is_alive = no
		}
	}
}

##################################################
### CHARIOT RACE TRIGGERS
##################################################

chariot_race_0201_sitting_in_kathisma_trigger = {
	OR = {
		AND = {
			exists = scope:activity.special_guest:chariot_race_honorary_guest
			this = scope:activity.special_guest:chariot_race_honorary_guest
		}
		is_close_family_of = scope:host
		is_consort_of = scope:host
	}
}

chariot_race_0201_negative_crowd_reaction_trigger = {
	OR = {
		scope:activity.var:emperor_speech_topic = flag:increase_legitimacy_fail
		scope:activity.var:emperor_speech_topic = flag:discredit_claimant_fail
		AND = {
			scope:host.capital_county = {
				county_opinion <= -30
			}
			NOT = { scope:activity.var:emperor_speech_topic = flag:appease_populace }
		}
		AND = {
			scope:host = {
				legitimacy_level < 2
			}
			NOR = {
				scope:activity.var:emperor_speech_topic = flag:increase_legitimacy_success
				scope:activity.var:emperor_speech_topic = flag:appease_populace
			}
		}
	}
}

cares_about_charioteer_trigger = {
	OR = {
		$CHARIOTEER$ = {
			trigger_if = {
				limit = { has_court_position = charioteer_court_position }
				is_court_position_employer = {
					court_position = charioteer_court_position
					who = prev
				}
			}
			trigger_else = { always = no }
		}
		is_close_family_of = $CHARIOTEER$
		trigger_if = {
			limit = { has_variable = wager_target }
			OR = {
				var:wager_target = $CHARIOTEER$
				trigger_if = {
					limit = { var:wager_target = root }
					trigger_if = {
						limit = { $CHARIOTEER$ = { has_trait = charioteer_blue } }
						var:wager_team = flag:blues
					}
					trigger_if = {
						limit = { $CHARIOTEER$ = { has_trait = charioteer_green } }
						var:wager_team = flag:greens
					}
					trigger_if = {
						limit = { $CHARIOTEER$ = { has_trait = charioteer_white } }
						var:wager_team = flag:whites
					}
					trigger_if = {
						limit = { $CHARIOTEER$ = { has_trait = charioteer_red } }
						var:wager_team = flag:reds
					}
				}
				trigger_else = { always = no }
			}
		}
		trigger_else = { always = no }
	}
}

supports_chariot_team_trigger = {
	trigger_if = {
		limit = { $TEAM$ = flag:blues }
		OR = {
			AND = {
				has_variable = wager_team
				var:wager_team = flag:blues
			}
			AND = {
				employs_court_position = charioteer_court_position
				court_position:charioteer_court_position = { has_trait = charioteer_blue }
			}
		}
	}
	trigger_else_if = {
		limit = { $TEAM$ = flag:greens }
		OR = {
			AND = {
				has_variable = wager_team
				var:wager_team = flag:greens
			}
			AND = {
				employs_court_position = charioteer_court_position
				court_position:charioteer_court_position = { has_trait = charioteer_green }
			}
		}
	}
	trigger_else_if = {
		limit = { $TEAM$ = flag:whites }
		OR = {
			AND = {
				has_variable = wager_team
				var:wager_team = flag:whites
			}
			AND = {
				employs_court_position = charioteer_court_position
				court_position:charioteer_court_position = { has_trait = charioteer_white }
			}
		}
	}
	trigger_else_if = {
		limit = { $TEAM$ = flag:reds }
		OR = {
			AND = {
				has_variable = wager_team
				var:wager_team = flag:reds
			}
			AND = {
				employs_court_position = charioteer_court_position
				court_position:charioteer_court_position = { has_trait = charioteer_red }
			}
		}
	}
	trigger_else = {
		always = no
	}
}

has_same_chariot_team_as = {
	trigger_if = {
		limit = { has_trait = charioteer_blue }
		$TARGET$ = { has_trait = charioteer_blue }
	}
	trigger_else_if = {
		limit = { has_trait = charioteer_green }
		$TARGET$ = { has_trait = charioteer_green }
	}
	trigger_else_if = {
		limit = { has_trait = charioteer_white }
		$TARGET$ = { has_trait = charioteer_white }
	}
	trigger_else_if = {
		limit = { has_trait = charioteer_red }
		$TARGET$ = { has_trait = charioteer_red }
	}
	trigger_else = { always = no }
}

chariot_racer_valid_trigger = {
	save_temporary_scope_as = chariot_racer
	is_alive = yes
	exists = var:current_place_in_race
	is_in_guest_subset = { name = charioteers }
}

chariot_race_anyone_ahead_of_racer_trigger = {
	scope:activity ?= {
		any_guest_subset = {
			name = charioteers
			chariot_racer_valid_trigger = yes
			NOT = { this = $RACER$ }
			var:current_place_in_race < $RACER$.var:current_place_in_race
		}
	}
}

chariot_race_anyone_behind_racer_trigger = {
	scope:activity ?= {
		any_guest_subset = {
			name = charioteers
			chariot_racer_valid_trigger = yes
			NOT = { this = $RACER$ }
			var:current_place_in_race > $RACER$.var:current_place_in_race
		}
	}
}

flag_matches_charioteer_team_trigger = {
	trigger_if = {
		limit = { $VAR$ = flag:blues }
		has_trait = charioteer_blue
	}
	trigger_else_if = {
		limit = { $VAR$ = flag:greens }
		has_trait = charioteer_green
	}
	trigger_else_if = {
		limit = { $VAR$ = flag:whites }
		has_trait = charioteer_white
	}
	trigger_else_if = {
		limit = { $VAR$ = flag:reds }
		has_trait = charioteer_red
	}
	trigger_else = { always = no }
}

stands_to_win_chariot_wager_trigger = {
	save_temporary_scope_as = gambler
	exists = scope:activity
	exists = var:wager_type
	# Specific Charioteer
	trigger_if = {
		limit = {
			exists = var:wager_target
			NOT = { this = var:wager_target }
		}
		var:wager_target ?= {
			chariot_racer_valid_trigger = yes
			save_temporary_scope_as = wager_target_temp
		}
		OR = {
			# All bets gain by first place
			scope:wager_target_temp.var:current_place_in_race = 1
			# Place & Show gain by second place
			trigger_if = {
				limit = {
					OR = {
						var:wager_type = flag:place
						var:wager_type = flag:show
					}
				}
				scope:wager_target_temp.var:current_place_in_race <= 2
			}
			trigger_else = { always = no }
			# Show gains by third place
			trigger_if = {
				limit = { var:wager_type = flag:show }
				scope:wager_target_temp.var:current_place_in_race <= 3
			}
			trigger_else = { always = no }
			# Fallback no one is ahead of wager
			NOT = {
				chariot_race_anyone_ahead_of_racer_trigger = { RACER = scope:wager_target_temp }
			}
		}
	}
	# Team
	trigger_else = {
		scope:activity ?= {
			any_guest_subset = {
				name = charioteers
				chariot_racer_valid_trigger = yes
				flag_matches_charioteer_team_trigger = { VAR = scope:gambler.var:wager_team }
			}
			OR = {
				# All bets gain by first place
				any_guest_subset = {
					name = charioteers
					flag_matches_charioteer_team_trigger = { VAR = scope:gambler.var:wager_team }
					var:current_place_in_race = 1
				}
				# Place & Show gain by second place
				trigger_if = {
					limit = {
						OR = {
							scope:gambler.var:wager_type = flag:place
							scope:gambler.var:wager_type = flag:show
						}
					}
					any_guest_subset = {
						name = charioteers
						flag_matches_charioteer_team_trigger = { VAR = scope:gambler.var:wager_team }
						var:current_place_in_race <= 2
					}
				}
				trigger_else = { always = no }
				# Show gains by third place
				trigger_if = {
					limit = { scope:gambler.var:wager_type = flag:show }
					any_guest_subset = {
						name = charioteers
						flag_matches_charioteer_team_trigger = { VAR = scope:gambler.var:wager_team }
						var:current_place_in_race <= 3
					}
				}
				trigger_else = { always = no }
				# Fallback no one is ahead of wager
				AND = {
					any_guest_subset = {
						name = charioteers
						flag_matches_charioteer_team_trigger = { VAR = scope:gambler.var:wager_team }
						save_temporary_scope_as = racer
					}
					NOT = {
						chariot_race_anyone_ahead_of_racer_trigger = { RACER = scope:racer }
					}
				}
			}
		}
	}
}

novice_charioteer_trigger = {
	OR = {
		has_trait_xp = {
			trait = charioteer_blue
			value < 40
		}
		has_trait_xp = {
			trait = charioteer_green
			value < 40
		}
		has_trait_xp = {
			trait = charioteer_white
			value < 40
		}
		has_trait_xp = {
			trait = charioteer_red
			value < 40
		}
		NOR = {
			has_trait = charioteer_blue
			has_trait = charioteer_green
			has_trait = charioteer_white
			has_trait = charioteer_red
		}
	}
}

middling_charioteer_trigger = {
	OR = {
		has_trait_xp = {
			trait = charioteer_blue
			value >= 40
		}
		has_trait_xp = {
			trait = charioteer_green
			value >= 40
		}
		has_trait_xp = {
			trait = charioteer_white
			value >= 40
		}
		has_trait_xp = {
			trait = charioteer_red
			value >= 40
		}
	}
}

experienced_charioteer_trigger = {
	OR = {
		has_trait_xp = {
			trait = charioteer_blue
			value >= 90
		}
		has_trait_xp = {
			trait = charioteer_green
			value >= 90
		}
		has_trait_xp = {
			trait = charioteer_white
			value >= 90
		}
		has_trait_xp = {
			trait = charioteer_red
			value >= 90
		}
	}
}

ep3_ideal_castration_candidate_trigger = {
	is_available_quick = {
		ai = yes
		female = no
		adult = yes
	}
	is_close_family_of = scope:actor
	is_eunuch_trigger = no
	is_available = yes
	is_betrothed = no
	age < 10
}

ep3_castration_male_family_trigger = {
	any_close_family_member = {
		count >= 2
		is_male = yes
		house ?= scope:actor.house
		is_eunuch_trigger = no
		NOR = {
			has_trait = celibate
			has_trait = devoted
			has_trait = order_member
			has_trait = bastard
		}
		OR = {
			#Is an old adult with a kid
			AND = {
				age >= 40
				any_child = {
					is_male = yes
				}
			}
			#Is a young adult or child
			age < 40
		}
	}
}

ep3_castration_interest_trigger = {
	OR = {
		is_landless_ruler = yes
		highest_held_title_tier <= tier_county
		AND = {
			is_landed = yes
			highest_held_title_tier <= tier_duchy
			influence_level <= 1
		}
		highest_held_title_tier >= tier_empire
	}
}

ep3_ai_castration_target_trigger = {
	age < 12
	is_male = yes
	OR = {
		AND = {
			exists = liege
			liege.culture = { has_cultural_parameter = family_castration }
		}
		AND = {
			NOT = { exists = liege }
			culture = { has_cultural_parameter = family_castration }
		}
	}
	is_available = yes
	is_landed = no
	is_betrothed = no
	NOR = {
		#Should not be close family of a player
		any_close_family_member = {
			is_ai = no
		}
		#Should not be close family of a character who can use the interaction
		any_close_family_member = {
			highest_held_title_tier >= tier_county
		}
		#Should not be the child of a playable title heir
		any_parent = {
			any_heir_title = {
				tier >= tier_county
			}
		}
		#Should not be the grandchild of a playable title heir, if their parent is the eldest son
		any_parent = {
			any_parent = {
				highest_held_title_tier >= tier_county
			}
			any_sibling = {
				count <= 0
				is_male = yes
				age > prev.age
				house ?= prev.house
			}
		}
	}
	#Not already a eunuch
	is_eunuch_trigger = no
	NOR = {
		#Doesn't have a positive trait being a eunuch would ruin
		has_trait = physique_good_1
		has_trait = physique_good_2
		has_trait = physique_good_3
		has_trait = fecund
		has_trait = strong
		has_trait = sayyid
		has_trait = giant
	}
	OR = {
		is_lowborn = yes
		has_trait = bastard
		#Sons of barons are valid if they have an elder male sibling
		any_sibling = {
			count >= 2
			is_male = yes
			age > prev.age
			house ?= prev.house
		}
	}
}

valid_for_pagan_conversion_trigger = {
	faith.religion = { is_in_family = rf_pagan }
	faith = { has_doctrine_parameter = unreformed }
	is_at_war = no
	NOR = {
		has_character_flag = do_not_disturb_preachers
		primary_title = { has_variable = do_not_disturb_preachers }
	}
}

ep3_story_cycle_admin_eunuch_valid_story_trigger = {
	any_owned_story = {
		type = story_cycle_admin_eunuch
		save_temporary_scope_as = story_temp
		var:eunuch ?= {
			is_alive = yes
			save_temporary_scope_as = eunuch_temp
		}
		story_owner = { save_temporary_scope_as = emperor_temp }
		trigger_if = {
			limit = { exists = var:protege }
			var:protege = { save_temporary_scope_as = protege_temp }
		}
		trigger_if = {
			limit = { exists = var:student }
			var:student = { save_temporary_scope_as = student_temp }
		}
		trigger_if = {
			limit = { exists = var:rival }
			var:rival = { save_temporary_scope_as = rival_temp }
		}
		trigger_if = {
			limit = { exists = var:seducer }
			var:seducer = { save_temporary_scope_as = seducer_temp }
		}
		trigger_if = {
			limit = { exists = var:spouse }
			var:spouse = { save_temporary_scope_as = spouse_temp }
		}
		trigger_if = {
			limit = { exists = var:puppet }
			var:puppet = { save_temporary_scope_as = puppet_temp }
		}
	}
}

ep3_story_cycle_admin_eunuch_involved_character = {
	employer.top_liege = {
		ep3_story_cycle_admin_eunuch_valid_story_trigger = yes
		OR = {
			scope:eunuch_temp ?= this
			scope:protege_temp ?= this
			scope:student_temp ?= this
			scope:seducer_temp ?= this
			scope:spouse_temp ?= this
			scope:puppet_temp ?= this
		}
	}
}

is_appointment_valid_trigger = {
	$TITLE$ = { save_temporary_scope_as = title_temp }
	$CANDIDATE$ = { save_temporary_scope_as = candidate_temp }
	$TOP_LIEGE$ = { save_temporary_scope_as = top_liege_temp }
	custom_tooltip = { # Capital should be never a valid appointment (go for higher title instead
		text = not_top_liege_capital_county_tt
		NOT = { scope:title_temp ?= scope:candidate_temp.top_liege.capital_county }
	}
	scope:candidate_temp = {
		trigger_if = {
			limit = { exists = scope:title_temp }
			custom_tooltip = { # Has relevant law
				text = has_appointment_succession_tt
				$TITLE$ = {
					OR = {
						has_title_law_flag = appointment_type_succession
						holder ?= { has_realm_law_flag = appointment_type_succession }
					}
				}
			}
			trigger_if = {
				limit = {
					NOT = { top_liege.highest_held_title_tier = scope:title_temp.tier }
				}
				is_adult = yes
			}
			trigger_if = {
				limit = {
					any_held_title = { count >= 1 }
				}
				trigger_if = {
					limit = { government_has_flag = government_is_celestial }
					custom_tooltip = { # Only one province of highest rank
						text = cannot_compete_for_lower_rank_titles_tt
						NOT = {
							any_held_title = {
								tier > scope:title_temp.tier
								is_landless_type_title = no
								is_noble_family_title = no
							}
						}
					}
				}
				trigger_else = {
					custom_tooltip = { # Only one province of highest rank
						text = only_one_province_of_highest_rank_tt
						NOT = {
							any_held_title = {
								tier = scope:title_temp.tier
								is_landless_type_title = no
								is_noble_family_title = no
							}
						}
					}
				}
				custom_tooltip = {
					text = promote_candidate_interaction_existing_holder_tt
					this != scope:title_temp.holder
				}
			}
		}
		custom_tooltip = {
			text = can_be_appointed_interaction_tt
			OR = {
				can_be_granted_titles_by = { RULER = scope:top_liege_temp }
				can_be_granted_theocratic_titles_by = { RULER = scope:top_liege_temp }
				AND = {
					is_diarch_of_target = scope:top_liege_temp
					scope:top_liege_temp = { has_diarchy_active_parameter = diarchy_is_co_rulership }
				}
			}
		}
		custom_tooltip = { # Only administrative
			text = only_administrative_tt
			trigger_if = {
				limit = { is_landed = yes }
				government_allows = administrative
			}
		}
		is_clergy = no
	}
}

ep3_adventurer_ai_logic_valid_trigger = {
	is_alive = yes
	is_ai = yes
	government_has_flag = government_is_landless_adventurer
	domicile ?= { is_domicile_type = camp }
}

ep3_laamp_diplo_range_trigger = {
	custom_description = {
		text = ep3_laamp_diplo_range_trigger_tt
		subject = scope:actor
		object = scope:recipient
		trigger_if = {
			limit = { exists = $LAAMP$.domicile.domicile_location }
			trigger_if = {
				limit = {
					NOT = { exists = $TARGET$.capital_province }
					exists = $TARGET$.host.capital_province
				}
				$TARGET$.host.capital_province ?= {
					squared_distance = {
						target = $LAAMP$.domicile.domicile_location
						value < define:NTaskContract|ADVENTURER_DISTANCE_RESTRICTION
					}
				}
			}
			trigger_else_if = {
				limit = {
					NOT = { exists = $TARGET$.capital_province }
					exists = $TARGET$.location
				}
				$TARGET$.location ?= {
					squared_distance = {
						target = $LAAMP$.domicile.domicile_location
						value < define:NTaskContract|ADVENTURER_DISTANCE_RESTRICTION
					}
				}
			}
			trigger_else = {
				$TARGET$.capital_province ?= {
					squared_distance = {
						target = $LAAMP$.domicile.domicile_location
						value < define:NTaskContract|ADVENTURER_DISTANCE_RESTRICTION
					}
				}
			}
		}
		trigger_else = { always = no }
	}
}

can_recruit_archer_cavalry_trigger = {
	custom_tooltip = {
		text = can_recruit_archer_cavalry_trigger_desc
		OR = {
			can_create_maa = horse_archers
			can_create_maa = mangudai
			can_create_maa = asawira
			can_create_maa = accolade_maa_horse_archers
			can_create_maa = emishi_horse_archers
			can_create_maa = japanese_horse_archers
			can_create_maa = kheshig
			can_create_maa = heavy_horse_archers
			can_create_maa = heavy_horse_archers
		}
	}
}

ep3_transport_contract_trigger = {
	OR = {
		has_task_contract_type = laamp_transport_vip
		has_task_contract_type = laamp_transport_artifact
		has_task_contract_type = laamp_transport_gold
		has_task_contract_type = laamp_transport_ward
		has_task_contract_type = laamp_transport_explorer
		has_task_contract_type = laamp_transport_animal
		has_task_contract_type = laamp_construction_contract
	}
}

ep3_vassal_will_become_admin = {
	#This trigger picks out vassals that automatically convert to Admin.
	#We convert vassals that are:
	#Clan or Feudal
	#De Jure part of the Empire
	#Have the State Faith
	#Aren't rivals of the admin liege
	#Dukes and above must like the main liege at least a little.
	highest_held_title_tier > tier_barony
	primary_title = {
		target_is_de_jure_liege_or_above = scope:administrative_liege.primary_title #We only auto convert de jure vassals
	}
	OR = { #We convert only clan and feudal vassals in this decision
		government_has_flag = government_is_feudal
		government_has_flag = government_is_clan
		government_has_flag = government_is_japan_feudal
	}
	faith = scope:administrative_liege.faith #The future state faith
}

ep3_kings_will_convert_trigger = {
	primary_title.tier >= tier_kingdom
	NOR = {
		opinion = {
			target = liege
			value < -50
		}
		has_relation_rival = liege
	}
}

ep3_is_clan_inclined_trigger = {
	OR = {
		faith.religion = religion:islam_religion
		culture ?= {
			OR = {
				has_cultural_pillar = heritage_arabic
				has_cultural_pillar = heritage_iranian
				has_cultural_pillar = heritage_turkic
			}
		}
	}
}

cid_story_cycle_start_trigger = {
	is_alive = yes
	is_playable_character = yes
	has_ep3_dlc_trigger = yes
	NOR = {
		has_variable = ongoing_cid_story_cycle
		has_variable = had_cid_story_cycle
	}
	has_government = landless_adventurer_government
	top_liege ?= {
		any_courtier = { is_available_healthy_ai_adult = yes }
	}
}

ep3_can_have_legitimists_camp_purpose_trigger = {
	custom_tooltip = {
		text = ep3_can_have_legitimists_camp_purpose_trigger.tt.explanation
		any_claim = {
			explicit = yes
			tier >= tier_kingdom
		}
	}
}

has_any_gallowsbait_xp_trigger = {
	OR = {
		has_trait_xp = {
			trait = gallowsbait
			track = bandit
			value >= 1
		}
		has_trait_xp = {
			trait = gallowsbait
			track = trickster
			value >= 1
		}
		has_trait_xp = {
			trait = gallowsbait
			track = marauder
			value >= 1
		}
		has_trait_xp = {
			trait = gallowsbait
			track = poacher
			value >= 1
		}
		has_trait_xp = {
			trait = gallowsbait
			track = thief
			value >= 1
		}
	}
}

ep3_restored_rome_hard_mode_trigger = {
	OR = {
		this = title:h_roman_empire.holder
		this = title:h_eastern_roman_empire.holder
	}
	any_owned_story = {
		type = ep3_story_cycle_restoring_rome
		has_variable = roman_empire_hard_mode
	}
}

faith_is_interesting_heresy_to_state_faith_trigger = {
	religion = root.top_liege.primary_title.state_faith.religion
	this != root.top_liege.primary_title.state_faith
	num_county_followers >= 3
	save_temporary_scope_as = temp_heresy
	root.top_liege.primary_title.state_faith = {
		faith_hostility_level = {
			target = scope:temp_heresy
			value >= faith_hostile_level
		}
	}
}

ep3_boundary_dispute_county_trigger = {
	tier = tier_county
	custom_tooltip = {
		text = dispute_border_county_neighbour_tt
		county_held_or_vassal_to_target_trigger = { TARGET = $TARGET$ }
		OR = {
			any_neighboring_county = {
				county_held_or_vassal_to_target_trigger = { TARGET = $OWNER$ }
			}
			AND = {
				de_jure_liege.holder ?= $OWNER$
				any_title_to_title_neighboring_and_across_water_county = {
					county_held_or_vassal_to_target_trigger = { TARGET = $OWNER$ }
				}
			}
		}
	}
}

ep3_subsume_province_duchy_trigger = {
	tier = tier_duchy
	holder ?= $TARGET$
	is_noble_family_title = no
	is_landless_type_title = no
	trigger_if = {
		limit = { tier = tier_duchy }
		custom_tooltip = {
			text = subsume_province_must_neighbor_tt
			any_de_jure_county = {
				county_held_or_vassal_to_target_trigger = { TARGET = $TARGET$ }
				any_neighboring_county = {
					county_held_or_vassal_to_target_trigger = { TARGET = $OWNER$ }
				}
			}
		}
		custom_tooltip = {
			text = subsume_province_more_than_half_tt
			any_de_jure_county = {
				percent < 0.5
				county_held_or_vassal_to_target_trigger = { TARGET = $OWNER$ }
			}
		}
	}
}

ep3_interesting_courtier_to_ask_trigger = {
	is_councillor = no
	has_any_court_position = no
	OR = {
		diplomacy >= high_skill_rating
		martial >= high_skill_rating
		stewardship >= high_skill_rating
		intrigue >= high_skill_rating
		learning >= high_skill_rating
		prowess >= high_skill_rating
		has_trait = education_diplomacy_4
		has_trait = education_diplomacy_5
		has_trait = education_martial_4
		has_trait = education_martial_5
		has_trait = education_stewardship_4
		has_trait = education_stewardship_5
		has_trait = education_intrigue_4
		has_trait = education_intrigue_5
		has_trait = education_learning_4
		has_trait = education_learning_5
		has_trait_xp = { trait = lifestyle_physician value >= 20 }
		has_trait_xp = { trait = lifestyle_traveler track = travel value >= 20 }
		has_trait_xp = { trait = lifestyle_traveler track = danger value >= 20 }
		has_trait_xp = { trait = lifestyle_hunter track = hunter value >= 20 }
		has_trait_xp = { trait = lifestyle_hunter track = falconer value >= 20 }
		has_trait_xp = { trait = charioteer_blue value >= 20 }
		has_trait_xp = { trait = charioteer_green value >= 20 }
		has_trait_xp = { trait = charioteer_red value >= 20 }
		has_trait_xp = { trait = charioteer_white value >= 20 }
		has_trait_xp = { trait = governor value >= 20 }
	}
}

ep3_admin_faction_trigger = {
	trigger_if = { # Enabled for all admin realms with EP3
		limit = { has_ep3_dlc_trigger = yes }
		$FACTION_TARGET$ = { government_allows = administrative }
	}
	trigger_else = { # Enabled for Byzantium without EP3
		$FACTION_TARGET$ = { has_title = title:e_byzantium }
	}
}

ep3_switch_faction_war_sides_war_trigger = {
	# Recipient involved in war
	is_participant = scope:recipient
	# Is a Faction war
	save_temporary_scope_as = faction_war_temp
	primary_attacker.joined_faction.faction_war ?= scope:faction_war_temp
	# Actor and recipient on opposing sides
	trigger_if = {
		limit = { is_defender = scope:recipient }
		is_attacker = scope:actor
		# Recipient must not be an ally of the opposing war leader
		NOT = {
			primary_defender = { is_allied_to = scope:recipient }
		}
	}
	trigger_else = {
		is_defender = scope:actor
		# Recipient must not be an ally of the opposing war leader
		NOT = {
			primary_attacker = { is_allied_to = scope:recipient }
		}
	}
	# Recipient must not be a war leader
	NOT = { is_war_leader = scope:recipient }
	# Recipient must not be the claimant
	primary_attacker.joined_faction.special_character != scope:recipient
}

ep3_raid_insight_trigger = {
	scope:owner = {
		NOT = { has_character_modifier = raid_insight_$TYPE$ }
	}
	scope:target_domicile = { has_domicile_building_or_higher = $TYPE$_01 }
}

ep3_adventurer_ai_valid_war_target_trigger = {
	is_landed = yes
	reverse_opinion = {
		target = $ADVENTURER$
		value <= 0
	}
	in_diplomatic_range = $ADVENTURER$
	NOR = {
		is_at_war_with = $ADVENTURER$
		is_allied_to = $ADVENTURER$
	}
	current_strength_with_allies_value < $ADVENTURER$.current_strength_with_allies_seventy_five_percent_value
	save_temporary_scope_as = war_target_temp
	trigger_if = {
		limit = { government_has_flag = government_is_tribal }
		OR = {
			$ADVENTURER$.culture.culture_head ?= { government_has_flag = government_is_tribal }
			capital_county.culture = {
				any_parent_culture_or_above = { this = $ADVENTURER$.culture }
			}
			$ADVENTURER$.culture = {
				any_parent_culture_or_above = { this = scope:war_target_temp.capital_county.culture }
			}
		}
	}
	$ADVENTURER$ = {
		trigger_if = {
			limit = { has_realm_law = camp_purpose_legitimists }
			any_claim = {
				tier >= tier_kingdom
				holder = scope:war_target_temp
				save_temporary_scope_as = claim_temp
			}
			can_declare_war = {
				defender = scope:war_target_temp
				casus_belli = claim_cb
				claimant = $ADVENTURER$
				target_titles = { scope:claim_temp }
			}
		}
		trigger_else = {
			OR = {
				AND = {
					scope:war_target_temp = {
						any_held_title = {
							count >= 1
							title_tier = empire
							save_temporary_scope_as = war_target_title_temp
						}
					}
					can_declare_war = {
						defender = scope:war_target_temp
						casus_belli = ep3_laamp_adventurer_empire_invasion
						target_titles = { scope:war_target_title_temp }
					}
				}
				AND = {
					scope:war_target_temp = {
						any_held_title = {
							count >= 1
							title_tier = kingdom
							save_temporary_scope_as = war_target_title_temp
						}
					}
					can_declare_war = {
						defender = scope:war_target_temp
						casus_belli = ep3_laamp_adventurer_kingdom_invasion
						target_titles = { scope:war_target_title_temp }
					}
				}
				AND = {
					scope:war_target_temp = {
						any_held_title = {
							count >= 1
							title_tier = duchy
							save_temporary_scope_as = war_target_title_temp
						}
					}
					can_declare_war = {
						defender = scope:war_target_temp
						casus_belli = ep3_laamp_adventurer_duchy_invasion
						target_titles = { scope:war_target_title_temp }
					}
				}
				AND = {
					scope:war_target_temp = {
						any_held_title = {
							count >= 1
							title_tier = county
							save_temporary_scope_as = war_target_title_temp
						}
					}
					can_declare_war = {
						defender = scope:war_target_temp
						casus_belli = ep3_laamp_adventurer_county_invasion
						target_titles = { scope:war_target_title_temp }
					}
				}
			}
		}
	}
}

ep3_adventurer_ai_valid_legitimist_target_trigger = {
	is_landed = yes
	NOR = {
		has_relation_friend = $ADVENTURER$
		is_at_war_with = $ADVENTURER$
		is_allied_to = $ADVENTURER$
	}
	save_temporary_scope_as = target_temp
	current_strength_with_allies_value < $ADVENTURER$.current_strength_with_allies_seventy_five_percent_value
	any_held_title = {
		title_tier >= kingdom
		any_claimant = { this = $ADVENTURER$ }
		save_temporary_scope_as = claim_temp
	}
	$ADVENTURER$ = {
		can_declare_war = {
			defender = scope:target_temp
			casus_belli = claim_cb
			claimant = $ADVENTURER$
			target_titles = { scope:claim_temp }
		}
	}
}

ep3_adventurer_might_attack_target_trigger = {
	has_government = landless_adventurer_government
	# Army at least half the size
	current_strength_with_allies_value > $TARGET$.current_strength_with_allies_fifty_percent_value
	# Not allies
	NOT = { is_allied_to = $TARGET$ }
	OR = {
		# Has a claim on a title in subrealm
		any_claim = {
			holder ?= {
				OR = {
					this = $TARGET$
					target_is_liege_or_above = $TARGET$
				}
			}
		}
		# Opinion
		opinion = {
			target = $TARGET$
			value < -25
		}
	}
}

ep3_adventurer_mercenary_war_trigger = {
	is_war_leader = $EMPLOYER$
	OR = {
		using_civil_war_cb_trigger = yes
		using_non_ghw_holy_war_cb_trigger = yes
		using_de_jure_cb_trigger = yes
		using_conquest_cb_trigger = yes
	}
	NOT = { is_participant = $LAAMP$ }
}

ep3_adventurer_ai_valid_contract_trigger = {
	$LAAMP$ = {
		OR = {
			# DIPLOMACY
			can_create_task_contract = { type_name = laamp_base_0001 employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_base_0011 employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_base_0021 employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_base_0031 employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_base_0011 employer = $EMPLOYER$ }
			# MARTIAL
			can_create_task_contract = { type_name = laamp_base_1001 employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_base_1011 employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_base_1021 employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_base_1031 employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_base_1041 employer = $EMPLOYER$ }
			# STEWARDSHIP
			can_create_task_contract = { type_name = laamp_base_2001 employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_base_2011 employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_base_2021 employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_base_2031 employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_base_2041 employer = $EMPLOYER$ }
			# INTRIGUE
			can_create_task_contract = { type_name = laamp_base_3001 employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_base_3011 employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_base_3021 employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_base_3031 employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_base_3041 employer = $EMPLOYER$ }
			# LEARNING
			can_create_task_contract = { type_name = laamp_base_4001 employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_base_4011 employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_base_4021 employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_base_4031 employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_base_4041 employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_base_4100 employer = $EMPLOYER$ }
			# PROWESS
			can_create_task_contract = { type_name = laamp_base_5001 employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_base_5011 employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_base_5021 employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_base_5031 employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_base_5041 employer = $EMPLOYER$ }
			# JUSTICAR
			can_create_task_contract = { type_name = laamp_base_6001 employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_base_6011 employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_base_6021 employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_base_6031 employer = $EMPLOYER$ }
			# EXTRA
			can_create_task_contract = { type_name = laamp_boost_legitimacy_contract employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_rid_councillor_contract employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_gain_wanderer_contract employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_find_secret_contract employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_eliminate_heir_contract employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_steal_artifact_contract employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_construction_contract employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_cultural_minority_contract employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_religious_minority_contract employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_prison_break_contract employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_join_faction_contract employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_help_faith_conversion_contract employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_fight_faith_conversion_contract employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_help_find_secrets_contract employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_help_fabricate_claim_contract employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_help_increase_control_contract employer = $EMPLOYER$ }
			can_create_task_contract = { type_name = laamp_help_find_secrets_contract employer = $EMPLOYER$ }
		}
		AND = {
			has_realm_law = camp_purpose_mercenaries
			OR = {
				can_create_task_contract = { type_name = laamp_raid_contract employer = $EMPLOYER$ }
				can_create_task_contract = { type_name = laamp_join_war_contract employer = $EMPLOYER$ }
				can_create_task_contract = { type_name = laamp_help_claimant_contract employer = $EMPLOYER$ }
			}
		}
	}
}

hasan_evangelize_province_trigger = {
	save_temporary_scope_as = county
	scope:county.faith = {
		# Religion is same as Hasan's (i.e. Muslim)
		#religion = root.religion # QA thinks its more fun without this!
		NOR = {
			# Faith is different from Hasan's
			custom_tooltip = {
				text = zealous_missionary_start_decision_other_faith_location
				this = root.faith
			}
			# County is not held by it's Faith's Religious Head
			custom_tooltip = {
				text = is_held_by_hof_tt
				religious_head ?= scope:county.holder
			}
		}
	}
	development_level <= 25
	custom_tooltip = {
		text = has_tougher_to_convert_tt
		NOT = { has_county_modifier = tougher_to_convert }
	}
	custom_tooltip = {
		text = 0_or_below_county_opinion_tt
		county_opinion <= 0
	}
	custom_tooltip = {
		text = NOT_IS_HOLY_SITE_TRIGGER
		NOT = {
			any_direct_de_jure_vassal_title = { is_holy_site_of = scope:county.faith }
		}
	}
}

hasan_camp_in_foes_realm_trigger = {
	trigger_if = {
		limit = {
			any_owned_story = {
				var:ultimate_foe ?= {
					save_temporary_scope_as = ultimate_foe
				}
			}
		}
		custom_description = {
			text = hasan_stroy_cycle_camp_at_foe_realm
			object = scope:ultimate_foe
			domicile.domicile_location.county.holder = {
				OR = {
					any_liege_or_above = {
						this = scope:ultimate_foe
					}
					this = scope:ultimate_foe
				}
			}
		}
	}
	trigger_else = {
		character:3096 = {
			save_temporary_scope_as = caliph
		}
		save_temporary_scope_as = hasan
		any_owned_story = {
			trigger_if = {
				limit = { exists = var:radical_points }
				save_temporary_scope_value_as = {
					name = radical_points
					value = var:radical_points
				}
			}
			trigger_else = {
				save_temporary_scope_value_as = {
					name = radical_points
					value = 0
				}
			}
		}
		custom_tooltip = {
			text = hasan_stroy_cycle_ultimate_foe
			any_owned_story = {
				story_type = story_hasan
				exists = var:ultimate_foe
				exists = var:radical_points
				var:radical_points >= 15
			}
		}
	}
}

estate_can_construct_market_03_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_02 }
}
estate_can_construct_market_04_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_03 }
}
estate_can_construct_market_05_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_04 }
}
estate_can_construct_market_06_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_05 }
}

estate_can_construct_garden_leisure_04_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_03 }
}
estate_can_construct_garden_leisure_05_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_04 }
}
estate_can_construct_garden_leisure_06_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_05 }
}
estate_can_construct_garden_fruit_04_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_03 }
}
estate_can_construct_garden_fruit_05_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_04 }
}
estate_can_construct_garden_fruit_06_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_05 }
}

estate_can_construct_guardhouse_03_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_02 }
}
estate_can_construct_guardhouse_04_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_03 }
}

estate_can_construct_workshop_carpenter_03_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_02 }
}
estate_can_construct_workshop_carpenter_04_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_03 }
}
estate_can_construct_workshop_carpenter_05_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_04 }
}
estate_can_construct_workshop_carpenter_06_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_05 }
}
estate_can_construct_workshop_mason_03_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_02 }
}
estate_can_construct_workshop_mason_04_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_03 }
}
estate_can_construct_workshop_mason_05_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_04 }
}
estate_can_construct_workshop_mason_06_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_05 }
}
estate_can_construct_workshop_textile_03_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_02 }
}
estate_can_construct_workshop_textile_04_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_03 }
}
estate_can_construct_workshop_textile_05_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_04 }
}
estate_can_construct_workshop_textile_06_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_05 }
}

estate_can_construct_barracks_03_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_02 }
}
estate_can_construct_barracks_04_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_03 }
}
estate_can_construct_barracks_05_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_04 }
}
estate_can_construct_barracks_06_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_05 }
}

estate_can_construct_vineyard_03_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_02 }
}
estate_can_construct_vineyard_04_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_03 }
}
estate_can_construct_vineyard_05_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_04 }
}
estate_can_construct_vineyard_06_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_05 }
}

estate_can_construct_olive_03_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_02 }
}
estate_can_construct_olive_04_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_03 }
}
estate_can_construct_olive_05_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_04 }
}
estate_can_construct_olive_06_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_05 }
}

estate_can_construct_health_03_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_02 }
}
estate_can_construct_health_04_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_03 }
}
estate_can_construct_health_05_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_04 }
}
estate_can_construct_health_06_trigger = {
	domicile ?= { has_domicile_building_or_higher = estate_main_05 }
}

estate_can_construct_japanese_tea_plantation_03_trigger = {
	domicile ?= { has_domicile_building_or_higher = japanese_manor_main_02 }
}
estate_can_construct_japanese_tea_plantation_04_trigger = {
	domicile ?= { has_domicile_building_or_higher = japanese_manor_main_03 }
}
estate_can_construct_japanese_tea_plantation_05_trigger = {
	domicile ?= { has_domicile_building_or_higher = japanese_manor_main_04 }
}
estate_can_construct_japanese_tea_plantation_06_trigger = {
	domicile ?= { has_domicile_building_or_higher = japanese_manor_main_05 }
}

# Check succession law types for Influence Candidacy validity
# TYPE should always be 'realm' or 'title'
influence_candidacy_valid_succession_law_trigger = {
	OR = {
		# Byzantium
		has_$TYPE$_law = acclamation_succession_law
		has_$TYPE$_law = appointment_succession_law
		# Celestial Governors
		has_$TYPE$_law = celestial_appointment_succession_law
		has_$TYPE$_law = celestial_military_appointment_succession_law
		# Meritocratic Governors
		has_$TYPE$_law = meritocratic_appointment_succession_law
		has_$TYPE$_law = meritocratic_military_appointment_succession_law
		# Japanese Governors
		has_$TYPE$_law = japanese_appointment_succession_law
		has_$TYPE$_law = japanese_military_appointment_succession_law
		# Ceremonial Regents
		has_$TYPE$_law = meritocratic_regency_succession_law
		has_$TYPE$_law = japanese_regency_succession_law
	}
}
