default_role_ratios = { # Vanilla Override
    allowed = { always = no }
    enable = { always = no }
    abort_when_not_enabled = yes

    # Voided, Will use new FAI_navy_role_ratios
}

slightly_naval_focused_nation = { # Vanilla Override
    allowed = { always = no }
    enable = { always = no }
    abort_when_not_enabled = yes

    # Voided, Will use new FAI_navy_role_ratios
}

more_naval_focused_nation = { # Vanilla Override
    allowed = { always = no }
    enable = { always = no }
    abort_when_not_enabled = yes

    # Voided, Will use new FAI_navy_role_ratios
}
# High-Level Fleet Composition
FAI_default_navy_unit_production = {
	enable = {
		always = yes
	}
	abort_when_not_enabled = yes

	ai_strategy = { type = unit_ratio id = capital_ship value = 10 }
	ai_strategy = { type = unit_ratio id = screen_ship value = 25 }
	ai_strategy = { type = unit_ratio id = submarine value = 10 }
}

FAI_navy_major_role_ratios = {
	enable = {
		has_dlc = "Man the Guns"
		is_major = yes
	}
	abort_when_not_enabled = yes

	# High Priority Capitals
	ai_strategy = { type = role_ratio id = naval_carrier value = 40 }
	ai_strategy = { type = role_ratio id = naval_capital_shbb value = 30 }
	ai_strategy = { type = role_ratio id = naval_capital_bb value = 20 }
	ai_strategy = { type = role_ratio id = naval_capital_bc value = 10 }
	
	# High Priority Screens (Survivability)
	ai_strategy = { type = role_ratio id = naval_screen value = 120 }
	ai_strategy = { type = role_ratio id = naval_cruiser_light value = 80 }
	ai_strategy = { type = role_ratio id = naval_cruiser_heavy value = 30 }
	
	# Secondary
	ai_strategy = { type = role_ratio id = naval_submarine value = 20 }
	ai_strategy = { type = role_ratio id = naval_escort value = 30 }

	# HARD BLOCK: No Mines
	ai_strategy = { type = role_ratio id = naval_mine_sweeper value = -100 }
	ai_strategy = { type = role_ratio id = naval_mine_layer value = -100 }
}

FAI_navy_minor_role_ratios = {
	enable = {
		has_dlc = "Man the Guns"
		is_major = no
	}
	abort_when_not_enabled = yes

	# HARD BLOCK: No Capitals for Minors
	ai_strategy = { type = role_ratio id = naval_carrier value = -75 }
	ai_strategy = { type = role_ratio id = naval_capital_shbb value = -75 }
	ai_strategy = { type = role_ratio id = naval_capital_bb value = -60 }
	ai_strategy = { type = role_ratio id = naval_capital_bc value = -60 }
	ai_strategy = { type = role_ratio id = naval_cruiser_heavy value = -40 }
	
	# Focus: Coastal Defense & Survival
	ai_strategy = { type = role_ratio id = naval_screen value = 100 }
	ai_strategy = { type = role_ratio id = naval_escort value = 80 }
	ai_strategy = { type = role_ratio id = naval_submarine value = 60 }
	ai_strategy = { type = role_ratio id = naval_cruiser_light value = 20 }

	# HARD BLOCK: No Mines
	ai_strategy = { type = role_ratio id = naval_mine_sweeper value = -100 }
	ai_strategy = { type = role_ratio id = naval_mine_layer value = -100 }
}
# Factory-Scaled Tiers
FAI_navy_very_low_naval_focused_nation = {
	enable = {
		num_of_naval_factories > 12
		num_of_naval_factories < 23
	}
	abort_when_not_enabled = yes

	# Cruisers
	ai_strategy = {
		type = role_ratio
		id = naval_cruiser_heavy
		value = -6
	}
	ai_strategy = {
		type = role_ratio
		id = naval_cruiser_light
		value = 80
	}
	ai_strategy = {
		type = role_ratio
		id = naval_screen
		value = 100
	}
	# Destroyers
	ai_strategy = {
		type = role_ratio
		id = naval_escort
		value = 80
	}
	ai_strategy = {
		type = role_ratio
		id = naval_mine_sweeper
		value = 10
	}
	ai_strategy = {
		type = role_ratio
		id = naval_mine_layer
		value = 30
	}
	# Submarines
	ai_strategy = {
		type = role_ratio
		id = naval_submarine
		value = 50
	}
}

