default_unit_production = {
	# If adding country-unique ones, bear in mind that they STACK unless excluding countries in the enable
	enable = {
		always = yes
		NOT = {
			OR = {
				original_tag = GER
				original_tag = FRA
				original_tag = CHI
				original_tag = ENG
				original_tag = CZE
				tag = SOV
				original_tag = ITA
				original_tag = JAP
				original_tag = HUN
				original_tag = SIA
				original_tag = USA
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes

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

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

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

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

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

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

default_unit_production_super_heavies = {
	enable = {
		is_major = yes
		num_of_military_factories > 150 # nly if we have loads of factories
		date > 1943.6.1 # Lets wait until late war
		NOT = { has_tech = main_battle_tank_chassis } # Abandon Super heavy projects if we start doing modern tanks instead
		NOT = { has_government = democratic } # Let the authoritarian regimes spend money on this 
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = role_ratio
		id = super_heavy_breakthrough_role
		value = 1
	}
}

default_unit_production_land_cruiser = {
	enable = {
		is_special_project_completed = sp:sp_land_land_cruiser
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = role_ratio
		id = mega_heavy_breakthrough_role
		value = 2
	}
}

default_role_ratios = {
	enable = {
		not = {
			has_dlc = "Man the Guns"
		}
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes

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

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

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

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

default_role_ratios = {
	enable = {
		has_dlc = "Man the Guns"
		not = {
			OR = {
				original_tag = GER
				original_tag = ENG
				original_tag = USA
				original_tag = JAP
				original_tag = SOV
				original_tag = ITA
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = role_ratio
		id = naval_capital_bb
		value = -80
	}

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

	ai_strategy = {
		type = role_ratio
		id = naval_carrier
		value = -70
	}

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

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

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

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

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

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

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

default_surplus_management = {
	# If we manage to get all equipment we want, keep producing more stuff according to this
	enable = {
		always = yes  # For now, applies to everyone
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = equipment_production_surplus_management
		id = infantry_equipment
		value = 10
	}

	ai_strategy = {
		type = equipment_production_surplus_management
		id = support_equipment
		value = 5
	}

	ai_strategy = {
		type = equipment_production_surplus_management
		id = artillery_equipment
		value = 5
	}

	ai_strategy = {  # Potentially move into a "specialization" strategy
		type = equipment_production_surplus_management
		id = anti_air_equipment
		value = 3
	}

	ai_strategy = {  # Potentially move into a "specialization" strategy
		type = equipment_production_surplus_management
		id = anti_tank_equipment
		value = 2
	}

	ai_strategy = {
		type = equipment_production_surplus_management
		id = convoy
		value = 5
	}
}

bba_air_prod_1 = {

	enable = {
		always = yes
		NOT = { original_tag = GER }
		NOT = { original_tag = ENG }
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}

	abort_when_not_enabled = yes

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

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

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

	ai_strategy = {
		type = unit_ratio
		id = cas
		value = 20 #because doctrine this = 15
	}

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

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

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

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

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

	ai_strategy = {
		type = equipment_production_min_factories
		id = cas
		value = 0
	}

	ai_strategy = {
		type = equipment_production_factor
		id = strategic_bomber
		value = 1
	}

	ai_strategy = {
		type = equipment_variant_production_factor
		id = large_plane_airframe
		value = 0
	}

	ai_strategy = {
		type = equipment_production_factor
		id = heavy_fighter
		value = 1
	}

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

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

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

}

bba_support_boosts = {

	enable = {
		is_historical_focus_on = yes
		date < 1939.1.1
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = equipment_variant_production_factor
		id = support_equipment
		value = 15
	}
}

convoy_voy_voy_voy = {
	enable = {
		has_dlc = "Man the Guns"
		convoy_threat > 0.2
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort = {
		convoy_threat < 0.2
	}

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

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

	ai_strategy = {
		type = role_ratio
		id = naval_mine_layer
		value = -10
	}
	ai_strategy = {
		type = unit_ratio
		id = screen_ship
		value = 30
	}

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

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

ill_show_you_mine = {
	enable = {
		has_dlc = "Man the Guns"
		mine_threat > 0.2
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort = {
		mine_threat < 0.2
	}

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

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

	ai_strategy = {
		type = role_ratio
		id = naval_mine_layer
		value = -10
	}
}

ill_show_you_mine_2 = {
	enable = {
		has_dlc = "Man the Guns"
		mine_threat > 0.5
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort = {
		mine_threat < 0.5
	}

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

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

	ai_strategy = {
		type = role_ratio
		id = naval_mine_layer
		value = -10
	}
}

default_pp_spend_amount = {
	enable = {
		always = yes
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = pp_spend_amount
		id = idea
		value = 100
	}

	ai_strategy = {
		type = pp_spend_amount
		id = decision
		value = 100
	}
}

default_paratroopers_production = {
	enable = {
		NOT = { original_tag = GER }
		ai_wants_divisions >  12 #Massively decreasing the amount of paratroopers the AI wants
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort = {
		ai_wants_divisions < 13 #Massively decreasing the amount of paratroopers the AI wants
	}

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

default_major_SF_para = {
	enable = {
		is_major = yes
		has_tech = special_forces_paratroopers
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = role_ratio
		id = paratroopers
		value = 4
	}
}

default_major_SF_marines = {
	enable = {
		is_major = yes
		has_tech = special_forces_marines
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = role_ratio
		id = marines
		value = 2
	}
}

build_patrol_bombers = {
	enable = {
		has_dlc = "By Blood Alone"
		has_navy_size = {
			size > 1
		}
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes

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

default_garrison_production = {
	enable = {
		NOT = {
			original_tag = GER
			original_tag = SOV
			original_tag = USA
			original_tag = CHI
			original_tag = FRA
			original_tag = JAP
			original_tag = ENG
			original_tag = SIA
			original_tag = TOM #NOTE
		}
		ai_wants_divisions >  12 #Massively decreasing the amount of garrison and suppression the AI wants
		is_major = yes
	}
	abort = {
		ai_wants_divisions < 13 #Massively decreasing the amount of garrison and suppression the AI wants
		is_major = no
	}

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

default_mountaineers_production = {
	enable = {
		NOT = { original_tag = GER }
		ai_wants_divisions > 11 #Decreasing the amount of mountaineers the AI wants
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort = {
		ai_wants_divisions < 12 #Decreasing the amount of mountaineers the AI wants
	}

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

default_mobile_production = {
	enable = {
		NOT = { original_tag = GER }
		ai_wants_divisions > 11
		has_tech = motorised_infantry
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort = {
		ai_wants_divisions < 12
	}

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

default_armored_production = {
	enable = {
		NOT = {
			OR = {
				original_tag = GER
				original_tag = CZE
				original_tag = SOV
				original_tag = TOM #NOTE
			}
		}
		ai_wants_divisions > 49
	}
	abort = {
		ai_wants_divisions < 50
	}

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

highered_armored_production = {
	enable = {
		NOT = { original_tag = GER }
		num_of_military_factories > 69
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort = {
		num_of_military_factories < 70
	}

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

slightly_naval_focused_nation = {
	enable = {
		OR = {
			tag = JAP
			tag = USA
			tag = ENG
			tag = FRA
			tag = ITA
		}
	}
	abort_when_not_enabled = yes

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

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

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

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

more_naval_focused_nation = {
	enable = {
		OR = {
			tag = JAP
			tag = USA
			tag = ENG
		}
		date > "1941.1.1"  # Delaying it by a couple of years
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = unit_ratio
		id = capital_ship
		value = 2		 #1 to 2
	}

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

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

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


default_area_priority = {
	enable = {
		NOT = { original_tag = GER }
		NOT = { original_tag = FRA }
		NOT = { original_tag = JAP }
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes

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

	ai_strategy = {
		type = area_priority
		id = scandinavia
		value = 0
	}

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

	ai_strategy = {
		type = area_priority
		id = south_america
		value = 40
	}

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

	ai_strategy = {
		type = area_priority
		id = middle_east
		value = 50
	}

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

	ai_strategy = {
		type = area_priority
		id = suez
		value = 50
	}

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

	ai_strategy = {
		type = area_priority
		id = oceania
		value = 75
	}

}

default_area_priority_non_africa = {
    enable = {
        NOT = { original_tag = ITA }
        NOT = { original_tag = FRA }
        NOT = { original_tag = USA }
        NOT = { original_tag = ENG }
        NOT = { is_subject_of = ENG }
        NOT = { capital_scope = { is_on_continent = africa } }
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
    }
    abort_when_not_enabled = yes

    ai_strategy = {
        type = area_priority
        id = africa
        value = -70
    }
    ai_strategy = {
        type = area_priority
        id = suez
        value = -40
    }
}

default_railway_gun_management = {
	enable = {
		num_divisions > 150
		is_major = yes
		has_dlc = "No Step Back"
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort = {
		num_divisions < 120
	}

	ai_strategy = { # This will add the specified value to the RAILWAY_GUN_PRODUCTION_BASE_DIVISIONS_RATIO_PERCENT define and use that as the desired railway guns / divisions ratio (in %)
		type = railway_gun_divisions_ratio
		value = 4
	}

}

default_stockpile_management = {
	enable = {
		num_divisions > 150
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}

	abort = {
		num_divisions < 130
	}

	ai_strategy = {
		type = equipment_stockpile_surplus_ratio
		value = 35 # add this to default PRODUCTION_EQUIPMENT_SURPLUS_FACTOR
	}
}

default_market_stockpile_management = {
	enable = {
		always = yes
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes

	# Hold your trains there, partner
	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = train
		value = 20  # only start considering selling trains if surplus more than 20
	}
	ai_strategy = {
		type = equipment_market_min_for_sale
		id = train
		value = 5  # only put up for sale in chunks of 5
	}
	ai_strategy = {
		type = equipment_market_for_sale_factor
		id = train
		value = -50  # put fewer trains up for sale
	}

	# Better not put all your boats up for sail
	# ai_strategy = {  # Commented because handled dynamically in code through the EQUIPMENT_MARKET_WANTED_CONVOY_USAGE_RATIO define
	# 	type = equipment_market_for_sale_threshold
	# 	id = convoy
	# 	value = 100  # only start considering selling convoys if surplus more than 100
	# }
	ai_strategy = {
		type = equipment_market_min_for_sale
		id = convoy
		value = 20  # only put up for sale in chunks of 20
	}

	# Don't let all your planes just fly out the window.
	# Only sell planes if we have more than one airwing in surplus.
	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = fighter
		value = 100
	}
	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = cas
		value = 100
	}
	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = cv_fighter
		value = 100
	}
	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = cv_cas
		value = 100
	}
	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = tactical_bomber
		value = 100
	}
	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = strategic_bomber
		value = 100
	}
}

default_market_stockpile_management_if_at_war = {
	enable = {
		has_war = yes
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes

	# Don't sell stuff that we need for the war
	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = infantry
		value = 20000
	}
	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = support
		value = 6000
	}
	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = artillery
		value = 1000
	}
	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = fighter
		value = 200
	}
	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = motorized
		value = 1000
	}
	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = train
		value = 50
	}
	ai_strategy = {
		type = equipment_market_for_sale_threshold
		id = convoy
		value = 50
	}
}

default_market_convoy_purchases = {
	enable = {
		naval_base > 0  # not land-locked
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = equipment_market_buying_threshold
		id = convoy
		value = 30  # Consider buying if we have too few (less than 30) convoys. Also interacts with the EQUIPMENT_MARKET_WANTED_CONVOY_USAGE_RATIO define.
	}
}

dont_build_capitals_if_on_treaty = {
	enable = {
		has_idea = MTG_naval_treaty_adherent
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}

	abort = {
		OR = {
				original_tag = ITA
				original_tag = ENG
				NOT = { has_idea = MTG_naval_treaty_adherent }
			}
	}

	ai_strategy = {
		type = unit_ratio
		id = capital_ship
		value = -2		 #1 to 2
	}
	ai_strategy = {
		type = role_ratio
		id = naval_capital_bb
		value = -100
	}

	ai_strategy = {
		type = role_ratio
		id = naval_capital_bc
		value = -100
	}
}

DEFAULT_early_template_design = {
	enable = {
		NOT = {
			OR = {
				tag = GER
				tag = ENG
				tag = SOV
				tag = ITA
				tag = JAP
				tag = USA
				tag = POL
				tag = SIA
				tag = TOM #NOTE
			}
		}
		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 = 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
	}
}

DEFAULT_midlate_template_design = {
	enable = {
		NOT = {
			OR = {
				tag = GER
				tag = ENG
				tag = SOV
				tag = ITA
				tag = JAP
				tag = USA
				tag = POL
				tag = SIA
				tag = TOM #NOTE
			}
		}
		date > 1940.1.1
	}
	abort_when_not_enabled = yes

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

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

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

	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 = infantry
		value = 10
	}
}

save_admiral_pp_for_later = {
	enable = {
		has_war = no
		threat < 0.3
		has_political_power < 200
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort = {
		OR = {
			has_war = yes
			threat > 0.3
			has_political_power > 200
		}
	}

	ai_strategy = { # dont burn PP on admirals (can still get free ones)
		type = pp_spend_priority
		id = admiral
		value = -100
	}
}

do_not_waste_pp_if_saving_for_manpower_laws = {

	enable = {
		manpower_per_military_factory < 500
		has_war = yes
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort = {
		OR = {
			manpower_per_military_factory > 500
			has_war = no
			AND = {
				original_tag = ETH
				is_government_in_exile = yes
			}
		}
	}

	ai_strategy = {
		type = pp_spend_priority
		id = relation
		value = -9999
	}

	ai_strategy = {
		type = pp_spend_priority
		id = guarantee
		value = -9999
	}
}

build_intelligence_agency_as_major = {
	enable = {
		is_major = yes
		OR = {
			has_war = yes
			date > 1938.1.1
		}
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = intelligence_agency_usable_factories
		value = 5
	}

}

build_intelligence_agency = {
	enable = {
		date > 1940.1.1
		has_war = no
		num_of_civilian_factories > 25
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort = {
		OR = {
			has_war = yes
			num_of_civilian_factories < 25
		}
	}

	ai_strategy = {
		type = intelligence_agency_usable_factories
		value = 5
	}

}

upgrade_intelligence_agency = {
	enable = {
		date > 1940.1.1
		num_of_civilian_factories > 50
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort = {
		OR = {
			num_of_civilian_factories < 40
		}
	}

	ai_strategy = {
		type = intelligence_agency_usable_factories
		value = 5
	}
}

upgrade_intelligence_agency_as_spy_master = {
	enable = {
		is_spymaster = yes
		OR = {
			has_war = no
			num_of_civilian_factories > 50
		}
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort = {
		is_spymaster = no
		num_of_civilian_factories < 40
	}

	ai_strategy = {
		type = intelligence_agency_usable_factories
		value = 10
	}
}

add_intelligence_agency_normal_upgrade_prio = {
	enable = {
		always = yes
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = intelligence_agency_branch_desire_factor
		id = branch_intelligence
		value = 1000
	}
	ai_strategy = {
		type = intelligence_agency_branch_desire_factor
		id = branch_defense
		value = 1000
	}
	ai_strategy = {
		type = intelligence_agency_branch_desire_factor
		id = branch_operation
		value = 500
	}
	ai_strategy = {
		type = intelligence_agency_branch_desire_factor
		id = branch_operative
		value = 100
	}
	ai_strategy = {
		type = intelligence_agency_branch_desire_factor
		id = branch_crypto
		value = 2000
	}
}

ask_foreign_manpower_as_major = {
	enable = {
		is_major = yes
		garrison_manpower_need > 200000
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}

	abort = {
		garrison_manpower_need < 100000
	}

	ai_strategy = {
		type = asking_foreign_garrison
		value = 100
		# id = ITA # id is optionnal. If it is filled, the value will just apply for this country. If not, the value will apply for all countries.
	}
}

more_upgrades_as_spymaster = {

	enable = {
		is_spymaster = yes
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}

	abort = {
		is_spymaster = no
	}

	ai_strategy = {
		type = agency_ai_base_num_factories_factor
		value = -50    # -50% on the define
	}

	ai_strategy = {
		type = agency_ai_per_upgrade_factories_factor
		value = -25    # -25% on the define
	}
}


put_garrisons_on_high_prio = {
	enable = {
		always = yes
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = garrison_reinforcement_priority
		value = 100 # positive is high prio, negative is low prio
	}
}

default_spyplanes_production = {
	enable = {
		OR = {
			has_tech = scout_plane1
			has_tech = photo_reconnaisance
		}
		is_major = yes
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = unit_ratio
		id = scout_plane
		value = -99
	}

	ai_strategy = {
		type = equipment_production_factor
		id = scout_plane
		value = -99
	}

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

minors_dont_spy = {
	enable = {
		OR = {
			has_tech = scout_plane1
			has_tech = photo_reconnaisance
		}
		is_major = no
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = unit_ratio
		id = scout_plane
		value = -10
	}
}

default_build_a_nl_facility = {
	enable = {
		has_tech = atomic_research
		num_of_civilian_factories > 25
		num_of_military_factories > 25 # Even if we have the base tech, let's wait until we have some kind of capacity
		nuclear_facility < 1  # one is enough
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = build_building
		id = nuclear_facility
		value = 100
	}
}

default_build_a_nav_facility = {
	enable = {
		num_of_naval_factories > 25 # Only Naval Powers should bother with these unless specifically told to do otherwise
		naval_facility < 1 # one is enough
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = build_building
		id = naval_facility
		value = 100
	}
}

default_build_a_gun_emplacement = {
	enable = {
		is_major = yes
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = build_building
		id = mega_gun_emplacement
		value = 1
	}
}

default_build_a_lw_facility = {
	enable = {
		is_major = yes
		num_of_civilian_factories > 40
		num_of_military_factories > 40
		OR = { # Don't start until we can build decent tanks of some kind
			has_tech = improved_light_tank_chassis
			has_tech = basic_medium_tank_chassis
			has_tech = improved_heavy_tank_chassis
		}
		land_facility < 1 # one is enough
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = build_building
		id = land_facility
		value = 1
	}
}

default_build_an_air_facility = {
	allowed = {
		NOT = { original_tag = GER } # Germany uses own strat
	}
	enable = {

		is_major = yes # Minors don't bother until strong enough to be considered major
		num_of_military_factories > 40 # We should first build up our military industry

		OR = { # Don't start until we can build decent aircraft
			has_tech = basic_small_airframe
			has_tech = basic_medium_airframe
			has_tech = basic_large_airframe
		}
		air_facility < 1 # one is enough
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = build_building
		id = air_facility
		value = 1
	}
}

default_become_spymaster_major = {
	allowed = {	
		has_dlc = "La Resistance"
	}
	enable = {
		is_major = yes
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = become_spymaster
		value = 30
	}
}
default_become_spymaster_minor = {
	allowed = {	
		has_dlc = "La Resistance"
	}
	enable = {
		is_major = no
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = become_spymaster
		value = 2
	}
}

default_become_head_of_crypto = {
	allowed = {	
		has_dlc = "No Compromise, No Surrender"
		has_dlc = "La Resistance"
	}
	enable = {
		always = yes
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = become_head_of_crypto
		value = 2
	}
}

default_become_head_of_operations = {
	allowed = {	
		has_dlc = "No Compromise, No Surrender"
		has_dlc = "La Resistance"
	}
	enable = {
		always = yes
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = become_head_of_operations
		value = 2
	}
}

default_become_counter_intel = {
	allowed = {	
		has_dlc = "No Compromise, No Surrender"
		has_dlc = "La Resistance"
	}
	enable = {
		always = yes
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = become_head_of_counter_intel
		value = 2
	}
}

default_become_supreme_commander = {
	allowed = {	
		has_dlc = "No Compromise, No Surrender"
		has_dlc = "La Resistance"
	}
	enable = {
		always = yes
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = spent_faction_initiative_priority
		id = unlock_faction_commander
		value = 2
	}
}

default_become_faction_leader = {
	enable = {
		always = yes
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = pp_spend_priority
		id = become_faction_leader
		value = 100
	}
}


default_add_faction_facility = {
	enable = {
		always = yes
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = spent_faction_initiative_priority
		id = program
		value = 5
	}
}

default_unlock_doctrine_sharing = {
	enable = {
		always = yes
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = spent_faction_initiative_priority
		id = unlock_doctrine_sharing
		value = 10
	}
}

default_assign_supportive_scientist = {

	enable = {
		OR = { 
			can_assign_supportive_scientist_to_faction = specialization_land
			can_assign_supportive_scientist_to_faction = specialization_nuclear
			can_assign_supportive_scientist_to_faction = specialization_naval
			can_assign_supportive_scientist_to_faction = specialization_naval
		}
		has_political_power > 74 # mainly to add some time padding for the player to react, and to not spend pp on it if there are cheaper things that we could want to do 
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = pp_spend_priority
		id = supportive_scientist
		value = 25
	}
}

default_recruit_land_scientist = {
	enable = {
		OR = {
			can_assign_supportive_scientist_to_faction = specialization_land
			nuclear_facility > 0
		}
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = recruit_scientist
		id = specialization_land
		value = 100
	}
}

default_recruit_nuclear_scientist = {
	enable = {
		OR = {
			can_assign_supportive_scientist_to_faction = specialization_nuclear
			nuclear_facility > 0
		}
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = recruit_scientist
		id = specialization_nuclear
		value = 100
	}
}

default_recruit_naval_scientist = {
	enable = {
		OR = {
			can_assign_supportive_scientist_to_faction = specialization_naval
			naval_facility > 0
		}
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = recruit_scientist
		id = specialization_naval
		value = 100
	}
}

default_recruit_air_scientist = {
	enable = {
		OR = {
			can_assign_supportive_scientist_to_faction = specialization_air
			air_facility > 0
		}
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = recruit_scientist
		id = specialization_air
		value = 100
	}
}

default_produce_some_trucks_for_buffer = {
	enable = {
		num_of_military_factories > 12
		has_tech = tech_trucks
		has_equipment = { motorized_equipment < 3000 }
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = equipment_production_min_factories_archetype
		id = motorized_equipment
		value = 1
	}
}

default_produce_floating_harbors = {
	enable = {
		is_historical_focus_on = no
		has_war = yes
		num_of_naval_factories > 25
		num_of_military_factories > 40 # floating harbors are used for invasions. Why do large invasions if you don't have the industrial capacity?
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	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
	}
}

###

comintern_avoid_starting_wars_during_endgame = { #Sov should avoid attacking allies while ww2 is still going on

	allowed = {
		OR = {
			original_tag = SOV
			is_in_faction_with = SOV
		}
	}
	enable = {
		is_historical_focus_on = yes
		SOV = { has_government = communism }
		OR = {
			USA = {
				has_capitulated = no
				has_war_with = JAP
			}
			ENG = {
				has_capitulated = no
				has_war_with = JAP
			}
		}
		date > 1943.1.1
		date < 1945.1.1
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = avoid_starting_wars
		value = -400
	}
	ai_strategy = {
		type = conquer
		id = POL
		value = -400 #REALLY dont try and conquer poland
	}
	ai_strategy = {
		type = befriend
		id = "POL"
		value = 200
	}
	ai_strategy = {
		type = conquer
		id = JAP
		value = 400 #These values offset each other. Basically we won't start wars with anyone except for japan while this strategy is active
	}
	ai_strategy = {
		type = conquer
		id = FIN
		value = 400 #These values offset each other. Basically we won't start wars with anyone except for finland while this strategy is active
	}
	ai_strategy = {
		type = conquer
		id = PER
		value = 400 #These values offset each other. Basically we won't start wars with anyone except for iran while this strategy is active
	}
}

allies_avoid_starting_wars_during_endgame = { #Allies should avoid attacking.. well, anyone while ww2 is in endgame
	allowed = {
		OR = {
			tag = ENG
			is_in_faction_with = ENG
		}
	}
	enable = {
		is_historical_focus_on = yes
		ENG = { has_government = democratic }
		OR = {
			tag = ENG
			is_in_faction_with = ENG
		}
		has_war_with = JAP
		JAP = {
			has_government = fascism #Just to make sure we're not looking at a puppet or sth
		}
		date > 1943.1.1
		date < 1945.1.1
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = avoid_starting_wars
		value = -400
	}
}

we_dont_believe_in_mountain_tanks = {
	enable = {
		is_historical_focus_on = yes
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = front_armor_score
		id = "GRE"
		value = -100
	}

	ai_strategy = {
		type = front_armor_score
		id = "YUG"
		value = -100
	}
}

# Build some rockets (simple strats to have a minimum production at least )
if_we_can_build_v1_rockets_we_want_rockets = {
	enable = {
		is_special_project_completed = sp:sp_rockets_flying_bomb
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = equipment_production_min_factories_archetype
		id = guided_missile_equipment
		value = 1
	}
}

if_we_can_build_v2_rockets_we_want_v2_rockets = {
	enable = {
		is_special_project_completed = sp:sp_rockets_ballistic_missile
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = equipment_production_min_factories_archetype
		id = ballistic_missile_equipment
		value = 1
	}
}
if_we_can_build_sams_we_want_sams = {
	enable = {
		is_special_project_completed = sp:sp_rockets_ground_to_air_missile
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = equipment_production_min_factories_archetype
		id = sam_missile_equipment
		value = 1
	}
}
if_we_can_build_nuclear_missiles_we_want_nuclear_missiles = {
	enable = {
		is_special_project_completed = sp:sp_nuclear_warheads
		NOT = {
			OR = {
				original_tag = TOM #NOTE
			}
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = equipment_production_min_factories_archetype
		id = nuclear_missile_equipment
		value = 1
	}
}
