JAP_sonar_are_cool = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		NOT = { has_tech = sonar }
	}

	abort = {
		has_tech = sonar
	}

	ai_strategy = {
		type = research_tech
		id = sonar
		value = 100
	}
}
JAP_sonar_are_cool_2 = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		NOT = { has_tech = improved_sonar }
	}

	abort = {
		has_tech = improved_sonar
	}

	ai_strategy = {
		type = research_tech
		id = improved_sonar
		value = 100
	}
}
JAP_convoy_voy_voy = {
	allowed = { original_tag = JAP }
	enable = {
		is_historical_focus_on = yes
		has_war = no
		has_equipment = {
			convoy < 1000
		}
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = equipment_production_min_factories
		id = convoy
		value = 10
	}
}
JAP_convoy_voy_voyw = {
	allowed = { original_tag = JAP }
	enable = {
		is_historical_focus_on = yes
		has_war = yes
		has_equipment = {
			convoy < 1000
		}
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = equipment_production_min_factories
		id = convoy
		value = 20
	}
}
japan_do_not_rely_on_AIFC_too_early = {
	enable = {
		is_historical_focus_on = yes
		is_in_faction_with = JAP
		date < 1938.9.1
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = force_concentration_factor
		value = -100
	}
}

mass_push_against_china = {
	allowed = {
		original_tag = JAP
	}

	enable = {
		has_equipment = { infantry_equipment > 15000 }
		has_manpower > 500000
		has_war_with = CHI
		has_idea = JAP_ichi_go

		set_temp_variable = { days = global.num_days }
		modulo_temp_variable = { days = 90 }
		check_variable = { days < 75 }
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = front_control

		tag = CHI

		ratio = 0.5

		priority = 700
		ordertype = front
		execution_type = rush_weak
		execute_order = yes
	}
}


the_push_into_china = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		has_equipment = { infantry_equipment > 3000 }
		has_manpower > 500000
		has_war_with = CHI
		has_idea = JAP_ichi_go
	}

	abort = {
		OR = {
			has_manpower < 300000
			has_equipment = { infantry_equipment < -2000 }
			NOT = { has_war_with = CHI }
		}
	}

	ai_strategy = {
		type = front_control

		country_trigger = {
			OR = {	
				tag = CHI
				tag = SHX
				tag = GXC
			}
		}

		ratio = 0.3

		priority = 300
		ordertype = front
		execution_type = balanced
		execute_order = yes
	}

}

the_unpush_into_china = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		has_equipment = { infantry_equipment < -2000 }
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = front_control

		country_trigger = {
			has_war_with = JAP
		}

		ratio = 0.3

		priority = 3000
		ordertype = front
		execution_type = balanced
		execute_order = no
	}

	ai_strategy = {
		type = front_control

		country_trigger = {
			has_war_with = JAP
		}

		ratio = 0.3

		priority = 3000
		ordertype = invasion
		execution_type = balanced
		execute_order = no
	}

}
dont_make_fun_of_soviets = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		NOT = {
			AND = {
				has_government = fascism
				OR = {
					SOV_is_careless = yes
					has_global_flag = SOV_has_early_war
				}
				OR = {
					SOV = { has_war_with = GER }
					SOV = { has_war_with = ENG }
					SOV = { has_war_with = USA }
				}
				NOT = {
					OR = {
						JAP = { has_war_with = GER }
						JAP = { has_war_with = ENG }
						JAP = { has_war_with = USA }
					}
				}
			}	
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = antagonize
		id = "SOV"
		value = -500
	}

	ai_strategy = {
		type = diplo_action_desire
		id = "SOV"
		target = declare_war
		value = -9999
	}

	ai_strategy = {
		type = declare_war
		id = "SOV"
		value = -9999
	}

	ai_strategy = {
		type = conquer
		id = "SOV"
		value = -200
	}
}

VIC_accept_JAP_access = {
	enable = {
		original_tag = FRA
		has_focus_tree = vichy_french_focus
		has_government = fascism
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = diplo_action_acceptance
		id = JAP
		target = military_access
		value = 1000
	}
}

