﻿###########################
# Japanese Events
###########################

add_namespace = japan

# Chinese Refuse Concessions
country_event = {
	id = japan.1
	title = china.1.t
	desc = japan.1.d
	picture = GFX_report_event_chinese_soldiers_01

	is_triggered_only = yes
	
	option = {
		name = japan.1.a

		add_war_support = 0.05

		IF = {
			limit = {
				NOT = {
					has_completed_focus = JAP_subdue_the_kwantung_army
				}
			}
			custom_effect_tooltip = JAP_first_strike_blocked_due_to_kwantung_army_tt
		}

		custom_effect_tooltip = generic_skip_one_line_tt

		IF = {
			limit = {
				CHI = {
					exists = yes
					NOT = {
						is_ally_with = ROOT
						has_war_with = ROOT
					}
				}
			}
			hidden_effect = {
				IF = {
					limit = {
						NOT = {
							has_completed_focus = JAP_subdue_the_kwantung_army
						}
					}
					CHI = {
						set_country_flag = JAP_first_strike_principle_blocked
					}
				}
			}
			declare_war_on = {
				target = CHI
				type = annex_everything
			}
			IF = {
				limit = {
					MAN = {
						is_subject_of = ROOT
						NOT = {
							has_completed_focus = MAN_assertiveness
							has_completed_focus = MAN_tsr_assertiveness
						}
					}
				}
				MAN = {
					add_to_war = {
					    targeted_alliance = ROOT
					    enemy = CHI
					    hostility_reason = asked_to_join
					}
				}
			}
			IF = {
				limit = {
					MEN = {
						is_subject_of = ROOT
					}
				}
				MEN = {
					add_to_war = {
					    targeted_alliance = ROOT
					    enemy = CHI
					    hostility_reason = asked_to_join
					}
				}
			}
			custom_effect_tooltip = generic_skip_one_line_tt
		}

		IF = {
			limit = {
				SHX = {
					exists = yes
					NOT = {
						is_ally_with = ROOT
						has_war_with = ROOT
					}
				}
			}
			hidden_effect = {
				IF = {
					limit = {
						NOT = {
							has_completed_focus = JAP_subdue_the_kwantung_army
						}
					}
					SHX = {
						set_country_flag = JAP_first_strike_principle_blocked
					}
				}
			}
			declare_war_on = {
				target = SHX
				type = annex_everything
			}
			IF = {
				limit = {
					MAN = {
						is_subject_of = ROOT
						NOT = {
							has_completed_focus = MAN_assertiveness
							has_completed_focus = MAN_tsr_assertiveness
						}
					}
				}
				MAN = {
					add_to_war = {
					    targeted_alliance = ROOT
					    enemy = SHX
					    hostility_reason = asked_to_join
					}
				}
			}
			IF = {
				limit = {
					MEN = {
						is_subject_of = ROOT
					}
				}
				MEN = {
					add_to_war = {
					    targeted_alliance = ROOT
					    enemy = SHX
					    hostility_reason = asked_to_join
					}
				}
			}
			custom_effect_tooltip = generic_skip_one_line_tt
		}

		IF = {
			limit = {
				SND = {
					exists = yes
					NOT = {
						is_ally_with = ROOT
						has_war_with = ROOT
					}
				}
			}
			hidden_effect = {
				IF = {
					limit = {
						NOT = {
							has_completed_focus = JAP_subdue_the_kwantung_army
						}
					}
					SND = {
						set_country_flag = JAP_first_strike_principle_blocked
					}
				}
			}
			declare_war_on = {
				target = SND
				type = annex_everything
			}
			IF = {
				limit = {
					MAN = {
						is_subject_of = ROOT
						NOT = {
							has_completed_focus = MAN_assertiveness
							has_completed_focus = MAN_tsr_assertiveness
						}
					}
				}
				MAN = {
					add_to_war = {
					    targeted_alliance = ROOT
					    enemy = SND
					    hostility_reason = asked_to_join
					}
				}
			}
			IF = {
				limit = {
					MEN = {
						is_subject_of = ROOT
					}
				}
				MEN = {
					add_to_war = {
					    targeted_alliance = ROOT
					    enemy = SND
					    hostility_reason = asked_to_join
					}
				}
			}
			custom_effect_tooltip = generic_skip_one_line_tt
		}

		IF = {
			limit = {
				HBC = {
					exists = yes
					NOT = {
						is_ally_with = ROOT
						has_war_with = ROOT
					}
				}
			}
			hidden_effect = {
				IF = {
					limit = {
						NOT = {
							has_completed_focus = JAP_subdue_the_kwantung_army
						}
					}
					HBC = {
						set_country_flag = JAP_first_strike_principle_blocked
					}
				}
			}
			declare_war_on = {
				target = HBC
				type = annex_everything
			}
			IF = {
				limit = {
					MAN = {
						is_subject_of = ROOT
						NOT = {
							has_completed_focus = MAN_assertiveness
							has_completed_focus = MAN_tsr_assertiveness
						}
					}
				}
				MAN = {
					add_to_war = {
					    targeted_alliance = ROOT
					    enemy = HBC
					    hostility_reason = asked_to_join
					}
				}
			}
			IF = {
				limit = {
					MEN = {
						is_subject_of = ROOT
					}
				}
				MEN = {
					add_to_war = {
					    targeted_alliance = ROOT
					    enemy = HBC
					    hostility_reason = asked_to_join
					}
				}
			}
			custom_effect_tooltip = generic_skip_one_line_tt
		}

		IF = {
			limit = {
				XIC = {
					exists = yes
					owns_state = 608
					NOT = {
						is_ally_with = ROOT
						has_war_with = ROOT
					}
				}
			}
			hidden_effect = {
				IF = {
					limit = {
						NOT = {
							has_completed_focus = JAP_subdue_the_kwantung_army
						}
					}
					XIC = {
						set_country_flag = JAP_first_strike_principle_blocked
					}
				}
			}
			declare_war_on = {
				target = XIC
				type = annex_everything
			}
			IF = {
				limit = {
					MAN = {
						is_subject_of = ROOT
						NOT = {
							has_completed_focus = MAN_assertiveness
							has_completed_focus = MAN_tsr_assertiveness
						}
					}
				}
				MAN = {
					add_to_war = {
					    targeted_alliance = ROOT
					    enemy = XIC
					    hostility_reason = asked_to_join
					}
				}
			}
			IF = {
				limit = {
					MEN = {
						is_subject_of = ROOT
					}
				}
				MEN = {
					add_to_war = {
					    targeted_alliance = ROOT
					    enemy = XIC
					    hostility_reason = asked_to_join
					}
				}
			}
			custom_effect_tooltip = generic_skip_one_line_tt
		}

		IF = {
			limit = {
				NOT = {
					has_completed_focus = JAP_subdue_the_kwantung_army
				}
			}
			
			add_timed_idea = {
				idea = JAP_surprise_invasion_idea
				days = 245 
			}	
			
		}

		hidden_effect = {
			country_event = { days = 5 id = news.1 }
		}

		USA = { set_country_flag = { flag = USA_china_window days = 60 value = 1 } }

		IF = {
			limit = {
				has_country_leader = { id = 700 ruling_only = yes }
			}
			remove_country_leader_trait = imperial_sanction
		}

	}
	
}

