add_namespace = ai_ships

# GER AI template 1940
country_event = {
	id = ai_ships.0
	
	hidden = yes
	fire_only_once = yes
	mean_time_to_happen = { days = 1 }
	trigger = {
		tag = GER
		is_ai = yes
		NOT = { has_country_flag = GER_SHIPS_1940 }
		date > 1940.6.1
		has_game_rule = { rule = allow_ai_tech_auto_unlock option = FREE }
	}
	immediate = {
		GER_AI_variants_1940 = yes
		set_country_flag = GER_SHIPS_1940
	}
	option = {
	}
}

# GER AI template 1943
country_event = {
	id = ai_ships.1
	
	hidden = yes
	fire_only_once = yes
	mean_time_to_happen = { days = 1 }
	trigger = {
		tag = GER
		is_ai = yes
		NOT = { has_country_flag = GER_SHIPS_1943 }
		date > 1943.3.1
		has_game_rule = { rule = allow_ai_tech_auto_unlock option = FREE }
	}
	immediate = {
		GER_AI_variants_1943 = yes
		set_country_flag = GER_SHIPS_1943
	}
	option = {
	}
}

# ENG AI template 1940
country_event = {
	id = ai_ships.2
	
	hidden = yes
	fire_only_once = yes
	mean_time_to_happen = { days = 1 }
	trigger = {
		tag = ENG
		is_ai = yes
		NOT = { has_country_flag = ENG_SHIPS_1940 }
		date > 1940.6.1
		has_game_rule = { rule = allow_ai_tech_auto_unlock option = FREE }
	}
	immediate = {
		ENG_AI_variants_1940 = yes
		set_country_flag = ENG_SHIPS_1940
	}
	option = {
	}
}

# ENG AI template 1943
country_event = {
	id = ai_ships.3
	
	hidden = yes
	fire_only_once = yes
	mean_time_to_happen = { days = 100 }
	trigger = {
		tag = ENG
		is_ai = yes
		NOT = { has_country_flag = ENG_SHIPS_1943 }
		date > 1943.3.1
		has_game_rule = { rule = allow_ai_tech_auto_unlock option = FREE }
	}
	immediate = {
		ENG_AI_variants_1943 = yes
		set_country_flag = ENG_SHIPS_1943
	}
	option = {
	}
}

# JAP AI template 1940
country_event = {
	id = ai_ships.4
	
	hidden = yes
	fire_only_once = yes
	mean_time_to_happen = { days = 1 }
	trigger = {
		tag = JAP
		is_ai = yes
		NOT = { has_country_flag = JAP_SHIPS_1940 }
		date > 1940.2.1
		has_game_rule = { rule = allow_ai_tech_auto_unlock option = FREE }
	}
	immediate = {
		JAP_AI_variants_1940 = yes
		set_country_flag = JAP_SHIPS_1940
	}
}

# JAP AI template 1943
country_event = {
	id = ai_ships.5
	
	hidden = yes
	fire_only_once = yes
	mean_time_to_happen = { days = 1 }
	trigger = {
		tag = JAP
		is_ai = yes
		NOT = { has_country_flag = JAP_SHIPS_1943 }
		date > 1943.2.1
		has_game_rule = { rule = allow_ai_tech_auto_unlock option = FREE }
	}
	immediate = {
		JAP_AI_variants_1943 = yes
		set_country_flag = JAP_SHIPS_1943
	}
}

# USA AI template 1940
country_event = {
	id = ai_ships.6
	hidden = yes
	fire_only_once = yes
	mean_time_to_happen = { days = 1 }
	trigger = {
		tag = USA
		is_ai = yes
		date > 1941.1.1
		NOT = { has_global_flag = USA_SHIPS_1941 }
		has_game_rule = { rule = allow_ai_tech_auto_unlock option = FREE }
	}
	immediate = {
		USA_AI_variants_1940 = yes
		set_global_flag = USA_SHIPS_1941
	}
}

# USA AI template 1943
country_event = {
	id = ai_ships.7
	hidden = yes
	fire_only_once = yes
	mean_time_to_happen = { days = 1 }
	trigger = {
		tag = USA
		is_ai = yes
		date > 1943.2.1
		NOT = { has_global_flag = USA_SHIPS_1943 }
		has_game_rule = { rule = allow_ai_tech_auto_unlock option = FREE }
	}
	immediate = {
		USA_AI_variants_1943 = yes
		set_global_flag = USA_SHIPS_1943
	}
}

