###MILITARY AI###

division_limiter = {
	allowed = {
		NOT = { has_game_rule = { rule = unit_limit_options option = NONE } }
	}
	enable = {
		has_reached_maximum_divisions = yes
	}

	abort_when_not_enabled = yes

	#AI roles
	ai_strategy = { type = build_army 		id = infantry					value = -1000 }
	ai_strategy = { type = build_army 		id = light_infantry				value = -1000 }
	ai_strategy = { type = build_army 		id = shock_infantry				value = -1000 }
	ai_strategy = { type = build_army 		id = motorized					value = -1000 }
	ai_strategy = { type = build_army 		id = mechanized					value = -1000 }
	ai_strategy = { type = build_army 		id = armor_role					value = -1000 }
	ai_strategy = { type = build_army 		id = heavy_armor_role			value = -1000 }
	ai_strategy = { type = build_army 		id = mountaineer				value = -1000 }
	ai_strategy = { type = build_army 		id = marine						value = -1000 }
	ai_strategy = { type = build_army 		id = suppression				value = -1000 }
}

default_army_composition = {
	enable = { always = yes }
	abort_when_not_enabled = yes

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

division_upgrades_are_very_important = {
	enable = {
		always = yes
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = land_xp_spend_priority
		id = division_template
		value = 100
	}
	ai_strategy = {
		type = template_prio
		id = infantry
		value = 100
	}
	ai_strategy = {
		type = template_prio
		id = cavalry
		value = 100
	}
	ai_strategy = {
		type = template_prio
		id = artillery
		value = 100
	}
	ai_strategy = {
		type = template_prio
		id = motorized
		value = 100
	}
	ai_strategy = {
		type = template_prio
		id = mechanized
		value = 100
	}
	ai_strategy = {
		type = template_prio
		id = light_armor
		value = 100
	}
	ai_strategy = {
		type = template_prio
		id = medium_armor
		value = 100
	}
	ai_strategy = {
		type = template_prio
		id = heavy_armor
		value = 100
	}
	ai_strategy = {
		type = template_prio
		id = modern_armor
		value = 100
	}
	ai_strategy = {
		type = template_prio
		id = mountaineer
		value = 100
	}
	ai_strategy = {
		type = template_prio
		id = marine
		value = 100
	}
}

############################################################################################################
#	ARMOR EFFORT 1
############################################################################################################

base_armor_production = {
	enable = {
		is_eligible_for_armor_production = yes
	}
	abort_when_not_enabled = yes

	ai_strategy = { type = role_ratio                          id = infantry                     value = -4 }
	ai_strategy = { type = role_ratio                          id = shock_infantry               value = 4 }
	ai_strategy = { type = role_ratio                          id = motorized                    value = 4 }
	ai_strategy = { type = role_ratio                          id = armor_role             		 value = 12 }
}

armor_effort_1 = {
	enable = {
		num_of_military_factories > 60
	}
	abort_when_not_enabled = yes

	ai_strategy = { type = role_ratio                          id = infantry                     value = -4 }
	ai_strategy = { type = role_ratio                          id = shock_infantry               value = 4 }
	ai_strategy = { type = role_ratio                          id = motorized                    value = 4 }
	ai_strategy = { type = role_ratio                          id = armor_role             		 value = 12 }
}

############################################################################################################
#	ARMOR EFFORT 2
############################################################################################################

mw_armor_effort_2 = {
	enable = {
		num_of_military_factories > 90
		has_doctrine = new_mobile_warfare
	}
	abort_when_not_enabled = yes

	ai_strategy = { type = role_ratio                          id = infantry                     value = -4 }
	ai_strategy = { type = role_ratio                          id = shock_infantry               value = 2 }
	ai_strategy = { type = role_ratio                          id = motorized                    value = 8 }
	ai_strategy = { type = role_ratio                          id = armor_role             		 value = 14 }
}

sp_armor_effort_2 = {
	enable = {
		num_of_military_factories > 90
		has_doctrine = superior_firepower
	}
	abort_when_not_enabled = yes

	ai_strategy = { type = role_ratio                          id = infantry                     value = -4 }
	ai_strategy = { type = role_ratio                          id = shock_infantry               value = 8 }
	ai_strategy = { type = role_ratio                          id = motorized                    value = 2 }
	ai_strategy = { type = role_ratio                          id = armor_role             		 value = 10 }
}

gbp_armor_effort_2 = {
	enable = {
		num_of_military_factories > 90
		has_doctrine = grand_battleplan
	}
	abort_when_not_enabled = yes

	ai_strategy = { type = role_ratio                          id = infantry                     value = -4 }
	ai_strategy = { type = role_ratio                          id = shock_infantry               value = 4 }
	ai_strategy = { type = role_ratio                          id = motorized                    value = 4 }
	ai_strategy = { type = role_ratio                          id = armor_role             		 value = 12 }
}

ma_armor_effort_2 = {
	enable = {
		num_of_military_factories > 90
		has_doctrine = mass_assault
	}
	abort_when_not_enabled = yes

	ai_strategy = { type = role_ratio                          id = infantry                     value = -4 }
	ai_strategy = { type = role_ratio                          id = shock_infantry               value = 6 }
	ai_strategy = { type = role_ratio                          id = motorized                    value = 4 }
	ai_strategy = { type = role_ratio                          id = armor_role             		 value = 8 }
}

############################################################################################################
#	ARMOR EFFORT 3
############################################################################################################

mw_armor_effort_3 = {
	enable = {
		is_eligible_for_heavy_armor_production = yes
		has_doctrine = new_mobile_warfare
		has_subdoctrine_in_track = infantry
		has_subdoctrine_in_track = combat_support
	}
	abort_when_not_enabled = yes

	ai_strategy = { type = role_ratio                          id = infantry                     value = -8 }
	ai_strategy = { type = role_ratio                          id = shock_infantry               value = 2 }
	ai_strategy = { type = role_ratio                          id = motorized                    value = 6 }
	ai_strategy = { type = role_ratio                          id = mechanized                   value = 4 }
	ai_strategy = { type = role_ratio                          id = armor_role             		 value = 16 }
	ai_strategy = { type = role_ratio                          id = heavy_armor_role             value = 6 }
}

sp_armor_effort_3 = {
	enable = {
		is_eligible_for_heavy_armor_production = yes
		has_doctrine = superior_firepower
		has_subdoctrine_in_track = infantry
		has_subdoctrine_in_track = combat_support
	}
	abort_when_not_enabled = yes

	ai_strategy = { type = role_ratio                          id = infantry                     value = -8 }
	ai_strategy = { type = role_ratio                          id = shock_infantry               value = 8 }
	ai_strategy = { type = role_ratio                          id = motorized                    value = 2 }
	ai_strategy = { type = role_ratio                          id = mechanized                   value = 6 }
	ai_strategy = { type = role_ratio                          id = armor_role             		 value = 12 }
	ai_strategy = { type = role_ratio                          id = heavy_armor_role             value = 4 }
}

gbp_armor_effort_3 = {
	enable = {
		is_eligible_for_heavy_armor_production = yes
		has_doctrine = grand_battleplan
		has_subdoctrine_in_track = infantry
		has_subdoctrine_in_track = combat_support
	}
	abort_when_not_enabled = yes

	ai_strategy = { type = role_ratio                          id = infantry                     value = -8 }
	ai_strategy = { type = role_ratio                          id = shock_infantry               value = 4 }
	ai_strategy = { type = role_ratio                          id = motorized                    value = 2 }
	ai_strategy = { type = role_ratio                          id = mechanized                   value = 4 }
	ai_strategy = { type = role_ratio                          id = armor_role             		 value = 14 }
	ai_strategy = { type = role_ratio                          id = heavy_armor_role             value = 8 }
}

ma_armor_effort_3 = {
	enable = {
		is_eligible_for_heavy_armor_production = yes
		has_doctrine = mass_assault
		has_subdoctrine_in_track = infantry
		has_subdoctrine_in_track = combat_support
	}
	abort_when_not_enabled = yes

	ai_strategy = { type = role_ratio                          id = infantry                     value = -8 }
	ai_strategy = { type = role_ratio                          id = shock_infantry               value = 6 }
	ai_strategy = { type = role_ratio                          id = motorized                    value = 4 }
	ai_strategy = { type = role_ratio                          id = mechanized                   value = 2 }
	ai_strategy = { type = role_ratio                          id = armor_role             		 value = 10 }
	ai_strategy = { type = role_ratio                          id = heavy_armor_role             value = 2 }
}

############################################################################################################
#	ARMOR EFFORT 4
############################################################################################################

mw_armor_effort_4 = {
	enable = {
		num_of_military_factories > 180
		has_doctrine = new_mobile_warfare
		has_subdoctrine_in_track = infantry
		has_subdoctrine_in_track = combat_support
	}
	abort_when_not_enabled = yes

	ai_strategy = { type = role_ratio                          id = infantry                     value = -8 }
	ai_strategy = { type = role_ratio                          id = shock_infantry               value = 2 }
	ai_strategy = { type = role_ratio                          id = motorized                    value = 6 }
	ai_strategy = { type = role_ratio                          id = mechanized                   value = 4 }
	ai_strategy = { type = role_ratio                          id = armor_role             		 value = 16 }
	ai_strategy = { type = role_ratio                          id = heavy_armor_role             value = 6 }
}

sp_armor_effort_4 = {
	enable = {
		num_of_military_factories > 180
		has_doctrine = superior_firepower
		has_subdoctrine_in_track = infantry
		has_subdoctrine_in_track = combat_support
	}
	abort_when_not_enabled = yes

	ai_strategy = { type = role_ratio                          id = infantry                     value = -8 }
	ai_strategy = { type = role_ratio                          id = shock_infantry               value = 8 }
	ai_strategy = { type = role_ratio                          id = motorized                    value = 2 }
	ai_strategy = { type = role_ratio                          id = mechanized                   value = 6 }
	ai_strategy = { type = role_ratio                          id = armor_role             		 value = 12 }
	ai_strategy = { type = role_ratio                          id = heavy_armor_role             value = 4 }
}

gbp_armor_effort_4 = {
	enable = {
		num_of_military_factories > 180
		has_doctrine = grand_battleplan
		has_subdoctrine_in_track = infantry
		has_subdoctrine_in_track = combat_support
	}
	abort_when_not_enabled = yes

	ai_strategy = { type = role_ratio                          id = infantry                     value = -8 }
	ai_strategy = { type = role_ratio                          id = shock_infantry               value = 4 }
	ai_strategy = { type = role_ratio                          id = motorized                    value = 2 }
	ai_strategy = { type = role_ratio                          id = mechanized                   value = 4 }
	ai_strategy = { type = role_ratio                          id = armor_role             		 value = 14 }
	ai_strategy = { type = role_ratio                          id = heavy_armor_role             value = 8 }
}

ma_armor_effort_4 = {
	enable = {
		num_of_military_factories > 180
		has_doctrine = mass_assault
		has_subdoctrine_in_track = infantry
		has_subdoctrine_in_track = combat_support
	}
	abort_when_not_enabled = yes

	ai_strategy = { type = role_ratio                          id = infantry                     value = -8 }
	ai_strategy = { type = role_ratio                          id = shock_infantry               value = 6 }
	ai_strategy = { type = role_ratio                          id = motorized                    value = 4 }
	ai_strategy = { type = role_ratio                          id = mechanized                   value = 2 }
	ai_strategy = { type = role_ratio                          id = armor_role             		 value = 10 }
	ai_strategy = { type = role_ratio                          id = heavy_armor_role             value = 2 }
}

############################################################################################################
#	ARMOR EFFORT 5
############################################################################################################

mw_armor_effort_5 = {
	enable = {
		num_of_military_factories > 240
		has_doctrine = new_mobile_warfare
		has_subdoctrine_in_track = infantry
		has_subdoctrine_in_track = combat_support
	}
	abort_when_not_enabled = yes

	ai_strategy = { type = role_ratio                          id = infantry                     value = -8 }
	ai_strategy = { type = role_ratio                          id = shock_infantry               value = 2 }
	ai_strategy = { type = role_ratio                          id = motorized                    value = 6 }
	ai_strategy = { type = role_ratio                          id = mechanized                   value = 4 }
	ai_strategy = { type = role_ratio                          id = armor_role             		 value = 16 }
	ai_strategy = { type = role_ratio                          id = heavy_armor_role             value = 6 }
}

sp_armor_effort_5 = {
	enable = {
		num_of_military_factories > 240
		has_doctrine = superior_firepower
		has_subdoctrine_in_track = infantry
		has_subdoctrine_in_track = combat_support
	}
	abort_when_not_enabled = yes

	ai_strategy = { type = role_ratio                          id = infantry                     value = -8 }
	ai_strategy = { type = role_ratio                          id = shock_infantry               value = 8 }
	ai_strategy = { type = role_ratio                          id = motorized                    value = 2 }
	ai_strategy = { type = role_ratio                          id = mechanized                   value = 6 }
	ai_strategy = { type = role_ratio                          id = armor_role             		 value = 12 }
	ai_strategy = { type = role_ratio                          id = heavy_armor_role             value = 4 }
}

gbp_armor_effort_5 = {
	enable = {
		num_of_military_factories > 240
		has_doctrine = grand_battleplan
		has_subdoctrine_in_track = infantry
		has_subdoctrine_in_track = combat_support
	}
	abort_when_not_enabled = yes

	ai_strategy = { type = role_ratio                          id = infantry                     value = -8 }
	ai_strategy = { type = role_ratio                          id = shock_infantry               value = 4 }
	ai_strategy = { type = role_ratio                          id = motorized                    value = 2 }
	ai_strategy = { type = role_ratio                          id = mechanized                   value = 4 }
	ai_strategy = { type = role_ratio                          id = armor_role             		 value = 14 }
	ai_strategy = { type = role_ratio                          id = heavy_armor_role             value = 8 }
}

ma_armor_effort_5 = {
	enable = {
		num_of_military_factories > 240
		has_doctrine = mass_assault
		has_subdoctrine_in_track = infantry
		has_subdoctrine_in_track = combat_support
	}
	abort_when_not_enabled = yes

	ai_strategy = { type = role_ratio                          id = infantry                     value = -8 }
	ai_strategy = { type = role_ratio                          id = shock_infantry               value = 6 }
	ai_strategy = { type = role_ratio                          id = motorized                    value = 4 }
	ai_strategy = { type = role_ratio                          id = mechanized                   value = 2 }
	ai_strategy = { type = role_ratio                          id = armor_role             		 value = 10 }
	ai_strategy = { type = role_ratio                          id = heavy_armor_role             value = 2 }
}

############################################################################################################
#	ARMOR EFFORT 6
############################################################################################################

mw_armor_effort_6 = {
	enable = {
		num_of_military_factories > 300
		has_doctrine = new_mobile_warfare
		has_subdoctrine_in_track = infantry
		has_subdoctrine_in_track = combat_support
	}
	abort_when_not_enabled = yes

	ai_strategy = { type = role_ratio                          id = infantry                     value = -8 }
	ai_strategy = { type = role_ratio                          id = shock_infantry               value = 2 }
	ai_strategy = { type = role_ratio                          id = motorized                    value = 6 }
	ai_strategy = { type = role_ratio                          id = mechanized                   value = 4 }
	ai_strategy = { type = role_ratio                          id = armor_role             		 value = 16 }
	ai_strategy = { type = role_ratio                          id = heavy_armor_role             value = 6 }
}

sp_armor_effort_6 = {
	enable = {
		num_of_military_factories > 300
		has_doctrine = superior_firepower
		has_subdoctrine_in_track = infantry
		has_subdoctrine_in_track = combat_support
	}
	abort_when_not_enabled = yes

	ai_strategy = { type = role_ratio                          id = infantry                     value = -8 }
	ai_strategy = { type = role_ratio                          id = shock_infantry               value = 8 }
	ai_strategy = { type = role_ratio                          id = motorized                    value = 2 }
	ai_strategy = { type = role_ratio                          id = mechanized                   value = 6 }
	ai_strategy = { type = role_ratio                          id = armor_role             		 value = 12 }
	ai_strategy = { type = role_ratio                          id = heavy_armor_role             value = 4 }
}

gbp_armor_effort_6 = {
	enable = {
		num_of_military_factories > 300
		has_doctrine = grand_battleplan
		has_subdoctrine_in_track = infantry
		has_subdoctrine_in_track = combat_support
	}
	abort_when_not_enabled = yes

	ai_strategy = { type = role_ratio                          id = infantry                     value = -8 }
	ai_strategy = { type = role_ratio                          id = shock_infantry               value = 4 }
	ai_strategy = { type = role_ratio                          id = motorized                    value = 2 }
	ai_strategy = { type = role_ratio                          id = mechanized                   value = 4 }
	ai_strategy = { type = role_ratio                          id = armor_role             		 value = 14 }
	ai_strategy = { type = role_ratio                          id = heavy_armor_role             value = 8 }
}

ma_armor_effort_6 = {
	enable = {
		num_of_military_factories > 300
		has_doctrine = mass_assault
		has_subdoctrine_in_track = infantry
		has_subdoctrine_in_track = combat_support
	}
	abort_when_not_enabled = yes

	ai_strategy = { type = role_ratio                          id = infantry                     value = -8 }
	ai_strategy = { type = role_ratio                          id = shock_infantry               value = 6 }
	ai_strategy = { type = role_ratio                          id = motorized                    value = 4 }
	ai_strategy = { type = role_ratio                          id = mechanized                   value = 2 }
	ai_strategy = { type = role_ratio                          id = armor_role             		 value = 10 }
	ai_strategy = { type = role_ratio                          id = heavy_armor_role             value = 2 }
}

############################################################################################################
#	INF REDUCTION
############################################################################################################

we_have_enough_inf_1 = {
	enable = {
		is_eligible_for_armor_production = yes
		has_army_size = { size > 60 type = infantry }
	}
	abort_when_not_enabled = yes

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

we_have_enough_inf_2 = {
	enable = {
		is_eligible_for_armor_production = yes
		has_army_size = { size > 90 type = infantry }
	}
	abort_when_not_enabled = yes

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

we_have_enough_inf_3 = {
	enable = {
		is_eligible_for_armor_production = yes
		has_army_size = { size > 120 type = infantry }
	}
	abort_when_not_enabled = yes

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

we_have_enough_inf_4 = {
	enable = {
		is_eligible_for_armor_production = yes
		has_army_size = { size > 150 type = infantry }
	}
	abort_when_not_enabled = yes

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

we_have_enough_inf_5 = {
	enable = {
		is_eligible_for_armor_production = yes
		has_army_size = { size > 180 type = infantry }
	}
	abort_when_not_enabled = yes

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

############################################################################################################
#	FORCE BUILD ARMIES
############################################################################################################

total_war = {
	enable = {
		is_eligible_for_heavy_armor_production = yes
		max_available_manpower_k > 1200
	}
	abort_when_not_enabled = yes
	
	ai_strategy = {
		type = force_build_armies
		value = 1000
    }
}

############################################################################################################
#	AREA DEFENSE
############################################################################################################

deploy_garrisons_1 = {
	enable = {
		num_controlled_states > 10
	}
	abort_when_not_enabled = yes

	ai_strategy = { type = build_army                          id = light_infantry                     value = 5 }
}

deploy_garrisons_2 = {
	enable = {
		num_controlled_states > 20
	}
	abort_when_not_enabled = yes

	ai_strategy = { type = build_army                          id = light_infantry                     value = 5 }
}

deploy_garrisons_3 = {
	enable = {
		num_controlled_states > 30
	}
	abort_when_not_enabled = yes

	ai_strategy = { type = build_army                          id = light_infantry                     value = 5 }
}

deploy_garrisons_4 = {
	enable = {
		num_controlled_states > 40
	}
	abort_when_not_enabled = yes

	ai_strategy = { type = build_army                          id = light_infantry                     value = 5 }
}

deploy_garrisons_5 = {
	enable = {
		num_controlled_states > 50
	}
	abort_when_not_enabled = yes

	ai_strategy = { type = build_army                          id = light_infantry                     value = 5 }
}

deploy_garrisons_6 = {
	enable = {
		num_controlled_states > 60
	}
	abort_when_not_enabled = yes

	ai_strategy = { type = build_army                          id = light_infantry                     value = 5 }
}

deploy_garrisons_7 = {
	enable = {
		num_controlled_states > 70
	}
	abort_when_not_enabled = yes

	ai_strategy = { type = build_army                          id = light_infantry                     value = 5 }
}

deploy_garrisons_8 = {
	enable = {
		num_controlled_states > 80
	}
	abort_when_not_enabled = yes

	ai_strategy = { type = build_army                          id = light_infantry                     value = 5 }
}

deploy_garrisons_9 = {
	enable = {
		num_controlled_states > 90
	}
	abort_when_not_enabled = yes

	ai_strategy = { type = build_army                          id = light_infantry                     value = 5 }
}

deploy_garrisons_10 = {
	enable = {
		num_controlled_states > 100
	}
	abort_when_not_enabled = yes

	ai_strategy = { type = build_army                          id = light_infantry                     value = 5 }
}

############################################################################################################
#	SPECIAL FORCES
############################################################################################################

default_mountaineer_production = {	
	enable = {
		has_tech = tech_mountaineers
		has_terrain = mountain
	}
	abort_when_not_enabled = yes

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

land_powers_make_more_mountaineers = {
	allowed = {
		OR = {
			is_chinese_tag = yes
			is_russian_tag = yes
			is_balkan_tag = yes
			tag = FRA
			tag = SWI
			tag = AUS
			tag = TUR
			tag = FIN
			tag = NOR
			tag = MEX
			tag = CHL
		}
	}
	enable = {
		has_tech = tech_mountaineers
	}
	abort_when_not_enabled = yes

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

default_marine_production = {
	enable = {
		has_tech = marines
		is_naval_power = yes
	}
	abort_when_not_enabled = yes

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

naval_powers_make_more_marines = {
	allowed = {
		OR = {
			is_american_tag = yes
			is_commonwealth_tag = yes
			tag = GBR
			tag = ENG
			tag = NFA
			tag = HOL
			tag = DEI
			tag = GER
			tag = GEX
			tag = GEA
			tag = JAP
		}
	}
	enable = {
		has_tech = marines
	}
	abort_when_not_enabled = yes

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

############################################################################################################
#	CIVS, MILS AND DOCKS
############################################################################################################

make_civs = {
	allowed = {
		NOT = {
			tag = GER
			is_american_tag = yes
		}
	}
	enable = {
		date < 1937.1.1
		has_war = no
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = building_target
		id = industrial_complex
		value = 1000
	}
}

make_mils = {
	enable = {
		num_of_civilian_factories > 15
		OR = {
			date > 1937.1.1
			has_war = yes
		}
	}
	abort_when_not_enabled = yes
		
	ai_strategy = {
		type = added_military_to_civilian_factory_ratio
		value = 1000
	}
}

island_nations_need_dockyards = {
	allowed = {
		OR = {
			tag = CAN
			tag = ENG
			tag = GBR
			tag = JAP
		}
	}
	enable = {
		num_of_military_factories > 9
		surrender_progress < 0.05
		set_temp_variable = { mil_fact = num_of_naval_factories }
		divide_temp_variable = { mil_fact = num_of_military_factories }
		check_variable = {
			var = mil_fact
			value = 0.60
			compare = less_than
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = dockyard_to_military_factory_ratio
		value = 1000
	}
}

americas_need_dockyards = {
	allowed = {
		is_american_tag = yes
	}
	enable = {
		has_global_flag = USA_civil_war_over_flag
		num_of_military_factories > 9
		surrender_progress < 0.05
		set_temp_variable = { mil_fact = num_of_naval_factories }
		divide_temp_variable = { mil_fact = num_of_military_factories }
		check_variable = {
			var = mil_fact
			value = 0.40
			compare = less_than
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = dockyard_to_military_factory_ratio
		value = 1000
	}
}

germany_needs_dockyards = {
	allowed = {
		tag = GER
	}
	enable = {
		num_of_military_factories > 9
		surrender_progress < 0.05
		set_temp_variable = { mil_fact = num_of_naval_factories }
		divide_temp_variable = { mil_fact = num_of_military_factories }
		check_variable = {
			var = mil_fact
			value = 0.30
			compare = less_than
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = dockyard_to_military_factory_ratio
		value = 1000
	}
}

other_majors_need_dockyards = {
	allowed = {
		NOT = {
			is_american_tag = yes
			tag = GER
			tag = CAN
			tag = ENG
			tag = GBR
			tag = JAP
		}
	}
	enable = {
		is_actual_major = yes
		num_of_military_factories > 9
		surrender_progress < 0.05
		set_temp_variable = { mil_fact = num_of_naval_factories }
		divide_temp_variable = { mil_fact = num_of_military_factories }
		check_variable = {
			var = mil_fact
			value = 0.10
			compare = less_than
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = dockyard_to_military_factory_ratio
		value = 1000
	}
}

minors_need_dockyards = {
	enable = {
		is_actual_major = no
		num_of_military_factories > 9
		surrender_progress < 0.05
		set_temp_variable = { mil_fact = num_of_naval_factories }
		divide_temp_variable = { mil_fact = num_of_military_factories }
		check_variable = {
			var = mil_fact
			value = 0.05
			compare = less_than
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = dockyard_to_military_factory_ratio
		value = 1000
	}
}

######################################
#	REFS AND SILOS
######################################

research_processing_techs_1 = {
	enable = {
		date > 1937.1.1
		has_tech = synth_oil_experiments
		num_of_military_factories > 50
		synthetic_refinery > 5
	}

	ai_strategy = {
		type = research_tech
		id = rubber_processing
		value = 100
	}
}

research_processing_techs_2 = {
	enable = {
		date > 1939.1.1
		has_tech = rubber_processing
		num_of_military_factories > 100
		synthetic_refinery > 15
	}

	ai_strategy = {
		type = research_tech
		id = improved_rubber_processing
		value = 100
	}
}

research_processing_techs_3 = {
	enable = {
		date > 1941.1.1
		has_tech = improved_rubber_processing
		num_of_military_factories > 150
		synthetic_refinery > 20
	}

	ai_strategy = {
		type = research_tech
		id = advanced_rubber_processing
		value = 100
	}
}

research_processing_techs_4 = {
	enable = {
		date > 1943.1.1
		has_tech = advanced_rubber_processing
		num_of_military_factories > 200
		synthetic_refinery > 30
	}

	ai_strategy = {
		type = research_tech
		id = modern_rubber_processing
		value = 100
	}
}

majors_build_some_refineries_1 = {
	enable = {
		date > 1938.1.1
		is_actual_major = yes
		has_tech = synth_oil_experiments
		num_of_military_factories > 30
		NOT = {
			any_subject_country = { check_variable = { resource_produced@rubber > 10 } }
			resource_produced@rubber > 10
		}
	}
	abort = { synthetic_refinery > 5 }

	ai_strategy = {
		type = building_target
		id = synthetic_refinery
		value = 2
	}
}

majors_build_some_refineries_2 = {
	enable = {
		date > 1938.1.1
		is_actual_major = yes
		has_tech = synth_oil_experiments
		num_of_military_factories > 60
		NOT = {
			any_subject_country = { check_variable = { resource_produced@rubber > 20 } }
			resource_produced@rubber > 20
		}
	}
	abort = { synthetic_refinery > 10 }

	ai_strategy = {
		type = building_target
		id = synthetic_refinery
		value = 2
	}
}

majors_build_some_refineries_3 = {
	enable = {
		date > 1938.1.1
		is_actual_major = yes
		has_tech = synth_oil_experiments
		num_of_military_factories > 90
		NOT = {
			any_subject_country = { check_variable = { resource_produced@rubber > 30 } }
			resource_produced@rubber > 30
		}
	}
	abort = { synthetic_refinery > 15 }

	ai_strategy = {
		type = building_target
		id = synthetic_refinery
		value = 2
	}
}

majors_build_some_refineries_4 = {
	enable = {
		date > 1938.1.1
		is_actual_major = yes
		has_tech = synth_oil_experiments
		num_of_military_factories > 120
		NOT = {
			any_subject_country = { check_variable = { resource_produced@rubber > 40 } }
			resource_produced@rubber > 40
		}
	}
	abort = { synthetic_refinery > 20 }

	ai_strategy = {
		type = building_target
		id = synthetic_refinery
		value = 2
	}
}

majors_build_some_refineries_5 = {
	enable = {
		date > 1938.1.1
		is_actual_major = yes
		has_tech = synth_oil_experiments
		num_of_military_factories > 150
		NOT = {
			any_subject_country = { check_variable = { resource_produced@rubber > 50 } }
			resource_produced@rubber > 50
		}
	}
	abort = { synthetic_refinery > 25 }

	ai_strategy = {
		type = building_target
		id = synthetic_refinery
		value = 2
	}
}

majors_build_some_refineries_6 = {
	enable = {
		date > 1938.1.1
		is_actual_major = yes
		has_tech = synth_oil_experiments
		num_of_military_factories > 180
		NOT = {
			any_subject_country = { check_variable = { resource_produced@rubber > 60 } }
			resource_produced@rubber > 60
		}
	}
	abort = { synthetic_refinery > 30 }

	ai_strategy = {
		type = building_target
		id = synthetic_refinery
		value = 2
	}
}

majors_build_some_refineries_7 = {
	enable = {
		date > 1938.1.1
		is_actual_major = yes
		has_tech = synth_oil_experiments
		num_of_military_factories > 210
		NOT = {
			any_subject_country = { check_variable = { resource_produced@rubber > 70 } }
			resource_produced@rubber > 70
		}
	}
	abort = { synthetic_refinery > 35 }

	ai_strategy = {
		type = building_target
		id = synthetic_refinery
		value = 2
	}
}

majors_build_some_refineries_8 = {
	enable = {
		date > 1938.1.1
		is_actual_major = yes
		has_tech = synth_oil_experiments
		num_of_military_factories > 240
		NOT = {
			any_subject_country = { check_variable = { resource_produced@rubber > 80 } }
			resource_produced@rubber > 80
		}
	}
	abort = { synthetic_refinery > 40 }

	ai_strategy = {
		type = building_target
		id = synthetic_refinery
		value = 2
	}
}

majors_build_some_refineries_9 = {
	enable = {
		date > 1938.1.1
		is_actual_major = yes
		has_tech = synth_oil_experiments
		num_of_military_factories > 270
		NOT = {
			any_subject_country = { check_variable = { resource_produced@rubber > 90 } }
			resource_produced@rubber > 90
		}
	}
	abort = { synthetic_refinery > 45 }

	ai_strategy = {
		type = building_target
		id = synthetic_refinery
		value = 2
	}
}

majors_build_some_refineries_10 = {
	enable = {
		date > 1938.1.1
		is_actual_major = yes
		has_tech = synth_oil_experiments
		num_of_military_factories > 300
		NOT = {
			any_subject_country = { check_variable = { resource_produced@rubber > 100 } }
			resource_produced@rubber > 100
		}
	}
	abort = { synthetic_refinery > 50 }

	ai_strategy = {
		type = building_target
		id = synthetic_refinery
		value = 2
	}
}

we_urgently_need_oil_or_rubber = {
	enable = {
		has_war = yes
		has_tech = synth_oil_experiments
		OR = {
			has_fuel < 100
			rubber < 0
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = building_target
		id = synthetic_refinery
		value = 10
	}
}

majors_build_some_silos_1 = {
	enable = {
		date > 1938.1.1
		is_actual_major = yes
		has_tech = fuel_silos
		fuel_silo < 5
		OR = {
			has_navy_size = {size > 75}
			has_deployed_air_force_size = {type = fighter	size > 1500}
			num_of_military_factories > 100
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = building_target
		id = fuel_silo
		value = 1
	}
}

majors_build_some_silos_2 = {
	enable = {
		date > 1938.1.1
		is_actual_major = yes
		has_tech = fuel_silos
		fuel_silo < 10
		OR = {
			has_navy_size = {size > 150}
			has_deployed_air_force_size = {type = fighter	size > 3000}
			num_of_military_factories > 200
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = building_target
		id = fuel_silo
		value = 1
	}
}

majors_build_some_silos_3 = {
	enable = {
		date > 1938.1.1
		is_actual_major = yes
		has_tech = fuel_silos
		fuel_silo < 15
		OR = {
			has_navy_size = {size > 225}
			has_deployed_air_force_size = {type = fighter	size > 4500}
			num_of_military_factories > 300
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = building_target
		id = fuel_silo
		value = 1
	}
}

majors_build_some_silos_4 = {
	enable = {
		date > 1938.1.1
		is_actual_major = yes
		has_tech = fuel_silos
		fuel_silo < 20
		OR = {
			has_navy_size = {size > 300}
			has_deployed_air_force_size = {type = fighter	size > 6000}
			num_of_military_factories > 400
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = building_target
		id = fuel_silo
		value = 1
	}
}

######################################
#	MISC
######################################

make_trains = {
	enable = { 
		is_eligible_for_armor_production = yes
	}
	abort_when_not_enabled = yes
	ai_strategy = { type = equipment_production_min_factories_archetype id = train_equipment value = 1 }
}

make_trucks = { 
	enable = { 
		is_eligible_for_armor_production = yes
		has_tech = motorised_infantry
		NOT = {has_tech = mechanised_infantry}
	} 
	abort_when_not_enabled = yes
	ai_strategy = { type = equipment_production_min_factories_archetype id = motorized_equipment value = 3 }
}

make_nukes = {
	enable = {
		has_tech = nuclear_reactor
		num_of_civilian_factories > 50
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = building_target
		id = nuclear_reactor 
		value = 5
	}
}

always_upgrade_tanks = {
	enable = { always = yes }
	abort_when_not_enabled = yes
	
	ai_strategy = { type = production_upgrade_desire_offset id = light_tank_chassis_1 value = 100 }
	ai_strategy = { type = production_upgrade_desire_offset id = light_tank_chassis_2 value = 100 }
	ai_strategy = { type = production_upgrade_desire_offset id = light_tank_chassis_3 value = 100 }
	ai_strategy = { type = production_upgrade_desire_offset id = medium_tank_chassis_1 value = 100 }
	ai_strategy = { type = production_upgrade_desire_offset id = medium_tank_chassis_2 value = 100 }
	ai_strategy = { type = production_upgrade_desire_offset id = medium_tank_chassis_3 value = 100 }
	ai_strategy = { type = production_upgrade_desire_offset id = heavy_tank_chassis_1 value = 100 }
	ai_strategy = { type = production_upgrade_desire_offset id = heavy_tank_chassis_2 value = 100 }
	ai_strategy = { type = production_upgrade_desire_offset id = heavy_tank_chassis_3 value = 100 }
	ai_strategy = { type = production_upgrade_desire_offset id = modern_tank_chassis value = 100 }
}

always_upgrade_fighters = {
	enable = { always = yes }
	abort_when_not_enabled = yes
	
	ai_strategy = { type = production_upgrade_desire_offset id = small_plane_airframe_1 value = 100 }
	ai_strategy = { type = production_upgrade_desire_offset id = small_plane_airframe_2 value = 100 }
	ai_strategy = { type = production_upgrade_desire_offset id = small_plane_airframe_3 value = 100 }
	ai_strategy = { type = production_upgrade_desire_offset id = small_plane_airframe_4 value = 100 }
}