# Chinese Concessions
country_event = {
	id = japan.2
	title = china.1.t
	desc = japan.2.d
	picture = GFX_report_event_chinese_soldiers_running
	
	is_triggered_only = yes
	

	option = {
		name = japan.2.a
		effect_tooltip = {
			set_truce = { target = FROM days = 180 }
		}
		hidden_effect = {
			country_event = { days = 5 id = news.2 }
		}

		#HBC STATES
		IF = {
			limit = {
				608 = {
					is_controlled_by = FROM
				}
			}
			JAP = {
				transfer_state = 608
			}
		}
		ELSE_IF = {
			limit = {
				608 = {
					OWNER = {
						is_literally_china = yes
						NOT = { 
							original_tag = FROM 
							original_tag = ROOT 
							has_country_flag = JAP_already_sent_demand_for_northern_chinese_concessions
						}
					}
				}
			}

			608 = { 
				OWNER = {
					set_country_flag = JAP_already_sent_demand_for_northern_chinese_concessions
					country_event = { id = SEA_china.28 days = 2 }
				}
			}
		}
		ELSE = {
			608 = { add_claim_by = ROOT }
		}

		IF = {
			limit = {
				614 = {
					is_controlled_by = FROM
				}
			}
			JAP = {
				transfer_state = 614
			}
		}
		ELSE_IF = {
			limit = {
				614 = {
					OWNER = {
						is_literally_china = yes
						NOT = { 
							original_tag = FROM 
							original_tag = ROOT 
							has_country_flag = JAP_already_sent_demand_for_northern_chinese_concessions
						}
					}
				}
			}
			614 = { 
				if = {
					limit = {
						OWNER = {
							owns_state = 608
						}
					}

					hidden_effect = { #to hide duplicate events in tooltip
						OWNER = {
							set_country_flag = JAP_already_sent_demand_for_northern_chinese_concessions
							country_event = { id = SEA_china.28 days = 2 }
						}
					}
				}
				else = {
					OWNER = {
						set_country_flag = JAP_already_sent_demand_for_northern_chinese_concessions
						country_event = { id = SEA_china.28 days = 2 }
					}
				}

			}
		}
		ELSE = {
			614 = { add_claim_by = ROOT }
		}

		IF = {
			limit = {
				1039 = {
					is_controlled_by = FROM
				}
				has_subject = MEN
			}
			MEN = {
				transfer_state = 1039
			}
		}
		ELSE_IF = {
			limit = {
				1039 = {
					is_controlled_by = FROM
				}
				NOT = {
					has_subject = MEN
				}
			}
			transfer_state = 1039
		}
		ELSE_IF = {
			limit = {
				1039 = {
					OWNER = {
						is_literally_china = yes

						NOT = {
							original_tag = ROOT 
							original_tag = FROM 
							has_country_flag = JAP_already_sent_demand_for_northern_chinese_concessions
						}
					}
				}
			}

			if = {
				limit = {
					OWNER = {
						owns_state = 608
					}
				}

				hidden_effect = { #to hide duplicate events in tooltip in the most
					OWNER = {
						set_country_flag = JAP_already_sent_demand_for_northern_chinese_concessions
						country_event = { id = SEA_china.28 days = 2 }
					}
				}
			}
			else = {
				OWNER = {
					set_country_flag = JAP_already_sent_demand_for_northern_chinese_concessions
					country_event = { id = SEA_china.28 days = 2 }
				}
			}
		}

		#### SND STATES

		IF = {
			limit = {
				597 = {
					is_controlled_by = FROM
				}
			}
			JAP = {
				transfer_state = 597
			}
		}
		ELSE_IF = {
			limit = {
				597 = {
					OWNER = {
						is_literally_china = yes
						NOT = { 
							original_tag = FROM 
							original_tag = ROOT 
							has_country_flag = JAP_already_sent_demand_for_northern_chinese_concessions
						}
					}
				}
			}
			597 = { 
				OWNER = {
					set_country_flag = JAP_already_sent_demand_for_northern_chinese_concessions
					country_event = { id = SEA_china.28 days = 2 }
				}
			}
		}
		ELSE = {
			597 = { add_claim_by = ROOT }
		}

		IF = {
			limit = {
				1038 = {
					is_controlled_by = FROM
				}
			}
			JAP = {
				transfer_state = 1038
			}
		}
		ELSE_IF = {
			limit = {
				1038 = {
					OWNER = {
						is_literally_china = yes
						NOT = { 
							original_tag = FROM 
							original_tag = ROOT 
							has_country_flag = JAP_already_sent_demand_for_northern_chinese_concessions
						}
					}
				}
			}
			if = {	
				limit = {
					1038 = {
						OWNER = {
							owns_state = 597
						}
					}
				}

				hidden_effect = {
					1038 = { 
						OWNER = {
							set_country_flag = JAP_already_sent_demand_for_northern_chinese_concessions
							country_event = { id = SEA_china.28 days = 2 }
						}
					}
				}
			}
			else = {
				1038 = { 
					OWNER = {
						set_country_flag = JAP_already_sent_demand_for_northern_chinese_concessions
						country_event = { id = SEA_china.28 days = 2 }
					}
				}
			}

		}
		ELSE = {
			1038 = { add_claim_by = ROOT }
		}

		#SHANDONG
		IF = {
			limit = {
				743 = {
					is_controlled_by = FROM
				}
			}
			JAP = {
				transfer_state = 743
			}
		}
		ELSE_IF = {
			limit = {
				743 = {
					OWNER = {
						is_literally_china = yes
						NOT = { 
							original_tag = FROM 
							original_tag = ROOT 
							has_country_flag = JAP_already_sent_demand_for_northern_chinese_concessions
						}
					}
				}
			}
			743 = { 
				OWNER = {
					set_country_flag = JAP_already_sent_demand_for_northern_chinese_concessions
					country_event = { id = SEA_china.28 days = 2 }
				}
			}
		}
		ELSE = {
			743 = { add_claim_by = ROOT }
		}




		####
		#IF = {
		#	limit = {
		#		597 = {
		#			is_controlled_by = FROM
		#		}
		#	}
		#	JAP = {
		#		transfer_state = 597
		#	}
		#}
		#IF = {
		#	limit = {
		#		614 = {
		#			is_controlled_by = FROM
		#		}
		#	}
		#	JAP = {
		#		transfer_state = 614
		#	}
		#}
		#IF = {
		#	limit = {
		#		743 = {
		#			is_controlled_by = FROM
		#		}
		#	}
		#	JAP = {
		#		transfer_state = 743
		#	}
		#}
		#ELSE = {
		#	add_state_claim = 743
		#}


		add_state_claim = 613

		IF = {
			limit = {
				has_country_leader = { id = 700 ruling_only = yes }
			}
			remove_country_leader_trait = imperial_sanction
		}
		
		add_ai_strategy = {
			type = antagonize
			id = CHI
			value = 500
		}

		custom_effect_tooltip = generic_skip_one_line_tt

		activate_mission = JAP_growing_unrest_in_the_shanghai_concession
		
	}
}