# FRA AI template 1940
country_event = {
	id = ai_ships.8
	hidden = yes
	fire_only_once = yes
	mean_time_to_happen = { days = 1 }
	trigger = {
		tag = FRA
		is_ai = yes
		NOT = { has_country_flag = FRA_SHIPS_1940 }
		date > 1940.2.1
		has_game_rule = { rule = allow_ai_tech_auto_unlock option = FREE }
	}
	immediate = {
		FRA_AI_variants_1940 = yes
		set_country_flag = FRA_SHIPS_1940
	}
}

# FRA AI template 1943
country_event = {
	id = ai_ships.9
	hidden = yes
	fire_only_once = yes
	mean_time_to_happen = { days = 1 }
	trigger = {
		tag = FRA
		is_ai = yes
		NOT = { has_country_flag = FRA_SHIPS_1943 }
		date > 1943.2.1
		has_game_rule = { rule = allow_ai_tech_auto_unlock option = FREE }
	}
	immediate = {
		FRA_AI_variants_1943 = yes
		set_country_flag = FRA_SHIPS_1943
	}
}

# ITA AI template 1940
country_event = {
	id = ai_ships.10
	hidden = yes
	fire_only_once = yes
	mean_time_to_happen = { days = 1 }
	trigger = {
		tag = ITA
		is_ai = yes
		NOT = { has_country_flag = ITA_SHIPS_1940 }
		date > 1940.2.1
		has_game_rule = { rule = allow_ai_tech_auto_unlock option = FREE }
	}
	immediate = {
		ITA_AI_variants_1940 = yes
		set_country_flag = ITA_SHIPS_1940
	}
}

# ITA AI template 1943
country_event = {
	id = ai_ships.11
	hidden = yes
	fire_only_once = yes
	mean_time_to_happen = { days = 1 }
	trigger = {
		tag = ITA
		is_ai = yes
		NOT = { has_country_flag = ITA_SHIPS_1943 }
		date > 1943.2.1
		has_game_rule = { rule = allow_ai_tech_auto_unlock option = FREE }
	}
	immediate = {
		ITA_AI_variants_1943 = yes
		set_country_flag = ITA_SHIPS_1943
	}
}

# SOV AI template 1940
country_event = {
	id = ai_ships.12
	hidden = yes
	fire_only_once = yes
	mean_time_to_happen = { days = 1 }
	trigger = {
		tag = SOV
		is_ai = yes
		NOT = { has_country_flag = SOV_SHIPS_1940 }
		date > 1940.2.1
		has_game_rule = { rule = allow_ai_tech_auto_unlock option = FREE }
	}
	immediate = {
		SOV_AI_variants_1940 = yes
		set_country_flag = SOV_SHIPS_1940
	}
}

# SOV AI template 1943
country_event = {
	id = ai_ships.13
	hidden = yes
	fire_only_once = yes
	mean_time_to_happen = { days = 1 }
	trigger = {
		tag = SOV
		is_ai = yes
		NOT = { has_country_flag = SOV_SHIPS_1943 }
		date > 1943.2.1
		has_game_rule = { rule = allow_ai_tech_auto_unlock option = FREE }
	}
	immediate = {
		SOV_AI_variants_1943 = yes
		set_country_flag = SOV_SHIPS_1943
	}
}