FAI_navy_low_naval_focused_nation = {
	enable = {
		num_of_naval_factories > 24
		num_of_naval_factories < 35
	}
	abort_when_not_enabled = yes

	# Heavy Ships
	ai_strategy = {
		type = role_ratio
		id = naval_capital_bc
		value = 9
	}
	# Carriers
	ai_strategy = {
		type = role_ratio
		id = naval_carrier_light
		value = 9
	}
	# Cruisers
	ai_strategy = {
		type = role_ratio
		id = naval_cruiser_heavy
		value = 9
	}
	ai_strategy = {
		type = role_ratio
		id = naval_cruiser_light
		value = 80
	}
	ai_strategy = {
		type = role_ratio
		id = naval_screen
		value = 150
	}
	# Destroyers
	ai_strategy = {
		type = role_ratio
		id = naval_escort
		value = 40
	}
	ai_strategy = {
		type = role_ratio
		id = naval_mine_sweeper
		value = 10
	}
	ai_strategy = {
		type = role_ratio
		id = naval_mine_layer
		value = 20
	}
	# Submarines
	ai_strategy = {
		type = role_ratio
		id = naval_submarine
		value = 25
	}
}

FAI_navy_medium_naval_focused_nation = {
	enable = {
		num_of_naval_factories > 36
		num_of_naval_factories < 47
	}
	abort_when_not_enabled = yes

	# Heavy Ships
	ai_strategy = {
		type = role_ratio
		id = naval_capital_bb
		value = 0
	}
	ai_strategy = {
		type = role_ratio
		id = naval_capital_bc
		value = 18
	}
	# Carriers
	ai_strategy = {
		type = role_ratio
		id = naval_carrier
		value = 0
	}
	ai_strategy = {
		type = role_ratio
		id = naval_carrier_light
		value = 18
	}
	# Cruisers
	ai_strategy = {
		type = role_ratio
		id = naval_cruiser_heavy
		value = 18
	}
	ai_strategy = {
		type = role_ratio
		id = naval_cruiser_light
		value = 80
	}
	ai_strategy = {
		type = role_ratio
		id = naval_screen
		value = 200
	}
	# Destroyers
	ai_strategy = {
		type = role_ratio
		id = naval_escort
		value = 20
	}
	ai_strategy = {
		type = role_ratio
		id = naval_mine_sweeper
		value = 20
	}
	ai_strategy = {
		type = role_ratio
		id = naval_mine_layer
		value = 10
	}
	# Submarines
	ai_strategy = {
		type = role_ratio
		id = naval_submarine
		value = 0
	}
}

FAI_navy_high_naval_focused_nation = {
	enable = {
		num_of_naval_factories > 48
		num_of_naval_factories < 59
	}
	abort_when_not_enabled = yes

	# Heavy Ships
	ai_strategy = {
		type = role_ratio
		id = naval_capital_bb
		value = 8
	}
	ai_strategy = {
		type = role_ratio
		id = naval_capital_bc
		value = 36
	}
	# Carriers
	ai_strategy = {
		type = role_ratio
		id = naval_carrier
		value = 8
	}
	ai_strategy = {
		type = role_ratio
		id = naval_carrier_light
		value = 36
	}
	# Cruisers
	ai_strategy = {
		type = role_ratio
		id = naval_cruiser_heavy
		value = 36
	}
	ai_strategy = {
		type = role_ratio
		id = naval_cruiser_light
		value = 80
	}
	ai_strategy = {
		type = role_ratio
		id = naval_screen
		value = 200
	}
	# Destroyers
	ai_strategy = {
		type = role_ratio
		id = naval_escort
		value = 20
	}
	ai_strategy = {
		type = role_ratio
		id = naval_mine_sweeper
		value = 20
	}
	ai_strategy = {
		type = role_ratio
		id = naval_mine_layer
		value = 10
	}
	# Submarines
	ai_strategy = {
		type = role_ratio
		id = naval_submarine
		value = -50
	}
}

