Ragnarok_base_area_priorities = {
	enable = {
		has_war_with = GER
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = area_priority
		id = europe
		value = 500
	}

	ai_strategy = {
		type = area_priority
		id = scandinavia
		value = 70
	}

	ai_strategy = {
		type = area_priority
		id = north_america
		value = 0
	}

	ai_strategy = {
		type = area_priority
		id = south_america
		value = 0
	}

	ai_strategy = {
		type = area_priority
		id = asia
		value = 10
	}

	ai_strategy = {
		type = area_priority
		id = middle_east
		value = 20
	}

	ai_strategy = {
		type = area_priority
		id = africa
		value = 20
	}

	ai_strategy = {
		type = area_priority
		id = suez
		value = 30
	}

	ai_strategy = {
		type = area_priority
		id = pacific
		value = 0
	}

	ai_strategy = {
		type = area_priority
		id = oceania
		value = 0
	}
}

Ragnarok_post_europea_area_priorities = {
	enable = {
		has_war_with = GER
		SOV = { NOT = { has_full_control_of_state = 219 } } # Moscow
		ENG = { NOT = { has_full_control_of_state = 126 } } # Greater London Area
		POR = { has_capitulated = yes }
		TUR = { has_capitulated = yes }
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = area_priority
		id = north_america
		value = 50
	}

	ai_strategy = {
		type = area_priority
		id = south_america
		value = 30
	}

	ai_strategy = {
		type = area_priority
		id = asia
		value = 200
	}

	ai_strategy = {
		type = area_priority
		id = middle_east
		value = 200
	}

	ai_strategy = {
		type = area_priority
		id = africa
		value = 150
	}

	ai_strategy = {
		type = area_priority
		id = suez
		value = 200
	}

	ai_strategy = {
		type = area_priority
		id = pacific
		value = 30
	}

	ai_strategy = {
		type = area_priority
		id = oceania
		value = 30
	}
}

Ragnarok_head_to_europe = {
	enable = {
		has_war_with = GER
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = front_unit_request
		tag = GER
		value = 1000
	}
	ai_strategy = {
        type = force_build_armies
        value = 300
    }
}

Ragnarok_western_europe_allies = {
	enable = {
		has_war_with = GER
		is_western_ally = yes
	}
	abort = {
		FRA = { has_capitulated = yes }
		OR = {
			ITA = { has_capitulated = yes }
			ITA = { surrender_progress > 0.8 }
		}
	}

	ai_strategy = {
		type = dont_defend_ally_borders
		id = POL
		value = 400
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = CZE
		value = 400
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = HUN
		value = 400
	}
	
	ai_strategy = {
		type = dont_defend_ally_borders
		id = ROM
		value = 400
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = YUG
		value = 400
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = BUL
		value = 400
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = ALB
		value = 400
	}
	
	# Turkey and Greece assist western Allies though
	ai_strategy = {
		type = dont_defend_ally_borders
		id = GRE
		value = 400
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = TUR
		value = 400
	}
	
	ai_strategy = {
		type = dont_defend_ally_borders
		id = SOV
		value = 400
	}
	
	ai_strategy = {
		type = dont_defend_ally_borders
		id = EST
		value = 400
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = LAT
		value = 400
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = LIT
		value = 400
	}
	
	ai_strategy = {
		type = dont_defend_ally_borders
		id = DEN
		value = 400
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = NOR
		value = 400
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = SWE
		value = 400
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = FIN
		value = 400
	}
}

Ragnarok_eastern_europe_allies = {
	enable = {
		has_war_with = GER
		is_eastern_ally = yes
	}
	abort = {
		SOV = { has_capitulated = yes }
	}

	ai_strategy = {
		type = dont_defend_ally_borders
		id = FRA
		value = 400
	}
	#ai_strategy = {
	#	type = dont_defend_ally_borders
	#	id = ITA
	#	value = 400
	#}
	
	ai_strategy = {
		type = dont_defend_ally_borders
		id = HOL
		value = 400
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = BEL
		value = 400
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = LUX
		value = 400
	}
	
	ai_strategy = {
		type = dont_defend_ally_borders
		id = SWI
		value = 400
	}
	
	ai_strategy = {
		type = dont_defend_ally_borders
		id = SPA
		value = 400
	}	
	ai_strategy = {
		type = dont_defend_ally_borders
		id = POR
		value = 400
	}
	
	ai_strategy = {
		type = dont_defend_ally_borders
		id = ENG
		value = 400
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = IRE
		value = 400
	}
}

