#########################################################
#	Production Strategies
#########################################################

EAI_USA_air_production = {
	allowed = { tag = USA }
	enable = { always = yes }
	abort_when_not_enabled = yes
	
	ai_strategy = { type = air_factory_balance value = 130 }
}

EAI_USA_strategic_bombers = {
	allowed = { tag = USA }
	enable = {
		has_tech = improved_large_airframe
		
		is_major = yes
		EAI_STR_equipment_production = yes
		has_deployed_air_force_size = { size < 1000 type = strategic_bomber }
	}
	abort = {
		NOT = {
			AND = {
				is_major = yes
				EAI_STR_equipment_production = yes
				has_deployed_air_force_size = { size < 2000 type = strategic_bomber }
			}
		}
	}

	ai_strategy = { type = equipment_production_min_factories id = strategic_bomber value = 30 }
}

EAI_USA_stockpile_for_lend_leasing = {
	allowed = { tag = USA }
	enable = {
		is_historical_focus_on = yes
		
		date < 1939.1.1
		has_war = no
		has_equipment = { infantry_equipment < 10000 }
	}

	abort_when_not_enabled = yes

	ai_strategy = { type = equipment_production_factor id = infantry            value = 400 }
	ai_strategy = { type = equipment_production_factor id = motorized           value = 400 }

	ai_strategy = { type = equipment_production_factor id = fighter             value = -100 }
	ai_strategy = { type = equipment_production_factor id = interceptor         value = -100 }
	ai_strategy = { type = equipment_production_factor id = tactical_bomber     value = -100 }
	ai_strategy = { type = equipment_production_factor id = cas                 value = -100 }
}

EAI_USA_strategy = {
	allowed = { tag = USA }
	enable = { is_major = yes }
	
	abort_when_not_enabled = yes

	ai_strategy = { type = build_army id = area_defense value = 40 }
}

EAI_USA_strategy_convoys = {
	allowed = { tag = USA }
	enable = { is_major = yes stockpile_ratio = { archetype = convoy ratio < 3000 } }
	
	abort_when_not_enabled = yes

	ai_strategy = { type = equipment_production_min_factories id = convoy value = 15 }
}

EAI_USA_strategy_convoy_shortage = {
	allowed = { tag = USA }
	enable = { is_major = yes stockpile_ratio = { archetype = convoy ratio < 100 } }
	
	abort_when_not_enabled = yes

	ai_strategy = { type = equipment_production_min_factories id = convoy value = 15 }
}

# EAI_USA_strategy_capitals = {
# 	allowed = { tag = USA }
# 	enable = { 
# 		date < 1942.1.1
# 		OR = {
# 			has_country_flag = EAI_ASW_DD_navy_production_1
# 			has_country_flag = EAI_ASW_CL_navy_production_1
# 		}
# 	}
	
# 	abort_when_not_enabled = yes

# 	ai_strategy = { type = role_ratio id = naval_carrier                      value = -4 }
# 	ai_strategy = { type = role_ratio id = naval_capital_bb                   value = -4 }
# 	ai_strategy = { type = role_ratio id = naval_capital_bc               	  value = -4 }
# 	ai_strategy = { type = role_ratio id = naval_cruiser_heavy                value = -4 }
# }

# EAI_USA_strategy_ASW_DD = {
# 	allowed = { tag = USA }
# 	enable = { has_country_flag = EAI_ASW_DD_navy_production_1 }
	
# 	abort_when_not_enabled = yes

# 	ai_strategy = { type = role_ratio id = naval_escort value = 20 }
# 	ai_strategy = { type = role_ratio id = naval_screen value = -20 }
# }

# EAI_USA_strategy_ASW_CL = {
# 	allowed = { tag = USA }
# 	enable = { has_country_flag = EAI_ASW_CL_navy_production_1 }
	
# 	abort_when_not_enabled = yes

# 	ai_strategy = { type = role_ratio id = naval_escort_cl value = 10 }
# 	ai_strategy = { type = role_ratio id = naval_screen value = -10 }
# }

#########################################################
#	Diplomacy Strategies
#########################################################

EAI_USA_joins_allies = {
	allowed = { OR = { tag = USA tag = ENG } }
	enable = {
		is_historical_focus_on = yes
		USA = {
			ENG = { EAI_PREV_has_same_ideology_with_THIS = yes }
			OR = {
				has_war_with = JAP
				has_war_with = GER
			}
		}
	}
	abort_when_not_enabled = yes
	
	ai_strategy = {
		type = alliance
		id = "ENG"			
		value = 2000
	}
	
	ai_strategy = {
		type = alliance
		id = "USA"			
		value = 2000
	}
}

EAI_USA_wardec_VIC = {
	allowed = {
		OR = {
			tag = USA
			tag = ENG
		}
	}
	enable = {
		country_exists = VIC
		VIC = { EAI_THIS_is_threat_to_PREV = yes }
		set_temp_variable = { _shift_days = 180 }
		set_temp_variable = { add_days = SOV.surrender_progress }
		multiply_temp_variable = { add_days = 180 }
		add_to_temp_variable = { _shift_days = add_days }
		set_temp_variable = { operation_start_day = 1942.9 }
		subtract_from_temp_variable = { operation_start_day = 1936 }
		multiply_temp_variable = { operation_start_day = 365 }
		subtract_from_temp_variable = { operation_start_day = _shift_days }
		check_variable = { global.EAI_days_elapsed > operation_start_day }
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = antagonize
		id = VIC
		value = 2500
	}
	ai_strategy = {
		type = declare_war
		id = VIC
		value = 500
	}
}

