﻿# Returns whether or not a given character is a valid scoutee
# for `task_scout_targets`. This specifically tests whether a
# character is valid to be marked as a capture target.
#
# scope = character
is_valid_scout_targets_scoutee = {
	is_female = yes
	NOT = {
		has_character_modifier = regula_scouted_target_modifier
	}
}

# Returns whether or not the scout targets task is valid for a given court.
#
# root = councillor_raid_leader
# scope:councillor = councillor_raid_leader
# scope:councillor_liege = the liege of the councillor_raid_leader
# scope:province = the capital province of the targeted county
# scope:county = the target county
is_valid_scout_targets_county = {
	scope:county = {
		exists = holder
		holder = {
			in_diplomatic_range = scope:councillor_liege
			custom_description = {
				text = task_scout_targets_own_court_unavailable_trigger
				NOT = {
					target_is_same_character_or_above = scope:councillor_liege
				}
			}
			custom_description = {
				text = task_scout_targets_no_available_targets_trigger
				OR = {
					is_valid_scout_targets_scoutee = yes
					any_courtier = {
						is_valid_scout_targets_scoutee = yes
					}
				}
			}
			custom_description = {
				text = task_scout_targets_only_capital_counties_trigger
				scope:county = capital_county
			}
		}
	}
}

# Tests whether or not the scoped county is a valid county to be raided for
# task_border_raids.
#
# In particular, this tests whether the councillor is allowed to raid the
# holder of the county & whether the county is already regula (and thus
# shouldn't be raided).
#
# scope:councillor_liege = the liege of the councillor_raid_leader
is_valid_border_raids_county = {
	custom_description = {
		text = task_border_raids_valid_county_trigger
		holder = {
			# Conditions which should block holder being raided by
			# scope:councillor_liege
			NOR = {
				has_raid_immunity_against = scope:councillor_liege
				is_allied_to = scope:councillor_liege
				has_truce = scope:councillor_liege
				target_is_vassal_or_below = scope:councillor_liege
				top_liege = scope:councillor_liege.top_liege
			}
		}
		NOT = { # Don't raid regula counties.
			is_regula_trigger = yes
		}
	}
}

# Tests whether the liege has any neighboring counties which are eligible for
# raids.
#
# scope:councillor_liege = the liege of the councillor_raid_leader
any_valid_border_raids_county = {
	scope:councillor_liege = {
		any_character_to_title_neighboring_county = {
			is_valid_border_raids_county = yes
		}
	}
}

# Determines whether the scoped character is valid to be a border raid
# captive.
#
# Specifically used to test eligibility of pool characters.
#
# scope = the character being tested for border raids capture eligibility
is_valid_border_raids_pool_captive = {
	is_female = yes
	is_landed = no
	is_lowborn = yes

	is_courtier = no
	is_foreign_court_or_pool_guest = no
	is_available = yes

	age < 45
	is_adult = yes

	is_regula_trigger = no
}