Ragnarok_SOV_CHI_ignores_italy = {
	allowed = {
		OR = {
			original_tag = SOV
			original_tag = CHI
		}
	}
	enable = {
		has_war_with = GER
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = dont_defend_ally_borders
		id = ITA
		value = 100
	}
}

Ragnarok_CHI_ignores_sweden = {
	allowed = {
		original_tag = CHI
	}
	enable = {
		has_war_with = GER
	}
	abort = {
		SWE = { surrender_progress > 0.1 }
	}

	ai_strategy = {
		type = dont_defend_ally_borders
		id = SWE
		value = 100
	}
}

Ragnarok_JAP_ignores_poland = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		has_war_with = GER
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = dont_defend_ally_borders
		id = POL
		value = 100
	}
}

# England/France ignores Italy early on
Ragnarok_ENG_FRA_ignores_italy = {
	allowed = {
		OR = {
			original_tag = ENG
			original_tag = FRA
		}
	}
	enable = {
		has_war_with = GER
	}
	abort = {
		ITA = { surrender_progress > 0.05 }
	}

	ai_strategy = {
		type = dont_defend_ally_borders
		id = ITA
		value = 100
	}
}

# Italy ignores France early on
Ragnarok_ITA_ignores_france = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		has_war_with = GER
	}
	abort = {
		FRA = { surrender_progress > 0.3 }
	}

	ai_strategy = {
		type = dont_defend_ally_borders
		id = FRA
		value = 100
	}
}

# Italy ignores Switzerland early on
Ragnarok_ITA_ignores_france = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		has_war_with = GER
	}
	abort = {
		SWI = { surrender_progress > 0.3 }
	}

	ai_strategy = {
		type = dont_defend_ally_borders
		id = SWI
		value = 100
	}
}

Ragnarok_ITA_ignores_benelux_and_iberia = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		has_war_with = GER
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = dont_defend_ally_borders
		id = HOL
		value = 100
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = BEL
		value = 100
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = LUX
		value = 100
	}
	
	ai_strategy = {
		type = dont_defend_ally_borders
		id = SPA
		value = 100
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = POR
		value = 100
	}
}

# Allow Italy to defend Yugoslavia
Ragnarok_ITA_defends_yugoslavia = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		has_war_with = GER
		date > 1937.2.10 # Wait a month otherwise AI can end up leaving Italian border with Germany undefended
	}
	abort_when_not_enabled = yes
	
	ai_strategy = {
		type = dont_defend_ally_borders
		id = YUG
		value = -400
	}
}

