
basic_production_AOI = {
	allowed = {
		original_tag = AOI
	}
	enable = {
		num_of_military_factories < 20
	}
	abort = {
		num_of_military_factories > 25
	}
	ai_strategy = {
		type = equipment_production_min_factories
		id = infantry
		value = 1
	}
	ai_strategy = {
		type = equipment_production_min_factories
		id = support
		value = -1
	}
	ai_strategy = {
		type = equipment_production_min_factories
		id = artillery
		value = 1
	}
	ai_strategy = {
		type = equipment_production_min_factories
		id = anti_air
		value = 1
	}
	ai_strategy = {
		type = equipment_production_min_factories
		id = anti_tank
		value = -1
	}
}


ITA_SOV_friendship = {
	allowed = {
		tag = ITA
	}
	enable = {
		has_government = communism
		NOT = { has_war_with = SOV }
		SOV = { has_government = communism }
		NOT = { SOV = { has_completed_focus = SOV_beaten_but_not_defeated } }
		date > 1939.1.1
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = alliance
		id = "SOV"
		value = 200
	}
}


ITA_ENG_friendship = {
	allowed = {
		tag = ITA
	}
	enable = {
		has_government = democratic
		NOT = { has_war_with = ENG }
		ENG = { has_government = democratic }
		NOT = { ENG = { has_completed_focus = ENG_a_change_in_course } }
		date > 1939.1.1
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = alliance
		id = "ENG"
		value = 200
	}
}
ITA_FRA_friendship = {
	allowed = {
		tag = ITA
	}
	enable = {
		has_government = democratic
		NOT = { has_war_with = FRA }
		FRA = { has_government = democratic }
		FRA = { has_completed_focus = FRA_review_foreign_policy }
		date > 1939.1.1
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = alliance
		id = "FRA"
		value = 500 #prioritize France
	}
}
ITA_GER_friendship = {
	allowed = {
		tag = ITA
	}
	enable = {
		has_government = democratic
		NOT = { has_war_with = GER }
		GER = { has_government = democratic }
		NOT = { ENG = { has_government = democratic } } 
		NOT = { FRA = { has_government = democratic } }
		date > 1939.1.1
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = alliance
		id = "GER"
		value = 500 #prioritize France
	}
}
AOI_our_life_in_africa = {
	reversed = yes
	allowed = {
		tag = AOI
	}
	enable = { 
		AOI = { is_subject_of = ITA }
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = dont_defend_ally_borders
		id = "AOI"
		value = 99999
	}
}
LBA_our_life_in_africa = {
	reversed = yes
	allowed = {
		tag = LBA
	}
	enable = {
		LBA = { is_subject_of = ITA }
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = dont_defend_ally_borders
		id = "LBA"
		value = 99999
	}
}

AOI_our_life_in_africa2 = {
	allowed = {
		tag = AOI
	}
	enable = {
		is_subject_of = ITA
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = front_unit_request
		state_trigger = {
			OR = {
				is_controlled_by = AOI
				is_owned_by = AOI
			}
		}
		value = 25
	}

	ai_strategy = {
		type = front_unit_request
		state_trigger = {
			NOT = { is_on_continent = africa }
		}
		value = -25
	}

}
LBA_our_life_in_africa2 = {
	allowed = {
		tag = LBA
	}
	enable = {
		is_subject_of = ITA
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = front_unit_request
		state_trigger = {
			OR = {
				is_controlled_by = LBA
				is_owned_by = LBA
			}
		}
		value = 25
	}

	ai_strategy = {
		type = front_unit_request
		state_trigger = {
			NOT = { is_on_continent = africa }
		}
		value = -25
	}

}
AOI_our_life_in_africa3 = {
	allowed = {
		OR = {
			tag = AOI
			tag = LBA
		}
	}
	enable = {
		is_subject_of = ITA
		check_variable = { num_divisions < 20 }
	}
	abort_when_not_enabled = yes
	
	ai_strategy = {
        	type = force_build_armies
        	value = 1000
    	}

	ai_strategy = {
		type = build_army
		id = infantry
		value = 550
	}

}