# unlock some naval techs for major powers in 1940
country_event = {
	id = ai_ships.101
	hidden = yes
	fire_only_once = yes
	trigger = {
		OR = {
			date > 1938.1.1
			OR = {
				AND = {
					expert_ai_style = no
					any_country = {
						is_ai = no
						count_triggers = {
							amount = 2
							has_tech = improved_ship_hull_heavy
							has_tech = improved_ship_hull_light
							has_tech = improved_ship_hull_cruiser
							has_tech = improved_ship_hull_submarine
						}
					}
				}
				AND = {
					expert_ai_style = yes
					any_country = {
						is_ai = no
						count_triggers = {
							amount = 1
							has_tech = improved_ship_hull_heavy
							has_tech = improved_ship_hull_light
							has_tech = improved_ship_hull_cruiser
							has_tech = improved_ship_hull_submarine
						}
					}
				}
			}
		}
		NOT = { has_global_flag = naval_tech_1940 }
		has_game_rule = { rule = allow_ai_tech_auto_unlock option = FREE }
	}
	immediate = {
		for_each_scope_loop = {
			array = global.vnr_naval_powers
			if = {
				limit = {
					is_ai = yes
				}
				complete_special_project = sp:sp_air_radar
				set_technology = {
					improved_ship_hull_heavy = 1 
					improved_ship_hull_light = 1 
					improved_ship_hull_cruiser = 1 
					improved_ship_hull_submarine = 1
					antiair2 = 1 
					antiair3 = 1 
					improved_fire_control_system = 1 
					cavity_magnatron = 1 
					basic_dp_light_battery = 1 
					improved_heavy_battery = 1
					improved_super_heavy_battery = 1
					improved_light_battery = 1 
					advanced_ship_torpedo_launcher = 1 
					improved_ship_hull_carrier = 1
					improved_cruiser_armor = 1 
					advanced_torpedo_defense = 1
					improved_heavy_armor = 1
					all_or_nothing_armor_scheme = 1
					sonar = 1
					improved_sonar = 1
					improved_depth_charges = 1
					escort_carriers_ship = 1
					destroyer_cruiser_trend = 1
					escort_destroyer_trend = 1
					improved_periscope = 1
					improved_airplane_launcher = 1
					cruiser_gun_upgrade = 1
					cruiser_aa_upgrade = 1
					krupp_cemented_steel = 1

					basic_light_shell = 1
					basic_heavy_shell = 1
					magnetic_detonator = 1
					oxygen_torpedo = 1

					damage_control_1 = 1
					fire_control_methods_1 = 1
					basic_ballast_tank = 1
					improved_ballast_tank = 1
					dive_bomber_study = 1
					carrier_radio_range = 1
				}
				ai_get_navy_experience = yes
				ai_get_mio_upgrade = yes
			}
		}
		set_global_flag = naval_tech_1940
	}
}

# unlock some naval techs for major powers in 1943
country_event = {
	id = ai_ships.102
	hidden = yes
	fire_only_once = yes
	trigger = {
		OR = {
			date > 1943.1.1
			OR = {
				AND = {
					expert_ai_style = no
					any_country = {
						is_ai = no
						count_triggers = {
							amount = 2
							has_tech = advanced_ship_hull_carrier
							has_tech = advanced_ship_hull_heavy
							has_tech = advanced_ship_hull_cruiser
							has_tech = advanced_ship_hull_light
							has_tech = advanced_ship_hull_submarine
						}
					}
				}
				AND = {
					expert_ai_style = yes
					any_country = {
						is_ai = no
						count_triggers = {
							amount = 1
							has_tech = advanced_ship_hull_carrier
							has_tech = advanced_ship_hull_heavy
							has_tech = advanced_ship_hull_cruiser
							has_tech = advanced_ship_hull_light
							has_tech = advanced_ship_hull_submarine
						}
					}
				}
			}
		}
		
		NOT = { has_global_flag = naval_tech_1943 }
		has_game_rule = { rule = allow_ai_tech_auto_unlock option = FREE }
	}
	immediate = {
		for_each_scope_loop = {
			array = global.vnr_naval_powers
			if = {
				limit = {
					is_ai = yes
				}
				set_technology = {
					advanced_ship_hull_carrier = 1 
					advanced_ship_hull_heavy = 1 
					advanced_ship_hull_cruiser = 1 
					advanced_ship_hull_light = 1 
					advanced_ship_hull_submarine = 1
					antiair4 = 1 
					antiair5 = 1 
					advanced_fire_control_system = 1 
					monopulse_radar = 1 
					advanced_dp_light_battery = 1 
					advanced_heavy_battery = 1 
					advanced_light_battery = 1
					advanced_heavy_armor = 1
					advanced_cruiser_armor = 1
					advanced_torpedo_defense = 1
					all_or_nothing_armor_box_armor_scheme = 1
					advanced_sonar = 1
					advanced_depth_charges = 1
					modern_depth_charges = 1
					advanced_periscope = 1
					basic_submarine_snorkel = 1
					destroyer_mass_production = 1
					ducol_steel = 1
					homogeneous_krupp_steel = 1

					modern_ship_torpedo_launcher = 1
					proximity_detonator = 1
					
					fire_control_methods_3 = 1
				}
				ai_get_navy_experience = yes
				ai_get_mio_upgrade = yes
			}
		}
		set_global_flag = naval_tech_1943
	}
}

