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

ENG_unit_production = {
	enable = {
		original_tag = ENG
	}
	abort = {
		always = no
	}
	
	ai_strategy = {
		type = role_ratio
		id = garrison
		value = 7
	}
	
	# Old garrison system against resistance
	# ai_strategy = {
	# 	type = role_ratio
	# 	id = suppression
	# 	value = 1
	# }


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

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

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

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

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

	ai_strategy = {
		type = role_ratio
		id = infantry
		value = 70
	}
	
	#Air unit factors
	ai_strategy = {
		type = unit_ratio
		id = fighter
		value = 80
	}
	
	ai_strategy = {
		type = unit_ratio
		id = cas
		value = 0
	}
	
	ai_strategy = {
		type = unit_ratio
		id = tactical_bomber
		value = 0
	}
	
	ai_strategy = {
		type = unit_ratio
		id = strategic_bomber
		value = 0
	}
	
	ai_strategy = {
		type = unit_ratio
		id = naval_bomber
		value = 0
	}
	
	
	# Naval unit factors
	ai_strategy = {
		type = unit_ratio
		id = capital_ship
		value = 5
	}

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

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

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

	ai_strategy = {
		type = unit_ratio
		id = convoy
		value = 100
	}
	
	ai_strategy = {
		type = equipment_production_factor
		id = fighter
		value = 90
	}
	
	ai_strategy = {
		type = equipment_production_factor
		id = infantry
		value = 10
	}
	
	ai_strategy = {
		type = equipment_production_factor
		id = artillery
		value = 45
	}
	
	ai_strategy = {
		type = equipment_production_factor
		id = armor
		value = 10
	}

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

}	

#protect_poland_against_germany = {
#	enable = {
#		tag = ENG
#		GER = { has_completed_focus = GER_end_of_czechoslovakia }
#		GER = { NOT = { has_war_with = POL } }
#		country_exists = POL
#	}
#	abort = {
#		NOT = { country_exists = POL }
#	}
	
#	ai_strategy = {
#		type = protect
#		id = "POL"			
#		value = 200
#	}
#	ai_strategy = {
#		type = alliance
#		id = "POL"			
#		value = 200
#	}
#	ai_strategy = {
#		type = diplo_action_desire
#		id = POL
#		target = guarantee
#		value = 20
#	}
#}

#protect_poland_against_germany_even_more = {
#	enable = {
#		tag = ENG
#		GER = { has_completed_focus = GER_end_of_czechoslovakia }
#		GER = { NOT = { has_war_with = POL } }
#		country_exists = POL
#	}
#	abort = {
#		NOT = { country_exists = POL }
#	}
	
#	ai_strategy = {
#		type = protect
#		id = "POL"			
#		value = 200
#	}
#	ai_strategy = {
#		type = alliance
#		id = "POL"			
#		value = 200
#	}	
#}

#defend_poland_against_germany = {
#	enable = {
#		tag = ENG
#		GER = { has_war_with = POL }
#		country_exists = POL
#	}
#	abort = {
#		NOT = { country_exists = POL }
#	}
	
#	ai_strategy = {
#		type = befriend
#		id = "POL"			
#		value = 200
#	}
#	ai_strategy = {
#		type = alliance
#		id = "POL"			
#		value = 200
#	}	
#}

royal_air_force = {
	enable = {
		tag = ENG
		date > 1939.4.1
	}
	abort = {
		NOT = { 
			tag = ENG 
			date > 1939.4.1 
		}
	}
	
	ai_strategy = {
		type = air_factory_balance
		value = 125
	}

}