ITA_garrison_is_necessary = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		has_war_with = ENG
		has_global_flag = allied_victory_in_africa
		surrender_progress < 0.2 #they have already landed otherwise
		OR = {
			ENG = { is_ai = no }
			USA = { is_ai = no }
			PAN = { is_ai = no }
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = garrison
		value = 60
	}
}

ITA_garrison_is_necessary_vs_ai = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		has_war_with = ENG
		has_global_flag = allied_victory_in_africa
		surrender_progress < 0.2 #they have already landed otherwise
		AND = {
			ENG = { is_ai = yes }
			USA = { is_ai = yes }
			PAN = { is_ai = yes }
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = garrison
		value = 20
	}
}
GER_ITA_garrison_is_in_trouble = {
	allowed = {
		original_tag = GER
	}
	enable = {
		is_in_faction_with = ITA
		has_war_with = ENG
		ITA = { surrender_progress > 0.1 }
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = front_unit_request
		area = italy
		value = 25
	}

	ai_strategy = {
		type = front_unit_request
		tag = SOV
		value = -5
	}
}

ITA_unit_production = {
	
	allowed = { original_tag = ITA }
	enable = {
		always = yes
	}
	abort = {
		always = no
	}

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

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

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

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

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

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

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

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

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

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

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

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

	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_factor
		id = fighter
		value = 30
	}

	ai_strategy = {
		type = equipment_production_factor
		id = naval_bomber
		value = 15
	}

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

	ai_strategy = {
		type = equipment_production_factor
		id = artillery
		value = 20
	}
}

ITA_trade_with_sweden = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		# if we're not communist and they're not communist
		NOT = { has_government = communism }
		NOT = { SWE = { has_government = communism } }
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = equipment_market_trade_desire
		id = SWE
		value = 60
	}
}

ITA_trade_with_germany = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		has_government = fascism
		GER = { has_government = fascism }
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = equipment_market_trade_desire
		id = GER
		value = 40
	}
}

latin_ita = {
	reversed = yes
	allowed = {
		original_tag = ITA
	}
	enable = {
		is_historical_focus_on = no
		NOT = { tag = FRA }
		NOT = { FRA = { has_government = communism } }
		date < 1938.1.1
		ITA = { is_in_faction = no }
		ITA = { has_government = fascism }
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = alliance
		id = "ITA"
		value = -1000
	}
}

latin_ita_fra = {
	reversed = yes
	allowed = {
		original_tag = ITA
	}
	enable = {
		is_faction_leader = yes
		tag = FRA
		has_completed_focus = FRA_latin_entente
		ITA = { has_government = fascism }
		ITA = { is_in_faction = no }
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = alliance
		id = "ITA"
		value = 1000
	}
}

stresa_front_ita = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		has_completed_focus = ITA_ratify_the_stresa_front
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = alliance
		id = "ENG"
		value = 400
	}
	ai_strategy = {
		type = alliance
		id = "FRA"
		value = 400
	}
}

stresa_front_eng_fra = {
	allowed = {
		OR = {
			original_tag = FRA
			original_tag = ENG
		}
	}
	enable = {
		ITA = {
			has_completed_focus = ITA_ratify_the_stresa_front
		}
	}
	abort = {
		always = no
	}

	ai_strategy = {
		type = alliance
		id = "ITA"
		value = 400
	}
}

albania_war_goal = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		has_completed_focus = ITA_albanian_occupation
		country_exists = ALB
	}
	abort = {
		NOT = {
			country_exists = ALB
		}
	}

	ai_strategy = {
		type = antagonize
		id = "ALB"
		value = 200
	}
}

greece_war_goal = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		has_completed_focus = ITA_war_with_greece
		country_exists = GRE
	}
	abort = {
		NOT = {
			country_exists = GRE
		}
	}

	ai_strategy = {
		type = antagonize
		id = "GRE"
		value = 200
	}
}

