﻿INJECT:ai_strategy_default = {
	
	# Added to willingness to support a country in diplomatic plays
	# Using this value in other strategies will function additively
	# root = supporting country doing the AI evaluation
	# scope:country = country we're evaluating support for (either initiator or target)
	# scope:enemy_country = the opposing side's leader
	# scope:diplomatic_play_type = the type of diplomatic play
	# scope:is_initiator = bool, set to true if evaluating support for initiator, false if target
	# NOTE: You need to include a description when adding values here so there are correct tooltips, this is different from most of ai strategy data!
	#
	# KAI: Fix incorrect checks for scope:is_initiator
	diplomatic_play_support = {
		value = 0

		add = {
			value = "scope:country.modifier:country_diplomatic_reputation_add"
			desc = "DIPLOMATIC_REPUTATION_REASON"
		}

		### German Leadership War
		if = {
			# Non-Germans should stay out of the leadership war unless they have a good reason to intervene
			limit = {
				scope:diplomatic_play_type = play_type:dp_leadership_germany
				NOR = {
					country_has_primary_culture = cu:north_german
					country_has_primary_culture = cu:south_german
				}
			}

			if = {
				limit = {
					NOR = {
						any_scope_treaty = {
							binds = scope:country
							any_scope_article = {
								has_type = alliance
							}
						}
						AND = {
							scope:is_initiator = no
							OR = {
								any_scope_treaty = {
									binds = scope:country
									any_scope_article = {
										has_type = defensive_pact
									}
								}
								any_scope_treaty = {
									binds = scope:country
									any_scope_article = {
										has_type = guarantee_independence
									}
								}
							}
						}
					}

					scope:enemy_country = {
						NOR = {
							play_participant_has_war_goal_of_type_against = {
								type = conquer_state
								target = scope:country
							}
							play_participant_has_war_goal_of_type_against = {
								type = make_protectorate
								target = scope:country
							}
							play_participant_has_war_goal_of_type_against = {
								type = liberate_country
								target = scope:country
							}
							play_participant_has_war_goal_of_type_against = {
								type = liberate_subject
								target = scope:country
							}
							play_participant_has_war_goal_of_type_against = {
								type = transfer_subject
								target = scope:country
							}
							play_participant_has_war_goal_of_type_against = {
								type = take_treaty_port
								target = scope:country
							}
						}
					}
				}

				add = {
					value = -200
					desc = "german_leadership_neutrality"
				}
			}
		}

		### Schleswig War
		if = {
			limit = {
				NOR = {
					country_has_primary_culture = cu:north_german
					country_has_primary_culture = cu:south_german
				}
				OR = {
					AND = {
						scope:country = {
							is_oppressor_of_schleswig_holstein = yes
						}
						scope:enemy_country = {
							has_journal_entry = je_schleswig_holstein_question
						}
					}
					AND = {
						scope:enemy_country = {
							is_oppressor_of_schleswig_holstein = yes
						}
						scope:country = {
							has_journal_entry = je_schleswig_holstein_question
						}
					}
				}
			}

			if = {
				limit = {
					NOR = {
						any_scope_treaty = {
							binds = scope:country
							any_scope_article = {
								has_type = alliance
							}
						}
						AND = {
							scope:is_initiator = no
							OR = {
								any_scope_treaty = {
									binds = scope:country
									any_scope_article = {
										has_type = defensive_pact
									}
								}
								any_scope_treaty = {
									binds = scope:country
									any_scope_article = {
										has_type = guarantee_independence
									}
								}
							}
						}
					}

					scope:enemy_country = {
						NOR = {
							play_participant_has_war_goal_of_type_against = {
								type = conquer_state
								target = scope:country
							}
							play_participant_has_war_goal_of_type_against = {
								type = make_protectorate
								target = scope:country
							}
							play_participant_has_war_goal_of_type_against = {
								type = liberate_country
								target = scope:country
							}
							play_participant_has_war_goal_of_type_against = {
								type = take_treaty_port
								target = scope:country
							}
							play_participant_has_war_goal_of_type_against = {
								type = enforce_treaty_article
								target = scope:country
							}
						}
					}
				}
				add = {
					value = -100
					desc = "je_schleswig_holstein_question"
				}
			}
		}

		### Ottomans vs Egypt - Great Powers pick sides
		if = {
			limit = {
				OR = {
					AND = {
						scope:country = { c:TUR ?= this }
						scope:enemy_country = { c:EGY ?= this }
					}
					AND = {
						scope:country = { c:EGY ?= this }
						scope:enemy_country = { c:TUR ?= this }
					}
				}
				c:TUR ?= {
					OR = {
						has_journal_entry = je_sick_man_syria
						has_journal_entry = je_sick_man_egypt
						has_journal_entry = je_veiled_protectorate
					}
				}
			}

			if = {
				limit = {
					has_variable = veiled_protectorate_support_ottomans
					scope:country = { c:TUR ?= this }
				}

				add = {
					value = 100
					desc = "veiled_protectorate_ottomans_support"
				}
			}
			else_if = {
				limit = {
					has_variable = veiled_protectorate_support_egypt
					scope:country = { c:EGY ?= this }
				}

				add = {
					value = 100
					desc = "veiled_protectorate_egypt_support"
				}
			}
		}

		### Risorgimento
		if = {
			limit = {
				scope:is_initiator = yes
				scope:diplomatic_play_type = play_type:dp_secession
				root = {
					has_variable = risorgimento_unifying_stance
				}
				scope:country = {
					OR = {
						country_has_primary_culture = cu:north_italian
						country_has_primary_culture = cu:south_italian
					}
				}
				scope:enemy_country = {
					NOR = {
						country_has_primary_culture = cu:north_italian
						country_has_primary_culture = cu:south_italian
					}
				}
			}
			add = {
				value = 150
				desc = "risorgimento_support"
			}
		}

		### The Great Game
		if = { # Great Powers will tend to meddle if you directly declare war on enemy countries to easily subjugate them.
			limit = {
				OR = {
					c:GBR ?= this
					c:RUS ?= this
				}
				has_journal_entry = je_great_game_control
				has_diplomatic_relevance = scope:enemy_country
				scope:enemy_country = { # enemy_country is the rival Great Power
					OR = {
						c:GBR ?= this
						c:RUS ?= this
					}
					NOT = {
						this = root
					}
					has_journal_entry = je_great_game_control
				}
				scope:country = { # country is the country they're at war with
					OR = {
						capital.region = sr:region_greater_persia
						capital.region = sr:region_central_asia
					}
					NOT = {
						is_subject_of = scope:enemy_country
					}
				}
				OR = {
					has_strategic_adjacency = scope:country
					AND = {
						has_port_country = yes
						navy_size >= 10
						scope:country = { has_port_country = yes }
					}
				}
			}
			if = {
				limit = {
					OR = { # They will meddle if you seek anything that subjugates them or harms the balance of power.
						scope:diplomatic_play_type = play_type:dp_make_protectorate
						scope:diplomatic_play_type = play_type:dp_join_power_bloc
						any_diplomatic_play = {
							scope:country = {
								is_diplomatic_play_enemy_of = scope:enemy_country
							}
							OR = {
								has_play_goal = make_protectorate
								has_play_goal = conquer_state
								has_play_goal = join_power_bloc
								has_play_goal = annex_country
							}
						}
					}
				}
				add = {
					value = 100
					desc = "defending_against_great_game_rival"
				}
			}
			else_if = {
				limit = {
					OR = { # They will meddle less if you just want to take states.
						scope:diplomatic_play_type = play_type:dp_conquer_state
						any_diplomatic_play = {
							scope:country = {
								is_diplomatic_play_enemy_of = scope:enemy_country
							}
							OR = {
								has_play_goal = conquer_state
							}
						}
					}
				}
				add = {
					value = 50
					desc = "defending_against_great_game_rival"
				}
			}
			else = {
				add = {
					value = 25
					desc = "defending_against_great_game_rival"
				}
			}
		}

		if = { # Britain will step in in favour of an Afghan country that it's supporting
			limit = {
				OR = {
					c:GBR ?= this
				}
				has_variable = committed_to_afghanistan_assistance
				scope:country = {
					has_variable = AFG_appealed_to_GBR
				}
				scope:enemy_country = {
					OR = {
						country_has_primary_culture = cu:pashtun
						country_has_primary_culture = cu:tajik
					}
				}
			}
			add = {
				value = 50
				desc = "support_for_afghan_claimant"
			}
		}

		if = { # Subjects of an overlord that has committed to assisting a claimant will be more inclined to help.
			limit = {
				overlord ?= {
					has_variable = committed_to_afghanistan_assistance
				}
				OR = {
					AND = {
						exists = c:GBR
						is_subject_of = c:GBR
						scope:country = {
							has_variable = AFG_appealed_to_GBR
						}
					}
					AND = {
						exists = c:RUS
						is_subject_of = c:RUS
						scope:country = {
							has_variable = AFG_appealed_to_RUS
						}
					}
				}
				scope:enemy_country = {
					OR = {
						country_has_primary_culture = cu:pashtun
						country_has_primary_culture = cu:tajik
					}
				}
			}
			add = {
				value = 50
				desc = "overlord_support_for_afghan_claimant"
			}
		}

		if = { # Britain will step in in favour of an Afghan country that it's supporting
			limit = {
				c:RUS ?= this
				has_variable = committed_to_afghanistan_assistance
				scope:country = {
					has_variable = AFG_appealed_to_RUS
				}
				scope:enemy_country = {
					OR = {
						country_has_primary_culture = cu:pashtun
						country_has_primary_culture = cu:tajik
					}
				}
			}
			add = {
				value = 50
				desc = "support_for_afghan_claimant"
			}
		}

		if = { # Donghak Rebellion - Japanese Behaviours - Pro-Government
			limit = {
				c:JAP ?= this
				is_involved_in_journal_entry = je_korean_rebellion
				has_variable = sided_with_korean_gov
				scope:country = {
					country_has_primary_culture = cu:korean
					is_revolutionary = no
				}
			}
			add = {
				value = 100
				desc = "committed_to_upholding_korean_government"
			}
		}

		if = { # Donghak Rebellion - Japanese Behaviours - Anti-Government
			limit = {
				c:JAP ?= this
				is_involved_in_journal_entry = je_korean_rebellion
				has_variable = sided_with_korean_rebels
				scope:country = {
					country_has_primary_culture = cu:korean
					is_revolutionary = yes
				}
			}
			add = {
				value = 100
				desc = "committed_to_overthrowing_korean_government"
			}
		}

		if = { # Modernised Japan and Russia will defend Korea from one another
			limit = {
				c:RUS ?= this
				scope:country = {
					country_has_primary_culture = cu:korean
				}
				scope:enemy_country = {
					country_has_primary_culture = cu:japanese
				}
			}
			add = {
				value = 50
				desc = "defending_korea"
			}
		}

		if = { # Modernised Japan and Russia will defend Korea from one another
			limit = {
				c:JAP ?= this
				NOT = {
					has_law_or_variant = law_type:law_isolationism
					has_law_or_variant = law_type:law_closed_borders
				}
				scope:country = {
					country_has_primary_culture = cu:korean
				}
				scope:enemy_country = {
					country_has_primary_culture = cu:russian
				}
			}
			add = {
				value = 50
				desc = "defending_korea"
			}
		}

		if = { # Qing and other Central Asian Khanates will be more willing help a player Kenesary Khan
			limit = {
				scope:country = {
					c:KAZ ?= this
					is_player = yes
				}
				has_strategic_adjacency = scope:country
				OR = {
					c:CHI ?= this
					capital.region = sr:region_central_asia
				}
				scope:enemy_country = {
					country_has_primary_culture = cu:russian
				}
			}
			add = {
				value = 50
				desc = "supporting_kenesary"
			}
		}

		if = { # Recognition of Kenesary
			limit = {
				scope:country = {
					c:KAZ ?= this
				}
				has_strategic_adjacency = scope:country
				has_variable = kenesary_recognizer_var
				scope:enemy_country = {
					country_has_primary_culture = cu:russian
				}
			}
			add = {
				value = 100
				desc = "recognised_kenesary"
			}
		}

		### Chinese unification warlord coalitions
		if = {
			limit = {
				has_journal_entry = je_reunify_china
				scope:country = {
					has_journal_entry = je_reunify_china
				}
				scope:enemy_country = {
					has_journal_entry = je_reunify_china
					this.country_rank >= scope:country.country_rank
			 	}
			}
			add = {
				value = 25
				desc = "alignment_politics"
			}
		}

		### Russia shouldn't join secession plays, since then it couldn't add wargoals of its own
		if = {
			limit = {
				scope:is_initiator = yes
				scope:diplomatic_play_type = play_type:dp_secession
				root = {
					c:RUS ?= this
					has_journal_entry = je_eastern_question_russia
				}
				OR = {
					scope:country = {
						country_has_primary_culture = cu:bulgarian
					}
					scope:enemy_country = {
						country_has_primary_culture = cu:bulgarian
					}
				}
				OR = {
					scope:enemy_country = {
						has_journal_entry = je_great_eastern_crisis
					}
					scope:country = {
						has_journal_entry = je_great_eastern_crisis
					}
				}
			}
			add = {
				value = -200
				desc = "focus_on_bulgaria"
			}
		}

 		### Austria doesn't want anything except for Bosnia
		if = {
			limit = {
				scope:is_initiator = yes
				scope:diplomatic_play_type = play_type:dp_secession
				root = {
					c:AUS ?= this
					has_journal_entry = je_eastern_question_austria
				}
				OR = {
					scope:enemy_country = {
						has_journal_entry = je_great_eastern_crisis
					}
					scope:country = {
						has_journal_entry = je_great_eastern_crisis
					}
				}
			}
			add = {
				value = -200
				desc = "focus_on_bosnia"
			}
		}

		### The Balkan League countries supporting each other against the Ottomans
		if = {
			limit = {
				has_journal_entry = je_the_balkan_league
				scope:country = {
					has_journal_entry = je_the_balkan_league
				}
				scope:enemy_country = {
					c:TUR ?= this
				}
			}
			add = {
				value = 1000
				desc = "support_for_balkan_league"
			}
		}

 		### War of the Confederation
		if = {
			limit = {
				scope:is_initiator = yes
				root = {
					has_variable = attack_bolivia
				}
				scope:country = {
					is_involved_in_journal_entry = je_peru_bolivia
					NOR = {
						play_participant_has_war_goal_of_type_against = {
							type = conquer_state
							target = scope:enemy_country
						}
						play_participant_has_war_goal_of_type_against = {
							type = make_protectorate
							target = scope:enemy_country
						}
						play_participant_has_war_goal_of_type_against = {
							type = take_treaty_port
							target = scope:enemy_country
						}
						play_participant_has_war_goal_of_type_against = {
							type = enforce_treaty_article
							target = scope:enemy_country
						}
					}
				}
				scope:enemy_country = {
					is_involved_in_journal_entry = je_peru_bolivia
					has_variable = pbc_member
				}
			}
			add = {
				value = 100
				desc = "je_war_of_the_confederation"
			}
		}

		### The Anglo Fun Police
		if = {
			limit = {
				scope:is_initiator = no
				root = {
					country_rank = rank_value:great_power
					OR = {
						c:GBR ?= this
						is_in_geographic_region = geographic_region_americas
					}
				}
				scope:enemy_country = {
					has_journal_entry = je_reconquista
				}
				scope:country = {
					is_historical_spanish_american_colony = yes
				}
			}
			add = {
				value = 50
				desc = "je_reconquista"
			}
		}
	}

	# How much construction output should the AI aim for
	# Using this value in other strategies will function additively
	wanted_construction_output = {
		value = 0

		add = {
			value = investment_pool_income
			subtract = 5000 # So small nations don't overshoot early on
			divide = 500 # 1 construction output per this much into the investment pool
			min = 0
		}

		add = {
			value = net_fixed_income
			divide = 500 # 1 construction output per this much income

			min = {
				value = fixed_income
				divide = 5000 # 1 construction output per this much income
			}

			# Multiply final value by diplomatic pact expenses ratio - countries paying a lot to pacts have lower spending ambitions
			# KAI: But exclude the investment pool
			multiply = {
				value = 1
				subtract = diplomatic_pact_expense_ratio
			}		

			min = 0
			max = 600
		}

		# Improved technology enables cheaper construction
		# Cost per wood construction 2000/2 = 1000
		# Cost per iron construction 3600/5 = 720
		# Cost per steel construction 5400/10 = 540
		if = {
			limit = { NOT = { has_technology_researched = urban_planning } }
			multiply = 0.72
		}

		if = {
			limit = { NOT = { has_technology_researched = steel_frame_buildings } }
			multiply = 0.75
		}

		# Accounts for the 2-10 free construction from base modifiers
		if = {
			limit = {
				OR = {
					has_game_rule = free_construction_unscaled
					AND = { # for when AI is enabled for player country via console
						is_ai = no
						has_game_rule = free_construction_scaled_player_exemption
					}
				}
			}
			add = 10
		}
		else = {
			add = {
				value = 2
				add = {
					value = gdp
					divide = 2000000
					multiply = 8
				}
				max = 10
			}
		}

		min = 2
	}

	# Add a multiplier to the score AI assigns to particular building groups (default 1)
	# Using this value in other strategies will result in several multiplications
	building_group_weights = {}

	# Which buildings should the AI subsidize
	# Using a different value in a strategy will override this value
	subsidies = {
		building_power_plant = wants_to_have
		building_railway = wants_to_have
		building_port = wants_to_have
	}

	# How should the AI plan for production and trade of specific goods
	# Using a different value in a strategy will override this value
	goods_stances = {
		small_arms = {
			stance = wants_high_supply
			trigger = {
				has_technology_researched = line_infantry
			}
		}
		artillery = {
			stance = wants_high_supply
			trigger = {
				has_technology_researched = artillery
			}
		}
		ammunition = {
			stance = wants_high_supply
			trigger = {
				has_technology_researched = general_staff
			}
		}
		aeroplanes = {
			stance = wants_high_supply
			trigger = {
				has_technology_researched = military_aviation
				country_rank >= rank_value:major_power
			}
		}
		tanks = {
			stance = wants_high_supply
			trigger = {
				has_technology_researched = mobile_armor
				country_rank >= rank_value:major_power
			}
		}
		clippers = {
			stance = wants_high_supply
			trigger = {
				has_technology_researched = navigation
				NOT = {
					has_technology_researched = gantry_cranes
				}
				has_port_country = yes
			}
		}
		steamers = {
			stance = wants_high_supply
			trigger = {
				has_technology_researched = gantry_cranes
				has_port_country = yes
			}
		}
		radios = {
			stance = wants_high_supply
			trigger = {
				OR = {
					has_technology_researched = defense_in_depth
					has_technology_researched = sea_lane_strategies
				}
			}
		}
		paper = {
			stance = wants_high_supply
			trigger = {
				has_technology_researched = centralization
			}
		}
		telephones = {
			stance = wants_high_supply
			trigger = {
				has_technology_researched = central_planning
			}
		}
		electricity = {
			stance = wants_high_supply
			trigger = {
				has_technology_researched = electrical_generation
			}
		}
		coal = {
			stance = wants_high_supply
			trigger = {
				has_technology_researched = atmospheric_engine
			}
		}
		engines = {
			stance = wants_high_supply
			trigger = {
				has_technology_researched = railways
			}
		}
		oil = {
			stance = wants_high_supply
			trigger = {
				has_technology_researched = combustion_engine
			}
		}
		hardwood = {
			stance = wants_high_supply
			trigger = {
				has_technology_researched = urbanization
			}
		}
		# Construction goods
		wood = {
			stance = wants_high_supply
			trigger = {
				has_technology_researched = urbanization
			}
		}
		iron = {
			stance = wants_high_supply
			trigger = {
				has_technology_researched = urban_planning
				NOT = { has_technology_researched = steel_frame_buildings }
			}
		}
		tools = {
			stance = wants_high_supply
			trigger = {
				has_technology_researched = urban_planning
			}
		}
		steel = {
			stance = wants_high_supply
			trigger = {
				has_technology_researched = steel_frame_buildings
			}
		}
		glass = {
			stance = wants_high_supply
			trigger = {
				has_technology_researched = steel_frame_buildings
			}
		}
		explosives = {
			stance = wants_high_supply
			trigger = {
				has_technology_researched = steel_frame_buildings
			}
		}
	}

	# How much should the AI value a wargoal against another country/state
	# Using this value in other strategies will function additively
	# scope:target_country = wargoal target country
	# scope:target_state = wargoal target state (if any)
	wargoal_scores = {
		conquer_state = {
			if = {
				limit = {
					OR = {
						has_secret_goal = {
							who = scope:target_state.owner
							secret_goal = conquer
						}
						has_attitude = {
							who = scope:target_country
							attitude = antagonistic
						}
					}
				}

				add = scope:target_state.ai_state_value:root
			}

			if = {
				limit = {
					has_variable = attack_bolivia
					scope:target_country = {
						is_involved_in_journal_entry = je_peru_bolivia
						has_variable = pbc_member
					}
				}
				multiply = 0
			}

			min = 0
			max = 100

			# Placement here is intentional
			if = {
				limit = {
					any_country_strategic_region = {
						scope:target_state.region = this
						root = {
							OR = {
								has_region_stance = {
									region = prev
									stance = stance_conquer_region
								}
								AND = {
									scope:target_country = { is_country_type = unrecognized }
									has_region_stance = {
										region = prev
										stance = stance_colonize_region
									}
								}
							}
						}
					}
				}
				multiply = 2.5
			}
			else = {
				multiply = 0.75
			}
		}

		return_state = {
			add = scope:target_state.ai_state_value:root

			if = {
				limit = {
					has_variable = attack_bolivia
					scope:target_country = {
						is_involved_in_journal_entry = je_peru_bolivia
						has_variable = pbc_member
					}
				}
				add = 200
			}
			if = {
				limit = {
					scope:target_country = {
						has_attitude = {
							who = ROOT
							attitude = loyal
						}
					}
				}

				multiply = 0.25
			}
			if = {
				limit = {
					is_diplomatic_play_enemy_of = scope:target_country
				}

				multiply = 5
				min = 0
				max = 1000
			}
			else = {
				min = 0
				max = 200
			}

			# Placement here is intentional
			if = {
				limit = {
					any_country_strategic_region = {
						scope:target_state.region = this
						root = {
							OR = {
								has_region_stance = {
									region = prev
									stance = stance_conquer_region
								}
								AND = {
									scope:target_country = { is_country_type = unrecognized }
									has_region_stance = {
										region = prev
										stance = stance_colonize_region
									}
								}
							}
						}
					}
				}
				multiply = 2.5
			}
			else = {
				multiply = 0.75
			}
		}

		transfer_subject = {
			if = {
				limit = {
					has_secret_goal = {
						who = scope:target_country
						secret_goal = dominate
					}
				}

				add = scope:target_country.ai_subject_value:root
			}

			if = {
				limit = {
					wants_to_solve_schleswig_holstein = yes
					exists = c:HOL
					scope:target_country = { c:HOL ?= THIS }
					can_reach_target_country = yes
				}
				add = 100
			}

			if = { # Japan will want to take Korea
				limit = {
					c:JAP ?= this
					OR = {
						is_country_type = recognized
						has_variable = japan_restoration_complete
					}
					exists = c:KOR
					scope:target_country = {
						c:KOR ?= THIS
						is_country_type = unrecognized
					}
					can_reach_target_country = yes
				}
				add = 25
			}

			if = {
				limit = {
					has_journal_entry = je_opium_wars
					scope:target_country = {
						has_variable = opium_wars_target
					}
				}
				multiply = 0
			}

			min = 0
			max = 100
		}

		make_protectorate = {

			if = { #TUR should want to invade MON
				limit = {
					has_journal_entry = je_tur_raided
					scope:target_country = {
						has_journal_entry = je_montenegrin_raiding
					}
				}
				add = {
					add = 20
					multiply = raiding_level
				}
			}

			if = {
				limit = {
					has_journal_entry = je_maintain_afghan_protectorate
					scope:target_country = {
						capital = {
							region = sr:region_greater_persia
						}
						OR = {
							country_has_primary_culture = cu:pashtun
							country_has_primary_culture = cu:tajik
						}
					}
				}
				add = 50
			}

			if = {
				limit = {
					has_journal_entry = je_consolidate_colonial_rule
					scope:target_country = {
						is_country_type = unrecognized
						target_is_our_or_fellow_subject = no
						any_scope_state = {
							OR = {
								is_in_geographic_region = geographic_region_india
								is_in_geographic_region = geographic_region_burma
							}
						}
					}
				}
				add = 25
			}

			if = { # Japan will want to take Korea
				limit = {
					c:JAP ?= this
					OR = {
						is_country_type = recognized
						has_variable = japan_restoration_complete
					}
					exists = c:KOR
					scope:target_country = {
						c:KOR ?= THIS
						is_country_type = unrecognized
					}
					can_reach_target_country = yes
				}
				add = 25
			}

			if = {
				limit = {
					c:DEI ?= this
					scope:target_country = {
						capital.region = sr:region_indonesia
						is_country_type = unrecognized
					}
				}
				add = 25
			}

			if = {
				limit = {
					has_secret_goal = {
						who = scope:target_country
						secret_goal = dominate
					}
				}

				add = scope:target_country.ai_subject_value:root
			}

			min = 0
			max = 100
		}

		make_tributary = {
			if = {
				limit = {
					has_secret_goal = {
						who = scope:target_country
						secret_goal = dominate
					}
				}

				add = scope:target_country.ai_subject_value:root
			}

			min = 0
			max = 100
		}

		increase_autonomy = {
			value = 100
		}

		reduce_autonomy = {
			value = 100

			if = {
				limit = {
					c:BIC ?= this
					has_journal_entry = je_uneasy_raj
				}
				multiply = 0.05
			}

			if = {
				limit = {
					c:JAP ?= this
					NOT = { has_law_or_variant = law_type:law_serfdom }
					scope:target_country ?= {
						is_in_geographic_region = geographic_region_japan
					}
				}
				add = 100
			}

			if = {
				limit = {
					country_has_primary_culture = cu:russian
					has_law_or_variant = law_type:law_national_supremacy
					has_technology_researched = nationalism
					scope:target_country = {
						OR = {
							c:OZH ?= this
							c:UZH ?= this
							c:KZH ?= this
							c:KAZ ?= this
						}
					}
				}
				add = 100
			}
		}

		humiliation = {
			value = 0

			if = {
				limit = {
					has_diplomatic_pact = {
						who = scope:target_country
						type = rivalry
					}
				}

				add = 5
			}
		}

		join_power_bloc = {
			if = {
				limit = {
					is_power_bloc_leader = yes
					has_attitude = {
						who = scope:target_country
						attitude = domineering
					}
				}

				add = {
					value = scope:target_country.ai_subject_value:root
					divide = 2
				}
			}

			min = 0
			max = 50
		}

		regime_change = {
			value = 0

			if = {
				limit = {
					country_rank >= rank_value:major_power
					OR = {
						# KAI: Enforcing regime change on a subject is pointless in my opinion.
						# has_diplomatic_pact = {
						# 	who = scope:target_country.top_overlord
						# 	type = rivalry
						# }
						AND = {
							is_power_bloc_leader = yes
							is_in_same_power_bloc = scope:target_country
							power_bloc ?= {
								has_identity = identity:identity_ideological_union
							}
						}
					}
					"ai_ideological_opinion(scope:target_country)" <= -50
				}
				add = 10
			}

			# France will want to regime change Spain if they enthrone a Hohenzollern
			if = {
				limit = {
					c:FRA ?= this
					scope:target_country = {
						c:SPA ?= this
						ruler = {
							has_variable = house_hohenzollern
						}
					}
				}
				add = 50
			}

			if = {
				limit = {
					AND = {
						has_radical_leftist_government = no
						scope:target_country = {
							has_radical_leftist_government = yes
						}
					}

				}
				add = 100
			}

			if = {
				limit = {
					AND = {
						has_radical_leftist_economy = no
						scope:target_country = {
							has_radical_leftist_economy = yes
						}
					}

				}
				add = 100
			}
		}

		force_nationalization = {
			value = 0

			# Score by how much it would cost to nationalize all their assets
			add = {
				value = "nationalization_cost(scope:target_country)"
				divide = {
					value = 1000000
				}
				max = 50 # Max score at 50 million nationalization cost
			}

			# Score by fraction of GDP that is owned by the target country
			add = {
				value = "gdp_ownership_ratio(scope:target_country)"
				divide = {
					value = root.gdp
					min = 100000 # Set a floor for GDP to avoid dividing by zero or other very small numbers
				}
				multiply = 10 # Max score at 10%+ of GDP
				max = 50
			}

			if = {
				limit = {
					NOT = {
						has_attitude = {
							who = scope:target_country
							attitude = antagonistic
						}
					}
				}

				multiply = 0.5
			}
		}

		open_market = {
			value = 0

			if = {
				limit = {
					scope:target_country = {
						has_diplomatic_pact = {
							who = root
							type = embargo
						}
					}
					can_reach_target_country = yes
				}
				add = 50
			}

			if = {
				limit = {
					has_journal_entry = je_opium_wars
					scope:target_country = {
						has_variable = opium_wars_target
					}
				}
				add = 75
			}

			if = {
				limit = {
					AND = {
						has_radical_leftist_government = no
						scope:target_country = {
							has_radical_leftist_government = yes
						}
					}

				}
				add = 50
			}

			if = {
				limit = {
					AND = {
						has_radical_leftist_economy = no
						scope:target_country = {
							has_radical_leftist_economy = yes
						}
					}

				}
				add = 50
			}

			# Not worth doing against very small markets
			if = {
				limit = {
					scope:target_country = {
						gdp < 2000000
					}
				}
				multiply = 0
			}

			# Don't want to open our own market...
			if = {
				limit = {
					market_capital.market = scope:target_country.market_capital.market
				}
				multiply = 0
			}
		}

		revoke_claim = {
			if = {
				limit = {
					scope:target_state = { owner = root }
				}

				add = 10

				add = {
					value = scope:target_state.state_population
					divide = 200000
					max = 10
				}

				add = {
					value = scope:target_state.gdp
					divide = 200000
					max = 10
				}

				if = {
					limit = {
						scope:target_state = { is_homeland_of_country_cultures = root }
					}
					multiply = 1.25
				}

				if = {
					limit = {
						scope:target_state = { is_incorporated = no }
					}
					multiply = 0.5
				}
			}

			min = 0
			max = 50
		}

		contain_threat = {
			value = 1000
		}

		annex_country = {
			value = 0

			if = {
				limit = {
					OR = {
						has_secret_goal = {
							who = scope:target_country
							secret_goal = conquer
						}
						has_attitude = {
							who = scope:target_country
							attitude = antagonistic
						}
					}
				}
				if = {
					limit = {
						root.gdp > 0
					}
					add = {
						value = scope:target_country.gdp
						divide = root.gdp
						multiply = 10
						max = 100
					}
				}
				if = {
					limit = {
						scope:target_country = {
							num_states > 1
						}
					}
					add = {
						value = scope:target_country.num_states
						multiply = 10
					}
				}
			}

			if = {
				limit = {
					has_journal_entry = je_reunify_china
					scope:target_country = {
						has_journal_entry = je_reunify_china
						has_strategic_adjacency = scope:target_country
					}
				}
				add = 100
			}

			if = {
				limit = {
					has_journal_entry = je_unify_afghanistan
					scope:target_country = {
						OR = {
							country_has_primary_culture = cu:pashtun
							country_has_primary_culture = cu:tajik
						}
					}
				}
				add = 100
			}

			if = {
				limit = {
					has_journal_entry = je_eastern_frontier
					capital = {
						has_claim_by = ROOT
					}
				}
				add = 50
			}

			if = { # Japan wants to consolidate herself
				limit = {
					c:JAP ?= this
					NOT = { has_law_or_variant = law_type:law_serfdom }
					scope:target_country ?= {
						is_in_geographic_region = geographic_region_japan
					}
				}
				add = 50
			}

			if = {
				limit = {
					has_strategic_adjacency = scope:target_country
				}
				multiply = 1.5
			}

			if = {
				limit = {
					c:BIC ?= this
					has_journal_entry = je_uneasy_raj
					scope:target_country = {
						is_princely_state = yes
					}
				}
				multiply = 0.25
			}

			if = {
				limit = {
					lenient_ai_behavior_trigger = yes
				}
				multiply = 0.0
			}

			if = {
				limit = {
					OR = {
						has_journal_entry = je_eastern_frontier
						has_journal_entry = je_unify_afghanistan
						has_journal_entry = je_reunify_china
					}
				}
				min = 0
				max = 500
			}
			else = {
				min = 0
				max = 200
			}

			# Placement here is intentional
			if = {
				limit = {
					any_country_strategic_region = {
						scope:target_country = {
							is_local_country = prev
							is_country_type = unrecognized

						}
						root = {
							has_region_stance = {
								region = prev
								stance = stance_colonize_region
							}
						}
					}
				}
				multiply = 2.5
			}
			else_if = {
				limit = {
					any_country_strategic_region = {
						scope:target_country = {
							is_local_country = prev
						}
						root = {
							has_region_stance = {
								region = prev
								stance = stance_conquer_region
							}
						}
					}
				}
				multiply = 1.5
			}
			else = {
				multiply = 0.75
			}
		}

		colonization_rights = {
			value = 100
		}

		unification = {
			value = 100

			add = {
				value = scope:target_country.gdp
				divide = 100000
				max = 100
			}

			if = {
				limit = {
					has_strategic_adjacency = scope:target_country
				}
				multiply = 1.5
			}

			if = {
				limit = {
					lenient_ai_behavior_trigger = yes
				}
				multiply = 0.0
			}

			min = 0
			max = 200
		}

		liberate_subject = {
			value = 0

			if = {
				limit = {
					scope:target_country.top_overlord.infamy >= infamy_threshold:notorious
				}
				add = 25

				if = {
					limit = {
						has_diplomatic_pact = {
							who = scope:target_country.top_overlord
							type = rivalry
						}
					}
					add = 25
				}

				if = {
					limit = {
						scope:target_country.top_overlord.infamy >= infamy_threshold:pariah
					}
					add = 25
				}
			}

			# Relations with subject
			multiply = {
				value = "scope:target_country.relations:root"
				multiply = 0.01
				add = 1
				min = 0.25
				max = 2.0
			}

			# Ideological opinion of subject
			multiply = {
				value = "ai_ideological_opinion(scope:target_country)"
				multiply = 0.05
				add = 1
				min = 0.5
				max = 2.0
			}

			min = 0
			max = 100

			if = {
				limit = {
					wants_to_solve_schleswig_holstein = yes
					exists = c:HOL
					scope:target_country = { c:HOL ?= THIS }
					can_reach_target_country = yes
				}
				add = 150
			}

			if = {
				limit = {
					scope:target_country = {
						is_involved_in_journal_entry = je_peru_bolivia
						has_variable = pbc_member
					}
					OR = {
						country_has_primary_culture = cu:south_andean
						country_has_primary_culture = cu:north_andean
						country_has_primary_culture = cu:platinean
						country_has_primary_culture = cu:argentine
						country_has_primary_culture = cu:chilean
						country_has_primary_culture = cu:colombian
						country_has_primary_culture = cu:ecuadorian
					}
				}
				add = 1000
			}
		}

		liberate_country = {
			value = 0

			# If there is a custom value scripted for the tag to be liberated in liberate_country_scores, that value is automatically added to the score here

			if = {
				limit = {
					scope:target_country.infamy >= infamy_threshold:notorious
				}
				add = 25

				if = {
					limit = {
						has_diplomatic_pact = {
							who = scope:target_country
							type = rivalry
						}
					}
					add = 25
				}

				if = {
					limit = {
						scope:target_country.infamy >= infamy_threshold:pariah
					}
					add = 25
				}
			}

			# Relations with target
			multiply = {
				value = "scope:target_country.relations:root"
				multiply = -0.01
				add = 1
				min = 0.5
				max = 2.0
			}

			# Ideological opinion of target
			multiply = {
				value = "ai_ideological_opinion(scope:target_country)"
				multiply = -0.05
				add = 1
				min = 0.5
				max = 2.0
			}

			min = 0
			max = 100
		}

		leave_power_bloc = {
			value = 50

			if = {
				limit = {
					would_accept_diplomatic_action = {
						actor = scope:target_country
						type = invite_to_power_bloc
					}
				}
				multiply = 0.0
			}
		}

		independence = {
			value = 100

			if = {
				limit = { # The EIC/Raj should never seek independence as it will lead to its demise via bic_breakup.1.
					exists = c:BIC
					c:BIC ?= THIS
				}
				multiply = 0.0
			}

			if = {
				limit = { # Likewise for the Dutch East Indies.
					exists = c:DEI
					c:DEI ?= THIS
				}
				multiply = 0.0
			}

			if = {
				limit = {
					is_involved_in_journal_entry = je_peru_bolivia
					scope:target_country = {
						is_involved_in_journal_entry = je_peru_bolivia
					}
					OR = {
						country_has_primary_culture = cu:south_andean
						country_has_primary_culture = cu:north_andean
						country_has_primary_culture = cu:platinean
						country_has_primary_culture = cu:argentine
						country_has_primary_culture = cu:chilean
						country_has_primary_culture = cu:colombian
						country_has_primary_culture = cu:ecuadorian
					}
				}
				add = 300
			}

			if = { # Hungary should be willing to do this.
				limit = {
					has_journal_entry = je_hungarian_revolution
					scope:target_country = {
						has_journal_entry = je_matter_of_hungary
					}
				}
				add = 100
			}
		}


		secession = {
			value = 100
		}
	}
}