# unlock some naval techs for major powers in 1944
country_event = {
	id = ai_ships.103
	hidden = yes
	fire_only_once = yes
	trigger = {
		OR = {
			has_global_flag = {
				flag = naval_tech_1943
				value > 0
				days > 545
			}
			has_global_flag = naval_tech_1949
		}
		NOT = { has_global_flag = naval_tech_1944 }
		has_game_rule = { rule = allow_ai_tech_auto_unlock option = FREE }
	}
	immediate = {
		for_each_scope_loop = {
			array = global.vnr_naval_powers
			if = {
				limit = {
					is_ai = yes
				}
				set_technology = {
					improved_submarine_snorkel = 1
					sub_AIP_engine = 1
					anechoic_tile = 1
					radar_jammer = 1
					naval_radio_guiding_system = 1
					full_armored_carrier = 1
				}
				ai_get_navy_experience = yes
				ai_get_mio_upgrade = yes
			}
		}
		set_global_flag = naval_tech_1944
	}
}

# unlock some naval techs for major powers in 1946
country_event = {
	id = ai_ships.104
	hidden = yes
	fire_only_once = yes
	trigger = {
		OR = {
			date > 1946.1.1
			has_global_flag = naval_tech_1949
		}
		NOT = { has_global_flag = naval_tech_1945 }
		has_game_rule = { rule = allow_ai_tech_auto_unlock option = FREE }
	}
	immediate = {
		for_each_scope_loop = {
			array = global.vnr_naval_powers
			if = {
				limit = {
					is_ai = yes
				}
				set_technology = {
					cruiser_missile_upgrade = 1
					destroyer_missile_upgrade = 1
					sound_surveillance_system = 1
					ship_to_ship_missile = 1
					helipad = 1
					gas_turbine = 1
					carrier_steam_catapult = 1
					carrier_angled_deck = 1
				}
				ai_get_navy_experience = yes
				ai_get_mio_upgrade = yes
			}
		}
		set_global_flag = naval_tech_1945
	}
}

# unlock some naval techs for major powers in 1949
country_event = {
	id = ai_ships.105
	hidden = yes
	fire_only_once = yes
	trigger = {
		OR = {
			date > 1949.1.1
			OR = {
				AND = {
					expert_ai_style = no
					any_country = {
						is_ai = no
						count_triggers = {
							amount = 2
							has_tech = modern_ship_hull_light
							has_tech = modern_ship_hull_cruiser
							has_tech = modern_ship_hull_submarine
							has_tech = super_carriers
						}
					}
				}
				AND = {
					expert_ai_style = yes
					any_country = {
						is_ai = no
						count_triggers = {
							amount = 1
							has_tech = modern_ship_hull_light
							has_tech = modern_ship_hull_cruiser
							has_tech = modern_ship_hull_submarine
							has_tech = super_carriers
						}
					}
				}
			}
		}
		NOT = { has_global_flag = naval_tech_1949 }
		has_game_rule = { rule = allow_ai_tech_auto_unlock option = FREE }
	}
	immediate = {
		for_each_scope_loop = {
			array = global.vnr_naval_powers
			if = {
				limit = {
					is_ai = yes
				}
				set_technology = {
					modern_ship_hull_light = 1
					modern_ship_hull_cruiser = 1
					modern_ship_hull_submarine = 1
					destroyer_guided_missile_upgrade = 1
					nuclear_engine_research = 1
					sub_nuclear_engine = 1
					full_missile_ship = 1
					naval_tactical_data_system = 1
					rocket_depth_charges = 1
					modern_sonar = 1
					tactical_air_navigation_system = 1
					iff_device = 1
					wire_guided_torpedo = 1
					super_carriers = 1
					coldwar_ship_torpedo_launcher = 1
				}
				ai_get_navy_experience = yes
				ai_get_mio_upgrade = yes
			}
		}
		set_global_flag = naval_tech_1949
	}
}