ita_shore_up_against_france = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		has_war_with = FRA
		FRA = {
			has_capitulated = no
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = front_unit_request

		state_trigger = {
			is_core_of = FRA
			any_neighbor_state = {
				is_core_of = SWI
			}
		}

		value = 25
	}

}

fra_shore_up_against_italy = {
	allowed = {
		original_tag = FRA
	}
	enable = {
		has_war_with = ITA
		ITA = {
			has_capitulated = no
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = front_unit_request

		state_trigger = {
			is_core_of = ITA
			any_neighbor_state = {
				is_core_of = SWI
			}
		}

		value = 10
	}

}

ita_slow_going_against_france = {
	allowed = { original_tag = ITA }
	enable = {
		is_historical_focus_on = yes
		has_war_with = FRA
		date < 1940.4.1
		FRA = {
			has_capitulated = no
			surrender_progress < 0.45
		}
		GER = { surrender_progress < 0.1 } 
	}
	abort_when_not_enabled = yes
	
	ai_strategy = {
		type = front_control

		tag = FRA

		ratio = 0.60

		priority = 100
		ordertype = front
		execution_type = careful
		execute_order = no
		manual_attack = no
	}
	
	ai_strategy = {
		type = front_control

		tag = FRA

		ratio = 0.60

		priority = 100
		ordertype = invasion
		execute_order = no
	}
	
}

anti_uk_war_goals = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		has_completed_focus = ITA_war_with_the_uk
		country_exists = ENG
	}
	abort = {
		NOT = {
			country_exists = ENG
		}
	}

	ai_strategy = {
		type = antagonize
		id = "ENG"
		value = 200
	}
}

yugoslavia_war_goal = { #TODO_Manu: Check this with new focus
	allowed = {
		original_tag = ITA
	}
	enable = {
		has_completed_focus = ITA_balkan_ambition
		has_completed_focus = ITA_war_with_greece
		country_exists = YUG
	}
	abort = {
		NOT = {
			country_exists = YUG
		}
	}

	ai_strategy = {
		type = antagonize
		id = "YUG"
		value = 200
	}
}

should_like_germany_a_little = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		OR = {
			is_historical_focus_on = yes
			date > 1939.1.1
			GER = { has_war = yes }
			threat > 0.50
		}
		country_exists = GER
		OR = {
			GER = { is_ai = yes }	
			has_global_flag = mp_selected
		}
		OR = {
			has_war = no
			is_at_peace_exiled_countries_excluded = yes
		}
		NOT = { is_in_faction_with = GER }
	}
	abort = {
		OR = {
			NOT = { has_government = fascism }
			GER = { NOT = { has_government = fascism } }
			is_in_faction_with = GER
			NOT = { country_exists = GER }
		}
	}
	ai_strategy = {
		type = alliance
		id = "GER"
		value = 1000
	}
}

be_wary_of_germany_struggle = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		OR = {
			has_global_flag = vanilla_history
			GER = { surrender_progress > 0 }
		}
		NOT = { is_in_faction_with = GER }
		country_exists = GER
		is_historical_focus_on = yes
	}
	abort = {
		OR = {
			AND = {
				OR = {
					has_completed_focus = ITA_pact_of_steel
					GER = { has_completed_focus = GER_form_rome_berlin_axis}
				}
				OR = {
					FRA = { surrender_progress > 0.6 }
					AND = {
						has_global_flag = {
							flag = danzig_or_war_flag
							days > 365 
						}
						NOT = { GER = { surrender_progress > 0.05 } }
					}
				}
			}
			is_in_faction_with = GER
			NOT = { country_exists = GER }
			NOT = { GER = { has_government = fascism } }
		}
	}
	ai_strategy = {
		type = befriend
		id = "GER"
		value = 1000
	}
	ai_strategy = {
		type = alliance
		id = "GER"
		value = -9999
	}
}

romania_ally = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		has_completed_focus = ITA_potential_allies_in_the_balkans
		country_exists = ROM
	}
	abort = {
		NOT = { country_exists = ROM }
	}

	ai_strategy = {
		type = befriend
		id = "ROM"
		value = 200
	}
	ai_strategy = {
		type = alliance
		id = "ROM"
		value = 200
	}
}

