GER_keep_italy_calm_before_maginot = {
	allowed = {
		original_tag = GER
	}
	enable = {
		tag = GER
		date < 1940.5.16
		has_completed_focus = GER_danzig_or_war
	}
	abort = {
		surrender_progress > 0.1
	}
	ai_strategy = {
    		type = diplo_action_desire
    		target = join_allies
    		id = ITA
    		value = -1000000
    	}
}

GER_temporize = {
	allowed = {
		original_tag = GER
	}
	enable = {
		has_completed_focus = GER_danzig_or_war
	}
	abort = {
		OR = { 
			date > 1940.4.16
			has_completed_focus = GER_operation_weserubung
			surrender_progress > 0.1
		}
	}

	ai_strategy = {
    		type = ignore
    		id = BEL
    		value = 50
	}
	ai_strategy = {
    		type = ignore
    		id = HOL
    		value = 50
	}
	ai_strategy = {
    		type = ignore
    		id = LUX
    		value = 50
	}
}

GER_maginot_now = {
	allowed = {
		original_tag = GER
	}
	enable = {
		OR = { 
			has_completed_focus = GER_operation_weserubung
			date > 1940.4.1
		}
	}
	abort = {
		FRA = { has_capitulated = yes }
	}
		
	ai_strategy = {
    		type = conquer
    		id = BEL
    		value = 50
	}
	ai_strategy = {
    		type = conquer
    		id = HOL
    		value = 50
	}
	ai_strategy = {
    		type = conquer
    		id = LUX
    		value = 50
	}
}

GER_unit_production = {
	allowed = {
		original_tag = GER
	}
	enable = {
		always = yes
	}
	abort = {
		always = no
	}

	ai_strategy = {
		type = role_ratio
		id = garrison
		value = 4
	}

	ai_strategy = {
		type = role_ratio
		id = paratroopers
		value = 1
	}

	ai_strategy = {
		type = role_ratio
		id = mountaineers
		value = 0
	}

	ai_strategy = {
		type = role_ratio
		id = marines
		value = 0
	}

	ai_strategy = {
		type = role_ratio
		id = cavalry
		value = -100
	}

	ai_strategy = {
		type = role_ratio
		id = motorized
		value = 1 #because doctrine this = 1
	}

	ai_strategy = {
		type = role_ratio
		id = anti_armor
		value = 1
	}

	ai_strategy = {
		type = role_ratio
		id = mechanized
		value = -3 #because doctrine this = 0
	}

	ai_strategy = {
		type = role_ratio
		id = armor
		value = -5 #because doctrine this = 3
	}

	ai_strategy = {
		type = role_ratio
		id = infantry
		value = 75 #88 to 70
	}

	# Naval unit factors
	ai_strategy = {
		type = unit_ratio
		id = capital_ship
		value = 15
	}

	ai_strategy = {
		type = unit_ratio
		id = screen_ship
		value = 20
	}

	ai_strategy = {
		type = unit_ratio
		id = convoy
		value = 20
	}

	ai_strategy = {
		type = equipment_production_factor
		id = naval_bomber
		value = -50
	}

	ai_strategy = {
		type = equipment_production_factor
		id = anti_tank
		value = 20
	}

	ai_strategy = {
		type = equipment_production_factor
		id = anti_air
		value = 25
	}

	ai_strategy = {
		type = equipment_production_factor
		id = artillery
		value = 100 #20 to 40
	}
	ai_strategy = {
		type = equipment_production_min_factories_archetype #Build these up over time, don't stall
		id = anti_air_equipment
		value = 2
	}
	ai_strategy = {
		type = equipment_production_min_factories_archetype
		id = artillery_equipment
		value = 4
	}
	
	ai_strategy = { #Germany struggles with manual management of this in an endless loop
		type = equipment_production_min_factories_archetype
		id = motorized_equipment
		value = 1
	}

	ai_strategy = { #added to railway gun define (set to 0 by default, increased in default strategies)
		type = railway_gun_divisions_ratio
		value = 1
	}
}

#Germany loves subs!
GER_submarine_ratio = {
	allowed = {
		original_tag = GER
	}
	enable = {
		always = yes
	}
	abort = {
		OR = {
			has_completed_focus = GER_trade_interdiction
			AND = {
				is_historical_focus_on = yes
				date > 1940.1.1
				OR = {
					has_war_with = ENG
					has_war_with = USA
				}
			}
		}
	}

	ai_strategy = {
		type = unit_ratio
		id = submarine
		value = -50 #because doctrine this = 50
	}
}

#Germany love subs so much they need even moar!
GER_increase_submarine_ratio = {
	allowed = {
		original_tag = GER
	}
	enable = {
		OR = {
			AND = {
				NOT = {
					has_completed_focus = GER_plan_z
				}
				has_completed_focus = GER_trade_interdiction
			}
			AND = {
				is_historical_focus_on = yes
				date > 1940.1.1
				OR = {
					has_war_with = ENG
					has_war_with = USA
				}
			}
		}
	}
	abort = {
		has_completed_focus = GER_plan_z
	}

	ai_strategy = {
		type = unit_ratio
		id = submarine
		value = 25 
	}
}

#Germany can't afford producing this many Destroyers
GER_screen_ratio = {
	allowed = {
		original_tag = GER
	}
	enable = {
		OR = {
			AND = {
				NOT = {
					has_completed_focus = GER_plan_z
				}
				has_completed_focus = GER_trade_interdiction
			}
			AND = {
				is_historical_focus_on = yes
				date > 1940.1.1
				OR = {
					has_war_with = ENG
					has_war_with = USA
				}
			}
		}
	}
	abort = {
		has_completed_focus = GER_plan_z
	}

	ai_strategy = {
		type = unit_ratio
		id = screen_ship
		value = -25
	}
}

#Historical Germany don't need carriers
GER_avoid_carriers = {
	allowed = {
		original_tag = GER
	}
	enable = {
		is_historical_focus_on = yes
	}
	abort = {
		has_completed_focus = GER_plan_z
	}
	ai_strategy = {
		type = unit_ratio
		id = carrier
		value = -20
	}
}

#Germany needs to stock up on inf eq early on, but can drop this strategy later in order to be more flexible with what it need to produce instead of being railroaded
GER_infantry_equipment_production = {
	allowed = {
		original_tag = GER
	}
	enable = {
		date < 1940.1.1
	}
	abort = {
		date > 1940.1.1
	}

	ai_strategy = {
		type = equipment_production_factor
		id = infantry
		value = 5 #30 to 50
	}
}

GER_anti_armor = {
	allowed = {
		original_tag = GER
	}
	enable = {
		ai_wants_divisions > 5 #Decreasing the amount of motorized the AI wants

		any_enemy_country = {
			ROOT = {
				estimated_intel_max_armor = {
					tag = PREV
					value > 25
				}
			}
		}
	}
	abort = {
		ai_wants_divisions < 6 #Decreasing the amount of motorized the AI wants
	}

	ai_strategy = {
		type = role_ratio
		id = anti_armor
		value = 15
	}
}

