
FRA_prepare_against_germany_ahist = {
	enable = {
		OR = {
			original_tag = FRA
			is_in_faction_with = FRA
		}
		is_historical_focus_on = no
		OR = {	
			threat > 0.60
			has_war_with = GER
			GER = { has_wargoal_against = FRA }
			GER = { is_justifying_wargoal_against = FRA }
			any_country = {
				is_in_faction_with = FRA
				GER = { has_wargoal_against = PREV }
			}
			any_country = {
				is_in_faction_with = FRA
				GER = { is_justifying_wargoal_against = PREV }
			}
		}
		OR = {
			capital_scope = { is_on_continent = europe }
			capital_scope = { is_on_continent = north_america }
			capital_scope = { is_on_continent = south_america }
		}
	}
	abort_when_not_enabled = yes

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

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

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

	ai_strategy = {
		type = force_defend_ally_borders
		value = 10
		target = mainland_europe
	}
}

ENG_respect_neutrality_idea = {
	allowed = { original_tag = ENG }
	reversed = yes
	enable = {
		has_idea = LSM_neutrality_idea
		is_historical_focus_on = yes
		has_war = no
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = antagonize
		id = ENG
		value = -300
	}

	ai_strategy = {
		type = front_unit_request
		id = ENG
		value = -100
	}
}

USA_respect_neutrality_idea = {
	allowed = { original_tag = USA }
	reversed = yes
	enable = {
		has_idea = LSM_neutrality_idea
		is_historical_focus_on = yes
		has_war = no
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = antagonize
		id = USA
		value = -300
	}

	ai_strategy = {
		type = front_unit_request
		id = USA
		value = -100
	}
}
going_slow = {
	allowed = {
		NOT = {
			OR = {
				tag = SOV
				tag = GER
			}
		}
	}
	enable = {
		has_global_flag = is_active
		has_equipment = { infantry_equipment < 500 }
	}
	abort = {
		has_equipment = { infantry_equipment > 2000 }
	}
	
	ai_strategy = {
		type = front_control

		country_trigger = {
			has_war_with = FROM
		}

		ratio = 0.0

		priority = 500
		ordertype = front
		execution_type = careful
	}
	
}
going_rslow = {
	allowed = {
		NOT = {
			OR = {
				tag = SOV
				tag = GER
			}
		}
	}
	enable = {
		has_global_flag = is_active
		has_equipment = { infantry_equipment < -8000 }
	}
	abort = {
		has_equipment = { infantry_equipment > 500 }
	}
	
	ai_strategy = {
		type = front_control

		country_trigger = {
			has_war_with = FROM
		}

		ratio = 0.0

		priority = 1299
		ordertype = front
		execution_type = careful
		execute_order = no
	}
	
}


going_erslow = {
	allowed = {
		NOT = {
			tag = DNZ
		}
	}
	enable = {
		has_global_flag = is_active
		has_equipment = { infantry_equipment < -20000 }
	}
	abort = {
		has_equipment = { infantry_equipment > -8000 }
	}
	
	ai_strategy = {
		type = front_control

		country_trigger = {
			has_war_with = FROM
		}

		ratio = 0.0

		priority = 1500
		ordertype = front
		execution_type = careful
		execute_order = no
	}
	
}