bulgaria_ally = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		has_completed_focus = ITA_potential_allies_in_the_balkans
		country_exists = BUL
	}
	abort = {
		NOT = { country_exists = BUL }
	}

	ai_strategy = {
		type = befriend
		id = "BUL"
		value = 200
	}
	ai_strategy = {
		type = alliance
		id = "BUL"
		value = 200
	}
}

yugoslavia_ally = { #TODO_Manu: Check this with new focus
	allowed = {
		original_tag = ITA
	}
	enable = {
		has_completed_focus = ITA_potential_allies_in_the_balkans
		country_exists = YUG
	}
	abort = {
		NOT = { country_exists = YUG }
	}

	ai_strategy = {
		type = befriend
		id = "YUG"
		value = 100
	}
	ai_strategy = {
		type = alliance
		id = "YUG"
		value = 100
	}
}

greece_ally = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		has_completed_focus = ITA_befriend_greece
		country_exists = GRE
	}
	abort = {
		NOT = { country_exists = GRE }
	}

	ai_strategy = {
		type = befriend
		id = "GRE"
		value = 100
	}
	ai_strategy = {
		type = alliance
		id = "GRE"
		value = 100
	}
}

turkey_ally = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		has_completed_focus = ITA_befriend_turkey
		country_exists = TUR
	}
	abort = {
		NOT = { country_exists = TUR }
	}

	ai_strategy = {
		type = befriend
		id = "TUR"
		value = 100
	}
	ai_strategy = {
		type = alliance
		id = "TUR"
		value = 100
	}
}

portugal_ally = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		has_completed_focus = ITA_befriend_portugal
		country_exists = POR
	}
	abort = {
		NOT = { country_exists = POR }
	}

	ai_strategy = {
		type = befriend
		id = "POR"
		value = 100
	}
	ai_strategy = {
		type = alliance
		id = "POR"
		value = 100
	}
}

#ITA_keep_your_nose_clean_for_a_bit
#{
#	enable = {
#		tag = ITA
#		date < 1940.5.1
#	}
#
#	ai_strategy = {
 #       type = dont_join_wars_with
  #      id = GER
  #      value = 1000000
  #  }
 #   ai_strategy = {
#        type = dont_join_wars_with
#        id = SLO
#        value = 1000000
#    }
#    ai_strategy = {
#    	type = diplo_action_desire
#    	target = join_allies
#    	id = SLO
#    	value = -1000
#    }
#}

ITA_template_design_1 = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		date < 1940.1.1
	}
	abort = {
		date > 1940.1.1
	}

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

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

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

	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 = role_ratio
		id = garrison
		value = 5
	}
}


ITA_template_design_2 = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		date > 1940.1.1
	}
	abort_when_not_enabled = yes

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

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

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

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

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

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

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

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


# extra scaryness around italy, this together with sufficient enemy superiority will make ai avoid transports around its coast
italy_be_careful_transporting_through_the_med = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		date < 1942.1.1
		has_war = yes
		enemies_naval_strength_ratio > 2
		GER = { is_ai = yes }
	}
	abort = {
		OR = {
			date > 1942.1.1
			has_war = no
			enemies_naval_strength_ratio < 2
			GER = { is_ai = no }
		}
	}

	ai_strategy = {
		type = naval_avoid_region
		id = 68
		value = 50
	}

	ai_strategy = {
		type = naval_avoid_region
		id = 169
		value = 50
	}

	ai_strategy = {
		type = naval_avoid_region
		id = 29
		value = 50
	}

	ai_strategy = {
		type = naval_avoid_region
		id = 168
		value = 50
	}

	ai_strategy = {
		type = naval_avoid_region
		id = 69
		value = 50
	}
}