# Minors prioritize their own borders rather than dispersing their already small armies across a wide front
Ragnarok_minors_defend_themselves = {
	enable = {
		has_war_with = GER
		is_neighbor_of = GER
		is_major_country = no
		is_european_country = yes
		
		# Sweden usually only borders Germany via Copenhagen, so ignore that until Germany makes headway into Sweden
		OR = {
			NOT = { tag = SWE }
			SWE = { surrender_progress > 0.01 }
		}
	}
	abort = {
		OR = {
			NOT = { is_neighbor_of = GER }
			has_capitulated = yes
		}
	}

	ai_strategy = {
		type = dont_defend_ally_borders
		id = POL
		value = 100
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = CZE
		value = 100
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = HUN
		value = 100
	}
	
	ai_strategy = {
		type = dont_defend_ally_borders
		id = ROM
		value = 100
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = YUG
		value = 100
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = BUL
		value = 100
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = ALB
		value = 100
	}
	
	ai_strategy = {
		type = dont_defend_ally_borders
		id = GRE
		value = 100
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = TUR
		value = 100
	}
	
	ai_strategy = {
		type = dont_defend_ally_borders
		id = SOV
		value = 100
	}
	
	ai_strategy = {
		type = dont_defend_ally_borders
		id = EST
		value = 100
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = LAT
		value = 100
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = LIT
		value = 100
	}
	
	ai_strategy = {
		type = dont_defend_ally_borders
		id = DEN
		value = 100
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = NOR
		value = 100
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = SWE
		value = 100
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = FIN
		value = 100
	}

	ai_strategy = {
		type = dont_defend_ally_borders
		id = FRA
		value = 100
	}
	
	ai_strategy = {
		type = dont_defend_ally_borders
		id = HOL
		value = 100
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = BEL
		value = 100
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = LUX
		value = 100
	}
	
	ai_strategy = {
		type = dont_defend_ally_borders
		id = SWI
		value = 100
	}
	
	ai_strategy = {
		type = dont_defend_ally_borders
		id = ITA
		value = 100
	}
	
	ai_strategy = {
		type = dont_defend_ally_borders
		id = SPA
		value = 100
	}	
	ai_strategy = {
		type = dont_defend_ally_borders
		id = POR
		value = 100
	}
	
	ai_strategy = {
		type = dont_defend_ally_borders
		id = ENG
		value = 100
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = IRE
		value = 100
	}
}

Ragnarok_army_size = {
	enable = {
		has_war_with = GER
	}
	abort_when_not_enabled = yes
	
	ai_strategy = {
        type = force_build_armies
        value = 20
    }	
	ai_strategy = {
		type = ai_wanted_divisions_factor
		value = 20
	}
}

Ragnarok_army_size_majors = {
	allowed = {
		is_major_country = yes
	}
	enable = {
		has_war_with = GER
	}
	abort_when_not_enabled = yes
	
	ai_strategy = {
        type = force_build_armies
        value = 100
    }	
	ai_strategy = {
		type = ai_wanted_divisions_factor
		value = 100
	}
}

#####################################################################################################
### INVASIONS
#####################################################################################################

Ragnarok_no_invasions = {
	enable = {
		has_war_with = GER
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = invade
		id = GER
		value = -500
	}
}

Ragnarok_invasions_after_fall_of_france = {
	allowed = {
		OR = {
			original_tag = ENG
			original_tag = USA
			original_tag = CAN
		}
	}
	enable = {
		has_country_flag = launch_naval_invasion
		has_war_with = GER
	}
	abort = {
		NOT = { has_country_flag = launch_naval_invasion }
	}

	ai_strategy = {
		type = invade
		id = GER
		value = 1500 # to offset Ragnarok_no_invasions
	}
	ai_strategy = {
		type = front_unit_request
		tag = GER
		value = -900
	}
	ai_strategy = {
		type = consider_weak
		id = GER
		value = 75
	}

	ai_strategy = {
		type = naval_invasion_focus
		value = 200
	}
	ai_strategy = {
		type = naval_invasion_dominance_weight
		value = 40
	}
	
	ai_strategy = {
		type = front_unit_request
		area = mainland_europe
		value = 50
	}
	ai_strategy = {
		type = front_unit_request
		area = normandy_landing_zone
		value = 50
	}
	ai_strategy = {
		type = front_unit_request
		area = italy
		value = 20
	}
	ai_strategy = {
		type = invasion_unit_request
		area = normandy_landing_zone
		value = 10
	}
	
	ai_strategy = {
		type = unit_ratio
		id = marines
		value = 5
	}
	ai_strategy = {
		type = template_prio
		id = marines
		value = 100
	}

	ai_strategy = {
		type = unit_ratio
		id = floating_harbor # not a ratio but an absolute desired number
		value = 6
	}

	ai_strategy = {
		type = dont_defend_ally_borders
		id = POL
		value = 400
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = CZE
		value = 400
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = HUN
		value = 400
	}
	
	ai_strategy = {
		type = dont_defend_ally_borders
		id = ROM
		value = 400
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = YUG
		value = 400
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = BUL
		value = 400
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = ALB
		value = 400
	}
	
	ai_strategy = {
		type = dont_defend_ally_borders
		id = GRE
		value = 400
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = TUR
		value = 400
	}
	
	ai_strategy = {
		type = dont_defend_ally_borders
		id = SOV
		value = 400
	}
	
	ai_strategy = {
		type = dont_defend_ally_borders
		id = EST
		value = 400
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = LAT
		value = 400
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = LIT
		value = 400
	}
	
	#ai_strategy = {
	#	type = dont_defend_ally_borders
	#	id = DEN
	#	value = 400
	#}
	#ai_strategy = {
	#	type = dont_defend_ally_borders
	#	id = NOR
	#	value = 400
	#}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = SWE
		value = 100
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = FIN
		value = 400
	}
}

