

ai_generic_operation_target_scorer  = {
	targets = {
		target_array = potential_and_current_enemies
		target_array = enemies_of_allies
		target_array = neighbors
		target_array = global.majors

		score = {
			base = 100

			modifier = {
				OR = {
					exists = no
					has_capitulated = yes
					is_ally_with = FROM
				}
				factor = 0 
			}
			
			modifier = {
				has_war_with = FROM
				factor = 4.0
			}
			
			modifier = {
				OR = {
					is_in_array = { FROM.potential_and_current_enemies = this }
					is_in_array = { FROM.enemies_of_allies = this }
				}
				factor = 1.5
			}

			# quite possibly we will attack this target due to strats
			modifier = {
				NOT = { has_war_with = FROM }
				OR = {
					check_variable = { FROM.ai_strategy_conquer@THIS > 0 }
					check_variable = { FROM.ai_strategy_antagonize@THIS > 0 }
					check_variable = { FROM.ai_strategy_declare_war@THIS > 0 }
					check_variable = { FROM.ai_strategy_prepare_for_war@THIS > 0 }
					check_variable = { FROM.ai_strategy_contain@THIS > 0 }
				}
				factor = 1.3
			}

			modifier = {
				is_in_array = { FROM.neighbors = this }
				factor = 1.5
			}

			
			modifier = {
				is_major = yes
				factor = 1.1
			}

			modifier = {
				has_government = FROM
				NOT = { has_war_with = FROM }
				factor = 0.6
			}

			# larger countries are a bit more prio
			modifier = {
				set_temp_variable = { temp_score = armies^num }
				divide_temp_variable = { temp_score = 100 }
				add_to_temp_variable = { temp_score = 1.0 }
				clamp_temp_variable = { var = temp_score max = 2.2 }
				factor = temp_score
			}
			
			# continue targetting same country
			modifier = {
				check_variable = { id = generic_operation_target }
				factor = 2.0
			}
			
			# we got tokens to spend
			modifier = {
				FROM = {
					has_operation_token = {
						tag = PREV
						token = token_resistance_contacts
					}
				}
				factor = 4.0
			}
		}
	}
}