JAP_ask_for_access_from_VIC = {
	allowed = {
		tag = JAP
	}
	enable = {
		any_country = {
			OR = {
				tag = VIC
				AND = {
					original_tag = FRA
					has_focus_tree = vichy_french_focus
				}
			}
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = diplo_action_desire
		id = VIC
		target = military_access
		value = 1000
	}
}

SIA_handle_their_own_business = {
	allowed = {
		original_tag = SIA
	}
	enable = {
		is_in_faction_with = JAP
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = put_unit_buffers

		# ratio of total armeis in country to be buffered
		ratio = 0.70

		# you can specify an order id. ratio of same orders ids will be share same ratio
		#order_id = 2

		# states to put garrison orders (if no state is friendly, strat is invalid)
		states = {
			289
		}

		# ai areas that the orders will use these buffers in
		area = asia

		# by default if you have orders in target areas, the buffer will request less units.
		# you can override this to disable the feature
		subtract_invasions_from_need = yes
		subtract_fronts_from_need = no
	}
}

JAP_unit_buffer_for_home_islands_invasion_force = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		has_completed_focus = JAP_strike_south_doctrine
		has_war_with = CHI
		any_state = {
			is_core_of = CHI
			is_coastal = no
			is_owned_by = CHI
			controller = { is_in_faction_with = JAP }
		}
		is_japanese_endsieg = no
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = put_unit_buffers

		# ratio of total armeis in country to be buffered
		ratio = 0.15

		# you can specify an order id. ratio of same orders ids will be share same ratio
		#order_id = 2

		# states to put garrison orders (if no state is friendly, strat is invalid)
		states = {
			528
			529
			530
			531
			532
			535
			534
			282
			533
			536
		}

		# ai areas that the orders will use these buffers in
		area = asia

		# by default if you have orders in target areas, the buffer will request less units.
		# you can override this to disable the feature
		subtract_invasions_from_need = no
		subtract_fronts_from_need = no
	}
}
JAP_unit_buffer_for_home_islands_invasion_force_2 = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		has_completed_focus = JAP_strike_south_doctrine
		OR = {
			NOT = { 
				any_state = {
					is_core_of = CHI
					is_coastal = no
					is_owned_by = CHI
					controller = { is_in_faction_with = JAP }
				}
			}
			NOT = { has_war_with = CHI }
		}
		is_japanese_endsieg = no
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = put_unit_buffers

		# ratio of total armeis in country to be buffered
		ratio = 0.35 #larger ratio

		# you can specify an order id. ratio of same orders ids will be share same ratio
		#order_id = 2

		# states to put garrison orders (if no state is friendly, strat is invalid)
		states = {
			528
			529
			530
			531
			532
			535
			534
			282
			533
			536
		}

		# ai areas that the orders will use these buffers in
		area = asia

		# by default if you have orders in target areas, the buffer will request less units.
		# you can override this to disable the feature
		subtract_invasions_from_need = no
		subtract_fronts_from_need = no
	}
}
JAP_unit_buffer_for_home_islands_invasion_force_endsieg = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		is_historical_focus_on = yes
		GER = { has_country_flag = LSM_eligibility_nation }
		has_global_flag = kwantung_intervention
		SOV = { has_idea = LSM_victory_in_europe }
		ENG = { has_idea = LSM_victory_in_europe }
		USA = { has_idea = LSM_victory_in_europe }
		RAJ = { has_capitulated = no } #we haven't yet killed India
		NOT = { SOV = { surrender_progress > 0.05 } }
		NOT = { ENG = { surrender_progress > 0.05 } }
		NOT = { USA = { surrender_progress > 0.05 } }
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = put_unit_buffers
		ratio = 2
		states = {
			528
			529
			530
			531
			532
			535
			534
			282
			533
			536
		}
		area = JAP_home_islands
		subtract_invasions_from_need = yes
		subtract_fronts_from_need = no
	}

	ai_strategy = {
		type = front_unit_request
		state_trigger = {
			NOT = { is_core_of = JAP }
		}
		value = -300
	}

	ai_strategy = {
		type = invasion_unit_request
		state_trigger = {
			NOT = { is_core_of = JAP }
		}
		value = -300
	}

	ai_strategy = {
		type = force_build_armies 
		value = 500
	}

	ai_strategy = {
		type = role_ratio
		id = paratroopers
		value = 500
	}
	ai_strategy = {
		type = garrison
		value = -3000
	}
}
JAP_once_we_lose_the_fleet_do_not_contest = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		is_historical_focus_on = yes
		any_owned_state = {
			NOT = { is_core_of = JAP }
		}
		NOT = {
			any_controlled_state = {
				NOT = { is_core_of = JAP }
				NOT = { is_claimed_by = JAP }
			}
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = naval_avoid_region
		id = 90
		value = 500
	}

	ai_strategy = {
		type = naval_avoid_region
		id = 76
		value = 500
	}

	ai_strategy = {
		type = naval_avoid_region
		id = 79
		value = 500
	}
}
JAP_island_defenders = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		has_completed_focus = JAP_strike_south_doctrine
		is_japanese_endsieg = no
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = put_unit_buffers
		ratio = 0.04
		states = {
			645
		}

		# ai areas that the orders will use these buffers in
		area = asia

		subtract_invasions_from_need = yes
		subtract_fronts_from_need = yes
	}

	ai_strategy = {
		type = put_unit_buffers
		ratio = 0.04
		states = {
			526
		}

		# ai areas that the orders will use these buffers in
		area = asia

		subtract_invasions_from_need = yes
		subtract_fronts_from_need = yes
	}

}
JAP_puppet_support_japan = {
	enable = {
		is_in_faction_with = JAP
		OR = {
			is_subject_of = JAP
			has_capitulated = yes
		}
		OR = {
			capital_scope = { is_on_continent = asia }
			has_capitulated = yes
		}
		has_civil_war = no
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = put_unit_buffers
		# home island states
		states = {
			531
			282
			535
			534
			530
			528
			532
			533
			529
		}
		ratio = 0.7
		area = JAP_home_islands
		subtract_invasions_from_need = yes
		subtract_fronts_from_need = yes
	}

	ai_strategy = {
		type = garrison
		value = -9999
	}
}


JAP_defend_home_island = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		has_civil_war = no
		surrender_progress > 0
	}

	abort = {
		NOT = { surrender_progress > 0 }
	}

	ai_strategy = {
	    	type = front_control
	    	state_trigger = {
	        	is_core_of = JAP
	   	}
	    	area = JAP_home_islands
	    	priority = 99999
	    	ratio = 0
	    	ordertype = front
	    	execution_type = rush
	    	execute_order = yes
	    	manual_attack = yes
	}

	ai_strategy = {
		type = put_unit_buffers
		# home island states
		states = {
			531
			282
			535
			534
			530
			528
			532
			533
			529
		}
		ratio = 0.2
		area = JAP_home_islands
		subtract_invasions_from_need = no
		subtract_fronts_from_need = no
	}

	ai_strategy = {
		type = area_priority
		id = JAP_home_islands
		value = 200
	}

	ai_strategy = {
		type = naval_convoy_raid_region
		id = 94
		value = 100
	}

	ai_strategy = {
		type = naval_convoy_raid_region
		id = 177
		value = 100
	}

	ai_strategy = {
		type = naval_convoy_raid_region
		id = 18
		value = 100
	}
}