Ragnarok_JAP_invasions_after_fall_of_balkans = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		has_country_flag = launch_naval_invasion
		has_war_with = GER
	}
	abort = {
		NOT = { has_country_flag = launch_naval_invasion }
	}

	ai_strategy = {
		type = invade
		id = GER
		value = 1500 # to offset Ragnarok_no_invasions
	}
	ai_strategy = {
		type = front_unit_request
		tag = GER
		value = -900
	}
	ai_strategy = {
		type = consider_weak
		id = GER
		value = 75
	}

	ai_strategy = {
		type = naval_invasion_focus
		value = 200
	}
	ai_strategy = {
		type = naval_invasion_dominance_weight
		value = 40
	}
	
	ai_strategy = {
		type = front_unit_request
		area = mainland_europe
		value = 50
	}
	ai_strategy = {
		type = front_unit_request
		area = italy
		value = 50
	}
	ai_strategy = {
		type = invasion_unit_request
		area = italy
		value = 10
	}
	
	ai_strategy = {
		type = unit_ratio
		id = marines
		value = 5
	}
	ai_strategy = {
		type = template_prio
		id = marines
		value = 100
	}

	ai_strategy = {
		type = unit_ratio
		id = floating_harbor # not a ratio but an absolute desired number
		value = 6
	}

	ai_strategy = {
		type = dont_defend_ally_borders
		id = POL
		value = 400
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = CZE
		value = 400
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = HUN
		value = 400
	}
	
	ai_strategy = {
		type = dont_defend_ally_borders
		id = ROM
		value = 400
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = YUG
		value = 400
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = BUL
		value = 400
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = ALB
		value = 400
	}
	
	ai_strategy = {
		type = dont_defend_ally_borders
		id = GRE
		value = 400
	}
	#ai_strategy = {
	#	type = dont_defend_ally_borders
	#	id = TUR
	#	value = 400
	#}
	
	ai_strategy = {
		type = dont_defend_ally_borders
		id = SOV
		value = 50
	}
	
	ai_strategy = {
		type = dont_defend_ally_borders
		id = EST
		value = 400
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = LAT
		value = 400
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = LIT
		value = 400
	}
	
	ai_strategy = {
		type = dont_defend_ally_borders
		id = DEN
		value = 400
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = NOR
		value = 400
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = SWE
		value = 400
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = FIN
		value = 400
	}
}

Ragnarok_scandinavian_invasions = {
	allowed = {
		OR = {
			original_tag = NOR
			original_tag = SWE
			original_tag = FIN
		}
	}
	enable = {
		has_country_flag = launch_naval_invasion
		has_war_with = GER
	}
	abort = {
		NOT = { has_country_flag = launch_naval_invasion }
	}

	ai_strategy = {
		type = invade
		id = GER
		value = 1000 # to offset Ragnarok_no_invasions
	}
	ai_strategy = {
		type = front_unit_request
		tag = GER
		value = -900
	}
	ai_strategy = {
		type = consider_weak
		id = GER
		value = 75
	}

	ai_strategy = {
		type = naval_invasion_focus
		value = 100
	}
	
	ai_strategy = {
		type = force_defend_ally_borders
		id = "POL"
		value = -150 # Reduce priority of defending Poland
	}
}