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

USA_garrison_production = {
	allowed = { original_tag = USA }
	enable = {
		GER = { has_capitulated = yes } # Ragnarok added
		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
	}
}


# USA should put some buffer units in africa and ENG to help with invasions
USA_unit_buffer_for_europe = {
	allowed = {
		tag = USA
	}
	enable = {
		NOT = { has_war_with = GER } # Ragnarok added
		date > 1941.1.1
		is_in_faction_with = ENG

		should_USA_invade_europe_or_africa = yes
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = put_unit_buffers

		order_id = 2

		# south england
		states = {
			125
			126
			127
			128
			129
			338
			123
			122
		}

		ratio = 0.20

		area = europe

		subtract_invasions_from_need = yes
	}

	ai_strategy = {
		type = put_unit_buffers

		order_id = 2

		# spain
		states = {
			171
			180
			112
			179
			795
			169
			173
			167
		}

		ratio = 0.1
		area = europe

		subtract_invasions_from_need = no
	}

	ai_strategy = {
		type = put_unit_buffers

		order_id = 1

		# north africa
		states = {
			290
			461
			459
			460
			458
			665
			448
			449
			450
			451
			452
			447
		}

		ratio = 0.15

		area = europe

		subtract_invasions_from_need = yes
	}
}

USA_unit_buffer_for_africa = {
	allowed = {
		tag = USA
	}
	enable = {
		NOT = { has_war_with = GER } # Ragnarok added
		date > 1941.1.1
		is_in_faction_with = ENG

		should_USA_invade_europe_or_africa = yes

		all_state = {
			OR = {
				is_on_continent = africa
				AND = {
					GER = {
						divisions_in_state = { state = PREV size < 1 }
					}
					ITA = {
						divisions_in_state = { state = PREV size < 1 }
					}
				}
			}
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = put_unit_buffers

		order_id = 1

		# north africa
		states = {
			290
			461
			459
			460
			458
			665
			448
			449
			450
			451
			452
			447
		}

		ratio = 0.2

		area = africa

		subtract_invasions_from_need = yes
	}

	ai_strategy = {
		type = put_unit_buffers

		order_id = 1

		# west africa
		states = {
			699
			557
			272
			792
			700
		}

		ratio = 0.15

		area = africa

		subtract_invasions_from_need = no
	}

	ai_strategy = {
		type = put_unit_buffers

		order_id = 1

		# east africa
		states = {
			559
			269
			268
			550
			551
		}

		ratio = 0.15

		area = africa

		subtract_invasions_from_need = no
	}

	ai_strategy = {
		type = put_unit_buffers

		order_id = 1

		# south africa
		states = {
			541
			681
			719
		}

		ratio = 0.15

		area = africa

		subtract_invasions_from_need = no
	}
}

USA_gang_up_GER_with_ENG = {
	allowed = {
		tag = USA
	}
	enable = {
		NOT = { has_war_with = GER } # Ragnarok added
		tag = USA
		date > 1940.6.6
		is_in_faction_with = ENG
	}
	abort_when_not_enabled = yes

	# help fronts in europe & africa
	ai_strategy = {
		type = force_defend_ally_borders
		value = 100
		target = europe
	}
	ai_strategy = {
		type = force_defend_ally_borders
		value = 100
		target = africa
	}

}

build_patrol_bombers = {
	allowed = {
		tag = USA
	}
	enable = {
		has_dlc = "By Blood Alone"
		has_navy_size = {
			size > 1
		}
		tag = USA
		date > 1940.6.6
		is_in_faction_with = ENG
	}
	abort_when_not_enabled = yes

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

USA_focus_on_africa = {
	allowed = { original_tag = USA }

	enable = {
		GER = { has_capitulated = yes } # Ragnarok added
		is_historical_focus_on = yes
		has_war_with = GER
		has_global_flag = FRA_already_surrendered
		OR = { # Check whole north-african coast
			448 = { CONTROLLER = { has_war_with = ROOT } } # tripoli
			450 = { CONTROLLER = { has_war_with = ROOT } } # benghazi
			458 = { CONTROLLER = { has_war_with = ROOT } } # tunisia
			461 = { CONTROLLER = { has_war_with = ROOT } } # casablanca
			462 = { CONTROLLER = { has_war_with = ROOT } } # marrakech
			459 = { CONTROLLER = { has_war_with = ROOT } } # algiers
			460 = { CONTROLLER = { has_war_with = ROOT } } # constantine
			665 = { CONTROLLER = { has_war_with = ROOT } } # gabès
			449 = { CONTROLLER = { has_war_with = ROOT } } # el agheila
			451 = { CONTROLLER = { has_war_with = ROOT } } # derna
			452 = { CONTROLLER = { has_war_with = ROOT } } # matrouh
			447 = { CONTROLLER = { has_war_with = ROOT } } # alexandria
			446 = { CONTROLLER = { has_war_with = ROOT } } # cairo
			290 = { CONTROLLER = { has_war_with = ROOT } } # spanish africa
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = front_unit_request
		area = africa
		value = 60
	}

	ai_strategy = {
		type = area_priority
		id = africa
		value = 60
	}
}

USA_ENG_sync_invasions_on_europe = {
	allowed = {
		#always = no
		OR = {
			tag = USA
			tag = ENG
		}
	}

	# only allow invasion on europe on every third month

	enable = {
		NOT = { has_war_with = GER } # Ragnarok added

		set_temp_variable = { days = global.num_days }
		modulo_temp_variable = { days = 90 }
		check_variable = { days < 60 }
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = front_control

		area = mainland_europe

		ordertype = invasion
		execute_order = no
	}
}

USA_take_out_italy_boost = {
	allowed = {
		original_tag = USA
		is_historical_focus_on = yes
	}
	enable = {
		NOT = { has_war_with = GER } # Ragnarok added

		date > 1942.6.1
		ITA = {
			surrender_progress < 0.2
		}
	}
	abort_when_not_enabled = yes

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

	ai_strategy = {
		type = area_priority
		id = italy
		value = 600
	}

	ai_strategy = {
		type = invasion_unit_request
		area = italy
		value = 3
	}

	ai_strategy = {
		type = area_priority
		id = north_africa
		value = 400
	}

	ai_strategy = {
		type = area_priority
		id = normandy_landing_zone
		value = -100
	}
}

#This is a boost to the ENG_USA_d_dat strategy to make the USA consider invading in europe and not only in the pacific for a while
USA_d_day_boost = {
	allowed = {
		original_tag = USA
	}
	enable = {
		GER = { has_capitulated = yes } # Ragnarok added		
		has_war_with = GER 
		date > 1943.9.1
		ITA = {
			surrender_progress > 0.2
		}
	}
	abort = {
		OR = {
			date > 1944.9.1 # if we haven't succeeded by now, kill Japan instead
			AND = {
				16 = { is_controlled_by_ROOT_or_ally = yes } # Paris has been liberated
				is_historical_focus_on = yes 
			}
		}
	}

	ai_strategy = {
		type = invade
		id = GER
		value = 50
	}

	ai_strategy = {
		type = area_priority
		id = normandy_landing_zone
		value = 400
	}

	ai_strategy = {
		type = invasion_unit_request
		area = normandy_landing_zone
		value = 5
	}
}

USA_torch_boost = {
	allowed = {
		original_tag = USA
	}
	enable = {
		GER = { has_capitulated = yes } # Ragnarok added		
		country_exists = VIC 
		has_war_with = GER 
		date > 1942.5.1
		#has_war_with = 461.owner 
	}
	abort = {
		OR = {
			date > 1943.9.1 # if we haven't succeeded by now, maybe try somewhere else
			461 = { is_controlled_by_ROOT_or_ally = yes }
			459 = { is_controlled_by_ROOT_or_ally = yes }
		}
	}

	ai_strategy = {
		type = area_priority
		id = torch_landing_zone
		value = 800
	}
	
	ai_strategy = {
		type = area_priority
		id = vichy_mainland
		value = -200
	}

	ai_strategy = {
		type = invasion_unit_request
		area = torch_landing_zone
		value = 2
	}
	ai_strategy = {
		type = front_unit_request
		area = torch_landing_zone
		value = 1
	}
	ai_strategy = {
		type = prepare_for_war
		id = VIC
		value = 200 
	}
	ai_strategy = {
		type = invade
		id = VIC
		value = 200
	}
}



USA_save_the_aussies = {
	allowed = { original_tag = USA }
	enable = {
		has_government = democratic
		is_in_faction = no
		has_war = no

		JAP = {	has_war_with = AST }
		AST = {
			has_government = democratic
			surrender_progress > 0.15
		}
		has_opinion = {
			target = AST
			value > 0 # not if we hate AST
		}
	}
	abort = {
		OR = {
			has_war_with = AST
			is_in_faction_with = JAP
			JAP = {
				NOT = { has_war_with = AST }
			}
		}
	}

	ai_strategy = {
		type = contain
		id = "JAP"
		value = 200
	}

	ai_strategy = {
		type = protect
		id = "AST"
		value = 200
	}
	ai_strategy = {
		type = support
		id = "AST"
		value = 100
	}
}

USA_save_india = { # in the case where japan has beaten china and is moving on india we should step up
	allowed = { original_tag = USA }
	enable = {
		has_government = democratic
		is_in_faction = no
		has_war = no

		JAP = {
			has_war_with = RAJ
			NOT = { has_war_with = CHI }
		}
		RAJ = {
			is_in_faction_with = ENG
			surrender_progress > 0.15
		}
	}
	abort = {
		OR = {
			has_war_with = RAJ
			is_in_faction_with = JAP
			JAP = {
				NOT = { has_war_with = RAJ }
			}
		}
	}

	ai_strategy = {
		type = contain
		id = "JAP"
		value = 200
	}

	ai_strategy = {
		type = protect
		id = "RAJ"
		value = 200
	}
}

USA_stop_soviet_from_falling = {
	allowed = { original_tag = USA }
	enable = {
		has_war = no
		num_divisions > 85 # we must have some divisions ourselves

		NOT = { has_government = fascism }
		NOT = { is_in_faction_with = GER }
		NOT = { has_war_with = SOV }
		GER = {
			has_war_with = SOV
			has_war_with = ENG
			has_government = fascism
		}
		SOV = {
			surrender_progress > 0.05
			has_capitulated = no
		}
	}

	abort = {
		OR = {
			has_war = yes
			has_war_with = SOV
			NOT = { GER = { has_war_with = SOV } }
			is_in_faction_with = GER
			has_government = fascism
			SOV = { has_war = no }
			SOV = { surrender_progress < 0.01 }
		}
	}

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

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

	ai_strategy = {
		type = template_prio
		id = light_armor
		value = -25
	}

	ai_strategy = {
		type = template_prio
		id = medium_armor
		value = -25
	}

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

# this one is same as above, but if you have entered the war yourself
USA_stop_soviet_from_falling_2 = {
	allowed = { original_tag = USA }
	enable = {
		has_war = yes
		NOT = { has_government = fascism }
		NOT = { is_in_faction_with = GER }
		NOT = { has_war_with = SOV }
		GER = {
			has_war_with = SOV
			has_war_with = USA
		}
		SOV = {
			surrender_progress > 0.05
			has_capitulated = no
		}
	}

	abort = {
		OR = {
			has_war = no
			has_war_with = SOV
			NOT = { GER = { has_war_with = SOV } }
			is_in_faction_with = GER
			has_government = fascism
			SOV = { has_war = no }
			SOV = { surrender_progress < 0.01 }
		}
	}

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

USA_template_design_1 = {
	allowed = { original_tag = USA }
	enable = {
		date < 1940.1.1
	}
	abort = {
		date > 1940.1.1
	}

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

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

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

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

USA_template_design_2 = {
	allowed = { original_tag = USA }
	enable = {
		date > 1940.1.1
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = template_prio
		id = mechanized
		value = -20
	}

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

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

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

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

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

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

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

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

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

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

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

	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
	}

	ai_strategy = {
		type = unit_ratio
		id = capital_ship
		value = 1		 #1 to 2
	}
	ai_strategy = {
		type = unit_ratio
		id = screen_ship
		value = 100		 #1 to 2
	}
	ai_strategy = {
		type = unit_ratio
		id = carrier
		value = 20		 #1 to 2
	}
}

USA_naval_role_ratios_anti_submarine = {
	allowed = {
		has_dlc = "Man the Guns"
		original_tag = USA
	}
	enable = {
		anti_submarine_strategy_required_trigger = yes
	}

	abort = {
		not = { anti_submarine_strategy_required_trigger = yes }
	}

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

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

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

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

	ai_strategy = {
		type = role_ratio
		id = naval_cruiser_heavy
		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
			}
		}
	}
	abort = {
		has_war_with = GER # Ragnarok added
	}


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

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_help_waters_around_GER = {
	allowed = { original_tag = USA }
	enable = {
		GER = { has_capitulated = yes } # Ragnarok added
		is_in_faction_with = ENG
		NOT = { has_war_with = JAP }
		has_war_with = GER
		ENG = { has_war_with = GER }
	}
	abort = {
		GER = {
			has_capitulated = yes
		}
	}

	ai_strategy = {
		type = strike_force_home_base
		id = 18 # channel
	}
}

USA_onto_the_beaches = {
	allowed = {
		original_tag = USA
	}
	enable = {
		has_war = yes
		GER = { has_capitulated = yes } # Ragnarok added
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = naval_invasion_focus
		value = 55
	}
}

USA_convoy_hungry = {
	enable = {
		date > 1940.1.1
		has_equipment = {
  			convoy < 600
  		}
		convoy_threat < 0.2 # there are other strategies for this, so we dont want to double up
	}
	abort_when_not_enabled = yes

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

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

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

GER_is_bad = {
	allowed = {
		tag = USA
	}

	enable = {
		GER = {
			exists = yes
		}
		NOT = { is_ally_with = GER }
		ENG = {
			has_war_with = GER
		}
		has_government = democratic
		ENG = {
			has_government = democratic
		}
		date > 1939.1.1
	}
	abort = {
		has_war_with = GER # Ragnarok added
	}

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

USA_Defends_australia_new_zealand = {
	allowed = {
		tag = USA
	}

	enable = {
		AST = {
			exists = yes
		}
		is_ally_with = USA
	}
	abort = {
		has_war_with = GER # Ragnarok added
	}

	# northen territory
	ai_strategy = {
		type = theatre_distribution_demand_increase
		id = 520
		value = 10
	}

	#papua
	ai_strategy = {
		type = theatre_distribution_demand_increase
		id = 523
		value = 10
	}

	#marshall islands
	ai_strategy = {
		type = theatre_distribution_demand_increase
		id = 633
		value = 10
	}
}

USA_produce_floating_harbors = {
	allowed = {	original_tag = USA }
	enable = {
		is_historical_focus_on = yes
		date > 1941.1.1
		has_war = yes
		num_of_naval_factories > 25
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = unit_ratio
		id = floating_harbor # for floating harbors, 'unit_ratio' is actually not a ratio but an absolute desired number
		value = 10
	}
}

USA_stay_away_from_my_pacific = {
	allowed = {
		original_tag = USA
	}
	enable = {
		has_war_with = JAP
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = area_priority
		id = pacific
		value = 100
	}
}

USA_lets_do_a_navy = {
	allowed = { original_tag = USA }
	enable = {
		has_government = democratic
		has_war = no
		date > 1937.10.1
		dockyard < 75 # If we have this many we can probably stop
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = build_building
		id = dockyard
		value = 2
	}
}

USA_srsly_mils_now = {
	allowed = {
		original_tag = USA
	}
	enable = {
		date > 1941.1.1
		has_war = yes
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = building_target
		id = arms_factory
		value = 200
	}
}

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_think_about_retaliation = {
	allowed = {
		original_tag = USA
	}
	enable = {
		has_war_with = JAP
		date > 1943.1.1
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = area_priority
		id = home_islands
		value = 100
	}
	
	ai_strategy = {
		type = naval_invasion_dominance_weight
		value = 30
	}

}

USA_go_time = {
	allowed = {
		OR = {
			original_tag = USA
			original_tag = ENG
		}
		is_historical_focus_on = yes
	}
	enable = {
		has_war_with = JAP
		date > 1943.6.1
		surrender_progress < 0.20
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = invade
		id = "JAP"
		value = 50
	}

	ai_strategy = {
		type = front_unit_request
		area = home_islands
		value = 100
	}

	ai_strategy = {
		type = consider_weak
		id = "JAP"
		value = 75
	}
	
	ai_strategy = {
		type = naval_invasion_dominance_weight
		value = 40
	}

}

USA_start_buffering_in_pacific = {
	allowed = {
		tag = USA
	}
	enable = {
		date > 1941.9.2
		OR = {
			has_war_with = JAP
			has_war_with = CHI
		}
	}
	abort_when_not_enabled = yes
	
	ai_strategy = {
		type = put_unit_buffers

		# pacific islands
		states = {
			633 #Marshall
			632 #Wake
			684 #Caroline
			645 #Iwo Jima
			638 #Guam
			646 #Saipan
		}

		ratio = 0.12

		area = pacific

		subtract_invasions_from_need = no
		subtract_fronts_from_need = no
	}
	
	ai_strategy = {
		type = put_unit_buffers

		# pacific islands
		states = {
			633 #Marshall
			632 #Wake
			684 #Caroline
			645 #Iwo Jima
			638 #Guam
			646 #Saipan
		}

		ratio = 0.12

		area = pacific

		subtract_invasions_from_need = yes
		subtract_fronts_from_need = no
	}

	ai_strategy = {
		type = put_unit_buffers

		# pacific islands
		states = {
			633 #Marshall
			632 #Wake
			684 #Caroline
			645 #Iwo Jima
			638 #Guam
			646 #Saipan
		}

		ratio = 0.12
		area = home_islands

		subtract_invasions_from_need = yes
		subtract_fronts_from_need = no
	}
	
	ai_strategy = {
		type = front_unit_request
		area = pacific
		value = 30
	}
	
	ai_strategy = {
		type = invasion_unit_request
		area = pacific
		value = 2
	}
	
	ai_strategy = {
		type = naval_invasion_dominance_weight
		value = 50
	}
}

USA_start_buffering_in_australia = {
	allowed = {
		tag = USA
	}
	enable = {
		NOT = { has_war_with = GER } # Ragnarok added
		date > 1943.1.1
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = put_unit_buffers

		# Australia
		states = {
			870 #North West Aus
			522 #Western Aus
		}

		ratio = 0.15

		area = pacific
		area = home_islands

		subtract_invasions_from_need = yes
		subtract_fronts_from_need = yes
	}
	
	ai_strategy = {
		type = invasion_unit_request
		area = pacific
		area = home_islands
		value = 6
	}
}

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_production_min_factories_archetype
		id = motorized_equipment
		value = 1
	}
	ai_strategy = {
		type = equipment_production_factor
		id = motorized
		value = 40
	}
	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_production_factor
		id = fighter
		value = 15
	}
	ai_strategy = {
		type = equipment_production_min_factories
		id = fighter
		value = 1
	}
	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_90_division_gamble = {
	allowed = { original_tag = USA }
	enable = { 
		is_historical_focus_on = yes
	}
	abort = {
		has_war_with = GER # Ragnarok added
	}

	ai_strategy = {
		type = ai_wanted_divisions_factor
		value = -30
	}
}

USA_sugar_daddy_for_UK = {
	allowed = { original_tag = USA }
	enable = {
		NOT = { has_war_with = ENG }
		has_government = democratic
		ENG = {
			has_government = democratic
			has_war = yes
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = send_lend_lease_desire
		id = ENG
		value = 500
	}
}

USA_sugar_daddy_for_SOV = {
	allowed = { original_tag = USA }
	enable = {
		NOT = { has_war_with = SOV }
		has_government = democratic
		GER = { has_government = fascism }
		SOV = {
			has_war_with = GER
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = send_lend_lease_desire
		id = SOV
		value = 500
	}
}

USA_TEST_PHILLIPINES = {
	allowed = {
		original_tag = USA
	}
	
	enable = {
		always = no
	}
	
	abort = {
		has_war_with = GER # Ragnarok added
	}

	ai_strategy = {
		type = naval_dominance
		id = 78
		value = 100
	}
	
	ai_strategy = {
		type = naval_dominance
		id = 80
		value = 100
	}
	
	ai_strategy = {
		type = naval_dominance
		id = 75
		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 = {
		NOT = { has_war_with = GER } # Ragnarok added
		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 = {
		NOT = { has_war_with = GER } # Ragnarok added
		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 = {
		NOT = { has_war_with = GER } # Ragnarok added
		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
	}

}


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