### ENG ###
ENG_protect_home_waters = {
    allowed = {
        original_tag = ENG
    }
    enable = {
        has_war_with = GER
        GER = {
            has_navy_size = { size > 30 }
        }
        enable_vnr_naval_ai = yes
    }
    abort_when_not_enabled = yes
    ai_strategy = {
		type = naval_dominance
		id = vnr_eng_home_waters
		value = 100
	}
	ai_strategy = {
		type = coast_defense
		id = 18
		value = 100
	}
	ai_strategy = {
		type = coast_defense
		id = 16
		value = 100
	}
	ai_strategy = {
        type = naval_avoid_region
        id = 18
        value = -1000
    }

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

ENG_protect_atlantic_route = {
	allowed = {
		original_tag = ENG
	}
	enable = {
		OR = {
			has_war_with = GER
			has_war_with = ITA
		}
		convoy_threat > 0.1
		enable_vnr_naval_ai = yes
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = naval_mission_threshold
		id = MISSION_CONVOY_ESCORT 
		value = -1000
	}
}

ENG_avoid_baltic = {
	allowed = {
        original_tag = ENG
    }
    enable = {
        has_war_with = GER
        GER = {
            has_navy_size = { size > 30 }
        }
        enable_vnr_naval_ai = yes
    }
    abort_when_not_enabled = yes

	ai_strategy = {
		type = naval_avoid_region
		id = 173
		value = 500
	}
	ai_strategy = {
		type = naval_avoid_region
		id = 207
		value = 500
	}
	ai_strategy = {
		type = naval_dominance
		id = vnr_ger_baltic
		value = -100
	}
}

ENG_secure_mediterranean = {
    allowed = {
        original_tag = ENG
    }
    enable = {
        has_war_with = ITA
        ITA = {
            has_navy_size = { size > 30 }
        }
		all_core_state = {
			is_controlled_by_ROOT_or_ally = yes
		}
        enable_vnr_naval_ai = yes
    }
    abort_when_not_enabled = yes
    ai_strategy = {
        type = naval_dominance
        id = vnr_eng_med_zones
        value = 80
    }
	ai_strategy = {
		type = naval_avoid_region
		id = 168
		value = 800
	}
	ai_strategy = {
        type = convoy_raiding_target
        id = ITA
        value = 70
    }
}

ENG_avoid_mediterranean = {
    allowed = {
        original_tag = ENG
    }
    enable = {
		has_war = yes
		any_core_state = {
			is_controlled_by_ROOT_or_ally = no
		}
        enable_vnr_naval_ai = yes
    }
    abort_when_not_enabled = yes
    ai_strategy = {
        type = naval_avoid_region
        id = 29
        value = 1000
    }
    ai_strategy = {
        type = naval_avoid_region
        id = 68
        value = 1000
    }
    ai_strategy = {
        type = naval_avoid_region
        id = 69
        value = 1000
    }
	ai_strategy = {
		type = naval_avoid_region
		id = 168
		value = 1000
	}
	ai_strategy = {
        type = naval_dominance
        id = vnr_eng_med_zones
        value = 0
    }
}

ENG_avoid_pacific = {
    allowed = {
        original_tag = ENG
    }
    enable = {
        has_war_with = JAP
		has_war_with = ITA
		ITA = { has_navy_size = { size > 99 } }
		war_length_with = {
			tag = JAP
			months < 24
		}
		any_core_state = {
			is_controlled_by_ROOT_or_ally = no
		}
        enable_vnr_naval_ai = yes
    }
    abort_when_not_enabled = yes
    ai_strategy = {
        type = naval_avoid_region
        id = 75
        value = 1000
    }
    ai_strategy = {
        type = naval_avoid_region
        id = 72
        value = 50
    }
    ai_strategy = {
        type = naval_avoid_region
        id = 73
        value = 200
    }
	ai_strategy = {
		type = naval_dominance
		id = vnr_eng_south_china_sea
		value = 0
	}
}

ENG_reinforce_pacific = {
    allowed = {
        original_tag = ENG
    }
    enable = {
        has_war_with = JAP
		OR = {
			war_length_with = {
				tag = JAP
				months > 23
			}
			NOT = { has_war_with = ITA }
		}
		OR = {
			NOT = { has_war_with = ITA }
			ITA = { has_navy_size = { size < 100 } }
		}
		336 = {
			is_controlled_by_ROOT_or_ally = yes
		}
		all_core_state = {
			is_controlled_by_ROOT_or_ally = yes
		}
        enable_vnr_naval_ai = yes
    }
    abort_when_not_enabled = yes
    ai_strategy = {
		type = naval_dominance
		id = vnr_eng_south_china_sea
		value = 65
	}
	ai_strategy = {
		type = naval_dominance
		id = vnr_eng_pacific_zone
		value = 20
	}
	ai_strategy = {
		type = naval_dominance
		id = vnr_pacific_2
		value = 45
	}
}

### JAP ###
JAP_destroy_china_navy_quick = {
    allowed = {
        original_tag = JAP
    }
    enable = {
        has_war_with = CHI
        NOT = { has_war_with = USA }
		CHI = {
			has_navy_size = { size > 9 }
		}
        enable_vnr_naval_ai = yes
    }
    abort_when_not_enabled = yes
    ai_strategy = {
        type = naval_dominance
        id = vnr_chi_coast
        value = 100
    }
	ai_strategy = {
        type = convoy_raiding_target
        id = CHI
        value = 100
    }
}

JAP_turuk_base = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		684 = { is_controlled_by_ROOT_or_ally = yes }
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = strike_force_home_base
		id = 84
		value = 500
	}
}