kill_yugoslavia_on_our_own = {
	reversed = yes
	allowed = {
		original_tag = ITA
	}
	enable = {
		country_exists = YUG
		is_historical_focus_on = yes
		ITA = {
			OR = {
				has_wargoal_against = YUG
				has_war_with = YUG
			}
			is_in_faction = yes
			NOT = {
				any_country = {
					OR = {
						has_guaranteed = YUG
						has_war_with = ITA
					}
					is_major = yes
					is_neighbor_of = ITA
					NOT = { tag = ENG }
					NOT = { is_in_faction_with = ITA }
				}
			}
			NOT = {
				any_country = {
					is_major = yes
					any_enemy_country = {
						is_in_faction_with = ITA
					}
				}
			}
		}
		NOT = { is_subject_of = ITA }
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = dont_defend_ally_borders
		target = all_mainland_europe
		value = 500
	}
}

kill_yugoslavia_on_our_own_2 = {
	reversed = yes
	allowed = {
		original_tag = ITA
	}
	enable = {
		country_exists = YUG
		is_historical_focus_on = yes
		is_in_faction_with = ITA
		ITA = {
			OR = {
				has_wargoal_against = YUG
				has_war_with = YUG
			}
		}
		NOT = {
			any_country = {
				OR = {
					has_guaranteed = YUG
					has_war_with = ITA
				}
				is_major = yes
				is_neighbor_of = ITA
				NOT = { tag = ENG }
				NOT = { is_in_faction_with = ITA }
			}
		}
		NOT = {
			any_country = {
				is_major = yes
				any_enemy_country = {
					is_in_faction_with = ITA
				}
			}
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = diplo_action_acceptance
		id = ITA
		target = join_allies
		value = -9999
	}

	ai_strategy = {
		type = diplo_action_desire
		id = ITA
		target = call_allies
		value = -9999
	}
}
ITA_naval_role_ratios_historical = {
	allowed = {
		has_dlc = "Man the Guns"
		original_tag = ITA
	}
	enable = {
		always = yes
	}
	abort_when_not_enabled = yes

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

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

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

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

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

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

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

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

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

spain_scw_support_ITA_resistance = {
	allowed = {
		original_tag = ITA
		has_dlc = "La Resistance"
	}
	enable = {
		has_government = fascism
		country_exists = SPA
	}
	abort = {
		OR = {
			NOT = { country_exists = SPA }
			SPA = { has_completed_focus = SPA_join_the_allies }
		}
	}

	ai_strategy = {
		type = support
		id = "SPA"
		value = 100
	}
	ai_strategy = {
		type = send_volunteers_desire
		id = "SPA"
		value = 100
	}
}

ITA_stockpile_less_early_game = {
	allowed = {
		original_tag = ITA
	}

	enable = {
		date < 1939.1.1
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = equipment_stockpile_surplus_ratio
		value = -25 # reduce while we build up troops for africa etc
	}
}

ITA_please_help_me_buget_this_my_country_is_dieing = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		has_government = fascism
		date < 1937.6.1
	}

	abort_when_not_enabled = yes
	ai_strategy = {
		type = building_target
		id = industrial_complex
		value = 35
	}
	ai_strategy = {
		type = equipment_production_min_factories
		id = artillery
		value = 1
	}
}

ITA_hold_africa = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		date < 1941.1.1
	}
	abort = {
		any_owned_state = { is_core_of = ITA NOT = { is_controlled_by = ITA } }
		date > 1941.1.1
	}

	# Tripoli
	ai_strategy = {
		type = theatre_distribution_demand_increase
		id = 448
		value = 2
	}

	# Benghasi
	ai_strategy = {
		type = theatre_distribution_demand_increase
		id = 450
		value = 2
	}

	# Alexandria
	ai_strategy = {
		type = theatre_distribution_demand_increase
		id = 447
		value = 2
	}
}

# lets not invade until we have europe
ITA_dont_invade_NOR_until_FRA_falls = {
	allowed = {
		original_tag = ITA
		is_historical_focus_on = yes
	}

	enable = {
		has_war_together_with = GER
		date < 1941.1.1
		FRA = {
			has_capitulated = no
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = invasion_unit_request

		tag = NOR

		value = -100
	}
}

ITA_let_germany_handle_polish_front_alone = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		is_in_faction_with = GER
		OR = {
			AND = {
				has_war_together_with = GER
				has_war_with = POL
			}
			GER = {
				focus_progress = {
					focus = GER_danzig_or_war
					progress > 0.01
				}
			}
		}
		date < 1940.8.1
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = dont_defend_ally_borders
		id = "GER"
		value = 100
	}
	ai_strategy = {
		type = dont_defend_ally_borders
		id = "SLO"
		value = 100
	}
}