# unlock some naval techs for major powers in 1952
country_event = {
	id = ai_ships.106
	hidden = yes
	fire_only_once = yes
	trigger = {
		has_global_flag = {
			flag = naval_tech_1949
			value > 1
			days > 1095
		}
		NOT = { has_global_flag = naval_tech_1952 }
		has_game_rule = { rule = allow_ai_tech_auto_unlock option = FREE }
	}
	immediate = {
		for_each_scope_loop = {
			array = global.vnr_naval_powers
			if = {
				limit = {
					is_ai = yes
				}
				set_technology = {
					destroyer_hull_improvement = 1
					new_ship_materials = 1
					decoy_launching_system = 1
					nuclear_reactor_cost_reduction = 1
					phased_array_radar = 1
					memory_expansion = 1
					integrated_combat_system = 1
					comprehensive_display_system = 1
					recon_drones = 1
					electromagnetic_signature_study = 1
					airborne_early_warning = 1
					optical_landing_system = 1
					rescue_submarine = 1
					hydrocooling_battery = 1
					sonar_telephone = 1
					wake_homing_torpedo = 1
					unmanned_gun_turret = 1
					modern_generic_battery = 1
					modern_periscope = 1
					advanced_missile_system = 1
				}
				ai_get_navy_experience = yes
				ai_get_mio_upgrade = yes
			}
		}
		set_global_flag = naval_tech_1952
	}
}

# unlock free cv air techs 1936
country_event = {
	id = ai_ships.107
	hidden = yes
	fire_only_once = yes
	trigger = {
		date > 1936.1.1
		NOT = { has_global_flag = cv_air_tech_1936 }
		expert_ai_plane = yes
	}
	immediate = {
		for_each_scope_loop = {
			array = global.vnr_naval_powers
			if = {
				limit = { is_ai = yes }
				set_technology = {
					armor_piercing_bombs = 1
					aircraft_construction = 1
					engines_2 = 1
				}
				add_ideas = vnr_cv_plane_output_boost
			}
		}
		set_global_flag = cv_air_tech_1936
	}
}

# unlock free cv air techs 1939
country_event = {
	id = ai_ships.108
	hidden = yes
	fire_only_once = yes
	trigger = {
		date > 1939.1.1
		NOT = { has_global_flag = cv_air_tech_1939 }
		expert_ai_plane = yes
	}
	immediate = {
		for_each_scope_loop = {
			array = global.vnr_naval_powers
			if = {
				limit = { is_ai = yes }
				set_technology = {
					improved_small_airframe = 1
					aa_hmg = 1
					air_torpedoe_2 = 1
					engines_3 = 1
					survivability_studies = 1
				}
				air_experience = 80
			}
		}
		set_global_flag = cv_air_tech_1939
	}
}

# unlock free cv air techs 1944
country_event = {
	id = ai_ships.109
	hidden = yes
	fire_only_once = yes
	trigger = {
		date > 1944.1.1
		NOT = { has_global_flag = cv_air_tech_1944 }
		expert_ai_plane = yes
	}
	immediate = {
		for_each_scope_loop = {
			array = global.vnr_naval_powers
			if = {
				limit = { is_ai = yes }
				set_technology = {
					advanced_small_airframe = 1
					air_torpedoe_3 = 1
					engines_4 = 1
				}
				air_experience = 80
			}
		}
		set_global_flag = cv_air_tech_1944
	}
}

# unlock free tech in 1941
country_event = {
	id = ai_ships.110
	hidden = yes
	fire_only_once = yes
	trigger = {
		OR = {
			has_global_flag = {
				flag = naval_tech_1940
				value > 0
				days > 900
			}
			has_global_flag = naval_tech_1943
		}
		
		NOT = { has_global_flag = naval_tech_1941 }
		has_game_rule = { rule = allow_ai_tech_auto_unlock option = FREE }
	}
	immediate = {
		for_each_scope_loop = {
			array = global.vnr_naval_powers
			if = {
				limit = {
					is_ai = yes
				}
				set_technology = {
					centimetric_radar = 1
					phased_array = 1
					folding_wing = 1
					carrier_mass_production = 1
					carrier_damage_control = 1
					air_fuel_storage = 1
					damage_control_2 = 1
					damage_control_3 = 1
					fire_control_methods_2 = 1
					battleship_aa_upgrade = 1
					escort_carriers_ship = 1

					improved_light_shell = 1
					improved_heavy_shell = 1
					improved_dp_light_battery = 1
					homing_torpedo = 1
				}
				ai_get_navy_experience = yes
				ai_get_mio_upgrade = yes
			}
		}
		set_global_flag = naval_tech_1941
	}
}