# befriend
# conquer
# antagonize
# build_ship
# build_army
# unit_ratio
# build_building
# research_tech
# garrison
# protect
# influence
# contain
# area_priority
# building_target


GER_unit_production = {
	enable = {
		original_tag = GER
	}
	abort = {
		always = no
	}
	
	ai_strategy = {
		type = role_ratio
		id = garrison
		value = 4
	}

	# Old garrison system against resistance
	# ai_strategy = {
	# 	type = role_ratio
	# 	id = suppression
	# 	value = 6
	# }
	
	ai_strategy = {
		type = role_ratio
		id = paratroopers
		value = 0
	}

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

	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 = -200 #because doctrine this = 2
	}

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

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

	ai_strategy = {
		type = role_ratio
		id = infantry
		value = 70 #88 to 70
	}
	
	#Air unit factors
	ai_strategy = {
		type = unit_ratio
		id = fighter
		value = 100
	}
	
	ai_strategy = {
		type = unit_ratio
		id = cas
		value = -35 #because doctrine this = 15
	}
	
	ai_strategy = {
		type = unit_ratio
		id = tactical_bomber
		value = -40
	}
	
	ai_strategy = {
		type = unit_ratio
		id = strategic_bomber
		value = -10
	}
	
	ai_strategy = {
		type = unit_ratio
		id = naval_bomber
		value = 5
	}
	
	
	# Naval unit factors
	ai_strategy = {
		type = unit_ratio
		id = capital_ship
		value = 0
	}

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

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

	ai_strategy = {
		type = unit_ratio
		id = convoy
		value = -100
	}
	
	ai_strategy = {
		type = equipment_production_factor
		id = fighter
		value = 180
	}

	ai_strategy = {
		type = equipment_production_factor
		id = cas
		value = -65
	}

	ai_strategy = {
		type = equipment_production_factor
		id = tactical_bomber
		value = -80
	}

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

	ai_strategy = {
		type = equipment_production_factor
		id = strategic_bomber
		value = -200
	}
	
	ai_strategy = {
		type = equipment_production_factor
		id = infantry
		value = 0 #30 to 50
	}

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

	ai_strategy = {
		type = equipment_production_factor
		id = anti_air
		value = 50
	}
	
	ai_strategy = {
		type = equipment_production_factor
		id = artillery
		value = 85 #20 to 40
	}
	
	ai_strategy = {
		type = equipment_production_factor
		id = armor
		value = -10 
	} 
	ai_strategy = {
		type = equipment_production_factor
		id = motorized
		value = -70
	}
	ai_strategy = {
		type = equipment_production_min_factories
		id = artillery
		value = 3
	}
	ai_strategy = {
		type = equipment_production_min_factories
		id = fighter
		value = 4
	}
	ai_strategy = {
		type = equipment_variant_production_factor
		id = strat_bomber_equipment
		value = -100
	}
	ai_strategy = {
		type = equipment_variant_production_factor
		id = support_equipment
		value = 30
	}
}	