GER_assault_armor = {
	allowed = {
		original_tag = GER
		OR = {
			has_dlc = "Gotterdammerung" # Needed for the assault engineers
			has_dlc = "No Step Back" # Needed for Flame tanks
		}
	}
	enable = {
		OR = { 
			has_war = yes
			AND = {
				ai_wants_divisions > 6 
				date > 1939.6.1
			}
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = role_ratio
		id = mechanized_assault
		value = 1
	}
}
GER_assault_armor_ostfront = {
	allowed = {
		original_tag = GER
		OR = {
			has_dlc = "Gotterdammerung" # Needed for the assault engineers
			has_dlc = "No Step Back" # Needed for Flame tanks
		}
	}
	enable = {
		OR = { 
			has_war = yes
			AND = {
				ai_wants_divisions > 6 
				has_war_with = SOV
			}
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = role_ratio
		id = mechanized_assault
		value = 2
	}
}

GER_armored_production = {
	allowed = {
		original_tag = GER
	}
	enable = {
		date > 1938.3.1
		ai_wants_divisions > 10 #Decreasing the amount of tanks the AI wants
	}
	abort = {
		OR = {
			ai_wants_divisions < 10 #Decreasing the amount of tanks the AI wants
		}
	}

	ai_strategy = {
		type = role_ratio
		id = armor
		value = 2
	}
}

GER_halt_light_armor_production_in_transitioning = {
	allowed = {
		original_tag = GER
	}
	enable = {
		has_template_majority_unit = medium_armor
		OR = {
			has_equipment = { light_tank_chassis > 600 }
			date > 1938.1.1
		}
	}
	abort = {
		always = no  # once we start we never go back to light armor
	}

	ai_strategy = {
		type = equipment_variant_production_factor
		id = light_tank_chassis
		value = -100
	}

	ai_strategy = {
		type = equipment_variant_production_factor
		id = light_tank_flame_chassis
		value = 50
	}

	ai_strategy = {
		type = equipment_variant_production_factor
		id = medium_tank_chassis
		value = 50
	}

	ai_strategy = {
		type = equipment_production_factor
		id = artillery
		value = -50 #downprio this for some more tanks
	}

}

GER_stockpile_less_early_game = {
	allowed = {
		original_tag = GER
	}

	enable = {
		date < 1940.1.1
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = equipment_stockpile_surplus_ratio
		value = -20 # reduce while we build up in case of CZE or Austria issues
	}
}

GER_raids_store_some_equipment = {
	allowed = {
		original_tag = GER
	}
	enable = {
		date > 1938.4.1
		date < 1941.1.1
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = save_equipment
		id = transport_plane_equipment
		value = 10
	}
	ai_strategy = {
		type = save_equipment
		id = support_equipment
		value = 100
	}
}
GER_raids_get_some_paras_for_eben_emael = {
	allowed = {
		original_tag = GER
	}
	enable = {
		date > 1937.5.1
	}

	abort = {
		has_tech = paratroopers
	}

	ai_strategy = {
		type = research_weight_factor
		id = paratroopers
		value = 100
	}
}

GER_highered_armored_production = {
	allowed = {
		original_tag = GER
	}
	enable = {
		num_of_military_factories > 59
	}
	abort = {
		num_of_military_factories < 60
	}
	
	ai_strategy = { #Germany struggles with manual management of this in an endless loop
		type = equipment_production_min_factories_archetype
		id = motorized_equipment
		value = 1
	}
	
	ai_strategy = {
		type = role_ratio
		id = armor
		value = 2
	}
}

GER_dont_waste_xp_until_medium_armor = {
	allowed = {
		original_tag = GER
	}
	enable = {
		always = yes
	}
	abort = {
		has_template_majority_unit = medium_armor
	}

	ai_strategy = {
		type = template_prio
		id = paratrooper
		value = -100
	}

	ai_strategy = {
		type = template_prio
		id = mountaineers
		value = -100
	}
}

GER_super_boost_light_for_med_armor = {
	allowed = {
		original_tag = GER
	}
	enable = {
		OR = {
			has_tech = basic_medium_tank
			has_tech = basic_medium_tank_chassis
		}
		NOT = { has_template_ai_majority_unit = medium_armor }
	}

	abort = {
		has_template_ai_majority_unit = medium_armor
	}

	# lets do changes more often during this period too
	ai_strategy = {
		type = land_xp_spend_priority
		id = division_template
		value = 100
	}

	# this is gateway
	ai_strategy = {
		type = template_prio
		id = light_armor
		value = 100
	}

	ai_strategy = {
		type = template_prio
		id = medium_armor
		value = 150
	}

	# Germany is set up to change their SS division into medium armor.
	ai_strategy = {
		type = template_prio
		id = motorized
		value = 200
	}
}

GER_super_boost_light_for_modern_armor = {
	allowed = {
		original_tag = GER
	}
	enable = {
		OR = {
			has_tech = main_battle_tank
			has_tech = main_battle_tank_chassis
		}
		NOT = { has_template_ai_majority_unit = modern_armor }
	}

	abort = {
		has_template_ai_majority_unit = modern_armor
	}

	# lets do changes more often during this period too
	ai_strategy = {
		type = land_xp_spend_priority
		id = division_template
		value = 100
	}

	# this is gateway
	ai_strategy = {
		type = template_prio
		id = medium_armor
		value = 100
	}

	ai_strategy = {
		type = template_prio
		id = modern_armor
		value = 150
	}
}

GER_how_about_some_more_transport_planes = {
	allowed = {
		original_tag = GER
	}
	enable = {
		num_of_military_factories > 50
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = equipment_production_min_factories
		id = air_transport
		value = 1
	}
}

GER_research_maus_to_enable_ratte = {
	allowed = {
		has_dlc = "No Step Back"
		has_dlc = "Gotterdammerung"
		original_tag = GER
	}
	enable = {
		date > 1944.5.1
	}

	abort = {
		has_tech = super_heavy_tank_chassis
	}

	ai_strategy = {
		type = research_weight_factor
		id = super_heavy_tank_chassis
		value = 100
	}
}


GER_template_design = {
	allowed = {
		original_tag = GER
	}
	enable = {
		date < 1940.1.1
	}
	abort = {
		date > 1940.1.1
	}

	ai_strategy = {
		type = template_prio
		id = infantry
		value = 20
	}

	ai_strategy = {
		type = template_prio
		id = artillery
		value = 20
	}

	ai_strategy = {
		type = template_prio
		id = motorized
		value = -50
	}

	ai_strategy = {
		type = template_prio
		id = cavalry
		value = -100
	}

	ai_strategy = {
		type = template_prio
		id = light_armor
		value = 30
	}

	ai_strategy = {
		type = template_prio
		id = heavy_armor
		value = -50
	}

	ai_strategy = {
		type = template_prio
		id = paratroopers
		value = -50
	}
}

GER_war_with_poland = {
	allowed = {
		original_tag = GER
	}
	enable = {
		has_completed_focus = GER_reassert_eastern_claims
		country_exists = POL
	}
	abort = {
		POL = { has_capitulated = yes }
	}

	ai_strategy = {
		type = antagonize
		id = POL
		value = 200
	}
}

GER_danzig_of_war_preparation = {
	allowed = {
		original_tag = GER
	}
	enable = {
		focus_progress = {
			focus = GER_danzig_or_war
			progress > 0.01
		}
		NOT = {
			has_completed_focus = GER_danzig_or_war
			owns_state = 85
		}
		country_exists = POL
	}

	abort = {
		OR = {
			NOT = { country_exists = POL }
			AND = {
				has_completed_focus = GER_danzig_or_war
				GER = { has_war_with = POL }
			}
			owns_state = 85
		}
	}

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

# Make sure we deploy our breakthrough units against Poland
GER_blitzkrieg_poland = {
	allowed = {
		original_tag = GER
	}
	enable = {
		#is_historical_focus_on = yes
		OR = {
			focus_progress = {
				focus = GER_danzig_or_war
				progress > 0.01
			}
			has_war_with = POL
		}
	}
	abort = {
		OR = {
			POL = {
				has_capitulated = yes
			}
			has_war_with = HOL
		}
	}
	ai_strategy = {
		type = front_armor_score
		id = POL
		value = 100
	}

	ai_strategy = {
		type = force_concentration_target_weight
		state = 87 # Lodz
		state = 10 # Warsaw

		value = 25 # +25%
	}

	ai_strategy = {
		# Still need to defend at the maginot...
		type = front_unit_request
		state = 28  # Alsace-Lorraine
		value = 30  # +30 %
	}
}

# Make sure we deploy our breakthrough units against Soviet
GER_blitzkrieg_russia_with_force_concentration = {
	allowed = {
		original_tag = GER
	}
	enable = {
		#is_historical_focus_on = yes
		OR = {
			focus_progress = {
				focus = GER_war_with_the_ussr
				progress > 0.01
			}
			focus_progress = {
				focus = GER_strike_eastward
				progress > 0.01
			}
			focus_progress = {
				focus = GER_strike_at_the_source
				progress > 0.01
			}
			focus_progress = {
				focus = GER_tackle_the_communist_threat
				progress > 0.01
			}
			has_war_with = SOV
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = force_concentration_target_weight
		state = 206 # Minsk
		state = 202 # Kyiv

		value = 25 # +25%
	}
}

GER_dont_die_in_mountains = {
	allowed = {
		original_tag = GER
	}
	enable = {
		date < 1942.5.1
		country_exists = SWI
		is_historical_focus_on = yes
	}
	abort = {
		OR = {
			AND = {
				NOT = { country_exists = FRA }
				date > 1942.5.1
			}
			SWI = {
				NOt = {has_idea = SWI_swiss_neutrality}
			}
		}
	}

	ai_strategy = {
		type = ignore
		id = SWI
		value = 1000
	}
}

GER_war_with_soviets = {
	allowed = {
		original_tag = GER
	}
	enable = {
		has_completed_focus = GER_war_with_the_ussr
		country_exists = SOV
	}
	abort = {
		NOT = { country_exists = SOV }
	}


	ai_strategy = {
		type = antagonize
		id = SOU # Yes, SOU is deliberate
		value = 200
	}
}

GER_soviet_ally = {
	allowed = {
		original_tag = GER
	}
	enable = {
		has_idea = soviet_german_friendship
		country_exists = SOV
	}
	abort = {
		NOT = { country_exists = SOV }
	}

	ai_strategy = {
		type = befriend
		id = SOV
		value = 200
	}
	ai_strategy = {
		type = alliance
		id = SOV
		value = 200
	}
}

GER_italy_ally = {
	allowed = {
		original_tag = GER
	}
	enable = {
		has_completed_focus = GER_form_rome_berlin_axis
		country_exists = ITA
	}
	abort = {
		NOT = { country_exists = ITA }
	}

	ai_strategy = {
		type = befriend
		id = ITA
		value = 200
	}
	ai_strategy = {
		type = alliance
		id = ITA
		value = 200
	}
}

GER_iron_pact_italy = {
	allowed = {
		original_tag = GER
	}
	enable = {
		ITA = {
			has_completed_focus = ITA_pact_of_steel
			exists = yes
		}
	}
	abort = {
		NOT = { country_exists = ITA }
	}

	ai_strategy = {
		type = befriend
		id = ITA
		value = 100
	}
	ai_strategy = {
		type = alliance
		id = ITA
		value = 100
	}
}

#Don't spend pp trying to get friends - Germany don't need no stinking friends!
GER_save_pp_vic = {
	allowed = {
		original_tag = GER
	}
	enable = {
		country_exists = VIC
		OR = {
			has_war_with = SOV
			has_war_with = USA
			has_opinion = {
			    target = VIC
			    value > 70
			}
		}
	}
	abort = {
		NOT = { 
			country_exists = VIC
			has_war_with = SOV
			has_war_with = USA
		}
		has_opinion = {
		    target = VIC
		    value < 20
		}
	}

	ai_strategy = {
		type = befriend
		id = VIC
		value = -200
	}
}

#Don't spend pp trying to get friends - Germany don't need no stinking friends!
GER_save_pp_fin = {
	allowed = {
		original_tag = GER
	}
	enable = {
		country_exists = FIN
		OR = {
			has_war_with = SOV
			has_war_with = USA
			has_opinion = {
			    target = FIN
			    value > 70
			}
		}
	}
	abort = {
		NOT = { 
			country_exists = FIN
			has_war_with = SOV
			has_war_with = USA
		}
		has_opinion = {
		    target = FIN
		    value < 20
		}
	}

	ai_strategy = {
		type = befriend
		id = FIN
		value = -200
	}
}

GER_dont_join_gie_wars_early = {
	allowed = {
		original_tag = GER
	}
	enable = {
		is_in_faction_with = ITA
		ITA = {
			all_enemy_country = {
				is_government_in_exile = yes
			}
		}
	}
	abort = {
		OR = {
			GER = {
				any_enemy_country = {
					is_government_in_exile = no
				}
			}
			ITA = {
				any_enemy_country = {
					is_government_in_exile = no
				}
			}
		}
	}

	ai_strategy = {
	    type = diplo_action_desire
	    id = ITA
	    value = -9999
	    target = join_allies
	}

	ai_strategy = {
	    type = diplo_action_acceptance
	    id = ITA
	    value = -9999
	    target = call_allies
	}
}

GER_japan_ally = {
	allowed = {
		original_tag = GER
	}
	enable = {
		has_completed_focus = GER_befriend_japan
		country_exists = JAP
	}
	abort = {
		NOT = { country_exists = JAP }
	}

	ai_strategy = {
		type = befriend
		id = JAP
		value = 200
	}
	ai_strategy = {
		type = alliance
		id = JAP
		value = 200
	}
}

GER_china_ally = {
	allowed = {
		original_tag = GER
	}
	enable = {
		OR = {
			has_completed_focus = GER_befriend_china
			has_completed_focus = GER_closer_sino_germanic_relations
		}
		country_exists = CHI
	}
	abort = {
		NOT = { country_exists = CHI }
	}

	ai_strategy = {
		type = befriend
		id = CHI
		value = 200
	}
	ai_strategy = {
		type = alliance
		id = CHI
		value = 200
	}
}

GER_turkey_ally = {
	allowed = {
		original_tag = GER
	}
	enable = {
		has_completed_focus = GER_befriend_turkey
		country_exists = TUR
	}
	abort = {
		NOT = { country_exists = TUR }
	}

	ai_strategy = {
		type = befriend
		id = TUR
		value = 100
	}
	ai_strategy = {
		type = alliance
		id = TUR
		value = 100
	}
}

GER_spain_ally = {
	allowed = {
		NOT = { has_dlc = "La Resistance" }
		original_tag = GER
	}
	enable = {
		has_completed_focus = GER_alliance_with_spain
		country_exists = SPR
		SPR = { has_government = fascism } # TODO Find way to detect dynamic revolter tag
	}
	abort = {
		NOT = { country_exists = SPR }
	}

	ai_strategy = {
		type = befriend
		id = SPR
		value = 100
	}
	ai_strategy = {
		type = alliance
		id = SPR
		value = 100
	}
}

GER_spain_ally_la_resistance = {
	allowed = {
		original_tag = GER
		has_dlc = "La Resistance"
	}
	enable = {
		has_completed_focus = GER_alliance_with_spain
		country_exists = SPA
	}
	abort = {
		OR = {
			NOT = { country_exists = SPA }
			SPA = { has_completed_focus = SPA_join_the_allies }
		}
	}

	ai_strategy = {
		type = befriend
		id = SPA
		value = 100
	}
	ai_strategy = {
		type = alliance
		id = SPA
		value = 100
	}
}

GER_denmark_ally = {
	allowed = {
		original_tag = GER
	}
	enable = {
		has_completed_focus = GER_utilize_the_nordliche_gesellschaft
		country_exists = DEN
	}
	abort = {
		NOT = { country_exists = DEN }
	}

	ai_strategy = {
		type = befriend
		id = DEN
		value = 100
	}
	ai_strategy = {
		type = alliance
		id = DEN
		value = 100
	}
}

GER_sweden_ally = {
	allowed = {
		original_tag = GER
	}
	enable = {
		has_completed_focus = GER_utilize_the_nordliche_gesellschaft
		country_exists = SWE
	}
	abort = {
		NOT = { country_exists = SWE }
	}

	ai_strategy = {
		type = befriend
		id = SWE
		value = 100
	}
	ai_strategy = {
		type = alliance
		id = SWE
		value = 100
	}
}

GER_dutch_ally = {
	allowed = {
		original_tag = GER
	}
	enable = {
		has_completed_focus = GER_influence_the_benelux
		country_exists = HOL
	}
	abort = {
		NOT = { country_exists = HOL }
	}

	ai_strategy = {
		type = befriend
		id = HOL
		value = 100
	}
	ai_strategy = {
		type = alliance
		id = HOL
		value = 100
	}
}

GER_norway_ally = {
	allowed = {
		original_tag = GER
	}
	enable = {
		has_completed_focus = GER_utilize_the_nordliche_gesellschaft
		country_exists = NOR
	}
	abort = {
		NOT = { country_exists = NOR }
	}

	ai_strategy = {
		type = befriend
		id = NOR
		value = 100
	}
	ai_strategy = {
		type = alliance
		id = NOR
		value = 100
	}
}

GER_anschluss_rejected = {
	allowed = {
		original_tag = GER
	}
	enable = {
		OR = {
			has_completed_focus = GER_anschluss
			has_completed_focus = GER_the_austrian_question
		}
		country_exists = AUS
	}
	abort = {
		NOT = {
			country_exists = AUS
		}
	}

	ai_strategy = {
		type = antagonize
		id = AUS
		value = 300
	}
}

GER_force_concentration_through_maginot_hurts_too_much = {
	allowed = {
		original_tag = GER
	}
	enable = {
		date < 1941.1.1  # Deactivate after some time
		28 = { # Alsace-Lorraine
			NOT = { is_controlled_by = GER }

			any_province_building_level = {  # Only if Maginot is actually fortified
				province = {
					all_provinces = yes
					limit_to_border = yes
				}
				building = bunker
				level > 5
			}
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = force_concentration_front_factor
		state = 28  # Alsace-Lorraine
		ratio = 0.50     # Only if > 50 % of the front consists of Alsace-Lorraine. This should make it deactivate if the frontline extends around the maginot
		value = -100
	}
	ai_strategy = {
		type = force_concentration_target_weight
		state = 28 # Alsace-Lorraine
		value = -100 # -100 % / Don't even consider targets here. Infantry and Artillery are better at dealing with the Maginot than tank formations are
	}
	ai_strategy = {
		type = force_concentration_target_weight
		state = 18 # Champagne
		value = -50 # -50 % / Let's try to avoid the areas behind the Maginot. It is risky, as we might end up trying to go through it anyways then
	}
	ai_strategy = {
		type = force_concentration_target_weight
		state = 17 # Franche Comte
		value = -75 # -75 % / Let's try to avoid the areas behind the Maginot. It is risky, as we might end up trying to go through it anyways then
	}
}

GER_prepare_against_czechoslovakia = {
	allowed = {
		original_tag = GER
	}
	enable = {
		date < 1940.1.1
		focus_progress = {
			focus = GER_demand_sudetenland
			progress > 0.01
		}
		country_exists = CZE
		NOT = { has_country_flag = sudetenland_acquired }

		# TODO This enable trigger should be made a bit more robust. Right now, if CZE is puppeted by Germany or just half-conquered by them, this strat would still be active.
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = prepare_for_war
		id = CZE
		value = 100
	}

	ai_strategy = {
		type = force_concentration_front_factor
		tag = CZE
		value = 200
	}
}

GER_prepare_against_czechoslovakia_again = {
	allowed = {
		original_tag = GER
	}
	enable = {
		date < 1940.6.1
		focus_progress = {
			focus = GER_fate_of_czechoslovakia
			progress > 0.01
		}
		country_exists = CZE
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = prepare_for_war
		id = CZE
		value = 100
	}

	ai_strategy = {
		type = force_concentration_front_factor
		tag = CZE
		value = 200
	}
}

GER_czechoslovakia_is_idiot = {
	allowed = {
		original_tag = GER
	}
	enable = {
		has_global_flag = CZE_refused_sudetenland
		country_exists = CZE
	}
	abort = {
		NOT = {
			country_exists = CZE
		}
	}

	ai_strategy = {
		type = antagonize
		id = CZE
		value = 300
	}
}

GER_play_nice_with_ribbentrop_pact = {
	allowed = {
		original_tag = GER
	}
	enable = {
		has_global_flag = sov_yes_pact
	}
	abort = {
		OR ={
			GER = { has_war_with = SOV }
			date > 1941.5.1
			AND = {
				LIT = { is_in_faction_with = SOV }
				LAT = { is_in_faction_with = SOV }
				EST = { is_in_faction_with = SOV }
			}
		}
	}

	# leave britney alone!
	ai_strategy = {
		type = ignore
		id = LIT
		value = 100
	}
	ai_strategy = {
		type = ignore
		id = LAT
		value = 100
	}
	ai_strategy = {
		type = ignore
		id = EST
		value = 100
	}
}

GER_tfv_protect_fascist_south_africa = {
	allowed = {
		original_tag = GER
	}
	enable = {
		has_country_flag = saf_fascist_uprising # Set from the national focus
	}
	abort = {
		surrender_progress > 0.8
		SAF = { has_civil_war = no }
	}

	ai_strategy = {
		type = protect
		id = SAF
		value = 200
	}
	ai_strategy = {
		type = send_volunteers_desire
		id = SAF
		value = 200
	}
	ai_strategy = {
		type = support
		id = SAF
		value = 200
	}
	ai_strategy = {
		type = alliance
		id = SAF
		value = 200
	}
}

GER_less_naval_focused_nation = {
	allowed = {
		original_tag = GER
		not = {
			has_dlc = "Man the Guns"
		}
	}
	enable = {
		date > 1936.1.1 #Don't Germany, just dont
	}
	abort = {
		date > 1943.1.1 #Don't Germany, just dont, if you haven't already won
	}

	ai_strategy = {
		type = unit_ratio
		id = capital_ship
		value = -3
	}

	ai_strategy = {
		type = unit_ratio
		id = submarine
		value = -3
	}

	ai_strategy = {
		type = unit_ratio
		id = screen_ship
		value = -3
	}

	ai_strategy = {
		type = unit_ratio
		id = convoy
		value = -3
	}
}

GER_naval_role_ratios_historical = {
	allowed = {
		original_tag = GER
		has_dlc = "Man the Guns"
	}
	enable = {
		GER_naval_interest_trigger = no
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = role_ratio
		id = naval_capital_bb
		value = 5
	}

	ai_strategy = {
		type = role_ratio
		id = naval_capital_bc
		value = -100
	}

	ai_strategy = {
		type = role_ratio
		id = naval_carrier
		value = -50
	}

	ai_strategy = {
		type = role_ratio
		id = naval_submarine
		value = 200
	}
	ai_strategy = {
		type = role_ratio
		id = submarine
		value = 200
	}

	ai_strategy = {
		type = role_ratio
		id = naval_screen
		value = 100
	}

	ai_strategy = {
		type = role_ratio
		id = naval_cruiser_light
		value = 50
	}

	ai_strategy = {
		type = role_ratio
		id = naval_cruiser_heavy
		value = 5
	}

	ai_strategy = {
		type = role_ratio
		id = naval_mine_sweeper
		value = 15
	}

	ai_strategy = {
		type = role_ratio
		id = naval_mine_layer
		value = 10
	}
}

GER_naval_role_ratios_ahistorical = {
	allowed = {
		original_tag = GER
		has_dlc = "Man the Guns"
	}
	enable = {
		GER_naval_interest_trigger = yes
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = role_ratio
		id = naval_capital_bb
		value = 5
	}

	ai_strategy = {
		type = role_ratio
		id = naval_capital_bc
		value = 0
	}

	ai_strategy = {
		type = role_ratio
		id = naval_carrier
		value = 50
	}

	ai_strategy = {
		type = role_ratio
		id = naval_submarine
		value = 150
	}

	ai_strategy = {
		type = role_ratio
		id = naval_screen
		value = 120
	}

	ai_strategy = {
		type = role_ratio
		id = naval_cruiser_light
		value = 35
	}

	ai_strategy = {
		type = role_ratio
		id = naval_cruiser_heavy
		value = 5
	}

	ai_strategy = {
		type = role_ratio
		id = naval_mine_sweeper
		value = 15
	}

	ai_strategy = {
		type = role_ratio
		id = naval_mine_layer
		value = 10
	}
}

GER_naval_role_ratios_maximum_kaiser = {
	allowed = {
		original_tag = GER
		has_dlc = "Man the Guns"
	}
	enable = {
		OR = {
			has_completed_focus = GER_rebuild_the_high_seas_fleet_ww
			has_completed_focus = GER_rebuild_the_high_seas_fleet
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = role_ratio
		id = naval_capital_bb
		value = 0
	}

	ai_strategy = {
		type = role_ratio
		id = naval_capital_bc
		value = 0
	}

	ai_strategy = {
		type = role_ratio
		id = naval_carrier
		value = 25
	}

	ai_strategy = {
		type = role_ratio
		id = naval_submarine
		value = 50
	}

	ai_strategy = {
		type = role_ratio
		id = naval_screen
		value = 120
	}

	ai_strategy = {
		type = role_ratio
		id = naval_cruiser_light
		value = 75
	}

	ai_strategy = {
		type = role_ratio
		id = naval_cruiser_heavy
		value = 50
	}

	ai_strategy = {
		type = role_ratio
		id = naval_mine_sweeper
		value = 15
	}

	ai_strategy = {
		type = role_ratio
		id = naval_mine_layer
		value = 10
	}
}

GER_area_priority = {
	allowed = {
		original_tag = GER
	}
	enable = {
		always = yes
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = area_priority
		id = europe
		value = 110 #more focus here
	}

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

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

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

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

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

	ai_strategy = {
		type = area_priority
		id = africa
		value = -70
	}

	ai_strategy = {
		type = area_priority
		id = pacific
		value = -120 #less focus here
	}

	ai_strategy = {
		type = area_priority
		id = oceania
		value = -80
	}
}

GER_start_the_blitz = {
	allowed = {
		original_tag = GER
	}
	enable = {
		is_historical_focus_on = yes
		has_war_with = ENG
		ENG = { controls_state = 126 } # Checks that they control London
		FRA = { has_capitulated = yes }
		NOT = { has_war_with = SOV }
		NOT = {
			focus_progress = {
				focus = GER_war_with_the_ussr
				progress > 0.01
			}
		}
		date > 1940.1.1
		date < 1940.11.1
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = strategic_air_importance
		id = 1 #Strategic Region ID - Southern England
		value = 5000 #value of stocked main front in active combat is usually around 35,000
	}

	ai_strategy = {
		type = strategic_air_importance
		id = 18 #Strategic Region ID - English Channel
		value = -20000 #Too easy to lose planes here
	}
}

GER_upgrade_the_blitz = {
	allowed = {
		original_tag = GER
	}
	enable = {
		is_historical_focus_on = yes
		has_war_with = ENG
		ENG = { controls_state = 126 } # Checks that they control London
		FRA = { has_capitulated = yes }
		NOT = { has_war_with = SOV }
		NOT = {
			focus_progress = {
				focus = GER_war_with_the_ussr
				progress > 0.01
			}
		}
		date > 1940.3.1
		date < 1940.11.1
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = strategic_air_importance
		id = 1 #Strategic Region ID - Southern England
		value = 10000 #value of stocked main front in active combat is usually around 35,000
	}
}

GER_upgrade_the_blitz_again = {
	allowed = {
		original_tag = GER
	}
	enable = {
		is_historical_focus_on = yes
		has_war_with = ENG
		ENG = { controls_state = 126 } # Checks that they control London
		FRA = { has_capitulated = yes }
		NOT = { has_war_with = SOV }
		NOT = {
			focus_progress = {
				focus = GER_war_with_the_ussr
				progress > 0.01
			}
		}
		date > 1940.6.1
		date < 1940.11.1
	}

	abort_when_not_enabled = yes
 
	ai_strategy = {
		type = strategic_air_importance
		id = 1 #Strategic Region ID - Southern England
		value = 10000 #value of stocked main front in active combat is usually around 35,000
	}
}

GER_stop_blitz = { #prevents GER air from suicidally continuing the Blitz after they decide to focus east next year, until the USSR is knocked out
	allowed = {
		original_tag = GER
	}
	enable = {
		is_historical_focus_on = yes
		has_war_with = ENG
		SOV = { has_capitulated = no }
		date > 1940.11.2
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = strategic_air_importance
		id = 1 #Strategic Region ID - Southern England
		value = -20000 #value of stocked main front in active combat is usually around 35,000
	}

	ai_strategy = {
		type = strategic_air_importance
		id = 2 #Strategic Region ID - Northern England
		value = -20000 #value of stocked main front in active combat is usually around 35,000
	}

	ai_strategy = {
		type = strategic_air_importance
		id = 3 #Strategic Region ID - Scotland
		value = -20000 #value of stocked main front in active combat is usually around 35,000
	}

	ai_strategy = {
		type = strategic_air_importance
		id = 4 #Strategic Region ID - Ireland
		value = -20000 #value of stocked main front in active combat is usually around 35,000
	}

	ai_strategy = {
		type = strategic_air_importance
		id = 18 #Strategic Region ID - English Channel
		value = -20000 #value of stocked main front in active combat is usually around 35,000
	}

	ai_strategy = {
		type = strategic_air_importance
		id = 43 #Strategic Region ID - Western Approaches
		value = -20000 #value of stocked main front in active combat is usually around 35,000
	}
}

GER_avoid_air_war_before_fall_gelb = { #prevents GER air from uselessly beating itself up prior to the invasion of France
	allowed = {
		original_tag = GER
	}
	enable = {
		is_historical_focus_on = yes
		has_war_with = FRA
		FRA = { controls_state = 16 } # Checks that they control Paris
		HOL = { has_capitulated = no }
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = strategic_air_importance
		id = 1 #Strategic Region ID - Southern England
		value = -20000 #value of stocked main front in active combat is usually around 35,000
	}

	ai_strategy = {
		type = strategic_air_importance
		id = 2 #Strategic Region ID - Northern England
		value = -20000 #value of stocked main front in active combat is usually around 35,000
	}

	ai_strategy = {
		type = strategic_air_importance
		id = 3 #Strategic Region ID - Scotland
		value = -20000 #value of stocked main front in active combat is usually around 35,000
	}

	ai_strategy = {
		type = strategic_air_importance
		id = 4 #Strategic Region ID - Ireland
		value = -20000 #value of stocked main front in active combat is usually around 35,000
	}

	ai_strategy = {
		type = strategic_air_importance
		id = 18 #Strategic Region ID - English Channel
		value = -20000 #value of stocked main front in active combat is usually around 35,000
	}

	ai_strategy = {
		type = strategic_air_importance
		id = 43 #Strategic Region ID - Western Approaches
		value = -20000 #value of stocked main front in active combat is usually around 35,000
	}

	ai_strategy = {
		type = strategic_air_importance
		id = 42 #Strategic Region ID - Bay of Biscay
		value = -20000 #value of stocked main front in active combat is usually around 35,000
	}

	ai_strategy = {
		type = strategic_air_importance
		id = 19 #Strategic Region ID - Northern France
		value = -20000 #value of stocked main front in active combat is usually around 35,000
	}

	ai_strategy = {
		type = strategic_air_importance
		id = 208 #Strategic Region ID - Western France
		value = -20000 #value of stocked main front in active combat is usually around 35,000
	}

	ai_strategy = {
		type = strategic_air_importance
		id = 20 #Strategic Region ID - Southern France
		value = -20000 #value of stocked main front in active combat is usually around 35,000
	}
}

GER_avoid_early_blitz = { #prevents GER air from uselessly attacking England while Fall Gelb is still on
	allowed = {
		original_tag = GER
	}
	enable = {
		is_historical_focus_on = yes
		has_war_with = ENG
		FRA = { has_capitulated = no }
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = strategic_air_importance
		id = 1 #Strategic Region ID - Southern England
		value = -20000 #value of stocked main front in active combat is usually around 35,000
	}

	ai_strategy = {
		type = strategic_air_importance
		id = 2 #Strategic Region ID - Northern England
		value = -20000 #value of stocked main front in active combat is usually around 35,000
	}

	ai_strategy = {
		type = strategic_air_importance
		id = 3 #Strategic Region ID - Scotland
		value = -20000 #value of stocked main front in active combat is usually around 35,000
	}

	ai_strategy = {
		type = strategic_air_importance
		id = 4 #Strategic Region ID - Ireland
		value = -20000 #value of stocked main front in active combat is usually around 35,000
	}

	ai_strategy = {
		type = strategic_air_importance
		id = 18 #Strategic Region ID - English Channel
		value = -20000 #value of stocked main front in active combat is usually around 35,000
	}

	ai_strategy = {
		type = strategic_air_importance
		id = 43 #Strategic Region ID - Western Approaches
		value = -20000 #value of stocked main front in active combat is usually around 35,000
	}
}

GER_invading_france_is_pointless_because_we_go_through_benelux_soon = {
	allowed = {
		original_tag = GER
	}
	enable = {
		if = {
			limit = { NOT = { has_dlc = "Man the Guns" } }
			NOT = { has_tech = landing_craft }
		}
		else = {
			NOT = { has_tech = mtg_landing_craft }
		}
		date < 1940.4.16
	}
	abort = {
		OR = {
			has_tech = landing_craft
			has_tech = mtg_landing_craft
			date > 1940.4.16
		}
	}

	ai_strategy = {
		type = invade
		id = FRA
		value = -2000 # that low means not going for islands either
	}

	# danzig corridor is too small to be worth opening extra invasion front
	ai_strategy = {
		type = invade
		id = POL
		value = -500
	}
}

GER_worry_about_barbarossa_before_africa = {
	allowed = {
		original_tag = GER
	}
	enable = {
		country_exists = SOV
		NOT = {	is_in_faction_with = SOV }
		has_war_with = ENG
		is_historical_focus_on = yes
	}

	abort_when_not_enabled = yes

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

	ai_strategy = {
		type = area_priority
		id = east_africa
		value = -200
	}
	ai_strategy = {
		type = front_unit_request
		area = east_africa
		value = -100
	}
	ai_strategy = {
		type = area_priority
		id = belgian_congo
		value = -200
	}
	ai_strategy = {
		type = invasion_unit_request
		area = belgian_congo
		value = -50
	}
}

GER_make_sure_poland_is_ganked_before_we_move = {
	allowed = {
		original_tag = GER
	}
	enable = {
		has_war_with = POL
		POL = { has_capitulated = no }
		date < 1940.4.1
	}
	abort = {
		OR = {
			POL = {
				has_capitulated = yes
                days_since_capitulated > 8
			}
			date > 1940.4.1
		}
	}

	ai_strategy = {
		type = conquer
		id = HOL
		value = -2000
	}
	ai_strategy = {
		type = conquer
		id = BEL
		value = -2000
	}
	ai_strategy = {
		type = conquer
		id = LUX
		value = -2000
	}
}

#make_sure_poland_is_ganked_before_we_move_bel = {
#	allowed = {
#		original_tag = GER
#	}
#	enable = {
#		has_war_with = POL
#		POL = { has_capitulated = no }
#		date < 1940.2.1
#	}
#	abort = {
#		OR = {
#			POL = {
#				has_capitulated = yes
#                days_since_capitulated > 16
#			}
#			date > 1940.2.1
#		}
#	}
#	ai_strategy = {
#		type = declare_war
#		id = BEL
#		value = -2000
#	}
#}

GER_want_to_invade_FRA_without_ITA = {
	allowed = {
		original_tag = GER
	}
	enable = {
		is_historical_focus_on = yes
		date < 1940.5.16
		FRA = {
			is_ai = yes
		}
		HOL = {	has_capitulated = no }
		BEL = {	has_capitulated = no }
	}

	abort = {
		OR = {
			date > 1940.5.16
			FRA = {
				is_ai = no
			}
			AND = {
				HOL = {	has_capitulated = yes }
				BEL = {	has_capitulated = yes }
			}
		}
	}

	ai_strategy = {
		type = dont_join_wars_with  # TODO seems bugged
		id = ITA
		value = 100000
	}
}

AXIS_stay_away_from_the_royal_navy = {
	enable = {
		has_war_with = ENG
		date < 1942.1.1

		OR = {
			GER = {
				naval_strength_ratio = {
					tag = ENG
  					ratio < 0.5
  				}
  			}

			# if we manage to get a foothold in UK we must do what we can to exploit it! (checks coastal states)
			divisions_in_state = { state = 127 size < 1 }
			divisions_in_state = { state = 126 size < 1 }
			divisions_in_state = { state = 125 size < 1 }
			divisions_in_state = { state = 129 size < 1 }
			divisions_in_state = { state = 130 size < 1 }
			divisions_in_state = { state = 131 size < 1 }
			divisions_in_state = { state = 123 size < 1 }
			divisions_in_state = { state = 122 size < 1 }
			divisions_in_state = { state = 132 size < 1 }
			divisions_in_state = { state = 121 size < 1 }
			divisions_in_state = { state = 136 size < 1 }
			divisions_in_state = { state = 120 size < 1 }
			divisions_in_state = { state = 133 size < 1 }
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = naval_avoid_region
		id = 18 #english channel
		value = 600 # avoid doing missions as well
	}
	ai_strategy = {
		type = naval_avoid_region
		id = 16 #around UK
		value = 100
	}
	ai_strategy = {
		type = naval_avoid_region
		id = 43 #around UK
		value = 100
	}
}

GER_dont_take_claims_on_POL_we_got_focus = {
	allowed = {
		original_tag = GER
	}
	enable = {
		country_exists = POL
		has_war = no
		has_completed_focus = GER_reassert_eastern_claims
	}

	abort = {
		OR = {
			NOT = { country_exists = POL }
			date > 1940.1.1
			has_war = yes
		}
	}

	ai_strategy = {
		type = ignore_claim
		id = POL
		value = 1
	}
}

AXIS_dont_mess_with_volunteers = {
	allowed = {
		OR = {
			original_tag = GER
			original_tag = ITA
		}
	}
	enable = {
		date < 1941.6.1
	}
	abort = {
		date > 1941.6.1
	}

	ai_strategy = {
		type = send_volunteers_desire
		id = JAP
		value = -500
	}

	ai_strategy = {
		type = send_volunteers_desire
		id = CHI
		value = -500 #sorry buds
	}

	ai_strategy = {
		type = send_volunteers_desire
		id = MAN
		value = -500
	}

	ai_strategy = {
		type = send_volunteers_desire
		id = MEN
		value = -500
	}
}

GER_industry_we_are_the_baddies = {
	allowed = {
		original_tag = GER
	}
	enable = {
		date > 1937.8.1
	}
	abort={
		date > 1940.1.1
	}

	ai_strategy = {
		type = added_military_to_civilian_factory_ratio
		value = 50
	}
	ai_strategy = {
		type = air_factory_balance
		value = 100
	}
}

GER_industry_we_are_the_baddies_2 = {
	allowed = {
		original_tag = GER
	}
	enable = {
		date > 1940.1.1
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = added_military_to_civilian_factory_ratio
		value = 20
	}
}

GER_industry_we_are_the_baddies_but_not_yet = {
	allowed = {
		original_tag = GER
	}
	enable = {
		date < 1936.8.1
	}
	abort={
		date > 1937.8.1
	}

	ai_strategy = {
		type = air_factory_balance
		value = 110
	}
	ai_strategy = {
		type = role_ratio
		id = armor
		value = -50 #because doctrine this = 3
	}
}

AXIS_care_less_about_making_friends = {

	enable = {
		has_government = fascism
		is_in_faction = yes
		manpower_per_military_factory < 3000
		has_war = yes
	}
	abort = {
		OR = {
			NOT = { has_government = fascism }
			is_in_faction = no
			manpower_per_military_factory > 3000
			has_war = no
		}
	}

	ai_strategy = {
		type = pp_spend_priority
		id = relation
		value = -9999
	}
}

GER_wants_civ = {
	allowed = {
		original_tag = GER
	}
	enable = {
		has_government = fascism
		date < 1937.9.15
		has_war = no
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = building_target
		id = industrial_complex
		value = 59
	}
}

GER_wants_synth = {
	allowed = {
		original_tag = GER
	}
	enable = {
		has_government = fascism
		date > 1937.10.20
		has_war = no
		synthetic_refinery < 8
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = building_target
		id = synthetic_refinery
		value = 8
	}
}

GER_share_borders_with_ITA_against_SOV = {
	allowed = {
		original_tag = GER
	}
	enable = {
		is_in_faction_with = ITA
		going_war_with_SOV = yes

		GER_should_split_SOV_front_with_ITA = yes
	}
	abort = {
		not = {
			is_in_faction_with = ITA
			going_war_with_SOV = yes
			GER_should_continue_split_SOV_front_with_ITA = yes
		}
	}

	ai_strategy = {
		type = dont_defend_ally_borders
		id = CRO
		value = 100
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = ROM
		value = 100
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = HUN
		value = 100
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = SLO
		value = 100
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = ITA
		value = 100
	}
}

GER_we_dont_fight_pathetic_sweden = { # :O
	allowed = {
		original_tag = GER
	}
	enable = {
		is_historical_focus_on = no
		has_government = fascism
		SWE = {
			has_idea = neutrality_idea
		}
	}
	abort = {
		SWE = {
			NOT = { has_idea = neutrality_idea }
			OR = {
				is_in_faction = yes
				has_war = yes
			}
		}
	}
	ai_strategy = {
		type = antagonize
		id = SWE
		value = -200 #keep the iron coming and no one gets hurt
	}
	ai_strategy = {
		type = protect
		id = SWE
		value = 100 #keep the iron coming and no one gets hurt
	}
}

GER_we_dont_fight_pathetic_sweden_on_historical = { # :O
	allowed = {
		original_tag = GER
	}
	enable = {
		is_historical_focus_on = yes
		has_government = fascism
		SWE = {
			has_idea = neutrality_idea
		}
	}
	abort = {
		SWE = {
			NOT = { has_idea = neutrality_idea }
			OR = {
				is_in_faction = yes
				has_war = yes
			}
		}
	}
	ai_strategy = {
		type = antagonize
		id = SWE
		value = -50 #keep the iron coming and no one gets hurt
	}
	ai_strategy = {
		type = protect
		id = SWE
		value = 50 #keep the iron coming and no one gets hurt
	}
}

GER_trade_with_sweden = {
	allowed = {
		original_tag = GER
	}
	enable = {
		# if we're not communist and they're not communist
		NOT = { has_government = communism }
		NOT = { SWE = { has_government = communism } }
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = equipment_market_trade_desire
		id = SWE
		value = 60
	}
}

GER_trade_with_italy = {
	allowed = {
		original_tag = GER
	}
	enable = {
		has_government = fascism
		ITA = { has_government = fascism }
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = equipment_market_trade_desire
		id = ITA
		value = 40
	}
}

GER_market_management_after_anschluss = {
	allowed = {
		original_tag = GER
	}
	enable = {
		has_government = fascism
		OR = {
			has_completed_focus = GER_anschluss
			has_completed_focus = GER_anschluss
		}
	}
	abort_when_not_enabled = yes

	# Time to start buffer for war
	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = infantry
		value = 100000
	}
	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = support
		value = 500
	}
	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = artillery
		value = 500
	}
	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = armor
		value = 500
	}
}

GER_market_management_after_sudetenland = {
	allowed = {
		original_tag = GER
	}
	enable = {
		has_government = fascism
		has_completed_focus = GER_demand_sudetenland
	}
	abort_when_not_enabled = yes

	# Oh nein, we're not gonna sell this, we're... "saving" it...
	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = infantry
		value = 200000
	}
	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = support
		value = 1500
	}
	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = artillery
		value = 1500
	}
	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = anti_air
		value = 1500
	}
	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = anti_tank
		value = 1500
	}
	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = armor
		value = 1000
	}
	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = motorized
		value = 2000
	}
	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = train
		value = 400
	}
}