JAP_pacific_war_naval_stage_zero = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		NOT = { has_war_with = USA }
		threat > 0.65
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = naval_dominance
		id = vnr_pacific_okinawa
		value = 100
	}
	ai_strategy = {
		type = naval_dominance
		id = vnr_pacific_iwo_jima
		value = 100
	}
}

JAP_pacific_war_naval_stage_one = {
    allowed = {
        original_tag = JAP
    }
    enable = {
        has_war_with = USA
		has_war_with = PHI
		has_war_with = MAL
		has_war_with = AST
		PHI = { has_capitulated = no }
		MAL = { has_capitulated = no }
        enable_vnr_naval_ai = yes
    }
    abort_when_not_enabled = yes
    ai_strategy = {
		type = naval_dominance
		id = vnr_pacific_philippines
		value = 100
	}
	ai_strategy = {
		type = naval_dominance
		id = vnr_pacific_solomons
		value = 100
	}
	ai_strategy = {
		type = naval_dominance
		id = vnr_pacific_iwo_jima
		value = 70
	}
	ai_strategy = {
		type = invade
		id = PHI
		value = 1000
	}
	ai_strategy = {
		type = invade
		id = MAL
		value = 1000
	}
	ai_strategy = {
		type = invade
		id = USA
		value = 500
	}
	ai_strategy = {
		type = invade
		id = AST
		value = 100
	}
	ai_strategy = {
		type = front_control
		area = pacific
		ordertype = invasion
    	execute_order = yes
	}
}

JAP_pacific_war_naval_stage_two = {
    allowed = {
        original_tag = JAP
    }
    enable = {
        has_war_with = USA
		has_war_with = PHI
		has_war_with = MAL
		has_war_with = AST
		PHI = { has_capitulated = yes }
		MAL = { has_capitulated = yes }
        enable_vnr_naval_ai = yes
    }
    abort_when_not_enabled = yes
    ai_strategy = {
		type = naval_dominance
		id = vnr_pacific_midway
		value = 100
	}
	ai_strategy = {
		type = naval_dominance
		id = vnr_pacific_hawaii
		value = 100
	}
	ai_strategy = {
		type = naval_dominance
		id = vnr_pacific_solomons
		value = 75
	}
	ai_strategy = {
		type = invade
		id = USA
		value = 1000
	}
	ai_strategy = {
		type = invade
		id = AST
		value = 500
	}
	ai_strategy = {
		type = invade
		id = INS
		value = 800
	}
	ai_strategy = {
		type = front_control
		area = pacific
		ordertype = invasion
    	execute_order = yes
	}
}

### USA ###
USA_pacific_fleet_command = {
	allowed = {
		original_tag = USA
	}

	enable = {
		629 = { is_controlled_by_ROOT_or_ally = yes }
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = strike_force_home_base
		id = 105
		value = 1000
	}
	ai_strategy = {
		type = strike_force_home_base
		id = 89
		value = -100
	}
}