soften_the_beijing_pocket = {
	allowed = {
		tag = JAP
	}
	enable = {
		has_war_with = CHI
		OR = {
			608 = { NOT = { controller = { is_in_faction_with = JAP } } }
			614 = { NOT = { controller = { is_in_faction_with = JAP } } }
			597 = { NOT = { controller = { is_in_faction_with = JAP } } }	
		}
		NOT = {
			OR = {
				has_idea = JAP_intervene_in_china_5
				has_idea = JAP_intervene_in_china_4
				has_idea = JAP_intervene_in_china_3
				has_idea = JAP_intervene_in_china_2
			}
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = strategic_air_importance
		id = 143
		value = 15000
	}

	ai_strategy = {
		type = strategic_air_importance
		id = 244
		value = -500
	}

}

soften_the_nanjing_pocket = {
	allowed = {
		tag = JAP
	}
	enable = {
		has_war_with = CHI
		613 = { NOT = { controller = { is_in_faction_with = JAP } } }
		613 = { JAP = { divisions_in_state = { state = PREV size > 5 } } }
		NOT = {
			OR = {
				has_idea = JAP_intervene_in_china_5
				has_idea = JAP_intervene_in_china_4
				has_idea = JAP_intervene_in_china_3
				has_idea = JAP_intervene_in_china_2
			}
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = strategic_air_importance
		id = 247
		value = 25000
	}

}

is_it_time_for_war_pearl_harbor = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		is_historical_focus_on = yes
		has_completed_focus = JAP_secure_the_philippines
		AND = {
			date < 1941.12.7
			has_global_flag = {
				flag = pearl_harbor_historical_date
				days < 365
			}
		}
		OR = {
			NOT = { has_idea = anti_soviet_pact }
			NOT = { USA = { has_idea = anti_soviet_pact } }
		}	
	}

	abort = {
		OR = {
			has_global_flag = {
				flag = pearl_harbor_historical_date
				days > 730
			}
			date > 1941.12.6
			is_historical_focus_on = no
		}
	}

	ai_strategy = {
		type = declare_war
		id = "USA"
		value = -9999
	}

	ai_strategy = {
		type = declare_war
		id = "PHI"
		value = -9999
	}
}

is_it_time_for_war_pearl_harbor_2 = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		is_historical_focus_on = yes
		has_completed_focus = JAP_strike_on_the_southern_resource_area
		AND = {
			date < 1941.12.8
			has_global_flag = {
				flag = pearl_harbor_historical_date
				days < 365
			}
		}
		OR = {
			NOT = { has_idea = anti_soviet_pact }
			NOT = { ENG = { has_idea = anti_soviet_pact } }
		}	
	}

	abort = {
		OR = {
			has_global_flag = {
				flag = pearl_harbor_historical_date
				days > 730
			}
			date > 1941.12.7
		}
	}

	ai_strategy = {
		type = declare_war
		id = "MAL"
		value = -9999
	}

	ai_strategy = {
		type = declare_war
		id = "ENG"
		value = -9999
	}

	ai_strategy = {
		type = declare_war
		id = "INS"
		value = -9999
	}

	ai_strategy = {
		type = declare_war
		id = "HOL"
		value = -9999
	}

	ai_strategy = {
		type = declare_war
		id = "FRA"
		value = -9999
	}
}

JAP_cultural_air_enthusiast = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		always = yes		
	}

	abort = {
		always = no
	}

	ai_strategy = {
		type = unit_ratio
		id = cv_cas
		value = 200
	}

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

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

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

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

	ai_strategy = {
		type = equipment_production_min_factories
		id = cv_naval_bomber
		value = 1
	}
}
JAP_cultural_air_enthusiast_china_is_ours = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		OR = {
			CHI = { is_subject_of = JAP }
			CHI = { exists = no }
		}
		OR = {
			PRC = { is_subject_of = JAP }
			PRC = { exists = no }
		}		
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = unit_ratio
		id = fighter
		value = 200
	}

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

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

	ai_strategy = {
		type = equipment_production_min_factories
		id = cv_naval_bomber
		value = 1
	}
}
JAP_reduce_the_need_for_garrison_ahist = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		is_historical_focus_on = no
		NOT = {
			any_enemy_country = { 
				is_major = yes
				is_ai = no
				has_navy_size = { size > 10 }
			}
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = garrison
		value = -25
	}
}
JAP_focus_on_china = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		NOT = { has_completed_focus = JAP_strike_south_doctrine }
		NOT = { is_in_faction_with = GER }
		has_completed_focus = JAP_purge_the_kodoha_faction
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = garrison
		value = -200
	}

	ai_strategy = {
		type = front_unit_request
		tag = CHI
		value = 80
	}
}
JAP_ignore_everything = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		OR = {
			has_completed_focus = JAP_strengthen_civilian_government
			has_completed_focus = JAP_the_unthinkable_option
		}
		has_war = no
		has_government = fascism
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = garrison
		value = 9999
	}

	ai_strategy = {
		type = front_unit_request
		country_trigger = {
			NOT = { original_tag = JAP }
		}
		value = -9999
	}
}

JAP_stock_up_on_trains_before_china = {
	allowed = {
		original_tag = JAP
	}

	enable = {
		has_war = no
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = min_wanted_supply_trains
		value = 50
	}
}
JAP_base_factory_buildup = {
	allowed = {
		original_tag = JAP
	}

	enable = {
		date < 1936.10.1
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = building_target
		id = arms_factory
		value = 30
	}
}