ITA_commit_to_ethiopian_theatre = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		has_global_flag = second_italo_ethiopian_war_flag
		country_exists = ETH
		ETH = { has_country_flag = italian_major_offensive_against_ethiopia_flag }
		ITA_is_communist_ai = no
		ITA_is_socialist_ai = no
	}
	abort = {
		OR = {
			NOT = { has_global_flag = second_italo_ethiopian_war_flag }
			NOT = { country_exists = ETH }
			date > 1939.6.1
			any_enemy_country = {
				is_major = yes
				capital_scope = { is_on_continent = europe }
			}
		}
	}

	# Eritrea
	ai_strategy = {
		type = theatre_distribution_demand_increase
		id = 550
		value = 2
	}

	# Somaliland
	ai_strategy = {
		type = theatre_distribution_demand_increase
		id = 559
		value = 2
	}

	#### Horn of Africa
	ai_strategy = {
		type = area_priority
		id = horn_of_africa
		value = 100
	}





}

ITA_prepare_ethiopian_theatre = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		has_war_with = ETH
		ITA_is_communist_ai = no
		ITA_is_socialist_ai = no
	}
	abort = {
		OR = {
			NOT = { has_global_flag = second_italo_ethiopian_war_flag }
			NOT = { country_exists = ETH }
			date > 1939.6.1
			any_enemy_country = {
				is_major = yes
				capital_scope = { is_on_continent = europe }
			}
			ETH = { has_country_flag = italian_major_offensive_against_ethiopia_flag }
		}
	}

	# Guard Sidamo for feck's sake
	ai_strategy = {
		type = put_unit_buffers
		states = {
			844
		}
		ratio = 0.2

		subtract_invasions_from_need = no
		subtract_fronts_from_need = yes
	}
}

ITA_prepare_losing_ethiopian_theatre = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		 OR = {
			NOT = { has_global_flag = second_italo_ethiopian_war_flag }
			NOT = { country_exists = ETH }
			any_enemy_country = {
				is_major = yes
				capital_scope = { is_on_continent = europe }
			}
			ETH = { has_country_flag = italian_major_offensive_against_ethiopia_flag }
		}
	}
	abort = {
		has_war_with = ETH
	}

	# ethiopia is not defending much
	ai_strategy = {
		type = area_priority
		id = horn_of_africa
		value = -25
	}
}


ITA_attack_north = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		has_war_with = ETH
		has_active_mission = ITA_conquer_the_north_mission
		ITA_is_communist_ai = no
		ITA_is_socialist_ai = no
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = front_control

		state = 841 # assault Begemder

		ratio = 0.2

		priority = 100
		ordertype = front
		execution_type = rush
		execute_order = yes
	}
}
ITA_attack_south = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		has_war_with = ETH
		has_active_mission = ITA_conquer_the_south_mission
		ITA_is_communist_ai = no
		ITA_is_socialist_ai = no
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = front_control

		state = 837 # assault Sidamo

		ratio = 0.2

		priority = 100
		ordertype = front
		execution_type = rush
		execute_order = yes
	}
}

ITA_attack_addis = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		has_war_with = ETH
		has_active_mission = ETH_conquer_addis_ababa_mission
		ITA_is_communist_ai = no
		ITA_is_socialist_ai = no
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = front_control

		state = 271 # assault Addis

		ratio = 0.2

		priority = 100
		ordertype = front
		execution_type = rush
		execute_order = yes
	}
}
ITA_attack_harar = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		has_war_with = ETH
		has_active_mission = ETH_conquer_harar_mission
		ITA_is_communist_ai = no
		ITA_is_socialist_ai = no
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = front_control

		state = 835 # assault Hararghe

		ratio = 0.2

		priority = 100
		ordertype = front
		execution_type = rush
		execute_order = yes
	}
}