#########################################################
#	Unit Strategies
#########################################################

EAI_USA_area_priority = {
	allowed = { tag = USA }
	enable = {
		always = yes
	}
	abort = { always = no }

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

EAI_USA_garrison = {
	allowed = { tag = USA }
	enable = {
		always = yes
	}
	abort_when_not_enabled = yes

	ai_strategy = { type = garrison value = 50 }
}

EAI_USA_garrison_coast = {
	allowed = { tag = USA }
	enable = {
		always = yes
	}
	abort_when_not_enabled = yes

	ai_strategy = { type = put_unit_buffers ratio = 0.01 states = { 361 } subtract_invasions_from_need = no subtract_fronts_from_need = no }
	ai_strategy = { type = put_unit_buffers ratio = 0.01 states = { 358 } subtract_invasions_from_need = no subtract_fronts_from_need = no }
	ai_strategy = { type = put_unit_buffers ratio = 0.01 states = { 357 } subtract_invasions_from_need = no subtract_fronts_from_need = no }
	ai_strategy = { type = put_unit_buffers ratio = 0.01 states = { 366 } subtract_invasions_from_need = no subtract_fronts_from_need = no }
	ai_strategy = { type = put_unit_buffers ratio = 0.01 states = { 362 } subtract_invasions_from_need = no subtract_fronts_from_need = no }
}

EAI_USA_garrison_allies = {
	allowed = { tag = USA }
	enable = {
		has_war_together_with = ENG
		has_war = yes
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = put_unit_buffers
		ratio = 0.3
		states = { 

			### uk
			127
			126
			125
			123
			338
			122
			129
			130
			132 

			### ast
			520
			521
			522
			517
			285
		}
		subtract_invasions_from_need = no
		subtract_fronts_from_need = no
	}
}

EAI_USA_garrison_PHI = {
	allowed = { tag = USA }
	enable = {
		PHI = { is_subject_of = ROOT }
		JAP = { is_ai = no }
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = put_unit_buffers
		ratio = 0.15
		states = { 
			### phi
			623
			327
			624
			625
			627
		}
		subtract_invasions_from_need = no
		subtract_fronts_from_need = no
	}
}

###########################
# 	Pacific war
###########################

### Deploy

EAI_USA_pacific_war_DEPLOY = {
	allowed = { tag = USA }
	enable = {
		has_war_with = JAP
	}
	abort_when_not_enabled = yes

	### Deploy

	ai_strategy = {
		type = force_concentration_factor
		value = 25
	}

	### Avoid
}

### Naval

### Invasions

EAI_USA_pacific_war_INVASION_hold = {
	allowed = { tag = USA }
	enable = {
		has_war_with = JAP
		JAP = { is_ai = yes }
		has_global_flag = { flag = EAI_JAP_blitz_pacific_1000d value = 1 days < 180 }
	}
	abort_when_not_enabled = yes

	ai_strategy = { type = invade id = JAP value = -3000 }
	ai_strategy = { type = invade id = MAN value = -3000 }
	ai_strategy = { type = invade id = MEN value = -3000 }
}

EAI_USA_pacific_war_INVASION = {
	allowed = { tag = USA }
	enable = {
		has_war_with = JAP
		EAI_MILITARY_army_readiness_HIGH = yes
	}
	abort = {
		NOT = {
			AND = {
				has_war_with = JAP
				EAI_MILITARY_army_readiness_HIGH_abort = yes
			}
		}
	}

	ai_strategy = { type = invade id = JAP value = 3000 }
	ai_strategy = { type = invade id = MAN value = 3000 }
	ai_strategy = { type = invade id = MEN value = 3000 }
}

#########################################################
#	Naval
#########################################################

EAI_USA_strike_force_europe = {
	allowed = { tag = USA }
	enable = {
		NOT = {
			any_home_area_neighbor_country = {
				has_war_with = ROOT
			}
		}

		any_enemy_country = {
			capital_scope = { is_on_continent = europe }
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = { type = strike_force_home_base id = 18 }
}

EAI_USA_invade_VIC = {
	allowed = { tag = USA }

	enable = {
		has_war_with = GER
		has_war_together_with = ENG
		check_variable = { deployed_army_manpower_k > 600 }
		
		VIC = { 
			has_government= fascism
			any_of_scopes = { array = global.EAI_MAP_operation_torch_theatre

				is_controlled_by = VIC
				is_coastal = yes
			}
			OR = {
				has_army_manpower = { size < 1000000 }
				date > 1941.1.1
			}
			if = { limit = { is_historical_focus_on = yes } 
			
				OR = {
					date > 1942.1.1
					GER = { surrender_progress > 0.2 }
					SOV = { surrender_progress > 0.2 }
				}
			}
		} 
		
		GER = { has_war_with = SOV }
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = antagonize
		id = VIC
		value = 2500
	}

	ai_strategy = {
		type = declare_war
		id = VIC
		value = 500
	}
}

EAI_USA_help_allies_in_north_africa = {
	allowed = { tag = USA }
	enable = {
		has_war_together_with = ENG
		has_war_with = ITA
		NOT = { EAI_MILITARY_home_threatened_TRIGGER = yes }
	}
	
	abort_when_not_enabled = yes

	### Deploy

	ai_strategy = { type = strategic_air_importance id = 128 value = 25000 }
	ai_strategy = { type = strategic_air_importance id = 225 value = 25000 }
	ai_strategy = { type = area_priority id = north_africa value = 200 }
}