FAI_navy_very_high_naval_focused_nation = {
	enable = {
		num_of_naval_factories > 60
		num_of_naval_factories < 99
	}
	abort_when_not_enabled = yes

	# Heavy Ships
	ai_strategy = {
		type = role_ratio
		id = naval_capital_bb
		value = 36
	}
	ai_strategy = {
		type = role_ratio
		id = naval_capital_bc
		value = 72
	}
	# Carriers
	ai_strategy = {
		type = role_ratio
		id = naval_carrier
		value = 36
	}
	ai_strategy = {
		type = role_ratio
		id = naval_carrier_light
		value = 72
	}
	# Cruisers
	ai_strategy = {
		type = role_ratio
		id = naval_cruiser_heavy
		value = 72
	}
	ai_strategy = {
		type = role_ratio
		id = naval_cruiser_light
		value = 80
	}
	ai_strategy = {
		type = role_ratio
		id = naval_screen
		value = 200
	}
	# Destroyers
	ai_strategy = {
		type = role_ratio
		id = naval_escort
		value = 20
	}
	ai_strategy = {
		type = role_ratio
		id = naval_mine_sweeper
		value = 20
	}
	ai_strategy = {
		type = role_ratio
		id = naval_mine_layer
		value = 10
	}
	# Submarines
	ai_strategy = {
		type = role_ratio
		id = naval_submarine
		value = -100
	}
}

FAI_navy_unnaturally_high_naval_focused_nation = { # Extra for rare super naval states.
	enable = {
		num_of_naval_factories > 100
	}
	abort_when_not_enabled = yes

	# Heavy Ships
	ai_strategy = {
		type = role_ratio
		id = naval_capital_bb
		value = 96
	}
	ai_strategy = {
		type = role_ratio
		id = naval_capital_bc
		value = 48
	}
	# Carriers
	ai_strategy = {
		type = role_ratio
		id = naval_carrier
		value = 96
	}
	ai_strategy = {
		type = role_ratio
		id = naval_carrier_light
		value = 48
	}
	# Cruisers
	ai_strategy = {
		type = role_ratio
		id = naval_cruiser_heavy
		value = 96
	}
	ai_strategy = {
		type = role_ratio
		id = naval_cruiser_light
		value = 60
	}
	ai_strategy = {
		type = role_ratio
		id = naval_screen
		value = 300
	}
	# Destroyers
	ai_strategy = {
		type = role_ratio
		id = naval_escort
		value = -50
	}
	ai_strategy = {
		type = role_ratio
		id = naval_mine_sweeper
		value = 35
	}
	ai_strategy = {
		type = role_ratio
		id = naval_mine_layer
		value = 35
	}
	# Submarines
	ai_strategy = {
		type = role_ratio
		id = naval_submarine
		value = 100
	}
}