ITA_prepare_to_invade_afar = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		has_war_with = ETH
		AFA = { exists = yes }
		date < 1937.1.1
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = prepare_for_war
		id = "AFA"
		value = 200
	}

}

ITA_communists_downplay_ethiopian_theatre = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		has_war_with = ETH
		OR = {	
			ITA_is_communist_ai = yes
			ITA_is_socialist_ai = yes
		}
		NOT = { has_completed_focus = ITA_defy_the_duce }
	}
	abort = {
		NOT = { has_war_with = ETH }
	}

	ai_strategy = {
		type = area_priority
		id = horn_of_africa
		value = -100
	}
	ai_strategy = {
		type = front_control

		tag = ETH

		ratio = 0.6

		priority = 100
		ordertype = front
		execution_type = careful
		manual_attack = no
	}
}


ITA_prepare_yugoslavian_invasion = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		country_exists = YUG
		NOT = {
			has_global_flag = second_italo_ethiopian_war_flag #Don't attack YUG if you can't handle ETH
			OR = {
				YUG = { is_subject_of = ROOT }
				is_in_faction_with = YUG
			}
		}
		OR = {
			focus_progress = { focus = ITA_balkan_ambition progress > 0.5 }
			has_decision = ITA_send_ultimatum_to_country_balkan
			has_wargoal_against = YUG
			is_justifying_wargoal_against = YUG
		}
	}

	abort = { #Italy gotta focus on bigger, badder nations
		any_other_country = {
			is_major = yes
			OR = {
				is_justifying_wargoal_against = ITA
				has_wargoal_against = ITA
				has_war_with = ITA
				ITA = { has_wargoal_against = PREV }
				ITA = { is_justifying_wargoal_against = PREV }
			}
		}
	}

	abort_when_not_enabled = yes

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

	ai_strategy = {
	    type = front_unit_request
	    tag = YUG
	    value = 300
	}
}

ITA_balbo_ignore_germany = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		ITA_is_alt_fascist_balbo_ai = yes
	}
	abort = {
		OR = {
			NOT = { country_exists = GER }
			is_in_faction = yes
			date > 1940.01.01
		}
	}
	ai_strategy = {
		type = ignore
		id = "GER"
		value = 200
	}
}

ITA_invasion_buffer = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		is_historical_focus_on = yes
		OR = {
			has_global_flag = allied_victory_in_africa
			date > 1942.1.1
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = put_unit_buffers
		states = {
			156
			117
			849
			157
			2
			162
			161
			### Oh no we forgot sicily! What could possibly go wrong.
		}
		ratio = 0.20
		area = italy
		subtract_invasions_from_need = no
		subtract_fronts_from_need = yes
	}
}

ITA_invasion_buffer_africa = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		is_historical_focus_on = yes
		any_state = {
			is_core_of = LBA
			controller = { is_in_faction_with = ITA }
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = put_unit_buffers
		states = {
			451
			448
			661
			663
			114
		}
		ratio = 0.15
		area = italy
		subtract_invasions_from_need = no
		subtract_fronts_from_need = yes
	}
}

ITA_prepare_british_invasion = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		NOT = {	has_war_with = ENG }
		OR = {
			focus_progress = { focus = ITA_war_with_the_uk progress > 0.1}
			has_completed_focus = ITA_war_with_the_uk
		}
	}

	abort = {
		OR = {
			any_other_country = {
				original_tag = ENG
				has_government = fascism
			} 
			has_war_with = ENG
		}
	}

	ai_strategy = {
		type = prepare_for_war
		id = "ENG"
		value = 200
	}
}

dont_die_in_mountains = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		date < 1942.5.1
		country_exists = SWI
		is_historical_focus_on = no
	}
	abort = {
		NOT = { country_exists = FRA }
		date > 1942.5.1
	}

	ai_strategy = {
		type = ignore
		id = "SWI"
		value = 1000
	}
}

