USA_unit_production = {

	allowed = {	original_tag = USA }
	enable = {
		always = yes
	}
	abort_when_not_enabled = yes

	# Land division factors
	ai_strategy = {
		type = role_ratio
		id = paratroopers
		value = 5
	}

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

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

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

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

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

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

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

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

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

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

	ai_strategy = {
		type = equipment_production_factor
		id = heavy_fighter
		value = -40 #Just build a few slowly
	}

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

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

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

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

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

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

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

	ai_strategy = {
		type = equipment_production_factor
		id = infantry
		value = 40
	}

	ai_strategy = {
		type = equipment_production_factor
		id = artillery
		value = 25
	}
	
	ai_strategy = {
		type = equipment_production_min_factories
		id = cv_fighter
		value = 2
	}

	ai_strategy = {
		type = equipment_production_min_factories
		id = cv_naval_bomber
		value = 2
	}
}

USA_garrison_production = {
	allowed = { original_tag = USA }
	enable = {
		ai_wants_divisions > 12 #Massively decreasing the amount of paratroopers the AI wants
	}
	abort = {
		ai_wants_divisions < 13 #Massively decreasing the amount of paratroopers the AI wants
	}

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

USA_min_tank_production = {
	# USA starts using armor templates quite late, but they should still produce some tanks before that so they can lend-lease
	allowed = {	original_tag = USA }
	enable = {
		num_of_military_factories > 9
	}
	abort_when_not_enabled = yes

	# Land division factors
	ai_strategy = {
		type = equipment_production_min_factories_archetype
		id = light_tank_chassis
		value = 1
	}

	ai_strategy = {
		# They don't start with medium tanks, but when they have them available they will start producing them
		type = equipment_production_min_factories_archetype
		id = medium_tank_chassis
		value = 1
	}
}

USA_upgrade_to_sherman_tanks_asap = {
	allowed = {
		original_tag = USA
	}
	enable = {
		is_historical_focus_on = yes
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = production_upgrade_desire_offset
		id = medium_tank_chassis_2
		value = 100  # 100 essentially means we don't require a stockpile surplus
	}
	ai_strategy = {
		type = production_upgrade_desire_offset
		id = medium_tank_equipment_2
		value = 100  # 100 essentially means we don't require a stockpile surplus
	}
}

USA_ask_ENG_FRA_for_access_before_war = {
	allowed = {
		tag = USA
	}
	enable = {
		date > 1940.9.9
		NOT = {
			OR = {
				is_in_faction_with = ENG
				has_military_access_to = ENG
			}
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = diplo_action_desire
		id = ENG
		target = military_access
		value = 1000
	}
	ai_strategy = {
		type = diplo_action_desire
		id = FRA
		target = military_access
		value = 1000
	}
}

# This will prompt USA to try and support countries who are fighting against extremist elements.
# Should improve alt-history situations like democratic Germany fighting the USSR etc.
USA_protect_against_extremism = { # Reverse strategy
	reversed = yes

	enable_reverse = {
		USA = {
			has_government = democratic
		}
	}

	enable = {
		NOT = { tag = USA }
		NOT = { has_government = communism }
		NOT = { has_government = fascism }
		OR = {
			capital_scope = {
				is_on_continent = europe # lets avoid smaller conflicts elsewhere
			}
			AND = {
				num_of_civilian_factories > 10
				is_subject = no
			}
		}
		any_of_scopes = {
			array = enemies
			NOT = { tag = USA }
			OR = {
				has_government = communism
				has_government = fascism
			}
		}
	}

	abort = {
		OR = {
			has_war = no
			OR = {
				has_government = communism
				has_government = fascism
			}
			USA = {
				OR = {
					NOT = {	has_government = democratic }
					has_war_with = ROOT
				}
			}
		}
	}

	ai_strategy = {
		type = support
		id = "USA"
		value = 100
	}
}

# USA_naval_role_ratios_historical = {
# 	allowed = {
# 		has_dlc = "Man the Guns"
# 		original_tag = USA
# 	}
# 	enable = {
# 		always = yes
# 	}
# 	abort_when_not_enabled = yes

# 	ai_strategy = {
# 		type = role_ratio
# 		id = naval_capital_bb
# 		value = 30
# 	}

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

# 	ai_strategy = {
# 		type = role_ratio
# 		id = naval_carrier
# 		value = 30
# 	}

# 	ai_strategy = {
# 		type = role_ratio
# 		id = naval_submarine
# 		value = 60
# 	}

# 	ai_strategy = {
# 		type = role_ratio
# 		id = naval_screen
# 		value = 320
# 	}

# 	ai_strategy = {
# 		type = role_ratio
# 		id = naval_escort
# 		value = 55
# 	}

# 	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 = 3
# 	}

# 	ai_strategy = {
# 		type = role_ratio
# 		id = naval_mine_layer
# 		value = -3
# 	}

# 	ai_strategy = {
# 		type = unit_ratio
# 		id = capital_ship
# 		value = 5		 #1 to 12
# 	}
# 	ai_strategy = {
# 		type = unit_ratio
# 		id = screen_ship
# 		value = 70		 #10 to 12
# 	}
# 	ai_strategy = {
# 		type = unit_ratio
# 		id = carrier
# 		value = 5		 #1 to 12
# 	}
# }

# USA_naval_role_ratios_produce_screen = {
# 	allowed = {
# 		has_dlc = "Man the Guns"
# 		original_tag = USA
# 	}
# 	enable = {
# 		has_navy_size = {
# 				unit = destroyer
# 				size < 200
# 			}
# 		has_war = yes
# 		date < 1943.6.1
# 	}

# 	abort_when_not_enabled = yes

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

# 	ai_strategy = {
# 		type = role_ratio
# 		id = naval_mine_layer
# 		value = -2
# 	}

# 	ai_strategy = {
# 		type = role_ratio
# 		id = naval_cruiser_light
# 		value = 20
# 	}

# 	ai_strategy = {
# 		type = unit_ratio
# 		id = screen_ship
# 		value = 60
# 	}
# }

# USA_naval_role_ratios_produce_screen_late = {
# 	allowed = {
# 		has_dlc = "Man the Guns"
# 		original_tag = USA
# 	}
# 	enable = {
# 		has_navy_size = {
# 				unit = destroyer
# 				size < 300
# 			}
# 		has_war = yes
# 		date > 1943.6.1
# 	}

# 	abort_when_not_enabled = yes

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

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

# 	ai_strategy = {
# 		type = role_ratio
# 		id = naval_mine_layer
# 		value = -2
# 	}

# 	ai_strategy = {
# 		type = role_ratio
# 		id = naval_cruiser_light
# 		value = 7
# 	}

# 	ai_strategy = {
# 		type = unit_ratio
# 		id = screen_ship
# 		value = 15
# 	}
# }

# USA_semper_fi = {
# 	allowed = { original_tag = USA }
# 	enable = {
# 		has_war_with = JAP
# 	}
# 	abort = {
# 		JAP = {
# 			has_capitulated = yes
# 		}
# 	}
# 	ai_strategy = {
# 		type = unit_ratio
# 		id = marines
# 		value = 5
# 	}
# 	ai_strategy = {
# 		type = template_prio
# 		id = marines
# 		value = 100
# 	}
# }

# USA_home_land_is_safe = {
# 	allowed = { original_tag = USA }
# 	enable = {
# 		NOT = {
# 			OR = {
# 				has_civil_war = yes
# 				has_war_with = CAN
# 				has_war_with = MEX
# 				USA_homeland_threatened = yes
# 			}
# 		}
# 	}
# 	abort_when_not_enabled = yes


# 	ai_strategy = {
# 		type = garrison
# 		value = -60
# 	}
# }

# # Hold a graduated reserve on the West Coast once an enemy has a Pacific launchpad.
# USA_home_guard_pacific = {
# 	allowed = { original_tag = USA }
# 	enable = {
# 		has_war = yes
# 		USA_pacific_foothold_threatened = yes
# 	}
# 	abort_when_not_enabled = yes

# 	ai_strategy = {
# 		type = garrison
# 		value = 150
# 	}

# 	ai_strategy = {
# 		type = put_unit_buffers
# 		ratio = 0.15
# 		states = {
# 			378 # California
# 			385 # Oregon
# 			386 # Washington
# 		}
# 		area = north_america
# 		subtract_invasions_from_need = yes
# 		subtract_fronts_from_need = no
# 	}
# }

# # Hold a graduated reserve on the East and Gulf coasts when threatened from the Atlantic,
# # or when the allies shielding the USA have collapsed.
# USA_home_guard_atlantic = {
# 	allowed = { original_tag = USA }
# 	enable = {
# 		has_war = yes
# 		OR = {
# 			USA_atlantic_foothold_threatened = yes
# 			USA_strategic_shield_cracked = yes
# 		}
# 	}
# 	abort_when_not_enabled = yes

# 	ai_strategy = {
# 		type = garrison
# 		value = 150
# 	}

# 	ai_strategy = {
# 		type = put_unit_buffers
# 		ratio = 0.15
# 		states = {
# 			357 # New England
# 			358 # New York
# 			359 # New Jersey
# 			361 # Maryland
# 			362 # Virginia
# 			363 # North Carolina
# 			364 # South Carolina
# 			365 # Georgia
# 			366 # Florida
# 			367 # Alabama
# 			370 # Mississippi
# 			371 # Louisiana
# 			375 # Texas
# 		}
# 		area = north_america
# 		subtract_invasions_from_need = yes
# 		subtract_fronts_from_need = no
# 	}
# }

# USA_home_guard_invaded = {
# 	allowed = { original_tag = USA }
# 	enable = {
# 		surrender_progress > 0
# 	}
# 	abort_when_not_enabled = yes

# 	ai_strategy = {
# 		type = front_control
# 		state_trigger = {
# 			is_core_of = USA
# 		}
# 		area = north_america
# 		priority = 250
# 		ratio = 0
# 		ordertype = front
# 		execution_type = rush
# 		execute_order = yes
# 		manual_attack = yes
# 	}

# 	ai_strategy = {
# 		type = area_priority
# 		id = north_america
# 		value = 60
# 	}

# 	ai_strategy = {
# 		type = front_unit_request
# 		state_trigger = {
# 			is_core_of = USA
# 		}
# 		area = north_america
# 		value = 250
# 	}
# }

# # Modest standing synthetic capacity: the USA is rubber-poor regardless of the war.
# USA_synthetic_industry_baseline = {
# 	allowed = { original_tag = USA }
# 	enable = { date > 1939.1.1 }
# 	abort_when_not_enabled = yes

# 	ai_strategy = {
# 		type = research_weight_factor
# 		id = synth_oil_experiments
# 		value = 100
# 	}
# 	ai_strategy = {
# 		type = research_weight_factor
# 		id = rubber_processing
# 		value = 100
# 	}
# 	ai_strategy = {
# 		type = building_target
# 		id = synthetic_refinery
# 		value = 5
# 	}
# }

# # Pacific war cuts off natural rubber from SE Asia, so prioritise synthetics hard.
# USA_synthetic_industry_pacific_war = {
# 	allowed = { original_tag = USA }
# 	enable = {
# 		has_war_with = JAP
# 	}
# 	abort_when_not_enabled = yes

# 	ai_strategy = {
# 		type = building_target
# 		id = synthetic_refinery
# 		value = 12
# 	}
# }

# USA_democracy_on_JAP = {
# 	allowed = { original_tag = USA }
# 	enable = {
# 		has_war_with = JAP
# 	}
# 	abort = {
# 		JAP = {
# 			has_capitulated = yes
# 		}
# 	}

# 	ai_strategy = {
# 		type = strike_force_home_base
# 		id = 105 # perl harbor
# 	}
# }

# USA_onto_the_beaches = {
# 	allowed = {
# 		original_tag = USA
# 	}
# 	enable = {
# 		has_war = yes
# 	}
# 	abort_when_not_enabled = yes

# 	ai_strategy = {
# 		type = naval_invasion_focus
# 		value = 55
# 	}
# }

# USA_stay_east_coast = {
# 	allowed = {
# 		original_tag = USA
# 	}
# 	enable = {
# 		ENG = { has_capitulated = yes }
# 		has_war_with = GER
# 	}
# 	abort_when_not_enabled = yes

# 	ai_strategy = {
# 		type = naval_dominance
# 		id = 54
# 		value = 100
# 	}
# }

# #allows usa to upgrade their ships earlier and commit to doctrines later when they get the cost bonuses
# USA_wait_with_doctrines = {
# 	allowed = {
# 		is_historical_focus_on = yes
# 		original_tag = USA
# 	}
# 	enable = {
# 		NOT = {
# 			has_completed_focus = USA_fund_the_navy
# 		}
# 	}
# 	abort_when_not_enabled = yes
# 	ai_strategy = {
# 		type = navy_xp_spend_priority
# 		id = unlock_doctrine
# 		value = -95
# 	}
# }

# USA_convoy_hungry = {
# 	enable = {
# 		date > 1940.1.1
# 		has_equipment = {
#   			convoy < 1000
#   		}
# 	}
# 	abort_when_not_enabled = yes

# 	ai_strategy = {
# 		type = unit_ratio
# 		id = convoy
# 		value = 1000
# 	}
# }

USA_lose_fateful_lightning_from_terribly_swift_sword = {

	allowed = {
		OR = {
			tag = USA
			tag = ENG # second breakfast protocol - activated
		}
	}
	enable = {
		country_exists = VIC
		FRA = {
			OR = {
				has_capitulated = yes
				controls_state = 16
			}
			has_war_with = GER
			is_in_faction_with = USA
		}
		OR = {
			AND = {
				VIC = {
					is_ai = no
					has_war = no
				}
				is_historical_focus_on = yes
				date > 1942.9.1
			}
			AND = {
				OR = {
					is_historical_focus_on = no
					VIC = { has_war = yes }
				}
				date > 1942.6.1
			}
			AND = {
				VIC = { is_ai = yes }
				date > 1942.6.1
			}
			AND = { #EAI
				GER = { has_war_with = SOV }
				SOV = { surrender_progress > 0.2 }
			}
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = antagonize
		id = VIC
		value = 2500 # we hateses them filthy Vichy Frenches
	}
	ai_strategy = {
		type = declare_war
		id = VIC
		value = 500 # we hateses them filthy Vichy Frenches. strategy >= 500 forces declaration
	}
}

USA_now_we_shall_strike = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		country_exists = JAP

	}

	abort = {
		OR = {
			has_war_with = USA
			NOT = {
				country_exists = USA
			}
		}
	}

	ai_strategy = {
		type = consider_weak
		id = "USA"
		value = 75
	}
}

USA_truck_export = { #GM
	allowed = {
		original_tag = USA
	}
	enable = {
		has_dlc = "Arms Against Tyranny"
		date > 1938.1.1
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = equipment_market_for_sale_factor
		id = motorized
		value = 100
	}
}

USA_fighter_export = { #GM
	allowed = {
		original_tag = USA
	}
	enable = {
		has_dlc = "Arms Against Tyranny"
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = equipment_market_for_sale_factor
		id = fighter
		value = 300 #We mostly use CV fighters
	}

	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = fighter
		value = -60
	}
}