# Soviets Push Back And Win
country_event = {
	id = japan.3
	title = japan.3.t
	desc = japan.3.d
	picture = GFX_report_event_soviet_soldiers_tank
	
	is_triggered_only = yes
	
	option = {
		if = {
			limit = { 
			714 = { 
				OR = {
					is_owned_by = JAP
					is_owned_by = MAN
				} 
				any_neighbor_state = { is_owned_by = SOV } }
			} 
			714 = { add_manpower = -30000 }
		}		
		if = {
			limit = {
				NOT = {
					714 = {
						OR = {
							is_owned_by = JAP
							is_owned_by = MAN
						}
						any_neighbor_state = { is_owned_by = SOV } 
					}
				}
			}
			random_owned_state = {
				limit = { any_neighbor_state = { is_owned_by = SOV } }
				add_manpower = -30000
			}
		}

		army_experience = 5
		add_tech_bonus = {
			name = japan.3.t #test_the_ussr_focus
			bonus = 1.0
			uses = 1
			category = cat_anti_tank
		}
		name = japan.3.a
		SOV = {
			country_event = { id = soviet.2 }
		}
	}
}
# Soviets Push Back And Lose
country_event = {
	id = japan.4
	title = japan.4.t
	desc = japan.4.d
	picture = GFX_report_event_japanese_soldiers_01
	
	is_triggered_only = yes
	
	option = {
		name = japan.4.a
		if = {
			limit = { 
			714 = { 
				OR = {
					is_owned_by = JAP
					is_owned_by = MAN						
				}
				any_neighbor_state = { is_owned_by = SOV } }
			} 
			714 = { add_manpower = -20000 }
		}		
		if = {
			limit = {
				NOT = {
					714 = {
						OR = {
							is_owned_by = JAP							
							is_owned_by = MAN						
						}
						any_neighbor_state = { is_owned_by = SOV } 
					}
				}
			}
			random_owned_state = {
				limit = { any_neighbor_state = { is_owned_by = SOV } }
				add_manpower = -20000
			}
		}
		army_experience = 15
		add_doctrine_cost_reduction = {
			name = japan.4.t
			cost_reduction = 0.35
			uses = 1
			category = cat_grand_battle_plan
		}
		SOV = {
			country_event = { id = soviet.3 }
		}
	}
}