GER_ignore_vichy_we_will_annex_them_later = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		country_exists = VIC
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = ignore
		id = "VIC"
		value = 100
	}
}

ITA_other_priorities = {
	allowed = { original_tag = ITA }
	enable = { 
		is_historical_focus_on = yes
		date > 1941.4.6
		date < 1943.6.6
		ENG = {
			is_ai = yes
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = area_priority
		id = north_africa
		value = -30
	}
	
	ai_strategy = {
		type = front_unit_request
		area = north_africa
		value = -60 
	}
	
}

# Don't consider joining Italy if they are only at war with GiEs 
ITA_AXIS_dont_join_against_eth = {
	allowed = {
		always = yes 
	}
	enable = {
		is_in_faction_with = ITA
		NOT = { original_tag = ITA }
		ITA = {
			all_enemy_country = {
				is_government_in_exile = yes
			}
		}
		date < 1941.1.1
	}
	abort_when_not_enabled = yes

	ai_strategy = {
	    type = diplo_action_desire
	    id = ITA
	    value = -1000
	    target = join_allies
	}

	ai_strategy = {
		type = diplo_action_acceptance
		id = ITA
		value = -1000
		target = call_allies
	}
 
}

# reverse  AI strat to make italy not call allies while fighting only Ethiopia in exile
ITA_dont_call_allies = {
	allowed = {
		always = yes 
	}
	enable = {
		is_in_faction_with = ITA
		ITA = {
			all_enemy_country = {
				is_government_in_exile = yes
			}
		}
		date < 1941.1.1
	}
	abort_when_not_enabled = yes
	reversed = yes 

	ai_strategy = {
		type = diplo_action_desire 
		id = ITA
		value = -1000
		target = call_allies
	}

}

# We don't want to join to early, better not risk our forces until the enemy is tired...
ITA_dont_join_ww2_too_early = {
	allowed = {
		always = yes
	}
	enable = {
		date < 1940.6.9 # It is ok after historical date
		#if = {
		#	limit = {
		#		GER = { is_ai = no }
		#	}
		#	NOT = { FRA = { surrender_progress > 0 } }
		#}
		if = {
			limit = {
				GER = { is_ai = yes }
			}
			NOT = { 
				any_country = {
					is_in_faction_with = GER
					capital_scope = { is_on_continent = europe }
					surrender_progress > 0.03
				}
			}
			NOT = { FRA = { surrender_progress > 0 } }
			NOT = { GER = { has_war_with = BEL } }
			NOT = { GER = { has_war_with = YUG } }
		}
		is_in_faction_with = ITA
		GER = {
			is_in_faction_with = ITA 
			is_faction_leader = yes 
		} 
		ITA = {
			OR = {
				ITA_is_historical_ai = yes
				ITA_is_alt_fascist_balbo_ai = yes
				ITA_is_alt_fascist_grandi_ai = yes
			}
		}
	}
	abort_when_not_enabled = yes
	reversed = yes 

	ai_strategy = {
		type = diplo_action_desire
		id = ITA
		value = -1000
		target = join_allies
	}

	ai_strategy = {
		type = diplo_action_acceptance
		id = ITA
		value = -1000
		target = call_allies
	}
 
}

ITA_garrison_is_not_necessary_yet = {
	allowed = {
		original_tag = ITA
	}
	enable = {
		has_war_with = ETH
		date < 1937.1.1
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = garrison
		value = -9999
	}

	ai_strategy = {
		type = front_unit_request
		state_trigger = {
			is_on_continent = europe 
		}
		value = -500
	}

	ai_strategy = {
		type = front_unit_request
		tag = ETH
		value = 50
	}
}
ita_get_planning_vs_eth_first = {
	allowed = { original_tag = ITA }
	enable = {
		is_historical_focus_on = yes
		has_war_with = ETH
		date < 1936.2.1
	}
	abort_when_not_enabled = yes
	
	ai_strategy = {
		type = front_control
		tag = ETH
		ratio = 0.0
		priority = 700
		ordertype = front
		execution_type = careful
		execute_order = no
		manual_attack = no
	}
	
}