USA_pacific_war_naval_avoid_first = {
	allowed = {
		original_tag = USA
	}
	enable = {
		OR = {
			has_war_with = JAP
			threat > 0.7
		}
		date < 1942.5.1
		naval_strength_ratio = {
			tag = JAP
			ratio < 5
		}
        enable_vnr_naval_ai = yes
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = put_unit_buffer
		ratio = 0.15
		states = {
			629
		}
		subtract_invasions_from_need = yes
	}

	ai_strategy = {
		type = naval_avoid_region
		id = 75
		value = 1000
	}
	ai_strategy = {
		type = naval_avoid_region
		id = 76
		value = 1000
	}
	ai_strategy = {
		type = naval_avoid_region
		id = 77
		value = 1000
	}
	ai_strategy = {
		type = naval_avoid_region
		id = 78
		value = 1000
	}
	ai_strategy = {
		type = naval_avoid_region
		id = 79
		value = 1000
	}
	ai_strategy = {
		type = naval_avoid_region
		id = 80
		value = 1000
	}
	ai_strategy = {
		type = naval_avoid_region
		id = 90
		value = 1000
	}
	ai_strategy = {
		type = naval_avoid_region
		id = 94
		value = 1000
	}
	ai_strategy = {
		type = naval_avoid_region
		id = 177
		value = 1000
	}
	
	ai_strategy = {
		type = naval_dominance
		id = vnr_pacific_hawaii
		value = 100
	}
	ai_strategy = {
		type = naval_dominance
		id = vnr_pacific_midway
		value = 100
	}
	ai_strategy = {
		type = naval_dominance
		id = vnr_pacific_philippines
		value = -100
	}
	ai_strategy = {
		type = naval_dominance
		id = vnr_pacific_iwo_jima
		value = -100
	}
	ai_strategy = {
		type = naval_dominance
		id = vnr_pacific_okinawa
		value = -100
	}
}

USA_do_not_waste_fleet_in_north_pacific = {
	allowed = {
		original_tag = USA
	}
	enable = {
		has_war_with = JAP
        enable_vnr_naval_ai = yes
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = naval_dominance
		id = 87
		value = -100
	}
	ai_strategy = {
		type = naval_dominance
		id = 88
		value = -100
	}
	ai_strategy = {
		type = naval_dominance
		id = 96
		value = -100
	}
	ai_strategy = {
		type = naval_dominance
		id = 176
		value = 0
	}
	ai_strategy = {
		type = naval_dominance
		id = 114
		value = 0
	}
	ai_strategy = {
		type = naval_dominance
		id = 171
		value = 0
	}
	ai_strategy = {
		type = coast_defense
		id = 88
		value = 0
	}
	ai_strategy = {
		type = naval_dominance
		id = us_west_coast
		value = -100
	}
}

USA_pacific_war_naval_counterattack_1 = {
    allowed = {
        original_tag = USA
    }
    enable = {
        has_war_with = JAP
		OR = {
			date > 1942.4.30
			naval_strength_ratio = {
				tag = JAP
				ratio > 5
			}
		}
		OR = {
			633 = { is_controlled_by_ROOT_or_ally = no }
			684 = { is_controlled_by_ROOT_or_ally = no }
		}
        enable_vnr_naval_ai = yes
    }
    abort_when_not_enabled = yes

	ai_strategy = {
		type = put_unit_buffer
		ratio = 0.15
		states = {
			629
		}
		subtract_invasions_from_need = yes
	}

	ai_strategy = {
		type = naval_avoid_region
		id = 75
		value = 1000
	}
	ai_strategy = {
		type = naval_avoid_region
		id = 76
		value = 1000
	}
	ai_strategy = {
		type = naval_avoid_region
		id = 77
		value = 1000
	}
	ai_strategy = {
		type = naval_avoid_region
		id = 78
		value = 1000
	}
	ai_strategy = {
		type = naval_avoid_region
		id = 79
		value = 1000
	}
	ai_strategy = {
		type = naval_avoid_region
		id = 80
		value = 1000
	}
	ai_strategy = {
		type = naval_avoid_region
		id = 90
		value = 1000
	}
	ai_strategy = {
		type = naval_avoid_region
		id = 94
		value = 1000
	}
	ai_strategy = {
		type = naval_avoid_region
		id = 177
		value = 1000
	}
	
	ai_strategy = {
		type = naval_dominance
		id = vnr_pacific_solomons
		value = 100
	}
	ai_strategy = {
		type = naval_dominance
		id = vnr_pacific_midway
		value = 100
	}
	ai_strategy = {
		type = naval_dominance
		id = vnr_pacific_iwo_jima
		value = -100
	}
	ai_strategy = {
		type = naval_dominance
		id = vnr_pacific_philippines
		value = -100
	}
	ai_strategy = {
		type = naval_dominance
		id = vnr_pacific_okinawa
		value = -100
	}
	
	ai_strategy = {
		type = invade
		id = JAP
		value = 500
	}
	ai_strategy = {
		type = naval_invasion_focus
		value = 1000
	}
	ai_strategy = {
		type = convoy_raiding_target
		id = JAP
		value = 100
	}

	ai_strategy = {
		type = invasion_unit_request
		state = 633
		value = 500
	}
	ai_strategy = {
		type = invasion_unit_request
		state = 684
		value = 500
	}

	ai_strategy = {
		type = front_control
		area = pacific
		ordertype = invasion
    	execute_order = yes
	}
	ai_strategy = {
		type = naval_invasion_dominance_weight
		value = 60
	}
}