JAP_we_have_killed_china_1 = {
	allowed = {
		original_tag = JAP
	}

	enable = {
		OR = {
			has_global_flag = treaty_of_nanjing
			CHI = { is_subject_of = JAP }
			PRC = { is_subject_of = JAP }
		}	
		num_of_civilian_factories < 60
		has_war = no
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = building_target
		id = industrial_complex
		value = 60
	}
}
JAP_we_have_killed_china_2 = {
	allowed = {
		original_tag = JAP
	}

	enable = {
		OR = {
			has_global_flag = treaty_of_nanjing
			CHI = { is_subject_of = JAP }
			PRC = { is_subject_of = JAP }
		}	
		OR = {
			num_of_civilian_factories > 60
			has_war = yes
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = build_building
		id = infrastructure
		target = 535 
		value = 2000
	}
	ai_strategy = {
		type = build_building
		id = infrastructure
		target = 533 
		value = 2000
	}
	ai_strategy = {
		type = build_building
		id = infrastructure
		target = 527 
		value = 2000
	}

	ai_strategy = {
		type = building_target
		id = arms_factory
		value = 80
	}

	ai_strategy = {
		type = building_target
		id = dockyard
		value = 50
	}
}
less_trucks_4_u_JAP = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		date < 1939.1.1
	}
	abort = {
		date > 1939.1.1
	}

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

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

	ai_strategy = {
		type = template_prio
		id = motorized
		value = -80
	}

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

	ai_strategy = {
		type = template_prio
		id = infantry
		value = 100
	}

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

	ai_strategy = {
		type = equipment_production_factor
		id = artillery
		value = 5
	}
	ai_strategy = {
		type = equipment_production_min_factories
		id = artillery
		value = 3
	}
}

JAP_build_some_factories_jeez = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		date > 1939.1.2
	}
	abort = {
		OR = {
			num_of_military_factories > 50
			CHI = { is_subject_of = JAP }
		}
	}

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

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

	ai_strategy = {
		type = template_prio
		id = motorized
		value = -80
	}

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

	ai_strategy = {
		type = template_prio
		id = armor
		value = -80
	}

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

	ai_strategy = {
		type = template_prio
		id = infantry
		value = 100
	}

	ai_strategy = {
		type = equipment_production_factor
		id = infantry
		value = 5 #10 to 5
	}

	ai_strategy = {
		type = equipment_production_factor
		id = artillery
		value = 7 #From 40 to 20
	}

	ai_strategy = {
		type = equipment_variant_production_factor
		id = light_tank_chassis
		value = -50
	}

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

	ai_strategy = {
		type = added_military_to_civilian_factory_ratio
		value = 15
	}
}

tanks_just_suck = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		always = yes
	}

	abort = {
		always = no
	}

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

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

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


JAP_glorious_nippon_steel_has_triumphed = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		OR = {
			num_of_military_factories > 50
			CHI = { is_subject_of = JAP }
		}
	}
	abort = {
		always = no
	}

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

	# Old garrison system against resistance
	# ai_strategy = {
	# 	type = role_ratio
	# 	id = suppression
	# 	value = 8
	# }

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

	ai_strategy = {
		type = template_prio
		id = motorized
		value = -80
	}

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

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

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

	ai_strategy = {
		type = equipment_production_factor
		id = infantry
		value = 4 #10 to 5
	}

	ai_strategy = {
		type = equipment_production_factor
		id = tactical_bomber
		value = -80
	}

	ai_strategy = {
		type = equipment_production_factor
		id = artillery
		value = 20 #From 40 to 20
	}

	ai_strategy = {
		type = equipment_production_min_factories
		id = artillery
		value = 3
	}
}
southern_expansion = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		has_completed_focus = JAP_strike_south_doctrine
		OR = {
			country_exists = HOL
			country_exists = ENG
		}
	}
	abort = {
		NOT = {
			country_exists = HOL
			country_exists = ENG
		}
	}

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

northern_expansion = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		has_completed_focus = JAP_prepare_for_war_with_the_soviet_union
		country_exists = SOV
	}
	abort = {
		NOT = {
			country_exists = SOV
		}
	}

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

chinese_war = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		has_completed_focus = JAP_intervene_in_china
		country_exists = CHI
		NOT = { has_global_flag = SOV_has_early_war }
	}
	abort = {
		NOT = {
			country_exists = CHI
		}
	}

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

strike_usa = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		has_completed_focus = JAP_secure_the_philippines
		country_exists = USA
	}
	abort = {
		NOT = {
			country_exists = USA
		}
	}

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

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

# "I can run wild for six months… after that, I have no expectation of success"
jap_hush_yamamoto_its_gonna_be_ok = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		has_completed_focus = JAP_secure_the_philippines
		NOT = { has_war_with = USA }
	}

	abort = {
		OR = {
			has_war_with = USA
			NOT = {
				country_exists = USA
			}
		}
	}

	ai_strategy = {
		type = consider_weak
		id = "USA"
		value = 75
	}
}

JAP_philippines_and_garrison = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		has_war_with = USA
		is_historical_focus_on = yes
		date > 1941.1.1
		is_japanese_endsieg = no
	}
	abort_when_not_enabled = yes

	ai_strategy = { #Take & Hold and supply DEI invasions
		type = put_unit_buffers

		# ratio of total armeis in country to be buffered
		ratio = 0.1

		# you can specify an order id. ratio of same orders ids will be share same ratio
		#order_id = 2

		# states to put garrison orders (if no state is friendly, strat is invalid)
		states = {
			623
			327
			624
			625
			628
			627
		}

		# ai areas that the orders will use these buffers in
		area = east_indies

		# by default if you have orders in target areas, the buffer will request less units.
		# you can override this to disable the feature
		subtract_invasions_from_need = yes
		subtract_fronts_from_need = yes
	}

}

JAP_philippines_and_garrison_prio = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		has_war_with = USA
		date > 1941.1.1
		date < 1944.1.1
		is_historical_focus_on = yes
	}
	abort_when_not_enabled = yes

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

JAP_leave_raj_a_bit = {
	allowed = {
		OR = {
			original_tag = JAP
			original_tag = SIA
		}
	}
	enable = {
		is_historical_focus_on = yes
		has_war_with = CHI
		CHI = { has_capitulated = no }
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = invade
		id = "RAJ"
		value = -200
	}
}