GER_anti_armor = {
	enable = {
		original_tag = GER
		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_armored_production = {
	enable = {
		date > 1939.1.1
		original_tag = GER
		ai_wants_divisions > 24 #Decreasing the amount of tanks the AI wants
	}
	abort = {
		ai_wants_divisions < 25 #Decreasing the amount of tanks the AI wants
	}

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

GER_halt_light_armor_production_in_transitioning = {
	enable = {
		original_tag = GER
		has_template_majority_unit = medium_armor
		OR = {
			has_equipment = { light_tank_equipment > 600 }
			date > 1939.1.1
		}		
	}
	abort = {
		# once we start we never go back to light armor
	}

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

GER_stockpile_less_early_game = {
	allowed = { 
		tag = GER 
	}

	enable = {
		tag = GER
		date < 1937.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_highered_armored_production = {
	enable = {
		original_tag = GER
		num_of_military_factories > 109
	}
	abort = {
		num_of_military_factories < 110
	}

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

GER_super_boost_light_for_med_armor = {
	
	enable = {
		original_tag = GER
		has_tech = basic_medium_tank
		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 = template_xp_reserve 
		value = -125
	}

	# 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 = {
	
	enable = {
		original_tag = GER
		has_tech = main_battle_tank
		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 = template_xp_reserve 
		value = -125
	}

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

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


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

	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 = medium_armor
		value = 50
	}

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

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

war_with_poland = {
	enable = {
		tag = GER
		country_exists = DEN
		has_completed_focus = WTT_attackwildlings
	}
	abort = {
		NOT = { country_exists = DEN }
	}
	
	ai_strategy = {
		type = antagonize
		id = "DEN"
		value = 200
	}
}

danzig_of_war_preparation = {
	enable = {
		tag = GER
		focus_progress = {
			focus = GER_danzig_or_war
			progress > 0.01
		}
		NOT = {
			has_completed_focus = WTT_takenorth
#			owns_state = 85 
		}
		country_exists = POL
	}
	
	abort = {
		OR = {
			NOT = { country_exists = FIN }
			
			AND = {
				has_completed_focus = WTT_takenorth
				GER = { has_war_with = FIN }
			}
			
#			owns_state = 85 
		}
	}
	
	ai_strategy = {
		type = conquer
		id = "FIN"
		value = 100
	}
}

dont_kill_craster = {
	enable = {
		tag = GER
#		date < 1942.5.1
		country_exists = ICE
		country_exists = CAN
	}
	abort = {
		NOT = { ICE = { has_country_leader = { ruling_only = yes name = "Craster Valurson" } } }
#		date > 1942.5.1
	}
	
	ai_strategy = {
		type = ignore
		id = "ICE"
		value = 100
	}
}

war_with_soviets = {
	enable = {
		tag = GER
		country_exists = FIN
		GER = { has_completed_focus = WTT_takenorth }
	}
	abort = {
		NOT = { country_exists = FIN }
	}
	
	ai_strategy = {
		type = antagonize
		id = "FIN"			
		value = 200
	}
}

anschluss_rejected = {
	enable = {
		tag = GER
		country_exists = CAN
		GER = { has_completed_focus = WTT_attackthewall }
	}
	abort = {
		NOT = {
			country_exists = CAN
		}
	}
	
	ai_strategy = {
		type = antagonize
		id = "CAN"			
		value = 300
	}		
}

CZE_is_idiot = {
	enable = {
		tag = CAN
#		has_global_flag = CZE_refused_sudetenland
		NOT = { has_global_flag = wildlings_can_pass }
		country_exists = DEN
	}
	abort = {
		NOT = {
			country_exists = DEN
		}
	}
	
	ai_strategy = {
		type = antagonize
		id = "DEN"			
		value = 300
	}		
}

play_nice_with_ribbentrop_pact = {
	enable = {
		tag = GER
		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
	}
}

tfv_protect_fascist_south_africa = {
	enable = {
		original_tag = GER
		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_area_priority = {
	enable = {
		original_tag = GER
	}

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

	ai_strategy = {
		type = area_priority
		id = north_america
		value = 0
	}
	
	ai_strategy = {
		type = area_priority
		id = south_america
		value = 0
	}
	
	ai_strategy = {
		type = area_priority
		id = asia
		value = 0
	}
	
	ai_strategy = {
		type = area_priority
		id = middle_east
		value = 0
	}
	ai_strategy = {
		type = area_priority
		id = suez
		value = 30
	}
	
	ai_strategy = {
		type = area_priority
		id = africa
		value = -90
	}
	
	ai_strategy = {
		type = area_priority
		id = pacific
		value = -120 #less focus here
	}
	
	ai_strategy = {
		type = area_priority
		id = oceania
		value = -80
	}
}

worry_about_barbarossa_before_africa = {
	enable = {
		tag = GER

		country_exists = SOV
		NOT = {	is_in_faction_with = SOV }
		has_war_with = ENG
		ENG = { is_ai = yes }
	}

	abort_when_not_enabled = yes

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

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
	}
}

dont_take_claims_on_POL_we_got_focus = {
	enable = {
		tag = GER
		country_exists = POL
		has_war = no
#		has_completed_focus = GER_demand_memel
	}

	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 = {
	enable = {
		tag = GER
	}
	abort = {
#		date > 1941.6.1
	}

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

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

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

GER_industry_we_are_the_baddies = {
	enable = {
		tag = GER
		date < 1940.1.1
		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 = 105 
	} 
}

GER_industry_we_are_the_baddies_2 = {
	enable = {
		tag = GER
		date > 1940.1.1
	}

	ai_strategy = {
		type = added_military_to_civilian_factory_ratio
		value = 20
	}
}

GER_industry_we_are_the_baddies_but_not_yet = {
	enable = {
		tag = GER
		date < 1937.8.1
	}
	abort={
		date > 1937.8.1 
	}

	ai_strategy = {
		type = air_factory_balance
		value = 115
	} 
	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 = no
		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 = {
	enable = {
		tag = GER
		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_share_borders_with_ITA_against_SOV = {
	enable = {
		tag = GER
		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_are_bad_at_espionage_because_it_is_expensive_and_not_tanks = {
	enable = {
		tag = GER
		has_government = fascism
		has_dlc = "La Resistance"
		num_of_civilian_factories < 90
		num_of_civilian_factories > 30
	}
	abort = {
		OR = {
			num_of_civilian_factories > 90
		}
	}
	ai_strategy = {
		type = intelligence_agency_usable_factories
		value = -20
	}
}

GER_my_precisioussss = {
	allowed = {
		tag = GER
	}

	enable = {
		tag = GER
#		OR = {
#			date < 1942.6.1
#			has_war = yes
#		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = send_lend_lease_desire
		id = FIN
		value = -999
	}
	ai_strategy = {
		type = send_lend_lease_desire
		id = HOL
		value = -999
	}
	ai_strategy = {
		type = send_lend_lease_desire
		id = HUN
		value = -999
	}
	ai_strategy = {
		type = send_lend_lease_desire
		id = ENG
		value = -999
	}
	ai_strategy = {
		type = send_lend_lease_desire
		id = FRA
		value = -999
	}
	ai_strategy = {
		type = send_lend_lease_desire
		id = SWE
		value = -999
	}
	ai_strategy = {
		type = send_lend_lease_desire
		id = SPR
		value = -999
	}
	ai_strategy = {
		type = send_lend_lease_desire
		id = BEL
		value = -999
	}
	ai_strategy = {
		type = send_lend_lease_desire
		id = ITA
		value = -999
	}
	ai_strategy = {
		type = send_lend_lease_desire
		id = NOR
		value = -999
	}
	ai_strategy = {
		type = send_lend_lease_desire
		id = ROM
		value = -999
	}
	ai_strategy = {
		type = send_lend_lease_desire
		id = SOV
		value = -999
	}	
}

GER_let_italy_handle_french_front_alone = {
	enable = {
		tag = GER
		is_in_faction_with = ITA
		has_war_together_with = ITA
		has_war_with = FRA
		date < 1940.8.1
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = dont_defend_ally_borders
		id = "ITA"
		value = 100
	}
}


# AI are not willing to invade if it is at war at its home against another country's home location
# lets force invade NOR for GER & ITA
#GER_enable_invasion_of_NOR = {
#	allowed = {
#		OR = {
#			original_tag = GER
#			original_tag = ITA
#		}
#	}
#	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
#	}
#}


# 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 = { always = yes }

		value = -100
	}
	
	ai_strategy = {
		type = front_unit_request
		
		# norway
		state = 110
		state = 142
		state = 143
		state = 144

		value = -100
	}
}