# Soviets Yield
country_event = {
	id = japan.5
	title = japan.5.t
	desc = japan.5.d
	picture = GFX_report_event_soviet_soldiers_tank
	
	is_triggered_only = yes
	
	option = {
		name = japan.5.a
		add_war_support = 0.05
		hidden_effect = {
			country_event = { days = 5 id = news.9 }
		}
	}
}

# French Accept Demands
country_event = {
	id = japan.6
	title = japan.6.t
	desc = japan.6.d
	picture = GFX_report_event_japanese_soldiers_02
	
	is_triggered_only = yes
	
	option = {
		name = japan.6.a
		USA = { set_country_flag = { flag = USA_indochina_window days = 60 value = 1 } }
		hidden_effect = {
			news_event = { days = 5 id = news.5 }
		}
		JAP = {
			IF = {
				limit = {
					286 = {
						CONTROLLER = {
							OR = {
								original_tag = FRA
								is_subject_of = FRA
								is_subject_of = VIC
							}
						}
					}
				}
				transfer_state = 286
			}
			IF = {
				limit = {
					670 = {
						CONTROLLER = {
							OR = {
								original_tag = FRA
								is_subject_of = FRA
								is_subject_of = VIC
							}
						}
					}
				}
				transfer_state = 670
			}
			IF = {
				limit = {
					671 = {
						CONTROLLER = {
							OR = {
								original_tag = FRA
								is_subject_of = FRA
								is_subject_of = VIC
							}
						}
					}
				}
				transfer_state = 671
			}
			IF = {
				limit = {
					741 = {
						CONTROLLER = {
							OR = {
								original_tag = FRA
								is_subject_of = FRA
								is_subject_of = VIC
							}
						}
					}
				}
				transfer_state = 741
			}
			IF = {
				limit = {
					728 = {
						CONTROLLER = {
							OR = {
								original_tag = FRA
								is_subject_of = FRA
								is_subject_of = VIC
							}
						}
					}
				}
				transfer_state = 728
			}
			IF = {
				limit = {
					1017 = {
						CONTROLLER = {
							OR = {
								original_tag = FRA
								is_subject_of = FRA
								is_subject_of = VIC
							}
						}
					}
				}
				transfer_state = 1017
			}
			add_named_threat = { threat = 3 name = france.1.t }
		}
	}
}