JAP_dei = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		is_historical_focus_on = yes
		has_war_with = INS
		OR = {
			PHI = { has_capitulated = yes }
			date > 1942.3.1
		}
		date > 1941.1.1
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = area_priority
		id = east_indies
		value = 220
	}

	ai_strategy = {
		type = invade
		id = "INS"
		value = 120
	}
}

jap_conserve_fuel_for_usa_fight = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		date < 1941.1.1
		NOT = { has_war_with = USA }
	}

	abort = {
		OR = {
			date > 1941.1.1
			has_war_with = USA
		}
	}

	ai_strategy = {
		type = naval_mission_threshold
		id = "MISSION_CONVOY_ESCORT"
		value = 150 #puts our threshold at 250
	}
}

germany_ally = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		has_completed_focus = JAP_technological_exchange
		country_exists = GER
	}
	abort = {
		NOT = { country_exists = GER }
	}

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

JAP_siam_ally_not_yet = {
	allowed = {
		original_tag = SIA
	}
	enable = {
		is_historical_focus_on = yes
		NOT = { JAP = { has_completed_focus = JAP_alliance_with_siam } }
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = alliance
		id = "JAP"
		value = -9999
	}
}
JAP_siam_ally = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		is_historical_focus_on = yes
		has_government = fascism
		JAP = { has_completed_focus = JAP_alliance_with_siam }
		SIA = { 
			OR = {
				has_government = fascism
				has_government = neutrality	
			}
		}
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = alliance
		id = "SIA"
		value = 200
	}
}

SIA_siam_ally = {
	allowed = {
		original_tag = SIA
	}
	enable = {
		is_historical_focus_on = yes
		JAP = { has_government = fascism }
		JAP = { has_completed_focus = JAP_alliance_with_siam }
		SIA = { 
			OR = {
				has_government = fascism
				has_government = neutrality	
			}
		}
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = alliance
		id = "JAP"
		value = 200
	}
}

cut_on_armored_production = {
	enable = {
		date < 1940.1.1
		num_of_military_factories < 50
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = role_ratio
		id = armor
		value = -30
	}
}
JAP_template_design = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		date > 1940.1.1
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = template_prio
		id = infantry
		value = -10
	}

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

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

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

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

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

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


# hey dynamic targets would be swole as f*
all_china_must_prosper_in_my_prosperity_sphere_SIK = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		OR = {
			AND = {
				NOT = { country_exists = CHI }
				any_state = {
					is_core_of = CHI
					is_coastal = no
					is_owned_by = JAP
				}
			}
			CHI = {
				is_in_faction_with = JAP
				is_puppet_of = JAP
			}
		}
		country_exists = SIK
		NOT = {
			SIK = {
				OR = {
					is_in_faction_with = JAP
					is_puppet_of = JAP
				}
			}
			AND = {
				OR = {
					AND = {
						has_global_flag = SOV_soviet_japanese_reconciliation_flag
						NOT = { has_war_with = SOU }
					}
					has_non_aggression_pact_with = SOU
					is_in_faction_with = SOU
				}
				SIK = {
					OR = {
						is_in_faction_with = SOU
						is_puppet_of = SOU
					}
				}
			}
		}
	}

	abort = {
		OR = {
			NOT = { country_exists = SIK }
			SIK = {
				OR = {
					is_in_faction_with = JAP
					is_puppet_of = JAP
				}
			}
			AND = {
				OR = {
					AND = {
						has_global_flag = SOV_soviet_japanese_reconciliation_flag
						NOT = { has_war_with = SOU }
					}
					has_non_aggression_pact_with = SOU
					is_in_faction_with = SOU
				}
				SIK = {
					OR = {
						is_in_faction_with = SOU
						is_puppet_of = SOU
					}
				}
			}
		}
	}

	ai_strategy = {
		type = antagonize
		id = "SIK"
		value = 5000
	}
}
all_china_must_prosper_in_my_prosperity_sphere_XSM = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		OR = {
			AND = {
				NOT = { country_exists = CHI }
				any_state = {
					is_core_of = CHI
					is_coastal = no
					is_owned_by = JAP
				}
			}
			CHI = {
				is_in_faction_with = JAP
				is_puppet_of = JAP
			}
		}
		country_exists = XSM
		NOT = {
			XSM = {
				OR = {
					is_in_faction_with = JAP
					is_puppet_of = JAP
				}
			}
		}
	}

	abort = {
		OR = {
			NOT = { country_exists = XSM }
			XSM = {
				OR = {
					is_in_faction_with = JAP
					is_puppet_of = JAP
					AND = {
						is_subject_of = CHI
						has_global_flag = SOV_has_early_war
					}
				}
			}
		}
	}

	ai_strategy = {
		type = antagonize
		id = "XSM"
		value = 5000
	}
}
all_china_must_prosper_in_my_prosperity_sphere_GXC = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		OR = {
			AND = {
				NOT = { country_exists = CHI }
				any_state = {
					is_core_of = CHI
					is_coastal = no
					is_owned_by = JAP
				}
			}
			CHI = {
				is_in_faction_with = JAP
				is_puppet_of = JAP
			}
		}
		country_exists = GXC
		NOT = {
			GXC = {
				OR = {
					is_in_faction_with = JAP
					is_puppet_of = JAP
				}
			}
		}
	}

	abort = {
		OR = {
			NOT = { country_exists = GXC }
			GXC = {
				OR = {
					is_in_faction_with = JAP
					is_puppet_of = JAP
					AND = {
						is_subject_of = CHI
						has_global_flag = SOV_has_early_war
					}
				}
			}
		}
	}

	ai_strategy = {
		type = antagonize
		id = "GXC"
		value = 5000
	}
}
all_china_must_prosper_in_my_prosperity_sphere_SHX = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		OR = {
			AND = {
				NOT = { country_exists = CHI }
				any_state = {
					is_core_of = CHI
					is_coastal = no
					is_owned_by = JAP
				}
			}
			CHI = {
				is_in_faction_with = JAP
				is_puppet_of = JAP
			}
		}
		country_exists = SHX
		NOT = {
			SHX = {
				OR = {
					is_in_faction_with = JAP
					is_puppet_of = JAP
				}
			}
		}
	}

	abort = {
		OR = {
			NOT = { country_exists = SHX }
			SHX = {
				OR = {
					is_in_faction_with = JAP
					is_puppet_of = JAP
					AND = {
						is_subject_of = CHI
						has_global_flag = SOV_has_early_war
					}
				}
			}
		}
	}

	ai_strategy = {
		type = antagonize
		id = "SHX"
		value = 5000
	}
}
all_china_must_prosper_in_my_prosperity_sphere_YUN = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		OR = {
			AND = {
				NOT = { country_exists = CHI }
				any_state = {
					is_core_of = CHI
					is_coastal = no
					is_owned_by = JAP
				}
			}
			CHI = {
				is_in_faction_with = JAP
				is_puppet_of = JAP
			}
		}
		country_exists = YUN
		NOT = {
			YUN = {
				OR = {
					is_in_faction_with = JAP
					is_puppet_of = JAP
				}
			}
		}
	}

	abort = {
		OR = {
			NOT = { country_exists = YUN }
			YUN = {
				OR = {
					is_in_faction_with = JAP
					is_puppet_of = JAP
					AND = {
						is_subject_of = CHI
						has_global_flag = SOV_has_early_war
					}
				}
			}
		}
	}

	ai_strategy = {
		type = antagonize
		id = "YUN"
		value = 5000
	}

}
all_china_must_prosper_in_my_prosperity_sphere_PRC = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		OR = {
			AND = {
				NOT = { country_exists = CHI }
				any_state = {
					is_core_of = CHI
					is_coastal = no
					is_owned_by = JAP
				}
			}
			CHI = {
				is_in_faction_with = JAP
				is_puppet_of = JAP
			}
		}
		country_exists = PRC
		NOT = {
			PRC = {
				OR = {
					is_in_faction_with = JAP
					is_puppet_of = JAP
				}
			}
		}
	}

	abort = {
		OR = {
			NOT = { country_exists = PRC }
			PRC = {
				OR = {
					is_in_faction_with = JAP
					is_puppet_of = JAP
					AND = {
						is_subject_of = CHI
						has_global_flag = SOV_has_early_war
					}
				}
			}
		}
	}

	ai_strategy = {
		type = antagonize
		id = "PRC"
		value = 5000
	}
}


