# Scripted by Mechano for use in determining valid targets for sporradic conflicts in events/Warcreation

# Protected nations that will not get involved in random conflicts, makes sure that nations or even regions are considerably more stable.
is_protected_lore_faction = {
	OR = {
		has_country_flag = random_war_protected
	}
}

elgible_wargoal_sender = {
	#NOT = {
	#	surrender_progress > 0.1
	#}
	is_ai = yes
	has_war = no
	#is_protected_lore_faction = no
	OR = { # Faction tension limits
		is_in_faction = no
		has_global_flag = faction_min_claim_temp_0
		threat > 0.9
		AND = {
			has_global_flag = faction_min_claim_temp_60
			threat > 60
		}
		AND = {
			has_global_flag = faction_min_claim_temp_30
			threat > 30
		}
	}
	#has_capitulated = no
	#exists = yes
}
elgible_wargoal_receiver = {
	OR = {
		has_war = no
		AND = {
				is_ai = no # is meaner to players, so if they are fighting an offensive war and and winning they can still get a claim put on them
				has_defensive_war = no
				NOT = {
					surrender_progress > 0.1
				}
		}
	}
	OR = { # Democratic protections
		has_global_flag = remove_democratic_protections
		NOT = { # democracies will not start wars with each other unless they strongly hate them for whatever reason
			AND = {
				OR = {
					has_peaceful_government = yes
				}
				OR = {
					ROOT = { has_peaceful_government = yes }
				}
			}
		}
		ROOT = {has_opinion = { target = PREV value < -50 }}
	}
	# considers strength ratios, invading someone who has more troops is generally a bad idea
	OR = {
		AND = {
			has_war = yes
			any_enemy_country = {
				strength_ratio = { tag = PREV ratio > 0.6 }
			}
		}
		ROOT = { strength_ratio = { tag = PREV ratio > 1.0}}
	}
	#is_protected_lore_faction = no
	#exists = yes
	#has_capitulated = no
	ROOT = {has_opinion = { target = PREV value < 30 }} # will not start wars with countries they like
}
is_island_nation = {
	AND = {
		NOT = {
			any_neighbor_country = {
				exists = yes
				}
			}
		all_owned_state = {
			is_coastal = yes
		}
	}
}
is_on_same_continent = {
	OR = {
		AND = {
			is_on_continent = europe
			ROOT = { any_owned_state = { is_on_continent = europe } }
		}
		AND = {
			is_on_continent = north_america
			ROOT = { any_owned_state = { is_on_continent = north_america } }
		}
		AND = {
			is_on_continent = south_america
			ROOT = { any_owned_state = { is_on_continent = south_america } }
		}
		AND = {
			is_on_continent = australia
			ROOT = { any_owned_state = { is_on_continent = australia } }
		}
		AND = {
			is_on_continent = africa
			ROOT = { any_owned_state = { is_on_continent = africa } }
		}
		AND = {
			is_on_continent = asia
			ROOT = { any_owned_state = { is_on_continent = asia } }
		}
		AND = {
			is_on_continent = middle_east
			ROOT = { any_owned_state = { is_on_continent = middle_east } }
		}
		#AND = {
		#	area = 6
		#	ROOT = { any_owned_state = { area = 6 } }
		#}
		#AND = {
		#	area = 7
		#	ROOT = { any_owned_state = { area = 7 } }
		#s}
	}
}