GER_spain_scw_support_la_resistance = {
	allowed = {
		original_tag = GER
		has_dlc = "La Resistance"
	}
	enable = {
		has_government = fascism
		country_exists = SPA
	}
	abort = {
		OR = {
			NOT = { country_exists = SPA }
			SPA = { has_completed_focus = SPA_join_the_allies }
		}
	}

	ai_strategy = {
		type = support
		id = SPA
		value = 100
	}

	ai_strategy = {
		type = send_volunteers_desire
		id = CHI
		value = -100 #Complicated
	}

	ai_strategy = {
		type = send_volunteers_desire
		id = SPA
		value = 100
	}
}

GER_we_are_bad_at_espionage_because_it_is_expensive_and_not_tanks = {
	allowed = {
		original_tag = GER
		has_dlc = "La Resistance"
	}
	enable = {
		has_government = fascism
		num_of_civilian_factories < 90
		num_of_civilian_factories > 30
	}
	abort = {
		num_of_civilian_factories > 90
	}
	ai_strategy = {
		type = intelligence_agency_usable_factories
		value = -20
	}
}

GER_my_precisioussss = {
	allowed = {
		original_tag = GER
	}

	enable = {
		OR = {
			date < 1944.6.1
			has_war = yes
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = send_lend_lease_desire
		id = SLO
		value = -999
	}
	ai_strategy = {
		type = send_lend_lease_desire
		id = MAN
		value = -999
	}
	ai_strategy = {
		type = send_lend_lease_desire
		id = CHI
		value = -999
	}
	ai_strategy = {
		type = send_lend_lease_desire
		id = YUN
		value = -999
	}
	ai_strategy = {
		type = send_lend_lease_desire
		id = SHX
		value = -999
	}
	ai_strategy = {
		type = send_lend_lease_desire
		id = XSM
		value = -999
	}
	ai_strategy = {
		type = send_lend_lease_desire
		id = SIK
		value = -999
	}
}

GER_let_italy_handle_french_front_alone = {
	allowed = {
		original_tag = GER
	}
	enable = {
		is_in_faction_with = ITA
		OR = {
			AND = {
				has_war_together_with = ITA
				has_war_with = FRA
			}
			focus_progress = {
				focus = GER_danzig_or_war
				progress > 0.01
			}
		}
		FRA = { has_capitulated = no } # Abort when France is out of the equation
		date < 1940.8.1
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = dont_defend_ally_borders
		id = ITA
		value = 100
	}
}

GER_ITA_close_up_maginot_line_after_FRA_falls  = {
	allowed = {
		OR = {
			original_tag = GER
			original_tag = FRA
		}
	}

	enable = {
		date < 1941.3.3
		has_war_with = FRA
		FRA = {
			has_capitulated = yes
			days_since_capitulated > 7 # let's give a week before things settle
			days_since_capitulated < 90
		}
		NOT = { has_full_control_of_state = 28 }
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = front_control

		state = 28 # close up maginot line

		ratio = 0.6

		priority = 100
		ordertype = front
		execution_type = rush
		execute_order = yes
	}

	ai_strategy = {
		type = front_unit_request

		state = 28

		value = 50 # lets put more units, should be safe
	}
}

# AI are not willing to invade if it is at war at its home against another country's home location (france...), unless it has a positive "invade" value
GER_enable_invasion_of_NOR = {
	allowed = {
		OR = {
			original_tag = GER
		}
	}
	enable = {
		# try to invade NOR if things are looking not so bad
		OR = {
			date < 1940.4.4
			FRA = { has_capitulated = yes } # uh oh, maybe we need more units against FRA
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = invade
		id = NOR
		value = 10
	}
}

GER_prepare_for_weserubung = {
	allowed = {
		original_tag = GER
	}
	enable = {
		focus_progress = {
			focus = GER_operation_weserubung
			progress > 0
		}
	}
	abort = {
		has_completed_focus = GER_operation_weserubung
		# Norway and Denmark are either defeated or have joined us (or at least not our enemies anymore)
		NOR = {
			OR = {
				has_capitulated = yes
				NOT = { has_war_with = ROOT }
			}
		}
		DEN = {
			OR = {
				has_capitulated = yes
				NOT = { has_war_with = ROOT }
			}
		}
	}

	ai_strategy = {
		type = invade
		id = NOR
		value = 100
	}
	ai_strategy = {
		type = invasion_unit_request
		tag = NOR
		value = 100
	}
	ai_strategy = {
		type = area_priority
		id = just_norway
		value = 50
	}
}

GER_no_no_definitely_not_planning_to_invade_norway = {
	# This strategy is only to make the AI understand that it needs to prepare naval invasion of Norway before starting the Weserubung focus, because invasion takes longer time to prepare than the focus takes to complete.
	allowed = {
		original_tag = GER
	}
	enable = {
		has_completed_focus = GER_danzig_or_war
		POL = { has_capitulated = yes }
	}
	abort = {
		OR = {
			has_completed_focus = GER_operation_weserubung  # already at war so no need to prepare anymore
			has_completed_focus = GER_utilize_the_nordliche_gesellschaft  # decided to befriend them instead
			date > 1940.9.1  # just for safety, if things really go south
		}
	}
	ai_strategy = {
		type = prepare_for_war
		id = NOR
		value = 100
	}
}

# focus armor units on HOL and LUX
GER_around_the_maginot = {
	allowed = {
		original_tag = GER
		is_historical_focus_on = yes
	}

	enable = {
		date < 1941.4.1
		FRA = {
			is_ai = yes
		}

		#uh oh, they are pushing
		42 = {
			is_controlled_by = GER
		}
		978 = {
			is_controlled_by = GER
		}

		# both low countries fell
		OR = {
			HOL = {
				has_capitulated = no
			}
			LUX = {
				has_capitulated = no
			}
		}

		# lux somehow joined the fun
		#NOT = { has_war_with = LUX }
		#LUX = {
		#	has_capitulated = no
		#	NOT = { is_in_faction_with = FRA }
		#}

		# we are ready to declare war on low countries
		OR = {
			focus_progress = {
				focus = GER_around_maginot
				progress > 0
			}
			AND = {
				is_in_array = { potential_and_current_enemies = HOL }
				is_in_array = { potential_and_current_enemies = LUX }
			}
		}
		is_in_array = { potential_and_current_enemies = FRA }
	}

	abort_when_not_enabled = yes

	# leave LUX for later
	#ai_strategy = {
	#	type = declare_war
	#	id = LUX
	#	value = -2000
	#}
	#ai_strategy = {
	#	type = diplo_action_desire
	#	id = LUX
	#	target = declare_war
	#	value = -50000
	#}

	ai_strategy = {
		type = front_armor_score
		id = FRA
		value = -100
	}

	ai_strategy = {
		type = front_armor_score
		id = HOL
		value = 250
	}
	ai_strategy = {
		type = prepare_for_war
		id = HOL
		value = 1000
	}
	ai_strategy = {
		type = force_concentration_front_factor
		tag = HOL
		value = 200
	}

	#ai_strategy = {
	#	type = front_armor_score
	#	id = BEL
	#	value = 100
	#}
	#ai_strategy = {
	#	type = prepare_for_war
	#	id = BEL
	#	value = 1000
	#}
	#ai_strategy = {
	#	type = force_concentration_front_factor
	#	tag = BEL
	#	value = 200
	#}

	ai_strategy = {
		type = front_armor_score
		id = LUX
		value = 100
	}
	ai_strategy = {
		type = prepare_for_war
		id = LUX
		value = 1000
	}
	ai_strategy = {
		type = force_concentration_front_factor
		tag = LUX
		value = 200
	}
}

#Pounce on BEL once the rest of the Low Countries are secured
GER_tanks_against_belgium = {
	allowed = {
		original_tag = GER
	}

	enable = {
		is_historical_focus_on = yes
		HOL = { has_capitulated = yes }
		#LUX = { has_capitulated = yes }
	}

	abort = {
		surrender_progress > 0.15 #Bring our metal bawkses home
	}

	ai_strategy = {
		type = front_armor_score
		id = BEL
		value = 100
	}
	ai_strategy = {
		type = prepare_for_war
		id = BEL
		value = 1000
	}
	ai_strategy = {
		type = force_concentration_front_factor
		tag = BEL
		value = 200
	}
}

# lets not invade until we have europe
GER_dont_invade_until_FRA_falls = {
	allowed = {
		original_tag = GER
		is_historical_focus_on = yes
	}

	enable = {
		date < 1941.3.1
		FRA = {
			has_capitulated = no
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = invasion_unit_request
		country_trigger = {
			NOT = { original_tag = NOR }  # We do want to allow invasion against norway
		}

		value = -100
	}

	ai_strategy = {
		# Even if we do invade Norway, we can play it cool there until France has fallen
		type = front_unit_request
		tag = NOR
		value = -30  
	}
}

GER_have_some_train_production = {
	allowed = {
		original_tag = GER
	}

	enable = {
		date > 1936.7.1
	}
	abort_when_not_enabled = yes
	
	ai_strategy = {
		type = equipment_production_min_factories
		id = train
		value = 1  # Always have some production of trains
	}
}

GER_stock_up_on_trains_before_barbarossa = {
	allowed = {
		original_tag = GER
	}

	enable = {
		is_historical_focus_on = yes
		date > 1940.7.1
		date < 1943.1.1
		has_war = yes
		# always = no
	}
	abort = {
		has_war_with = SOV # Barbarossa has started, let wartime prioritization do its thing
		date > 1943.1.1
	}

	#ai_strategy = {
	#	type = min_wanted_supply_trains  # Causes large spike, not optimal
	#	value = 300
	#}

	ai_strategy = {
		type = equipment_production_min_factories
		id = train
		value = 4  # Boost train production before Barbarossa
	}
}

GER_xp_upgrade_spending_land = {
	allowed = {
		original_tag = GER
	}

	enable = {
		date < 1941.6.1
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = land_xp_spend_priority
		id = upgrade_xp_cutoff
		value = 100
	}
}

GER_ignore_vichy_we_will_annex_them_later = {
	allowed = {
		original_tag = GER
	}

	enable = {
		country_exists = VIC
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = ignore
		id = VIC
		value = 100
	}
}

GER_vichy_has_served_its_purpose = {
	allowed = {
		original_tag = GER
	}

	enable = {
		country_exists = VIC
		VIC = {
			OR = {
				has_country_flag = case_anton # Germany has activated the decision

				count_triggers = { # Conditions for decision GER_case_anton
					amount = 3 # lost control of ca half french north africa
					458 = { CONTROLLER = { has_war_with = ROOT } }
					459 = { CONTROLLER = { has_war_with = ROOT } }
					460 = { CONTROLLER = { has_war_with = ROOT } }
					461 = { CONTROLLER = { has_war_with = ROOT } }
					462 = { CONTROLLER = { has_war_with = ROOT } }
					513 = { CONTROLLER = { has_war_with = ROOT } }
					665 = { CONTROLLER = { has_war_with = ROOT } }
				}
			}
		}
	}
	abort = { always = no }

	ai_strategy = {
		type = prepare_for_war
		id = VIC
		value = 100
	}
}

GER_dont_upgrade_to_weapons_3_too_early = {
	allowed = {
		original_tag = GER
	}
	enable = {
		is_historical_focus_on = yes
		has_equipment = { infantry_equipment < 60000 }
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = production_upgrade_desire_offset
		id = infantry_equipment_3
		value = -100
	}
}

GER_blitzkrieg_benelux  = {
	allowed = {
		original_tag = GER
	}

	enable = {
		date < 1940.9.15 #Don't keep pushing wildly if we haven't capitulated benelux in 4 months - we lost anyway
		OR = {
			AND = {
				focus_progress = {
					focus = GER_around_maginot
					progress > 0.01
				}
				NOT = { has_war_with = HOL  }
			}
			AND = {
				focus_progress = {
					focus = GER_around_maginot
					progress > 0.01
				}
				NOT = { has_war_with = BEL  }
			}
			AND = {
				focus_progress = {
					focus = GER_around_maginot
					progress > 0.01
				}
				NOT = { has_war_with = LUX  }
			}
			AND = {
				has_war_with = HOL
				HOL = { has_capitulated = no }
			}
			AND = {
				has_war_with = BEL
				BEL = { has_capitulated = no }
			}
			AND = {
				has_war_with = LUX
				LUX = { has_capitulated = no }
			}
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = front_control

		tag = HOL

		ratio = 0.25

		priority = 100
		ordertype = front
		execution_type = rush
		execute_order = yes
	}

	ai_strategy = {
		type = front_control

		tag = BEL

		ratio = 0.25

		priority = 100
		ordertype = front
		execution_type = rush
		execute_order = yes
	}

	ai_strategy = {
		type = front_control

		tag = LUX

		ratio = 0.25

		priority = 100
		ordertype = front
		execution_type = rush
		execute_order = yes
	}

	ai_strategy = {
		type = front_unit_request

		tag = BEL

		value = 50 # lets put more units, should be safe
	}

	ai_strategy = {
		type = front_unit_request

		tag = HOL

		value = 60 # lets put more units, should be safe
	}

	ai_strategy = {
		type = front_unit_request

		tag = LUX

		value = 50 # lets put more units, should be safe
	}
}

GER_blitz_france = {

	allowed = {
		original_tag = GER
	}

	enable = {
		date < 1940.9.1
		HOL = { has_capitulated = yes }
		is_historical_focus_on = yes
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = consider_weak
		id = FRA
		value = 25
	}

	ai_strategy = {
		type = front_control

		tag = FRA

		ratio = 0.5

		priority = 100
		ordertype = front
		execution_type = rush_weak
		execute_order = yes
	}

	ai_strategy = {
		type = force_concentration_target_weight
		state = 29 # Nord-Pas_de_Calais
		state = 785 # Picardy
		state = 16 # Ile de France
		state = 15 # Normandy
		# include Belgium as well even though we hopefully have already taken it
		state = 6 # Vlaanderen
		state = 34 # Wallonie
		state = 977 # Antwerpen

		value = 80 # +80%
	}

	ai_strategy = {
		# Avoid the areas behind the Maginot line
		type = force_concentration_target_weight
		state = 18 # Champagne
		state = 17 # Franche-Comte
		state = 28 # Alsace-Lorraine
		state = 27 # Bourgogne

		value = -60 # -60%
	}
}

GER_tanks_in_the_snow = {
	allowed = {
		original_tag = GER
	}

	enable = {
		OR = {
			focus_progress = {
				focus = GER_war_with_the_ussr
				progress > 0.01
			}
			has_completed_focus = GER_war_with_the_ussr
		}
	}

	abort = {
		surrender_progress > 0.15 #Bring our metal bawkses home
	}

	ai_strategy = {
		type = front_armor_score
		id = SOV
		value = 250
	}

	ai_strategy = {
		type = front_unit_request

		tag = SOV

		value = 40
	}

	ai_strategy = { #GER might be fighting GRE when Barbarossa needs to take place; prioritize SOV
		type = prepare_for_war
		id = SOV
		value = 100
	}
}

GER_tanks_against_france = {
	allowed = {
		original_tag = GER
	}

	enable = {
		is_historical_focus_on = yes
		HOL = { has_capitulated = yes }
		BEL = { has_capitulated = yes }
		LUX = { has_capitulated = yes }
	}

	abort = {
		surrender_progress > 0.15 #Bring our metal bawkses home
	}

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

	ai_strategy = {
		type = front_unit_request
		tag = FRA
		value = 10
	}
}

GER_abandon_ship = {
	allowed = {
		original_tag = GER
	}

	enable = {
		surrender_progress > 0.25 #Bring our metal bawkses home
	}

	abort = {
		surrender_progress < 0.25 #Bring our metal bawkses home
	}

	ai_strategy = {
		type = front_unit_request

		tag = SOV

		value = -40
	}
}

GER_blitzkrieg_russia_hard  = { #STEINER, IT IS NOT TIME YET
	allowed = {
		original_tag = GER
	}

	enable = {
		date < 1942.8.1
		OR = {
			focus_progress = {
				focus = GER_war_with_the_ussr
				progress > 0.01
			}
			has_war_with = SOV
		}
		has_equipment = { infantry_equipment > 15000 } #WE NEED GUNS
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = front_control

		tag = SOV

		ratio = 0.5

		priority = 100
		ordertype = front
		execution_type = rush
		execute_order = yes
	}
}

GER_blitzkrieg_russia_hard_air_north  = { #get GER to focus on breaking border defenses in the initial stages of Barb
	allowed = {
		original_tag = GER
	}

	enable = {
		date < 1942.1.1

		OR = {
			focus_progress = {
				focus = GER_war_with_the_ussr
				progress > 0.01
			}
			has_war_with = SOV
		}
		NOT = {
			GER = {
				controls_state = 188 
				controls_state = 189
				controls_state = 814
				controls_state = 11
				controls_state = 815
				controls_state = 190
				controls_state = 809
				controls_state = 808
				controls_state = 810
				controls_state = 12
				controls_state = 811
				controls_state = 13
				controls_state = 812
				controls_state = 191
				controls_state = 813
			}
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = strategic_air_importance
		id = 37 #Strategic Region ID - Baltic States
		value = 20000 #value of stocked main front in active combat is usually around 35,000
	}
}

GER_blitzkrieg_russia_hard_air_center  = { #get GER to focus on breaking border defenses in the initial stages of Barb
	allowed = {
		original_tag = GER
	}

	enable = {
		date < 1942.1.1
		OR = {
			focus_progress = {
				focus = GER_war_with_the_ussr
				progress > 0.01
			}
			has_war_with = SOV
		}
		NOT = {
			GER = {
				controls_state = 96
				controls_state = 784
				controls_state = 95
				controls_state = 97
				controls_state = 92
				controls_state = 94
				controls_state = 93
				controls_state = 91
				controls_state = 89
			}
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = strategic_air_importance
		id = 39 #Strategic Region ID - Eastern Poland
		value = 20000 #value of stocked main front in active combat is usually around 35,000
	}
}

GER_blitzkrieg_russia_hard_air_south  = { #get GER to focus on breaking border defenses in the initial stages of Barb
	allowed = {
		original_tag = GER
	}

	enable = {
		date < 1942.1.1

		OR = {
			focus_progress = {
				focus = GER_war_with_the_ussr
				progress > 0.01
			}
			has_war_with = SOV
		}
		NOT = {
			GER = {
				controls_state = 199
				controls_state = 201
				controls_state = 198
				controls_state = 834
				controls_state = 192
				controls_state = 202
				controls_state = 203
				controls_state = 197
				controls_state = 196
				controls_state = 137
				controls_state = 200
				controls_state = 226
				controls_state = 259
				controls_state = 193
				controls_state = 225
				controls_state = 221
				controls_state = 227
				controls_state = 228
			}
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = strategic_air_importance
		id = 130 #Strategic Region ID - Ukraine
		value = 20000 #value of stocked main front in active combat is usually around 35,000
	}
}

GER_blitzkrieg_russia_soft  = { #Rolling incursions
	allowed = {
		original_tag = GER
	}

	enable = {
		#always = no #This isn't great
		date < 1942.4.1 #To space!
		date > 1941.8.1
		has_war_with = SOV
		OR = {
			has_idea = GER_barbarossa
			SOV = { has_idea = SOV_desperate_measures_ns }
		}
		has_equipment = { infantry_equipment > 15000 } #WE NEED GUNS
		set_temp_variable = { days = global.num_days }
		modulo_temp_variable = { days = 40 }
		check_variable = { days < 20 }
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = front_control

		tag = SOV

		ratio = 0.5

		priority = 100
		ordertype = front
		execution_type = rush_weak
		execute_order = yes
	}

	ai_strategy = {
		type = strategic_air_importance
		id = 39 #Strategic Region ID - Southern England
		value = 10000 #value of stocked main front in active combat is usually around 35,000
	}

	ai_strategy = {
		type = strategic_air_importance
		id = 130 #Strategic Region ID - Southern England
		value = 10000 #value of stocked main front in active combat is usually around 35,000
	}
}

GER_normandy_buffer = {
	allowed = {
		original_tag = GER
	}
	enable = {
		is_historical_focus_on = yes
		FRA = {
			has_capitulated = yes
		}
		date < 1943.1.1
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = put_unit_buffers
		states = {
			14
			15
			29
			735
			22
		}
		ratio = 0.11
		area = normandy_landing_zone
		subtract_invasions_from_need = no
		subtract_fronts_from_need = yes
	}

	ai_strategy = {
		type = role_ratio
		id = garrison
		value = 10
	}
}

GER_invasion_buffer = {
	allowed = {
		original_tag = GER
	}
	enable = {
		is_historical_focus_on = yes
		FRA = {
			has_capitulated = yes
		}
		date > 1943.1.1
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = put_unit_buffers
		states = {
			15
			14
			23
			29
			6
		}
		ratio = 0.20
		area = normandy_landing_zone
		subtract_invasions_from_need = no
		subtract_fronts_from_need = yes
	}
	ai_strategy = {
		type = role_ratio
		id = garrison
		value = 10
	}
}

GER_build_more_cas_to_invade_russia = {
	allowed = {
		original_tag = GER
	}
	enable = {
		is_historical_focus_on = yes
		FRA = {
			has_capitulated = yes
		}
		date > 1940.1.1
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = equipment_production_factor
		id = cas
		value = 60
	}
}

GER_push_back_our_coasts_until_overlord  = {
	allowed = {
		original_tag = GER
	}

	enable = {
		always = no #No longer necessary, leaving for reference
		date < 1943.6.6
		is_historical_focus_on = yes
		FRA = { has_capitulated = yes }
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = front_control

		tag = HOL

		ratio = 0.25

		priority = 100
		ordertype = front
		execution_type = balanced
		execute_order = yes
	}

	ai_strategy = {
		type = front_control

		tag = BEL

		ratio = 0.25

		priority = 100
		ordertype = front
		execution_type = balanced
		execute_order = yes
	}

	ai_strategy = {
		type = front_control

		tag = FRA

		ratio = 0.25

		priority = 100
		ordertype = front
		execution_type = balanced
		execute_order = yes
	}

	ai_strategy = {
		type = front_unit_request

		tag = BEL

		value = 25
	}

	ai_strategy = {
		type = front_unit_request

		tag = HOL

		value = 25 # lets put more units, should be safe
	}

	ai_strategy = {
		type = front_unit_request

		tag = FRA

		value = 25
	}
}

GER_pause_in_SOV = { #We got this far but our home is under siege
	allowed = {
		original_tag = GER
	}

	enable = {
		is_historical_focus_on = yes
		has_war_with = SOV
		SOV = { has_capitulated = no }
		OR = {
			surrender_progress > 0.25
			16 = {
				controller = {
					has_war_with = GER
				}
			}
		}
		date > 1942.1.1
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = front_control

		tag = SOV

		ratio = 0.60

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

	ai_strategy = {
		type = front_unit_request

		tag = FRA

		value = 20 # omg no, the french
	}

	ai_strategy = {
		type = front_unit_request

		tag = SOV

		value = -20 # FLEE
	}
}

GER_make_some_radar_2 = {
	allowed = {
		original_tag = GER
	}
	enable = {
		has_tech = radio_detection
	}

	abort = {
		has_tech = cavity_magnatron
	}

	ai_strategy = {
		type = research_weight_factor
		id = cavity_magnatron
		value = 2000
	}
}

GER_make_some_radar_4 = {
	allowed = {
		original_tag = GER
	}
	enable = {
		has_tech = radio_detection
		90 = {
			is_controlled_by = FROM
			free_building_slots = {
				building = radar_station
				size > 0
			}
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = build_building
		id = radar_station
		target = 90 #Kielce
		value = 2000
	}
}

GER_make_some_radar_5 = {
	allowed = {
		original_tag = GER
	}
	enable = {
		has_tech = radio_detection
		763 = {
			is_controlled_by = FROM
			free_building_slots = {
				building = radar_station
				size > 0
			}
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = build_building
		id = radar_station
		target = 763 #Konigsberg
		value = 2000
	}
}

GER_make_some_radar_6 = {
	allowed = {
		original_tag = GER
	}
	enable = {
		has_tech = radio_detection
		36 = {
			is_controlled_by = FROM
			free_building_slots = {
				building = radar_station
				size > 0
			}
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = build_building
		id = radar_station
		target = 36 #Holland
		value = 2000
	}
}

GER_make_some_radar_7 = {
	allowed = {
		original_tag = GER
	}
	enable = {
		has_tech = radio_detection
		42 = {
			is_controlled_by = FROM
			free_building_slots = {
				building = radar_station
				size > 0
			}
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = build_building
		id = radar_station
		target = 42 #Moselland
		value = 2000
	}
}

GER_focus_yugo = {
	allowed = { original_tag = GER }
	enable = {
		has_war_with = YUG
		YUG = { has_capitulated = no }
		is_historical_focus_on = yes
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = strategic_air_importance
		id = 24 #Strategic Region ID - Western Balkans
		value = 30000
	}
}

GER_protect_hungary = {
	allowed = { original_tag = GER }
	enable = {
		is_historical_focus_on = yes
		HUN = {
			has_government = fascism
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = protect
		id = HUN
		value = 50
	}
}

GER_protect_romania = {
	allowed = { original_tag = GER }
	enable = {
		is_historical_focus_on = yes
		ROM = {
			OR = {
				has_government = fascism
				has_government = neutrality
			}
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = protect
		id = ROM
		value = 50
	}
}

GER_avoid_war_with_SWI = {
	allowed = { original_tag = GER }
	enable = {
		is_historical_focus_on = yes
		SWI = {
			exists = yes
		}
	}
	abort = {
		OR = {
			has_wargoal_against = SWI
			SWI = {
				NOT = { has_idea = SWI_swiss_neutrality }
			}
		}
	}

	ai_strategy = {
		type = conquer
		id = SWI
		value = -999
	}

	ai_strategy = {
		type = antagonize
		id = SWI
		value = -75
	}
}

GER_bba_air_prod_1 = {
	# TODO BFW:
	allowed = { original_tag = GER }
	enable = {
		date < 1940.1.1
	}

	abort_when_not_enabled = yes

	# Air unit factors
	ai_strategy = {
		type = unit_ratio
		id = fighter
		value = 200
	}

	ai_strategy = {
		type = equipment_production_factor
		id = fighter
		value = 15
	}

	ai_strategy = {
		type = equipment_production_min_factories
		id = fighter
		value = 6  # Germany needs a minimum production of fighters
	}

	ai_strategy = {
		type = unit_ratio
		id = cas
		value = 25 # because doctrine this = 15
	}

 	ai_strategy = {
		type = equipment_production_factor
		id = cas
		value = 10
	}

	ai_strategy = {
		type = equipment_production_min_factories
		id = cas
		value = 5  # Germany needs a minimum production of CAS planes
	}

	ai_strategy = {
		type = unit_ratio
		id = naval_bomber
		value = 5
	}

	ai_strategy = {
		type = unit_ratio
		id = tactical_bomber
		value = 10
	}

	ai_strategy = {
		type = equipment_production_factor
		id = tactical_bomber
		value = 5
	}

	ai_strategy = {
		type = unit_ratio
		id = strategic_bomber
		value = 1
	}

	ai_strategy = {
		type = equipment_production_factor
		id = strategic_bomber
		value = 1
	}

	ai_strategy = {
		type = equipment_variant_production_factor
		id = large_plane_airframe
		value = 0
	}

	ai_strategy = {
		type = equipment_production_factor
		id = heavy_fighter
		value = 2
	}

	ai_strategy = {
		type = unit_ratio
		id = heavy_fighter
		value = 2
	}
}

GER_bba_air_prod_2 = {
	# TODO BFW:
	allowed = { original_tag = GER }
	enable = {
		date > 1940.1.1
	}
	abort_when_not_enabled = yes

	#Air unit factors
	ai_strategy = {
		type = unit_ratio
		id = fighter
		value = 300
	}

	ai_strategy = {
		type = equipment_production_factor
		id = fighter
		value = 25
	}

	ai_strategy = {
		type = equipment_production_min_factories
		id = fighter
		value = 8
	}

	ai_strategy = {
		type = unit_ratio
		id = cas
		value = 25 #because doctrine this = 15
	}

	ai_strategy = {
		type = equipment_production_factor
		id = cas
		value = 15
	}

	ai_strategy = {
		type = equipment_production_min_factories
		id = cas
		value = 5
	}

	ai_strategy = {
		type = unit_ratio
		id = naval_bomber
		value = 5
	}

	ai_strategy = {
		type = unit_ratio
		id = tactical_bomber
		value = 15
	}

	ai_strategy = {
		type = equipment_production_factor
		id = tactical_bomber
		value = 5
	}

	ai_strategy = {
		type = unit_ratio
		id = strategic_bomber
		value = 1
	}

	ai_strategy = {
		type = equipment_production_factor
		id = strategic_bomber
		value = 0
	}

	ai_strategy = {
		type = equipment_variant_production_factor
		id = large_plane_airframe
		value = 0
	}

	ai_strategy = {
		type = equipment_production_factor
		id = heavy_fighter
		value = 3
	}

	ai_strategy = {
		type = unit_ratio
		id = heavy_fighter
		value = 3
	}
}

GER_gotta_have_enough_medium_tanks = {
	allowed = {
		original_tag = GER
	}
	enable = {
		date > 1938.8.1
		has_tech = basic_medium_tank_chassis
		stockpile_ratio = {
			archetype = medium_tank_chassis
			ratio < 1.3
		}
	}
	abort_when_not_enabled = yes
	
	ai_strategy = {
		type = equipment_production_min_factories_archetype
		id = motorized_equipment
		value = 1
	}
	
	ai_strategy = {
		type = equipment_production_min_factories_archetype
		id = medium_tank_chassis
		value = 3  # Germany need medium tanks to crush the enemies!
	}
}

GER_gotta_have_enough_light_tanks = {
	allowed = {
		original_tag = GER
	}
	enable = {
		date > 1938.1.1
		stockpile_ratio = {
			archetype = light_tank_chassis
			ratio < 1.3
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = equipment_production_min_factories_archetype
		id = light_tank_chassis
		value = 1  # Germany need light tanks to support their bigger brother tanks
	}
}

GER_dont_act_on_danzig_if_things_went_south = {
	allowed = {
		original_tag = GER
	}
	enable = {
		has_war_with = CZE
		date < 1940.6.1
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = declare_war
		id = POL
		value = -2000
	}
}

GER_dont_send_half_the_army_to_finland_if_not_in_our_faction = {
	allowed = {
		original_tag = GER
	}
	enable = {
		FIN = { has_war_with = SOV }
		has_war_with = SOV
		NOT = { is_in_faction_with = FIN }
		has_military_access_to = FIN
		925 = { is_controlled_by = ROOT }  # Germany still controls Finnmark in Northern Norway

		# Safety measures, if Soviets have lost Leningrad or Novgorod the Finnish and German frontlines are probably close to becoming one, and then we need to disable the strategy
		195 = { is_controlled_by = SOV }  # Leningrad
		263 = { is_controlled_by = SOV }  # Novgorod
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = put_unit_buffers

		# ratio of total armies in country to be buffered
		ratio = 0.05

		# states to put garrison orders (if no state is friendly, strat is invalid)
		states = {
			925  # Finnmark
		}

		# ai areas that the orders will use these buffers in
		area = scandinavia
	}

	ai_strategy = {
		type = front_unit_request

		# As long as the front touches any of these regions. I hope this doesn't mess up the bigger Eastern Front if the Finnish and German frontlines merge...
		strategic_region = 13  # Eastern Finland
		strategic_region = 277  # Northern Finland
		strategic_region = 265  # East Karelia
		strategic_region = 12  # Kola

		value = -90
	}

	ai_strategy = {
		type = send_lend_lease_desire
		id = FIN
		value = 200
	}
}

GER_protect_swedish_ore = {
	allowed = {
		original_tag = GER
	}
	enable = {
		NOT = { has_war_with = SWE }
		SWE = { has_capitulated = no }

		142 = { is_fully_controlled_by = ROOT }
		110 = { is_fully_controlled_by = ROOT }
		143 = { is_fully_controlled_by = ROOT }
		144 = { is_fully_controlled_by = ROOT }
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = put_unit_buffers

		# ratio of total armies in country to be buffered
		ratio = 0.05

		# you can specify an order id. ratio of same orders ids will be share same ratio
		order_id = 1

		# states to put garrison orders (if no state is friendly, strat is invalid)
		states = {
			142
			110
			143
			144
		}

		# ai areas that the orders will use these buffers in
		area = europe
	}
}

GER_TEMP_avoid_sweden = {
	allowed = {
		original_tag = GER
	}
	enable = {
		country_exists = SWE
		is_historical_focus_on = yes
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = conquer
		id = SWE
		value = -999
	}
}

GER_SWE_nils_flyg_is_in_charge_and_he_is_a_weird_communist_that_does_not_like_stalin_so_we_like_him = {
	allowed = {
		original_tag = GER
	}
	enable = {
		country_exists = SWE
		SWE = {
			has_country_leader = {
				ruling_only = yes
				character = SWE_nils_flyg
			}
			has_government = communism
		}
	}
	abort = {
		SWE = {
			NOT = {
				has_government = communism
				has_country_leader = {
					ruling_only = yes
					character = SWE_nils_flyg
				}
			}
		}
	}

	ai_strategy = {
		type = avoid_starting_wars
		id = SWE
		value = 200
	}

	ai_strategy = {
		type = befriend
		id = SWE
		value = 200
	}

	ai_strategy = {
		type = alliance
		id = SWE
		value = 1000
	}
}

GER_sweden_was_a_puppet_and_broke_free_so_now_we_are_angry = {
	allowed = {
		original_tag = GER
	}
	enable = {
		has_country_flag = sweden_was_a_puppet_and_has_broken_free
	}

	abort = {
		NOT = { has_country_flag = sweden_was_a_puppet_and_has_broken_free }
	}

	ai_strategy = {
		type = conquer
		id = SWE
		value = 200
	}
	ai_strategy = {
		type = antagonize
		id = SWE
		value = 200
	}
}

GER_sweden_joined_our_pact_so_we_are_kinda_happy = {
	allowed = {
		original_tag = GER
	}
	enable = {
		SWE = { has_completed_focus = SWE_join_the_anti_soviet_pact }
	}

	abort = {
		SWE = { has_war_with = GER }
	}

	ai_strategy = {
		type = alliance
		id = SWE
		value = 50
	}
	ai_strategy = {
		type = protect
		id = SWE
		value = 70
	}
}

GER_dont_DOW_benelux = { #Don't try to bypass Around the Maginot!
	allowed = {
		original_tag = GER
	}
	enable = {
		is_historical_focus_on = yes
	}

	abort = {
		OR = {
			has_completed_focus = GER_around_maginot
			has_completed_focus = GER_oppose_hitler_ww
			has_war_with = HOL
			has_war_with = BEL
			has_war_with = LUX
		}
	}

	ai_strategy = {
		type = declare_war
		id = HOL
		value = -300
	}
	ai_strategy = {
		type = declare_war
		id = BEL
		value = -300
	}
	ai_strategy = {
		type = declare_war
		id = LUX
		value = -300
	}
}

# FACTION RELATED STRATEGIES

GER_base_faction_priorities = {
	allowed = {
		original_tag = GER
	}
	enable = {
		always = yes
	}
	abort_when_not_enabled = yes
	# Note these adds to the base, as defined in default
	ai_strategy = {
		type = spent_faction_initiative_priority
		id = program
		value = 15
	}
	ai_strategy = {
		type = spent_faction_initiative_priority
		id = unlock_faction_commander
		value = 5
	}
	ai_strategy = {
		type = spent_faction_initiative_priority
		id = unlock_doctrine_sharing
		value = 10
	}
}


# SPECIAL PROJECT FACILITIES
# Penemnde
GER_build_an_air_facility_in_penemunde = {
	allowed = {
		original_tag = GER
	}
	enable = {
		62 = { is_owned_and_controlled_by = GER }
		air_facility < 1 # one is enough
		date > 1940.6.1 # Was 1937.2.1 Moving it to later in order to let them focus on building their industry
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = build_building
		id = air_facility
		target = 9388
		value = 1
	}
}

GER_build_an_air_facility_anywhere = {
	allowed = {
		original_tag = GER
	}
	enable = {
		62 = { NOT = { is_owned_and_controlled_by = GER } }
		air_facility < 1 # one is enough
		date > 1940.6.1 # Was 1937.2.1
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = build_building
		id = air_facility
		value = 1
	}
}

GER_tanks_in_greece = { #Gotta rush GRE so we're ready for SOV
	allowed = {
		original_tag = GER
	}

	enable = {
		has_war_with = GRE
	}

	abort = {
		OR = {
			focus_progress = {
				focus = GER_war_with_the_ussr
				progress > 0.01
			}
			has_war_with = SOV
		}
	}

	#ai_strategy = {
	#	type = front_armor_score
	#	id = GRE
	#	value = -50
	#}

	ai_strategy = {
		type = front_unit_request
		tag = GRE
		value = 30
	}
}

#Yo-ho-ho and a bottle of rum! We set sail for the North Sea aaaargh!
GER_raid_the_north_sea = {
	allowed = { original_tag = GER }
	enable = {
		has_war = yes
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = naval_convoy_raid_region
		id = 45 #Norwegian Sea
		value = 100
	}
	ai_strategy = {
		type = naval_convoy_raid_region
		id = 174 #Norwegian coast
		value = 250
	}
	ai_strategy = {
		type = naval_convoy_raid_region
		id = 173 #Eastern North Sea
		value = 250
	}
	ai_strategy = {
		type = naval_convoy_raid_region
		id = 207 #Danish Belts
		value = 100
	}
}

#Yo-ho-ho and a bottle of rum! We set sail for the North Atlantic aaaargh!
GER_raid_the_atlantic = {
	allowed = { original_tag = GER }
	enable = {
		OR = {
			has_war_with = ENG
			has_war_with = USA
		}
		#Gotta control the Western coast of France
		any_controlled_state = {
			OR = {
				state = 14
				state = 30
				state = 23
				state = 19
			}
		}
		has_navy_size = {
		    type = submarine
		    size > 40
		}
	}
	abort = {
		has_war = no
		NOT = {
			any_controlled_state = {
				state = 14
				state = 30
				state = 23
				state = 19
			}
		}
		has_navy_size = {
		    type = submarine
		    size < 30
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = naval_convoy_raid_region
		id = 42 #Bay of Biscay
		value = 250
	}
	ai_strategy = {
		type = naval_convoy_raid_region
		id = 47 #Iberian Coast
		value = 250
	}
	ai_strategy = {
		type = naval_convoy_raid_region
		id = 49 #North Atlantic Ridge
		value = 250
	}
	ai_strategy = {
		type = naval_convoy_raid_region
		id = 49 #North Atlantic Ridge
		value = 250
	}
	ai_strategy = {
		type = naval_convoy_raid_region
		id = 44 #Denmark Strait
		value = 250
	}
	ai_strategy = {
		type = naval_convoy_raid_region
		id = 56 #Mid Atlantic
		value = 100
	}
}