jap_building_boats_is_great = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		num_of_civilian_factories_available_for_projects > 40
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = dockyard_to_military_factory_ratio
		value = 40  #aim for a 2-1 ratio on naval factories
	}
}


JAP_dont_mess_with_volunteers = { # Reverse strategy
	reversed = yes

	enable = {
		NOT = { tag = JAP }
		OR = {
			AND = {
				is_historical_focus_on = yes
				is_allied_ai = yes
				NOT = { is_in_faction_with = GER }
			}
			AND = {
				date < 1941.12.8
				capital_scope = {
					NOT = { is_on_continent = asia }
				}
				NOT = {
					any_enemy_country = {
						is_ai = no
					}
				}
				OR = {
					AND = {
						has_government = fascism
						JAP = { has_government = fascism }
					}
					AND = {
						has_government = neutrality
						JAP = { has_government = neutrality }
					}
				}
			}
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = send_volunteers_desire
		id = "JAP"
		value = -500
	}
}

JAP_help_mess_with_volunteers = { # Reverse strategy
	reversed = yes
	allowed = {
		tag = JAP
	}
	enable = {
		NOT = { tag = JAP }
		date > 1939.1.1

		OR = {
			any_enemy_country = {
				is_ai = no
			}
			is_historical_focus_on = no
		}
		OR = {
			AND = {
				has_government = fascism
				JAP = { has_government = fascism }
			}
			AND = {
				has_government = neutrality
				JAP = { has_government = neutrality }
			}
		}

		any_owned_state = { is_coastal = yes }
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = send_volunteers_desire
		id = "JAP"
		value = 200
	}
}
support_japan_is_necessary = {
	enable = {
		is_axis_ai = yes
		JAP = { is_ai = yes }
		has_government = fascism
		JAP = { has_government = fascism }
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = send_lend_lease_desire
		id = "JAP"
		value = 500
	}
}

JAP_mess_with_volunteers = { # Reverse strategy
	reversed = yes
	allowed = {
		tag = JAP
	}
	enable = {
		NOT = { tag = JAP }
		date < 1938.1.1
		JAP = {
			OR = {
				has_government = fascism
				has_government = neutrality
			}
		}

		AND = {
			OR = {
				has_government = fascism
				has_government = neutrality
			}
			OR = {
				original_tag = SPR
				original_tag = POR
				tag = ITA
				tag = ENG
				tag = GER
			}
			has_civil_war = yes
		}
	}

	abort = {
		date > 1938.1.1
	}

	ai_strategy = {
		type = send_volunteers_desire
		id = "JAP"
		value = 1000
	}
}
JAP_naval_role_ratios_historical = {
	allowed = {
		has_dlc = "Man the Guns"
		original_tag = JAP
	}
	enable = {
		always = yes
	}
	abort = {
		num_of_naval_factories > 60
	}

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

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

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

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

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

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

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

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

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

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

	ai_strategy = {
		type = role_ratio
		id = naval_mine_layer
		value = 5
	}
	# general building directives
	ai_strategy = {
		type = unit_ratio
		id = capital_ship
		value = 5
	}

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

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

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

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

JAP_naval_role_ratios_historical_late = {
	allowed = {
		original_tag = JAP
		has_dlc = "Man the Guns"
	}
	enable = {
		num_of_naval_factories > 60
	}
	abort_when_not_enabled = yes

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

	ai_strategy = {
		type = role_ratio
		id = naval_capital_shbb
		value = 1
	}

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

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

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

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

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

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

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

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

	ai_strategy = {
		type = role_ratio
		id = naval_mine_layer
		value = 5
	}
	# general building directives
	ai_strategy = {
		type = unit_ratio
		id = capital_ship
		value = 3
	}

	ai_strategy = {
		type = unit_ratio
		id = carrier
		value = 4
	}

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

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

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

jap_invasions_of_gxc_are_super_tough_and_waste_manpower = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		date < 1942.6.6 # if we still stuck we might need a trick
	}

	abort = {
		OR = {
			date > 1942.6.6
			NOT = { has_war_with = CHI }
		}
	}

	ai_strategy = {
		type = invade
		id = "GXC"
		value = -500
	}
}

jap_doesnt_care_about_relation = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		OR = {
			has_war = yes
			date < 1940.1.1
		}
	}

	abort = {
		has_war = no
		date > 1940.1.1
	}

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