USA_pacific_war_naval_counterattack_2 = {
    allowed = {
        original_tag = USA
    }
    enable = {
        has_war_with = JAP
		OR = {
			date > 1942.4.30
			naval_strength_ratio = {
				tag = JAP
				ratio > 5
			}
		}
		633 = { is_controlled_by_ROOT_or_ally = yes }
		684 = { is_controlled_by_ROOT_or_ally = yes }
		645 = { is_controlled_by_ROOT_or_ally = no }
        enable_vnr_naval_ai = yes
    }
    abort_when_not_enabled = yes
	ai_strategy = {
		type = naval_avoid_region
		id = 75
		value = 1000
	}
	ai_strategy = {
		type = naval_avoid_region
		id = 76
		value = 1000
	}
	ai_strategy = {
		type = naval_avoid_region
		id = 77
		value = 1000
	}
	ai_strategy = {
		type = naval_avoid_region
		id = 79
		value = 1000
	}
	ai_strategy = {
		type = naval_avoid_region
		id = 80
		value = 1000
	}
	ai_strategy = {
		type = naval_avoid_region
		id = 90
		value = 1000
	}
	ai_strategy = {
		type = naval_avoid_region
		id = 177
		value = 1000
	}
	
	ai_strategy = {
		type = naval_dominance
		id = vnr_pacific_philippines
		value = 100
	}
	ai_strategy = {
		type = naval_dominance
		id = vnr_pacific_iwo_jima
		value = 100
	}
	ai_strategy = {
		type = naval_dominance
		id = vnr_pacific_midway
		value = 70
	}
	ai_strategy = {
		type = invade
		id = JAP
		value = 1000
	}
	ai_strategy = {
		type = naval_invasion_focus
		value = 1000
	}
	
	ai_strategy = {
		type = convoy_raiding_target
		id = JAP
		value = 100
	}

	ai_strategy = {
		type = invasion_unit_request
		state = 645
		value = 500
	}

	ai_strategy = {
		type = front_control
		area = pacific
		ordertype = invasion
    	execute_order = yes
	}

	ai_strategy = {
		type = front_control
		area = home_islands
		ordertype = invasion
    	execute_order = yes
	}
	ai_strategy = {
		type = naval_invasion_dominance_weight
		value = 60
	}
}

USA_pacific_war_naval_counterattack_3 = {
    allowed = {
        original_tag = USA
    }
    enable = {
        has_war_with = JAP
		OR = {
			date > 1942.4.30
			naval_strength_ratio = {
				tag = JAP
				ratio > 5
			}
		}
		633 = { is_controlled_by_ROOT_or_ally = yes }
		684 = { is_controlled_by_ROOT_or_ally = yes }
		645 = { is_controlled_by_ROOT_or_ally = yes }
        enable_vnr_naval_ai = yes
    }
    abort_when_not_enabled = yes
	ai_strategy = {
		type = naval_avoid_region
		id = 77
		value = 1000
	}
	ai_strategy = {
		type = naval_avoid_region
		id = 79
		value = 1000
	}
	
	ai_strategy = {
		type = naval_dominance
		id = vnr_pacific_okinawa
		value = 100
	}
	ai_strategy = {
		type = naval_dominance
		id = vnr_pacific_iwo_jima
		value = 100
	}
	ai_strategy = {
		type = naval_dominance
		id = vnr_pacific_philippines
		value = 75
	}
	ai_strategy = {
		type = naval_dominance
		id = vnr_pacific_hawaii
		value = 0
	}
	ai_strategy = {
		type = invade
		id = JAP
		value = 1000
	}
	ai_strategy = {
		type = naval_invasion_focus
		value = 1000
	}
	
	ai_strategy = {
		type = convoy_raiding_target
		id = JAP
		value = 100
	}

	ai_strategy = {
		type = invasion_unit_request
		state = 526
		value = 500
	}

	ai_strategy = {
		type = front_control
		area = pacific
		ordertype = invasion
    	execute_order = yes
	}

	ai_strategy = {
		type = front_control
		area = home_islands
		ordertype = invasion
    	execute_order = yes
	}
	ai_strategy = {
		type = naval_invasion_dominance_weight
		value = 100
	}
}