USA_west_coast_defense = {
	allowed = {
		original_tag = USA
	}
	
	enable = {
		has_war = yes
	}
	
	abort_when_not_enabled = yes

	ai_strategy = {
		type = naval_dominance
		id = us_west_coast
		value = 100
	}
}

USA_dont_guarantee_SA_unless_everyhting_is_shit = {
	allowed = {
		original_tag = USA
		has_dlc = "Trial of Allegiance"
	}
	enable = {
		threat < 0.9

	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = protect
		id = CAN
		value = -200
	}
	ai_strategy = {
		type = protect
		id = MEX
		value = -200
	}
	ai_strategy = {
		type = protect
		id = GUA
		value = -200
	}

	ai_strategy = {
		type = protect
		id = HON
		value = -200
	}
	ai_strategy = {
		type = protect
		id = ELS
		value = -200
	}

	ai_strategy = {
		type = protect
		id = NIC
		value = -200
	}
	ai_strategy = {
		type = protect
		id = CUB
		value = -200
	}

	ai_strategy = {
		type = protect
		id = HAI
		value = -200
	}
	ai_strategy = {
		type = protect
		id = DOM
		value = -200
	}
	ai_strategy = {
		type = protect
		id = COS
		value = -200
	}
	ai_strategy = {
		type = protect
		id = PAN
		value = -200
	}
	ai_strategy = {
		type = protect
		id = COL
		value = -200
	}
	ai_strategy = {
		type = protect
		id = VEN
		value = -200
	}

	ai_strategy = {
		type = protect
		id = ECU
		value = -200
	}
	ai_strategy = {
		type = protect
		id = PRU
		value = -200
	}

	ai_strategy = {
		type = protect
		id = BOL
		value = -200
	}
	ai_strategy = {
		type = protect
		id = CHL
		value = -200
	}

	ai_strategy = {
		type = protect
		id = ARG
		value = -200
	}
	ai_strategy = {
		type = protect
		id = PAR
		value = -200
	}

	ai_strategy = {
		type = protect
		id = URG
		value = -200
	}
	ai_strategy = {
		type = protect
		id = BRA
		value = -200
	}
}