# if china has fallen and we are going for USA we will end up at war with allies suddenly while maybe bordering them,
# but thats hard to guess for AI considering all the steps. So we warn it so it can prep vs the allies
jap_early_part_beware_allies = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		USA = { is_in_faction = no }
		focus_progress = {
			focus = JAP_secure_the_philippines
			progress > 0
		}
		PHI = {	is_subject_of = USA }
		NOT = { has_war_together_with = ENG }
	}

	abort = {
		OR = {
			USA = { is_in_faction = yes } # they know where to stand so we can go back to regular logic
			has_war_together_with = ENG
		}
	}

	ai_strategy = {
		type = prepare_for_war
		id = "ENG"
		value = 100
	}
	ai_strategy = {
		type = prepare_for_war
		id = "FRA"
		value = 100
	}
	ai_strategy = {
		type = prepare_for_war
		id = "PHI"
		value = 100
	}
	ai_strategy = {
		type = prepare_for_war
		id = "USA"
		value = 100
	}
	ai_strategy = {
		type = prepare_for_war
		id = "RAJ"
		value = 100
	}
}

JAP_area_priority = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		always = yes
	}
	abort_when_not_enabled = yes

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

	ai_strategy = {
		type = area_priority
		id = scandinavia
		value = -30
	}

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

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

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

	ai_strategy = {
		type = area_priority
		id = middle_east
		value = 30
	}
	ai_strategy = {
		type = area_priority
		id = suez
		value = 20
	}

	ai_strategy = {
		type = area_priority
		id = africa
		value = -60
	}

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

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