FAI_navy_limit_after_100_naval_factories = {
	enable = {
		num_of_naval_factories > 100
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = building_target
		id = dockyard
		value = -50
	}
}
# Minor Navy Scaling (by Ship Count)
FAI_navy_unit_role_ratios_minors_coastal = {
	allowed = {
		has_dlc = "Man the Guns"
	}
	enable = {
		is_major = no
		has_navy_size = { size < 50 }
	}

	abort_when_not_enabled = yes

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

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

FAI_navy_unit_role_ratios_minors_defensive = {
	allowed = {
		has_dlc = "Man the Guns"
	}
	enable = {
		is_major = no
		has_navy_size = { size < 100 }
	}

	abort_when_not_enabled = yes

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

	ai_strategy = {
		type = role_ratio
		id = naval_cruiser_light
		value = 50
	}
	
	ai_strategy = {
		type = role_ratio
		id = naval_cruiser_medium
		value = 20
	}
	
	ai_strategy = {
		type = role_ratio
		id = naval_submarine
		value = 20
	}
}

FAI_navy_unit_role_ratios_minors_offensive = {
	allowed = {
		has_dlc = "Man the Guns"
	}
	enable = {
		is_major = no
		has_navy_size = { size < 200 }
	}

	abort_when_not_enabled = yes

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

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

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

	ai_strategy = {
		type = role_ratio
		id = naval_submarine
		value = 20
	}
}
# Production Throttle
FAI_navy_unit_role_ratios_minors_global = {
	allowed = {
		has_dlc = "Man the Guns"
	}
	enable = {
		is_major = no
		has_navy_size = { size < 300 }
	}

	abort_when_not_enabled = yes

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

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

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

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

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

FAI_navy_stall_naval_capital_bb_production = {
	enable = {
		has_navy_size = {
			unit = battleship
			size > 15
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = unit_ratio
		id = capital_ship
		value = -30
	}
	ai_strategy = {
		type = role_ratio
		id = naval_capital_bc
		value = 15
	}
}

FAI_navy_stop_naval_capital_bb_production = {
	enable = {
		has_navy_size = {
			unit = battleship
			size > 50
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = unit_ratio
		id = capital_ship
		value = -100
	}
	ai_strategy = {
		type = role_ratio
		id = naval_capital_bc
		value = 50
	}
}

FAI_navy_stall_naval_capital_bc_production = {
	enable = {
		has_navy_size = {
			unit = battle_cruiser
			size > 25
		}
	}
	abort_when_not_enabled = yes

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

FAI_navy_stop_naval_capital_bc_production = {
	enable = {
		has_navy_size = {
			unit = battle_cruiser
			size > 100
		}
	}
	abort_when_not_enabled = yes

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

FAI_navy_stall_naval_carrier_production = {
	enable = {
		has_navy_size = {
			unit = carrier
			size > 8 # Was 12
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = role_ratio
		id = naval_carrier
		value = -30
	}
	ai_strategy = {
		type = role_ratio
		id = naval_carrier_light
		value = -15
	}
}

FAI_navy_stop_naval_carrier_production = {
	enable = {
		has_navy_size = {
			unit = carrier
			size > 14 # Was 18
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = role_ratio
		id = naval_carrier
		value = -100
	}
	ai_strategy = {
		type = role_ratio
		id = naval_carrier_light
		value = -50
	}
}

FAI_navy_stall_naval_cruiser_heavy_production = {
	enable = {
		has_navy_size = {
			unit = heavy_cruiser
			size > 65
		}
	}
	abort_when_not_enabled = yes

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

FAI_we_need_screen_1 = {
	enable = {
		is_major = yes
		has_navy_size = { size < 50 type = screen_ship archetype = ship_hull_light }
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = role_ratio
		id = naval_screen
		value = 300
	}
}
# Carrier Aviation Production Ratios
FAI_navy_we_need_cv_planes_1 = {
	allowed = {
		always = yes
	}
	enable = {
		has_navy_size = { size > 0 type = carrier }
		has_navy_size = { size < 5 type = carrier }
	}
	abort_when_not_enabled = yes
	
	ai_strategy = {
		type = unit_ratio
		id = cv_fighter
		value = 5
	}

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

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

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

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

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

	ai_strategy = {
		type = equipment_variant_production_factor
		id = cv_small_plane_airframe
		value = 5
	}
}

FAI_navy_we_need_cv_planes_2 = {
	allowed = {
		always = yes
	}
	enable = {
		has_navy_size = { size > 3 type = carrier }
		has_navy_size = { size < 7 type = carrier }
	}
	abort_when_not_enabled = yes
	
	ai_strategy = {
		type = unit_ratio
		id = cv_fighter
		value = 7.5
	}

	ai_strategy = {
		type = equipment_production_factor
		id = cv_fighter
		value = 7.5
	}

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

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

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

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

	ai_strategy = {
		type = equipment_variant_production_factor
		id = cv_small_plane_airframe
		value = 10
	}
}

FAI_navy_we_need_cv_planes_3 = {
	allowed = {
		always = yes
	}
	enable = {
		has_navy_size = { size > 10 type = carrier }
	}
	abort_when_not_enabled = yes
	
	ai_strategy = {
		type = unit_ratio
		id = cv_fighter
		value = 10
	}

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

	ai_strategy = {
		type = equipment_production_min_factories
		id = cv_fighter
		value = 3
	}

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

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

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

	ai_strategy = {
		type = equipment_variant_production_factor
		id = cv_small_plane_airframe
		value = 20
	}
}
# Carrier Aviation Production Desire
FAI_navy_upgrade_cv_plane_strategy_0 = {
	allowed = {
		always = yes
	}
	enable = {
		has_tech = basic_small_airframe
		NOT = { has_tech = improved_small_airframe }
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = production_upgrade_desire_offset
		id = cv_small_plane_airframe_1
		value = 1000
	}
	ai_strategy = {
		type = production_upgrade_desire_offset
		id = cv_small_plane_naval_bomber_airframe_1
		value = 1000
	}
	ai_strategy = {
		type = production_upgrade_desire_offset
		id = cv_small_plane_cas_airframe_1
		value = 1000
	}
}

FAI_navy_upgrade_cv_plane_strategy_1 = {
	allowed = {
		always = yes
	}
	enable = {
		has_tech = improved_small_airframe
		NOT = { has_tech = advanced_small_airframe }
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = production_upgrade_desire_offset
		id = cv_small_plane_airframe_2
		value = 1000
	}
	ai_strategy = {
		type = production_upgrade_desire_offset
		id = cv_small_plane_naval_bomber_airframe_2
		value = 1000
	}
	ai_strategy = {
		type = production_upgrade_desire_offset
		id = cv_small_plane_cas_airframe_2
		value = 1000
	}
}

FAI_navy_upgrade_cv_plane_strategy_2 = {
	allowed = {
		always = yes
	}
	enable = {
		has_tech = advanced_small_airframe
		NOT = { has_tech = modern_small_airframe }
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = production_upgrade_desire_offset
		id = cv_small_plane_airframe_3
		value = 1000
	}
	ai_strategy = {
		type = production_upgrade_desire_offset
		id = cv_small_plane_naval_bomber_airframe_3
		value = 1000
	}
	ai_strategy = {
		type = production_upgrade_desire_offset
		id = cv_small_plane_cas_airframe_3
		value = 1000
	}
}

FAI_navy_upgrade_cv_plane_strategy_3 = {
	allowed = {
		always = yes
	}
	enable = {
		has_tech = modern_small_airframe
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = production_upgrade_desire_offset
		id = cv_small_plane_airframe_4
		value = 1000
	}
	ai_strategy = {
		type = production_upgrade_desire_offset
		id = cv_small_plane_naval_bomber_airframe_4
		value = 1000
	}
	ai_strategy = {
		type = production_upgrade_desire_offset
		id = cv_small_plane_cas_airframe_4
		value = 1000
	}
}
# Static Convoy Logic
FAI_navy_we_need_convoys_majors1 = {
	enable = {
		is_major = yes
		stockpile_ratio = { archetype = convoy ratio < 75 }
	}
	abort = { stockpile_ratio = { archetype = convoy ratio > 125 } }

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

FAI_navy_we_need_convoys_majors2 = {
	enable = {
		is_major = yes
		stockpile_ratio = { archetype = convoy ratio < 125 }
	}
	abort = { stockpile_ratio = { archetype = convoy ratio > 500 } }

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

FAI_navy_we_need_convoys_majors3 = {
	enable = {
		is_major = yes
		stockpile_ratio = { archetype = convoy ratio < 500 }
	}
	abort = { stockpile_ratio = { archetype = convoy ratio > 1000 } }

	ai_strategy = {
		type = equipment_production_min_factories
		id = convoy
		value = 2
	}
}
# Dynamic Convoy Logic
FAI_navy_convoy_dynamic_production = {
	enable = {
		check_variable = { var = num_equipment@convoy value = FAI_convoy_target compare = less_than }
	}
	abort_when_not_enabled = yes

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

FAI_navy_convoy_dynamic_overflow1 = {
	enable = {
		check_variable = { var = num_equipment@convoy value = FAI_convoy_of1_limit compare = greater_than }
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = equipment_production_factor
		id = convoy
		value = -500
	}
}

FAI_navy_convoy_dynamic_overflow2 = {
	enable = {
		check_variable = { var = num_equipment@convoy value = FAI_convoy_of2_limit compare = greater_than }
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = equipment_production_factor
		id = convoy
		value = -500
	}
}
# Resource/Threat Overrides
save_admiral_pp_for_later = { # Vanilla Override
	enable = {
		has_war = no
		threat < 0.3
		has_political_power < 200
	}
	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
	}
}

convoy_voy_voy_voy = { # Vanilla Override
	enable = {
		has_dlc = "Man the Guns"
		convoy_threat > 0.2
	}
	abort = {
		convoy_threat < 0.2
	}

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

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