### PACIFIC BUILDUP STRATEGIES

# GUAM NAVAL BASE 
USA_prepare_guam = {
	allowed = {
		original_tag = USA
	}
	enable = {
		date > 1940.1.1
		638 = {
			naval_base < 4
		}
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = build_building
		id = naval_base
		target = 12140
		value = 100
	}
}

USA_prepare_guam_2 = {
	allowed = {
		original_tag = USA
	}
	enable = {
		date > 1943.1.1
		638 = {
			naval_base < 8
		}
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = build_building
		id = naval_base
		target = 12140
		value = 100
	}
}

# GUAM HEADQUARTERS
USA_prepare_guam_3_naval_hq_supply = { 
	allowed = {
		original_tag = USA
		has_dlc = "No Compromise, No Surrender"
	}
	enable = {
		date > 1943.1.1
		638 = {
			OR = {
				naval_headquarters < 1
				naval_supply_hub < 1
			}
		}
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = build_building
		id = naval_headquarters
		target = 12140
		value = 100
	}
	ai_strategy = {
		type = build_building
		id = naval_supply_hub
		target = 12140
		value = 100
	}

}

USA_prepare_wake = {
	allowed = {
		original_tag = USA
	}
	enable = {
		date > 1940.1.1
		632 = {
			naval_base < 3
		}
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = build_building
		id = naval_base
		target = 13047
		value = 50
	}
}