GER_nonhis_always_prioritize_europe_core = {
	allowed = {
		original_tag = GER
	}
	enable = {
		is_historical_focus_on = no
		any_country = {
			is_neighbor_of = GER
			is_major = yes
			is_in_faction = yes
			any_owned_state = {
				is_on_continent = europe
			}
			NOT = { is_in_faction_with = GER }
			NOT = { has_non_aggression_pact_with = GER }
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = front_unit_request
		state_trigger = {
			NOT = { is_on_continent = europe }
		}
		value = -5
	}
	ai_strategy = {
		type = front_unit_request
		state_trigger = {
			OR = {
				AND = {
					owner = { NOT = { original_tag = GER } }
					OR = {
						is_on_continent = asia
						is_on_continent = north_america
						is_on_continent = south_america
						is_on_continent = middle_east
					}
				}
			}
		}
		value = -20
	}

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

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

FRA_nonhis_always_prioritize_europe_core = {
	allowed = {
		original_tag = FRA
	}
	enable = {
		is_historical_focus_on = no
		any_country = {
			is_neighbor_of = FRA
			is_major = yes
			is_in_faction = yes
			NOT = { is_in_faction_with = FRA }
			NOT = { has_non_aggression_pact_with = FRA }
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = front_unit_request
		state_trigger = {
			NOT = { is_on_continent = europe }
		}
		value = -5
	}

	ai_strategy = {
		type = front_unit_request
		state_trigger = {
			is_on_continent = europe
			is_in_home_area = yes
		}
		value = 15
	}

	ai_strategy = {
		type = front_unit_request
		state_trigger = {
			owner = { NOT = { original_tag = FRA } }
			OR = {
				is_on_continent = asia
				is_on_continent = north_america
				is_on_continent = south_america
				is_on_continent = middle_east
			}
		}
		value = -15
	}

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

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

}

this_state_is_empty = {
	enable = {
		always = yes
	}
	abort = {
		always = no
	}
	
	ai_strategy = {
		type = front_control

		state_trigger = {
			FROM = { has_war_with = FROM.FROM }
			FROM = {
				divisions_in_state = { state = ROOT size < 1 }
			}
		}

		ratio = 0.8

		priority = 5000
		ordertype = front
		execution_type = rush
		execute_order = yes
	}
	
}
lets_gang_on_germany = {
	enable = {
		has_idea = SOV_unprepared_offensive
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = front_unit_request
		country_trigger = { 
			OR = {
				tag = GER
				is_in_faction_with = GER 
			}
		}
		value = 25
	}

	ai_strategy = {
		type = garrison
		value = -50
	}
}
lets_have_fun_invading_the_soviet_onion = {
	enable = {
		has_war_with = SOV
		any_state = {
			is_core_of = SOV
			OR = {
				is_core_of = UKR
				is_core_of = EST
				any_neighbor_state = {
					OR = {
						is_core_of = UKR
						is_core_of = EST
					}
				}
			}
			SOV = { divisions_in_state = { state = PREV size < 1 } }
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = invasion_unit_request
		state_trigger = {
			is_core_of = SOV
			OR = {
				is_core_of = UKR
				is_core_of = EST
				any_neighbor_state = {
					OR = {
						is_core_of = UKR
						is_core_of = EST
					}
				}
			}
			SOV = { divisions_in_state = { state = PREV size < 1 } }
		}
		value = 15
	}

	ai_strategy = {
		type = invade
		id = "SOV"
		value = 25
	}
}
dont_help_player_target = {
	enable = {
		has_country_flag = avoid_player_like_a_plague
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = front_unit_request
		country_trigger = { has_country_flag = LSM_designated_target }
		value = -500
	}
	ai_strategy = {
		type = front_unit_request
		state_trigger = { has_state_flag = LSM_designated_state_target }
		value = -500
	}

	ai_strategy = {
		type = garrison
		value = 50
	}
}

help_player_target = {
	enable = {
		has_country_flag = help_player
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = front_unit_request
		country_trigger = { has_country_flag = LSM_designated_target }
		value = 50
	}
	ai_strategy = {
		type = front_unit_request
		state_trigger = { has_state_flag = LSM_designated_state_target }
		value = 50
	}
}

axis_avoid_helping_germany_if_they_are_pushing_too_quickly_vs_Soviets = {
	enable = {
		is_historical_focus_on = yes
		OR = {
			SOV = {
				has_country_flag = {
					flag = last_map_change_axis_purpose
					days < 30
				}
			}
			SOV = { has_army_manpower = { size < 2000000 } }
		}
		is_in_faction_with = GER
		has_war_with = SOV
		NOT = { tag = GER }
		NOT = { is_neighbor_of = SOV }
		GER = { is_ai = yes }
		OR = {
			SOV = {
				has_country_flag = {
					flag = last_map_change_allies_purpose
					days > 59
				}
			}
			SOV = {
				NOT = { has_country_flag = last_map_change_allies_purpose }
			}
		}
	}
	abort = {
		OR = {
			is_historical_focus_on = no
			AND = {
				has_country_flag = help_player
				SOV = { has_country_flag = LSM_designated_target }
			}
			SOV = {
				has_country_flag = {
					flag = last_map_change_axis_purpose
					days > 119 #it has calmed down, lets dig in
				}
			} 
			AND = {
				has_global_flag = GER_ally_support
			}
			SOV = {
				has_country_flag = {
					flag = last_map_change_axis_purpose
					days > 90
				}
				has_country_flag = {
					flag = last_map_change_allies_purpose
					days > 2
				}
				has_country_flag = {
					flag = last_map_change_allies_purpose
					days < 60
				}
			}
			SOV = { 
				NOT = { has_country_flag = last_map_change_axis_purpose }
			}
			SOV = { 
				has_country_flag = last_map_change_allies_purpose
				OR = {
					NOT = { has_country_flag = last_map_change_axis_purpose }
					has_country_flag = {
						flag = last_map_change_axis_purpose
						days > 365
					}
					AND = {
						SOV = { has_army_manpower = { size > 2999999 } } 
						has_country_flag = {
							flag = last_map_change_axis_purpose
							days > 60
						}
					}
					has_global_flag = d_day_crisis
				}
			}
		}
		OR = {
			SOV = { has_army_manpower = { size > 1999999 } } 
			AND = {
				has_country_flag = help_player
				SOV = { has_country_flag = LSM_designated_target }
			}
			AND = {
				has_global_flag = GER_ally_support
			}
			AND = {
				SOV = {
					has_country_flag = {
						flag = last_map_change_axis_purpose
						days > 60
					}
					has_country_flag = {
						flag = last_map_change_allies_purpose
						days > 7
					}
					has_country_flag = {
						flag = last_map_change_allies_purpose
						days < 119
					}
				}
			}
			SOV = { 
				NOT = { has_country_flag = last_map_change_axis_purpose }
			}
			SOV = { 
				has_country_flag = last_map_change_allies_purpose
				OR = {
					NOT = { has_country_flag = last_map_change_axis_purpose }
					has_country_flag = {
						flag = last_map_change_axis_purpose
						days > 365
					}
				}
			}
		}	
	}
	ai_strategy = {
		type = front_unit_request
		country_trigger = { 
			tag = SOV
		}
		value = -50
	}
	ai_strategy = {
		type = front_unit_request
		country_trigger = { 
			NOT = { tag = SOV }
			is_in_faction_with = SOV
		}
		value = -70
	}

	ai_strategy = {
		type = garrison
		value = 80
	}
}

remember_to_help_on_nonhis_ITA = {
	enable = {
		is_historical_focus_on = no
		is_in_faction = yes
		is_in_faction_with = ITA
		ITA = { surrender_progress > 0 }
		NOT = { surrender_progress > 0 }
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = force_defend_ally_borders
		value = 9999
		id = "ITA"
	}
}

remember_to_help_on_nonhis_GER = {
	enable = {
		is_historical_focus_on = no
		is_in_faction = yes
		is_in_faction_with = GER
		GER = { surrender_progress > 0 }
		NOT = { surrender_progress > 0 }
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = force_defend_ally_borders
		value = 9999
		id = "GER"
	}
}
remember_to_help_on_nonhis_FRA = {
	enable = {
		is_historical_focus_on = no
		is_in_faction = yes
		is_in_faction_with = FRA
		FRA = { surrender_progress > 0 }
		NOT = { surrender_progress > 0 }
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = force_defend_ally_borders
		value = 99999
		id = "FRA"
	}
}
remember_to_help_on_nonhis_ENG = {
	enable = {
		is_historical_focus_on = no
		is_in_faction = yes
		is_in_faction_with = ENG
		ENG = { surrender_progress > 0 }
		ENG = { surrender_progress > 0 }
		OR = {
			capital_scope = { is_on_continent = europe }
			capital_scope = { is_on_continent = north_america }
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = force_defend_ally_borders
		value = 9999
		id = "ENG"
	}
}
remember_to_help_on_nonhis_JAP = {
	enable = {
		is_historical_focus_on = no
		is_in_faction = yes
		is_in_faction_with = JAP
		JAP = { surrender_progress > 0 }
		NOT = { surrender_progress > 0 }
		capital_scope = { is_on_continent = asia }
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = force_defend_ally_borders
		value = 9999
		id = "JAP"
	}
}
remember_to_help_on_nonhis_SOV = {
	enable = {
		is_historical_focus_on = no
		is_in_faction = yes
		is_in_faction_with = SOV
		SOV = { surrender_progress > 0 }
		NOT = { surrender_progress > 0 }
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = force_defend_ally_borders
		value = 9999
		id = "SOV"
	}
}
remember_to_help_on_nonhis_USA = {
	enable = {
		is_historical_focus_on = no
		is_in_faction = yes
		is_in_faction_with = USA
		USA = { surrender_progress > 0 }
		NOT = { surrender_progress > 0 }
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = force_defend_ally_borders
		value = 9999
		id = "USA"
	}
}

always_prioritize_our_core = {
	enable = {
		surrender_progress > 0.25
		is_historical_focus_on = no
	}
	abort = {
		OR = {
			surrender_progress < 0.15
			has_country_flag = LSM_eligibility_nation
			has_capitulated = yes
		}
	}
	ai_strategy = {
		type = dont_defend_ally_borders #bypass value 1 on force defend
		value = 50
	}
}

always_prioritize_our_core_2 = {
	enable = {
		surrender_progress > 0.50
	}
	abort = {
		OR = {
			surrender_progress < 0.40
			has_country_flag = LSM_eligibility_nation
			has_capitulated = yes
		}
	}
	ai_strategy = {
		type = dont_defend_ally_borders #bypass value 100 on force defend
		value = 200
	}
}
always_prioritize_our_core_3 = {
	enable = {
		surrender_progress > 0.75
	}
	abort = {
		OR = {
			surrender_progress < 0.60
			has_country_flag = LSM_eligibility_nation
			has_capitulated = yes
		}
	}
	ai_strategy = {
		type = dont_defend_ally_borders #bypass value 1000 on force defend
		value = 2000
	}
}
always_prioritize_our_core_4 = {
	enable = {
		surrender_progress > 0.90
	}
	abort = {
		OR = {
			surrender_progress < 0.75
			has_country_flag = LSM_eligibility_nation
			has_capitulated = yes
		}
	}
	ai_strategy = {
		type = dont_defend_ally_borders #bypass value 9999 on force defend
		value = 9999
	}
}
always_prioritize_our_core_cw = {
	enable = {
		OR = {
			has_civil_war = yes
			AND = {	
				tag = USA
				has_war_with = CSA
			}
		}
		any_state = {
			is_core_of = ROOT
			is_island_state = no 
			controller = { has_war_with = ROOT }
		}
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = dont_defend_ally_borders
		value = 9999
	}
}