# French Reject Demands
country_event = {
	id = japan.7
	title = japan.7.t
	desc = japan.7.d
	picture = GFX_report_event_japanese_soldiers_03
	
	is_triggered_only = yes
	
	option = {
		name = japan.7.a
		create_wargoal = {
			type = take_state
			target = FROM
			generator = {
				286 741 670 671 728 1017 
			}
		}
		hidden_effect = {
			country_event = { days = 5 id = news.6 }
		}
	}
}

# Germany Agrees to Withdraw Falkenhausen
country_event = {
	id = japan.8
	title = japan.8.t
	desc = japan.8.d
	picture = GFX_report_event_german_detained_china
	
	is_triggered_only = yes
	
	option = {
		name = japan.8.a
	}
}

# Germany Refuses to Withdraw Falkenhausen
country_event = {
	id = japan.9
	title = japan.9.t
	desc = japan.9.d
	picture = GFX_report_event_german_advisors_remain
	
	is_triggered_only = yes
	
	option = {
		name = japan.9.a
	}
	#option = { # Withdraw from the Anti-Comintern Pact
	#	name = japan.9.b
	#}
}

#MM: Never used. Unlocalized
# USA condemns our war 
country_event = {
	id = japan.10
	title = japan.10.t
	desc = japan.10.d
	picture = GFX_report_event_FDR_speech
	
	is_triggered_only = yes
	
	option = {
		name = japan.10.a
		USA = { 
			add_opinion_modifier = { target = JAP modifier = condemn_aggression }
		}
	}
}

# Pressure Siam to become a puppet
country_event = {
	id = japan.11
	title = japan.11.t
	desc = japan.11.d
	picture = GFX_report_event_japanese_officers
	
	is_triggered_only = yes
	
	option = {
		name = japan.11.a
		SIA = { 
			country_event = { id = japan.12 }
		}
	}

	option = {
		name = japan.11.b
		trigger = { OR = { is_ai = no is_historical_focus_on = no } } #EAI
		ai_chance = { factor = 0 }
	}
}