USA_prepare_iwo_jima = {
	allowed = {
		original_tag = USA
	}
	enable = {
		date > 1943.3.1
		OR = {
			645 = {
				naval_base < 6
			}
			645 = {
				air_base < 4
			}
		}
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = build_building
		id = naval_base
		target = 13025
		value = 100
	}
	ai_strategy = {
		type = build_building
		id = air_base
		target = 645
		value = 100
	}
}


### FACTION RELATED STRATEGIES

USA_base_faction_priorities = {
	allowed = {
		original_tag = USA
	}
	enable = {
		always = yes
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = spent_faction_initiative_priority
		id = program
		value = 25
	}
	ai_strategy = {
		type = spent_faction_initiative_priority
		id = unlock_faction_commander
		value = 5
	}
}

### JAPAN ASSISTANCE ###

USA_dont_send_lend_lease_to_japan_except_certain_scenarios = {
	allowed = {
		original_tag = USA
	}
	enable = {
		JAP = { 
			OR = {
				has_government = neutrality
				has_government = fascism
			}
			NOT = {
				has_completed_focus = JAP_form_the_jikyoku_iinkai
			}
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = send_lend_lease_desire
		id = JAP
		value = -999
	}
}

USA_maybe_send_some_lend_lease_to_japan = {
	allowed = {
		original_tag = USA
	}
	enable = {
		JAP = { 
			OR = {
				has_government = neutrality
				has_government = fascism
			}
			has_completed_focus = JAP_form_the_jikyoku_iinkai
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = send_lend_lease_desire
		id = JAP
		value = 25  
	}
}

### Pacific war strategies