USA_atlantic_war = {
	allowed = {
		original_tag = USA
	}
	enable = {
		is_ally_with = ENG
		has_war_with = GER
		has_navy_size = {
			type = carrier
			size > 19
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = strike_force_home_base
		id = 43
		value = 100
	}
	ai_strategy = {
		type = naval_dominance
		id = vnr_eng_atlantic_route
		value = 90
	}
}

### ITA ###
ITA_avoid_mediterranean = {
    allowed = {
        original_tag = ITA
    }
    enable = {
		OR = {
			has_war_with = ENG
			threat > 0.4
		}
        has_navy_size = { size < 250 }
        enable_vnr_naval_ai = yes
    }
    abort_when_not_enabled = yes
    ai_strategy = {
		type = naval_dominance
		id = vnr_ita_med_zones
		value = 100
	}
	ai_strategy = {
		type = naval_convoy_raid_region
		id = 29
		value = 100
	}
	ai_strategy = {
		type = naval_convoy_raid_region
		id = 68
		value = 100
	}
	ai_strategy = {
		type = naval_convoy_raid_region
		id = 69
		value = 100
	}
}

### GER ###
GER_forget_sealion = {
    allowed = {
        original_tag = GER
    }
    enable = {
        has_war_with = ENG
        naval_strength_ratio = {
            tag = ENG
            ratio < 0.7
        }
        enable_vnr_naval_ai = yes
    }
    abort_when_not_enabled = yes
    ai_strategy = {
		type = naval_dominance
		id = vnr_eng_home_waters
		value = 0
	}
	ai_strategy = {
		type = invade
		tag = ENG
		value = -500
	}
}

GER_unrestricted_submarine_warfare = {
    allowed = {
        original_tag = GER
    }
    enable = {
        has_war_with = ENG
        enable_vnr_naval_ai = yes
    }
    abort_when_not_enabled = yes
    ai_strategy = {
        type = naval_convoy_raid_region
        id = 47
        value = 200
    }
    ai_strategy = {
        type = naval_convoy_raid_region
        id = 49
        value = 500
    }
    ai_strategy = {
        type = naval_convoy_raid_region
        id = 44
        value = 150
    }
    ai_strategy = {
        type = naval_convoy_raid_region
        id = 50
        value = 30
    }
}

GER_avoid_mediterranean = {
	allowed = {
        original_tag = GER
    }
    enable = {
        country_exists = ENG
		NOT = { is_ally_with = ENG }
		enable_vnr_naval_ai = yes
    }
	abort_when_not_enabled = yes

	ai_strategy = {
		type = naval_dominance
		id = vnr_eng_med_zones
		value = -100
	}
	ai_strategy = {
		type = naval_dominance
		id = vnr_ita_med_zones
		value = -100
	}
}

GER_invade_norway = {
	allowed = {
        original_tag = GER
    }
	enable = {
		has_war_with = NOR
		NOR = {
			has_capitulated = no
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = invade
		id = NOR
		value = 1000
	}
	ai_strategy = {
		type = invasion_unit_request
		tag = NOR
		value = 50
	}
	ai_strategy = {
		type = naval_dominance
		id = vnr_ger_baltic
		value = 100
	}
}

major_train_fleet_strategy = {
	allowed = {
		OR = {
			original_tag = JAP
			original_tag = USA
			original_tag = ENG
			original_tag = ITA
			original_tag = FRA
			original_tag = GER
		}
	}
	enable = {
		has_war = no
		date < 1939.1.1
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = naval_mission_threshold
		id = MISSION_TRAINING
		value = -500
	}
}