# Siam event from Japan: Become puppet or not
country_event = {
	id = japan.12
	title = japan.12.t
	desc = japan.12.d
	picture = GFX_report_event_japanese_officers
	
	is_triggered_only = yes
	
	option = {
		name = japan.12.a
		ai_chance = {
			factor = 90 
			modifier = {
				#If they have a fighting chance, they should stand their ground
				factor = 0
				is_historical_focus_on = no #EAI
				strength_ratio = {
					tag = JAP
					ratio > 0.75
				}
			}
		}
		JAP = { 
			country_event = { id = japan.13 }
			effect_tooltip = { puppet = SIA }
		}
	}

	option = {
		name = japan.12.b
		trigger = { OR = { is_ai = no is_historical_focus_on = no } } #EAI
		ai_chance = { 
			factor = 10 
			modifier = { factor = 0 is_historical_focus_on = no } 
		}
		JAP = { 
			country_event = { id = japan.14 }
			effect_tooltip = {
				declare_war_on = {
					target = SIA
					type = puppet_wargoal_focus
				}
			}
		}
	}
}

# Siam accepts and is puppeted
country_event = {
	id = japan.13
	title = japan.13.t
	desc = japan.13.d
	picture = GFX_report_event_japanese_siam_politicians
	
	is_triggered_only = yes
	
	option = {
		name = japan.13.a
		puppet = SIA
	}
}

# Siam refuses, nations go to war 
country_event = {
	id = japan.14
	title = japan.14.t
	desc = japan.14.d
	picture = GFX_report_event_japanese_chinese_surrender
	
	is_triggered_only = yes
	
	option = {
		name = japan.14.a
		declare_war_on = {
			target = SIA
			type = puppet_wargoal_focus
		}
	}
}

# Indian national army 
country_event = {
	id = japan.15
	title = japan.15.t
	desc = japan.15.d
	picture = GFX_report_event_indian_soldiers
	
	is_triggered_only = yes
	
	option = {
		name = japan.15.a
		hidden_effect = {
			load_oob = "JAP_Indian_National_Army_reinforcement"
		}
		custom_effect_tooltip = JAP_Indian_National_Army_arrives
		add_manpower = 10000
		set_global_flag = indian_national_army_setup
		RAJ = {
			add_stability = -0.2
			if = {
				limit = { has_dlc = "Together for Victory" }
				add_popularity = {
					ideology = fascism
					popularity = 0.1
				}
				add_popularity = {
					ideology = democratic
					popularity = -0.05
				}
				else = {
					add_ideas = RAJ_azad_hind 
					ENG = {
						country_event = { id = britain.19 }
					}
				}
			}
		}
	}
}

# China event from Japan: Become puppet or not
country_event = {
	id = japan.16
	title = japan.16.t
	desc = japan.16.d
	picture = GFX_report_event_asian_politicians
	
	is_triggered_only = yes
	
	#Accept - become puppet
	option = {
		name = japan.16.a
		ai_chance = {
			factor = 60
			modifier = {
				factor = 0
				strength_ratio = {
					tag = JAP
					ratio > 0.10
				}
				CHI_is_on_historical_plan_trigger = yes
			}
		}
		JAP = { 
			country_event = { id = japan.17 }
			effect_tooltip = { puppet = CHI }
		}
	}

	option = {
		name = japan.16.b
		ai_chance = { factor = 40 }
		JAP = { 
			country_event = { id = japan.18 }
			effect_tooltip = {
				create_wargoal = {
					type = take_state
					target = CHI
					generator = owned_states
				}
			}
		}
	}
}

# China accepts and is puppeted
country_event = {
	id = japan.17
	title = japan.17.t
	desc = japan.17.d
	picture = GFX_report_event_chinese_japanese_handshake
	
	is_triggered_only = yes
	
	option = {
		name = japan.17.a
		puppet = CHI
		add_named_threat = { threat = 20 name = chinese_puppet_focus }
		hidden_effect = {
			news_event = { hours = 6 id = news.210 }
		}
	}
}

# China refuses, gain cb
country_event = {
	id = japan.18
	title = japan.18.t
	desc = japan.18.d
	picture = GFX_report_event_chinese_soldiers_02
	
	is_triggered_only = yes
	
	option = {
		name = japan.18.a
		create_wargoal = {
			type = take_state
			target = CHI
			generator = owned_states
		}
	}
}