ENG_template_design_1 = {
	enable = {
	
		original_tag = ENG
		date < 1940.1.1				
	}
	abort = { 
		date > 1940.1.1
	}
	
	ai_strategy = {
		type = template_prio
		id = infantry
		value = 40
	}

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

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

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

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

ENG_template_design_2 = {
	enable = {
	
		original_tag = ENG
		date > 1940.1.1				
	}
	
	ai_strategy = {
		type = template_prio
		id = infantry
		value = -10
	}

	ai_strategy = {
		type = template_prio
		id = motorized
		value = 10
	}

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

	ai_strategy = {
		type = template_prio
		id = medium_armor
		value = 40
	}
	
	ai_strategy = {
		type = template_prio
		id = modern_armor
		value = 50
	}

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

	ai_strategy = {
		type = template_prio
		id = paratroopers
		value = -10
	}
	
	ai_strategy = {
		type = template_prio
		id = mechanized
		value = 10
	}
}

# lets make sure the allies dont overcommit to invasions early on
careful_with_early_invasions = {
	enable = {
		if = {
			limit = { NOT = { has_dlc = "Man the Guns"} }
			NOT = { has_tech = landing_craft }
		}
		else = {
			NOT = { has_tech = mtg_landing_craft }
		}
		
		OR = {
			is_in_faction_with = ENG # anyone in allies
			tag = FRA
		}

		date < 1943.1.1
		NOT = {
			SOV = { 
				has_war_with = GER 
				surrender_progress > 0.07
			}
		}
	}
	abort = {
		OR = {
			has_tech = landing_craft
			has_tech = mtg_landing_craft
		}
		OR = {
			SOV = { 
				has_war_with = GER 
				surrender_progress > 0.07
			}
			date > 1943.1.1
		}
	}

	ai_strategy = {
		type = invade
		id = "ITA"			
		value = -500
	}

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

	ai_strategy = {
		type = invade
		id = "VIC"
		value = -500
	}
	
	ai_strategy = {
		type = area_priority
		id = scandinavia
		value = -300
	}
	
}

east_prussia_invasion_is_death_trap = {
	enable = {
		
		OR = {
			is_in_faction_with = ENG # anyone in allies
			tag = FRA
		}

		GER = { has_war_with = POL }
		POL = { 
			OR = {
				exists = yes 
				has_capitulated = no
			}
		}

		date < 1940.1.1
	}
	
	abort = {
		OR = {
			NOT = { GER = { has_war_with = POL } }
			POL = { 
				OR = {
					exists = no
					has_capitulated = yes
				}
			}
			date > 1940.1.1
		}
	}

	ai_strategy = {
		type = invade
		id = "GER"			
		value = -2000
	}
}

# AI gets trapped here and dies to germany, although this takes a big toll 
# on germany as well leading to bad attack on soviet as well as no UK troops
# Crownlands dont go up North 
ENG_trying_to_save_benelux_is_deathtrap = {
	enable = {
		tag = ENG
		has_war_with = GER
#		date < 1940.3.1
		OR = {
			FIN = { has_capitulated = no }
			ITA = { has_capitulated = no }
		}
	}
	
	abort = {
		OR = {
#			date > 1940.3.1
			AND = {
				FIN = { has_capitulated = yes }
				ITA = { has_capitulated = yes }
			}
		}
	}
	
	ai_strategy = {
		type = dont_defend_ally_borders
		id = "FIN"
		value = 100
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = "ITA"
		value = 100
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = "NOR"
		value = 100
	}
}

ENG_naval_role_ratios_historical = {
	enable = {
		has_dlc = "Man the Guns"
		original_tag = ENG
	}

	ai_strategy = {
		type = role_ratio
		id = naval_capital_bb
		value = -90
	}
	ai_strategy = {
		type = dockyard_to_military_factory_ratio
		value = 20  #aim for a 2-1 ratio on naval factories
	}
	ai_strategy = {
		type = role_ratio
		id = naval_capital_bc
		value = -10
	}

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

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

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

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

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

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

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

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

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

ENG_naval_role_ratios_anti_submarines = {
	enable = {
		has_dlc = "Man the Guns"
		original_tag = ENG
		anti_submarine_strategy_required_trigger = yes
	}
	abort = {
		not = { anti_submarine_strategy_required_trigger = yes }
	}
	ai_strategy = {
		type = role_ratio
		id = naval_capital_bb
		value = -90
	}
	ai_strategy = {
		type = dockyard_to_military_factory_ratio
		value = 20  #aim for a 2-1 ratio on naval factories
	}
	ai_strategy = {
		type = role_ratio
		id = naval_capital_bc
		value = -10
	}

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

	ai_strategy = {
		type = role_ratio
		id = naval_carrier_light
		value = -25
	}

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

	ai_strategy = {
		type = role_ratio
		id = naval_screen
		value = -70
	}

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

	ai_strategy = {
		type = role_ratio
		id = naval_cruiser_light
		value = -25
	}

	ai_strategy = {
		type = role_ratio
		id = naval_cruiser_heavy
		value = -10
	}
}


ENG_the_channel_is_dangerous = {
	enable = {
		original_tag = ENG
		has_war_with = GER
	}
	abort_when_not_enabled = yes
	
	ai_strategy = {
		type = naval_avoid_region
		id = 18 #english channel
		value = 100
	}
}

ENG_lifeline_of_the_empire = {
	enable = {
		original_tag = ENG
	}
	abort = {
		always = no
	}

	ai_strategy = {
		type = area_priority
		id = 51 #Blackwater Bay
		value = 100
	}
}


ENG_USA_focus_on_europe = {
	allowed = {
		OR = {
			tag = USA
			tag = ENG
		}
	}
	
	enable = {
		date > 1941.1.1
		has_global_flag = FRA_already_surrendered
	}
	
	ai_strategy = {
		type = front_unit_request

		area = europe
		
		value = 150
	}
}

ENG_time_to_ditch_FRA = {
	allowed = {
		tag = ENG
	}
	
	enable = {
		FRA = {
			has_capitulated = no
			surrender_progress > 0.7
		}
		OR = {
			NOT = { has_global_flag = FRA_already_surrendered }
			#lets give a month of retreat time after capitulation
			set_temp_variable = { t = global.num_days }
			subtract_from_temp_variable = { t = global.FRA_capitulation_days }
			check_variable = { t < 30 }
		}
	}
	
	abort_when_not_enabled = yes
	
	ai_strategy = {
		type = dont_defend_ally_borders
		id = FRA
		value = 100
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = BEL
		value = 100
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = HOL
		value = 100
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = LUX
		value = 100
	}
}

ENG_gang_up_GER_with_USA = {
	enable = {
		tag = ENG
		FRA = {
			OR = {
				has_capitulated = yes
				exists = no
			}
		}
	}
	# after FRA falls, both ENG and USA will try to help in europe and africa
	ai_strategy = {
		type = force_defend_ally_borders
		value = 100
		target = europe
	}
	ai_strategy = {
		type = force_defend_ally_borders
		value = 100
		target = africa
	}
}

ENG_accept_USA_access = {
	allowed = {
		tag = ENG
	}
	enable = {
		tag = ENG
		date > 1940.9.9
		USA = {
			is_ai = yes
			NOT = {
				OR = {
					is_in_faction_with = ENG
					has_military_access_to = ENG
				}
			}
		}
	}
	abort_when_not_enabled = yes
	
	ai_strategy = {
		type = diplo_action_acceptance
		id = USA
		target = military_access
		value = 1000
	}
}


dont_get_sucked_into_FRA_and_die = {

	enable = {
		OR = {
			tag = ENG
			is_subject_of = ENG
		}
		has_war_with = GER
		has_war_together_with = FRA

		date < 1941.9.9

		NOT = { has_global_flag = FRA_already_surrendered }
	}
	abort_when_not_enabled = yes	

	ai_strategy = {
		type = front_unit_request
		area = europe
		value = -60
	}

	ai_strategy = {
  		type = garrison
   		value = 70
   	}
}

ENG_please_stop_stomping_italy_so_hard_in_africa_ty = {

	enable = {
		OR = {
			tag = ENG
			is_subject_of = ENG
		}

		date < 1941.2.1

		has_global_flag = FRA_already_surrendered
	}
	abort_when_not_enabled = yes	

	ai_strategy = {
		type = front_unit_request
		area = africa
		value = -30
	}

	ai_strategy = {
  		type = garrison
   		value = 40
   	}
}

ENG_in_for_the_long_haul_bruv = {
	enable = {
		tag = ENG
		has_government = democratic
		date < 1937.10.1
		has_war = no
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = building_target
		id = industrial_complex
		value = 49
	}
	ai_strategy = {
		type = air_factory_balance
		value = 20
	} 
}

#ENG_industry_we_on_an_island_bruv = {
#	enable = {
#		tag = ENG
#		has_government = democratic
#		has_war = no
#		date > 1937.10.1
#	}
#	abort_when_not_enabled = yes
#
#	ai_strategy = {
#		type = added_military_to_civilian_factory_ratio
#		value = -60
#	}
#	ai_strategy = {
#		type = air_factory_balance
#		value = 55
#	} 
#}

ENG_growing_confidence_in_the_air = {
	enable = {
		tag = ENG
		has_war = yes
		has_government = democratic
		date > 1938.1.1
	}
	abort_when_not_enabled = yes
 
	ai_strategy = {
		type = air_factory_balance
		value = 120
	} 
}

ENG_allies_dont_ask_for_diplo_access_to_SOV = {
	enable = {
		ENG = {
			has_government = democratic
		}
		SOV = {
			has_government = communism
		}
		is_in_faction_with = ENG
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = diplo_action_desire
		id = SOV
		target = military_access
		value = -5000
	}
	ai_strategy = {
		type = diplo_action_desire
		id = TAN
		target = military_access
		value = -5000
	}	
	ai_strategy = {
		type = diplo_action_desire
		id = MON
		target = military_access
		value = -5000
	}
	ai_strategy = {
		type = diplo_action_desire
		id = SOV
		target = docking_rights
		value = -5000
	}
	ai_strategy = {
		type = diplo_action_desire
		id = TAN
		target = docking_rights
		value = -5000
	}	
	ai_strategy = {
		type = diplo_action_desire
		id = MON
		target = docking_rights
		value = -5000
	}
}