JAP_USA_we_love_islands = {
	allowed = {
		OR = {
			original_tag = JAP
			original_tag = USA
		}
	}
	enable = {
		OR = {
			JAP = { has_war_with = USA }
			CHI = { is_subject_of = JAP }
		}
	}

	abort_when_not_enabled = yes

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

JAP_marco_polo_5_is_risky = { 
	allowed = {
		original_tag = JAP
	}

	enable = {
		OR = {
			AND = {
				country_exists = CHI
				NOT = { has_war_with = CHI }
				NOT = { is_in_faction_with = CHI }
				NOT = { CHI = { has_war_with = PRC } }
			}
			has_idea = JAP_intervene_in_china_5
			has_idea = JAP_intervene_in_china_4
			has_idea = JAP_intervene_in_china_3
			has_idea = JAP_intervene_in_china_2
			AND = {
				date > 1937.11.22
				date < 1938.3.22
			}
		}
	}
	abort = {
		OR = {
			has_global_flag = SOV_has_early_war
			NOT = { country_exists = CHI }
			CHI = { is_in_faction_with = JAP }
			AND = {
				is_historical_focus_on = no
				date > 1940.1.1
			}
			has_idea = JAP_ichi_go
			AND = {
				has_war_with = CHI
				NOT = { has_idea = JAP_intervene_in_china_5 }
				NOT = { has_idea = JAP_intervene_in_china_4 }
				NOT = { has_idea = JAP_intervene_in_china_3 }
				NOT = { has_idea = JAP_intervene_in_china_2 }
				NOT = { has_idea = JAP_intervene_in_china_1 }
				NOT = {
					OR = {
						AND = {
							date > 1937.11.22
							date < 1938.3.22
						}
					}
				}
			}
		}
	}

	ai_strategy = {
		type = front_control

		tag = CHI

		ratio = 0.25

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

	ai_strategy = {
		type = front_control

		country_trigger = {
			OR = {
				tag = SHX
				tag = XSM
				tag = PRC
			}
		}

		ratio = 0.25

		priority = 100
		ordertype = front
		execution_type = careful
		execute_order = no
	}
	
	ai_strategy = {
		type = invade
		id = "CHI"
		value = -100 
	}

}


JAP_marco_polo_5_prep = { 
	allowed = {
		original_tag = JAP
	}

	enable = {
		has_idea = JAP_intervene_in_china_1
	}
	abort_when_not_enabled = yes
	
	ai_strategy = {
		type = invade
		id = "CHI"
		value = 200 
	}
}

JAP_hol_up_in_china = { 
	allowed = {
		original_tag = JAP
	}

	enable = {
		has_war_with = CHI
		has_equipment = { infantry_equipment < -2000 }
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = front_control

		tag = CHI

		ratio = 0.25

		priority = 2000
		ordertype = front
		execution_type = careful
		execute_order = no
	}

}

JAP_hold_up_in_china = { #We got this far but there are bigger targets to worry about for a while
	allowed = {
		original_tag = JAP
	}

	enable = {
		OR = {
			AND = {
				date > 1941.6.1
				date < 1945.1.1
				CHI = { 
					has_capitulated = no 
					surrender_progress < 0.8 #finish it if we can
				}
			}
		}
		is_historical_focus_on = yes

		613 = { # Nanjing
			is_controlled_by = JAP
		}

		OR = {
			INS = { has_capitulated = no }
			PHI = { has_capitulated = no }
		}
		
		OR = {
			has_war_with = ENG
			has_war_with = USA
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = front_control

		country_trigger = {
			is_literally_china = yes
			has_war_with = JAP
		}

		ratio = 0.25

		priority = 100
		ordertype = front
		execution_type = careful
	}

}

it_is_our_endgame = {
	allowed = { 
		original_tag = JAP
	}
	enable = {
		is_historical_focus_on = yes
		has_war = yes
		any_country = {
			is_major = yes
			has_war_with = JAP
			has_idea = LSM_victory_in_europe
		}
		surrender_progress > 0
		NOT = { 
			any_state = {
				is_core_of = CHI
				controller = { is_in_faction_with = JAP }
			}
		}
		OR = {
			AND = {
				has_war_with = ENG 
				ENG = {
					has_navy_size = {
						size > 300
					}
				}
			}
			AND = {
				has_war_with = USA 
				USA = {
					has_navy_size = {
						size > 300
					}
				}
			}
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = invasion_unit_request
		country_trigger = { always = yes }
		value = -200
	}
}


JAP_invade_andaman = {
	allowed = {
		original_tag = JAP
	}
	abort_when_not_enabled = yes
	enable = {
		 has_country_flag = agreed_to_help_bose
		 NOT = {
		 	OR = {
		 		has_full_control_of_state = 733
		 		RAJ = { has_full_control_of_state = 733 }
		 	}
		}	
		is_japanese_endsieg = no
	}

	ai_strategy = {
		type = invasion_unit_request
		area = andaman_islands
		value = 400
	}


	ai_strategy = {
		type = naval_invasion_focus
		value = 400
	}

	ai_strategy = { #Take & Hold and supply DEI invasions
		type = put_unit_buffers

		# ratio of total armeis in country to be buffered
		ratio = 0.01

		# you can specify an order id. ratio of same orders ids will be share same ratio
		#order_id = 2

		states = {
			733
		}

		# ai areas that the orders will use these buffers in
		area = andaman_islands

		# by default if you have orders in target areas, the buffer will request less units.
		# you can override this to disable the feature
		subtract_invasions_from_need = yes
		subtract_fronts_from_need = yes
	}

	ai_strategy = {
		type = area_priority
		id = andaman_islands
		value = 400
	}

	ai_strategy = {
		type = invade
		id = "ENG"
		value = 120
	}
}

JAP_get_the_rubber_islands = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		OR = {
			336 = {
				controller = {
					has_war_with = JAP
				}
			}
			AND = {
				is_historical_focus_on = yes
				OR = {
					JAP = { has_wargoal_against = ENG }
					JAP = { has_wargoal_against = USA }
				}
			}
		}
	}

	abort_when_not_enabled = yes
	ai_strategy = {
		type = invade
		id = "MAL"
		value = 500
	}

	ai_strategy = {
	    type = invasion_unit_request
	    state = 336
	    value = 25
	}
	ai_strategy = {
		type = naval_invasion_focus
		value = 200
	}
}
JAP_invade_philippines = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		is_historical_focus_on = yes
		country_exists = PHI
		PHI = { has_capitulated = no }
		JAP = {
			OR = { 
				has_wargoal_against = PHI
				has_wargoal_against = USA
				has_war_with = PHI
				has_war_with = USA
			}
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = invade
		id = "PHI"
		value = 500
	}

	ai_strategy = {
	    type = invasion_unit_request
	    state = 623
	    value = 15
	}
	ai_strategy = {
	    type = invasion_unit_request
	    state = 327
	    value = 15
	}

	ai_strategy = {
		type = naval_invasion_focus
		value = 50
	}
}
JAP_invade_pacific = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		is_historical_focus_on = yes
		OR = {
			AND = {
				has_war_with = PHI
				PHI = { has_capitulated = yes }
			}
			NOT = {
				any_state = {
					is_core_of = PHI
					controller = { has_war_with = JAP }
				}
			}
		}
	}

	abort_when_not_enabled = yes
	ai_strategy = {
		type = invade
		id = "USA"
		value = 200
	}

	ai_strategy = {
	    	type = invasion_unit_request
	    	state_trigger = {
			is_island_state = yes
		}
	    	value = 5
	}

	ai_strategy = {
		type = naval_invasion_focus
		value = 100
	}
}
JAP_invade_burma = {
	enable = {
		SIA = { is_in_faction_with = JAP }
		336 = {
			controller = {
				OR = {
					is_in_faction_with = JAP
					original_tag = JAP
				}
			}
		}
	}
	
	ai_strategy = {
		type = invade
		id = "BRM"
		value = 500
	}

	ai_strategy = {
	    type = invasion_unit_request
	    state = 431
	    value = 15
	}

	ai_strategy = {
	    type = invasion_unit_request
	    state = 430
	    value = 15
	}

	ai_strategy = {
		type = naval_invasion_focus
		value = 50
	}
	abort_when_not_enabled = yes

}

JAP_the_home_fleet = {
	allowed = {
		original_tag = JAP
	}
	enable = {
		is_historical_focus_on = yes
		any_state = {
			is_core_of = PHI
			controller = { NOT = { is_in_faction_with = JAP } }
		}
		any_state = {
			is_core_of = MAL
			controller = { NOT = { is_in_faction_with = JAP } }
		}
		any_state = {
			is_core_of = INS
			controller = { NOT = { is_in_faction_with = JAP } }
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = strike_force_home_base
		id = 75
	}

	ai_strategy = {
		type = strike_force_home_base
		id = 90
	}
}