### Strong conquest desire for all primary-culture homelands (Manifest Destiny–style).
### Pushes conquer_state / return_state diplomatic plays even without Union War.

ai_strategy_uw_reclaim_homelands = {
	icon = "gfx/interface/icons/ai_strategy_icons/territorial_expansion.dds"

	type = diplomatic

	will_form_power_bloc = {
		OR = {
			global_country_ranking <= 3
			AND = {
				country_rank >= rank_value:great_power
				has_technology_researched = nationalism
			}
		}
	}

	undesirable_infamy_level = {
		value = 50

		if = {
			limit = {
				has_technology_researched = pan-nationalism
			}
			multiply = 1.5
		}
		else_if = {
			limit = {
				has_technology_researched = nationalism
			}
			multiply = 1.25
		}
	}

	unacceptable_infamy_level = {
		value = 100
	}

	ideological_opinion_effect_mult = {
		value = 0.75
	}

	wargoal_maneuvers_fraction = {
		value = 0.2
	}

	diplomatic_play_neutrality = {
		value = 10
	}

	diplomatic_play_boldness = {
		value = 50

		# Confident against anyone holding our cultural homelands (cf. Manifest Destiny +1).
		if = {
			limit = {
				scope:target_country = {
					any_scope_state = {
						is_homeland_of_country_cultures = root
					}
				}
			}
			add = 50
		}
	}

	recklessness = {
		value = 0.35
	}

	aggression = {
		value = 1

		# Strong push to attack holders of primary-culture homelands.
		if = {
			limit = {
				NOT = { scope:target_country = { is_subject_of = root } }
				scope:target_country = {
					any_scope_state = {
						is_homeland_of_country_cultures = root
					}
				}
			}
			add = 2

			if = {
				limit = {
					has_strategic_adjacency = scope:target_country
				}
				add = 2
			}

			if = {
				limit = {
					scope:target_country.country_rank <= root.country_rank
				}
				add = 1
			}
		}

		# Less aggressive against countries we're just antagonistic against, rather than belligerent/domineering
		if = {
			limit = {
				has_attitude = {
					who = scope:target_country
					attitude = antagonistic
				}
			}
			multiply = 0.25
		}

		# More aggressive against ideological enemies, a bit less aggressive against ideological allies
		multiply = {
			value = "ai_ideological_opinion(scope:target_country)"
			multiply = -0.1
			add = 1
			max = 2.0
			min = 0.5
		}
	}

	building_group_weights = {
		bg_army = 1.5
		bg_military_industry = 1.25
	}

	secret_goal_weights = {
		protect = 0.5
		conquer = 2.0
	}

	wargoal_weights = {
		annex_country = 1.25
		conquer_state = 2.0
		return_state = 2.0
		force_nationalization = 0.25
	}

	# Manifest Destiny–style state valuation for primary-culture homelands.
	state_value = {
		if = {
			limit = {
				can_reach_target_state = yes
				scope:target_state = {
					is_homeland_of_country_cultures = root
					NOT = { owner = root }
					NOT = { owner = { is_subject_of = root } }
				}
			}
			add = 50

			if = {
				limit = {
					is_adjacent_to_state = scope:target_state
				}
				multiply = 2
			}
		}
	}

	wargoal_scores = {
		return_state = {
			if = {
				limit = {
					can_reach_target_state = yes
					scope:target_state = {
						is_homeland_of_country_cultures = root
					}
				}
				add = 250
			}
		}
		conquer_state = {
			if = {
				limit = {
					can_reach_target_state = yes
					scope:target_state = {
						is_homeland_of_country_cultures = root
						NOT = { owner = root }
						NOT = { owner = { is_subject_of = root } }
					}
				}
				add = 250

				if = {
					limit = {
						is_adjacent_to_state = scope:target_state
					}
					add = 250
				}
			}
		}
	}

	secret_goal_scores = {
		conquer = {
			trigger = {
				NOT = { scope:target_country = { is_subject_of = root } }
				can_reach_target_country = yes
				scope:target_country = {
					any_scope_state = {
						is_homeland_of_country_cultures = root
					}
				}
			}
			score = {
				value = 500

				if = {
					limit = {
						has_strategic_adjacency = scope:target_country
					}
					add = 500
				}

				if = {
					limit = {
						scope:target_country.country_rank <= root.country_rank
					}
					add = 250
				}
			}
		}
	}

	possible = {
		is_subject = no
		NOT = { is_country_type = decentralized }
		uw_has_unowned_primary_culture_homeland = yes
	}

	weight = {
		value = 40

		# Extra weight when a land neighbour holds our homeland (most actionable plays).
		if = {
			limit = {
				uw_has_adjacent_unowned_primary_culture_homeland = yes
			}
			add = 40
		}

		if = {
			limit = {
				country_fervor_primary_culture > 10
			}
			add = {
				value = country_fervor_primary_culture
				divide = 2
			}
		}

		if = {
			limit = { ig:ig_armed_forces ?= { is_powerful = yes } }
			multiply = 1.5
		}

		if = {
			limit = { has_radical_leftist_government = yes }
			multiply = 0.5
		}
	}
}
