###########################
# Chinese Events
###########################

add_namespace = china

# Japanese Stage Border Incident
country_event = {
	id = china.1
	title = china.1.t
	desc = china.1.d
	picture = GFX_report_event_chinese_soldiers_fighting
	
	is_triggered_only = yes
	
	option = { # Breaking point!
		name = china.1.a
		ai_chance = { 
			base = 90 
			modifier = {
				factor = 0.5
				has_war = yes
			}
			modifier = {
				factor = 0.5
				any_enemy_country = {
					is_major = yes
				}
			}
		}

		effect_tooltip = {
			JAP = {
				add_war_support = 0.05
				country_event = { id = japan.1 }
				declare_war_on = {
					target = CHI
					type = annex_everything
				}
				declare_war_on = {
					target = SHX
					type = annex_everything
				}
				declare_war_on = {
					target = SND
					type = annex_everything
				}
				declare_war_on = {
					target = HBC
					type = annex_everything
				}
			}
		}

		hidden_effect = {
			JAP = { country_event = { id = japan.1 } }
		}

	}

	option = { # Make more concessions
		name = china.1.b
		ai_chance = { 
			base = 10 
			modifier = {
				factor = 0
				OR = {
					is_historical_focus_on = yes
					has_country_flag = CHI_AI_RANDOM_HISTORICAL
					has_game_rule = {
						rule = CHI_ai_behavior
						option = HISTORICAL
					}
				}
				NOT = {
					has_game_rule = { #used here instead of checking for default because people might not have WTT
						rule = CHI_ai_behavior
						option = ALTERNATE
					}
				}
			}
			modifier = {
				factor = 0.5
				JAP = {
					has_war = yes
				}
			}
			modifier = {
				factor = 0.25
				JAP = {
					any_enemy_country = {
						is_major = yes
					}
				}
			}
		}

		JAP = {

			set_truce = { target = ROOT days = 180 }
			effect_tooltip = {
				IF = {
					limit = {
						ROOT = { controls_state = 608 }
					}
					transfer_state = 608
				}
				IF = {
					limit = {
						ROOT = { controls_state = 1489 }
					}
					transfer_state = 1489
				}
				IF = {
					limit = {
						ROOT = { controls_state = 597 }
					}
					transfer_state = 597
				}
				IF = {
					limit = {
						ROOT = { controls_state = 1503 }
					}
					transfer_state = 1503
				}
				IF = {
					limit = {
						ROOT = { controls_state = 1504 }
					}
					transfer_state = 1504
				}
				IF = {
					limit = {
						ROOT = { controls_state = 1505 }
					}
					transfer_state = 1505
				}
				IF = {
					limit = {
						ROOT = { controls_state = 1038 }
					}
					transfer_state = 1038
				}
				IF = {
					limit = {
						ROOT = { controls_state = 1494 }
					}
					transfer_state = 1494
				}
				IF = {
					limit = {
						ROOT = { controls_state = 1495 }
					}
					transfer_state = 1495
				}
				IF = {
					limit = {
						ROOT = { controls_state = 1496 }
					}
					transfer_state = 1496
				}
				IF = {
					limit = {
						ROOT = { controls_state = 1497 }
					}
					transfer_state = 1497
				}
				IF = {
					limit = {
						ROOT = { controls_state = 1498 }
					}
					transfer_state = 1498
				}
				IF = {
					limit = {
						ROOT = { controls_state = 1499 }
					}
					transfer_state = 1499
				}
				IF = {
					limit = {
						ROOT = { controls_state = 1501 }
					}
					transfer_state = 1501
				}
				IF = {
					limit = {
						ROOT = { controls_state = 1502 }
					}
					transfer_state = 1502
				}
				IF = {
					limit = {
						ROOT = { controls_state = 614 }
					}
					transfer_state = 614
				}
				IF = {
					limit = {
						ROOT = { controls_state = 1490 }
					}
					transfer_state = 1490
				}
				IF = {
					limit = {
						ROOT = { controls_state = 1491 }
					}
					transfer_state = 1491
				}
				IF = {
					limit = {
						ROOT = { controls_state = 1492 }
					}
					transfer_state = 1492
				}
				IF = {
					limit = {
						ROOT = { controls_state = 1493 }
					}
					transfer_state = 1493
				}
				IF = {
					limit = {
						ROOT = { controls_state = 743 }
					}
					transfer_state = 743
				}
				IF = {
					limit = {
						ROOT = { controls_state = 1039 }
						JAP = {
							has_subject = MEN
						}
					}
					MEN = {
						transfer_state = 1039
					}
				}
				ELSE_IF = {
					limit = {
						ROOT = { controls_state = 1039 }
						JAP = {
							NOT = {
								has_subject = MEN
							}
						}
					}
					transfer_state = 1039
				}
				add_state_claim = 613
			}
			custom_effect_tooltip = generic_skip_one_line_tt
			if = {
				limit = {
					SND = { exists = yes }
					
				}

				custom_effect_tooltip =  china.1.b_tt_SND
			}

			custom_effect_tooltip = generic_skip_one_line_tt

			if = {
				limit = {
					HBC = { exists = yes }
					
				}

				custom_effect_tooltip =  china.1.b_tt_HBC
			}

									
			country_event = { id = japan.2 }
		}

	}

}

# Germany Withdraws Advisors
country_event = {
	id = china.2
	title = china.2.t
	desc = china.2.d
	picture = GFX_report_event_chinese_army_training
	
	is_triggered_only = yes
	
	option = {
		name = china.2.a
		remove_ideas = german_advisors
	}
}

# Chinese - German Relations Poor, Mission Recalled
country_event = {
	id = china.3
	title = china.3.t
	desc = china.3.d
	picture = GFX_report_event_chinese_soldiers
	
	is_triggered_only = yes
	
	option = {
		name = china.3.a
	}
}

# China is at war with Germany, Advisors Detained
country_event = {
	id = china.4
	title = china.4.t
	desc = china.4.d
	picture = GFX_report_event_german_detained_china
	
	is_triggered_only = yes
	
	option = {
		name = china.4.a
	}
}

# Mao is gaining ground, loses his Cornered Fox trait
country_event = {
	id = china.5
	title = china.5.t
	desc = china.5.d
	picture = GFX_report_event_chinese_officers
	
	fire_only_once = yes

	mean_time_to_happen = {
		days = 1
	}

	trigger = {
		tag = PRC
		num_of_controlled_states > 3
		has_country_leader = { ruling_only = yes character = PRC_mao_zedong }
		NOT = {
			has_dlc = "No Compromise, No Surrender"
		}
	}
	
	option = {
		name = china.5.a
		remove_country_leader_trait = cornered_fox
	}
}

# Kuomintang Offensive
country_event = {
	id = china.6
	title = china.6.t
	desc = china.6.d
	picture = GFX_report_event_chinese_soldiers_fighting

	fire_only_once = yes

	mean_time_to_happen = {
		days = 100
	}

	trigger = {
		tag = CHI
		NOT = { has_war_with = PRC }
		NOT = {
			has_dlc = "Waking the Tiger"
		}
		any_neighbor_country = {
			tag = PRC
			has_opinion_modifier = hostile_status
		}
	}

	immediate = { set_country_flag = CCW_offensive_executed }

	option = {
		name = china.6.a
		effect_tooltip = {
			custom_effect_tooltip = china.6.tt
			random_list = {
				70 = {
					country_event = { id = china.9 days = 1 }
					add_political_power = 200
					add_manpower = -10000
				}
				30 = {
					country_event = { id = china.10 days = 1 }
					add_political_power = -100
					add_manpower = -50000
				}
			}
			custom_effect_tooltip = china.6.tt_2
			country_event = { id = china.8 days = 1 }
			add_political_power = 100
		}
		hidden_effect = {
			PRC = {
				set_country_flag = CCW_major_attack
				country_event = { id = china.7 days = 1 }
			}
		}
	}

	option = {
		name = china.6.b
		effect_tooltip = {
			custom_effect_tooltip = china.6.tt
			random_list = {
				50 = {
					country_event = { id = china.9 days = 1 }
					add_political_power = 100
					add_manpower = -1000
				}
				50 = {
					country_event = { id = china.10 days = 1 }
					add_political_power = -50
					add_manpower = -5000
				}
			}
			custom_effect_tooltip = china.6.tt_2
			country_event = { id = china.8 days = 1 }
			add_political_power = 50
		}
		hidden_effect = {
			PRC = {
				set_country_flag = CCW_medium_attack
				country_event = { id = china.7 days = 1 }
			}
		}
	}

	option = {
		name = china.6.c
		effect_tooltip = {
			custom_effect_tooltip = china.6.tt
			random_list = {
				30 = {
					country_event = { id = china.9 days = 1 }
					add_political_power = 50
					add_manpower = -100
				}
				70 = {
					country_event = { id = china.10 days = 1 }
					add_political_power = -25
					add_manpower = -500
				}
			}
			custom_effect_tooltip = china.6.tt_2
			country_event = { id = china.8 days = 1 }
			add_political_power = 25
		}
		hidden_effect = {
			PRC = {
				set_country_flag = CCW_minor_attack
				country_event = { id = china.7 days = 1 }
			}
		}
	}
}

country_event = {
	id = china.7
	title = china.7.t
	desc = china.7.d
	picture = GFX_report_event_chinese_soldiers_fighting

	is_triggered_only = yes

	option = {
		name = china.7.a
		ai_chance = { factor = 80 }
		effect_tooltip = {
			random_list = {
				50 = {
					country_event = { id = china.11 }
					add_political_power = -75
					add_manpower = -5000
				}
				50 = {
					country_event = { id = china.12 }
					add_political_power = 150
					add_manpower = -1000
				}
			}
		}
		hidden_effect = {
			if = {
				limit = { has_country_flag = CCW_major_attack }
				CHI = {
					random_list = {
						70 = {
							country_event = { id = china.9 }
						}
						30 = {
							country_event = { id = china.10 }
						}
					}
				}
			}
			if = {
				limit = { has_country_flag = CCW_medium_attack }
				CHI = {
					random_list = {
						50 = {
							country_event = { id = china.9 }
						}
						50 = {
							country_event = { id = china.10 }
						}
					}
				}
			}
			if = {
				limit = { has_country_flag = CCW_minor_attack }
				CHI = {
					random_list = {
						30 = {
							country_event = { id = china.9 }
						}
						70 = {
							country_event = { id = china.10 }
						}
					}
				}
			}
		}
	}

	option = {
		name = china.7.b
		ai_chance = { factor = 20 }
		CHI = { country_event = { id = china.8 days = 1 } }
		add_political_power = -50
	}
}

country_event = {
	id = china.8
	title = china.8.t
	desc = china.8.d
	picture = GFX_report_event_chinese_soldiers_fighting
	
	is_triggered_only = yes
	
	option = {
		name = china.8.a
		if = {
			limit = { PRC = { has_country_flag = CCW_major_attack } }
			add_political_power = 100
		}
		if = {
			limit = { PRC = { has_country_flag = CCW_medium_attack } }
			add_political_power = 50
		}
		if = {
			limit = { PRC = { has_country_flag = CCW_minor_attack } }
			add_political_power = 25
		}
		PRC = {
			clr_country_flag = CCW_major_attack
			clr_country_flag = CCW_medium_attack
			clr_country_flag = CCW_minor_attack
		}
	}
}

country_event = {
	id = china.9
	title = china.9.t
	desc = china.9.d
	picture = GFX_report_event_chinese_soldiers_fighting
	
	is_triggered_only = yes
	
	option = {
		name = china.9.a
		if = {
			limit = { PRC = { has_country_flag = CCW_major_attack } }
			add_political_power = 200
			add_manpower = -10000
		}
		if = {
			limit = { PRC = { has_country_flag = CCW_medium_attack } }
			add_political_power = 100
			add_manpower = -1000
		}
		if = {
			limit = { PRC = { has_country_flag = CCW_minor_attack } }
			add_political_power = 50
			add_manpower = -100
		}
		PRC = {
			country_event = { id = china.11 }
			clr_country_flag = CCW_major_attack
			clr_country_flag = CCW_medium_attack
			clr_country_flag = CCW_minor_attack
		}
	}
}

country_event = {
	id = china.10
	title = china.10.t
	desc = china.10.d
	picture = GFX_report_event_chinese_soldiers_fighting
	
	is_triggered_only = yes
	
	option = {
		name = china.10.a
		if = {
			limit = { PRC = { has_country_flag = CCW_major_attack } }
			add_political_power = -100
			add_manpower = -50000
		}
		if = {
			limit = { PRC = { has_country_flag = CCW_medium_attack } }
			add_political_power = -50
			add_manpower = -5000
		}
		if = {
			limit = { PRC = { has_country_flag = CCW_minor_attack } }
			add_political_power = -25
			add_manpower = -500
		}
		PRC = {
			country_event = { id = china.12 }
			clr_country_flag = CCW_major_attack
			clr_country_flag = CCW_medium_attack
			clr_country_flag = CCW_minor_attack
		}
	}
}

country_event = {
	id = china.11
	title = china.11.t
	desc = china.11.d
	picture = GFX_report_event_chinese_soldiers_fighting
	
	is_triggered_only = yes
	
	option = {
		name = china.11.a
		add_political_power = -75
		add_manpower = -5000
	}
}

country_event = {
	id = china.12
	title = china.12.t
	desc = china.12.d
	picture = GFX_report_event_chinese_soldiers_fighting
	
	is_triggered_only = yes
	
	option = {
		name = china.12.a
		add_political_power = 150
		add_manpower = -1000
	}
}

# Border War
country_event = {
	id = china.13
	title = china.13.t
	desc = china.13.d
	picture = GFX_report_event_chinese_soldiers_fighting
	
	fire_only_once = yes

	trigger = {
		has_country_flag = CCW_offensive_executed
		NOT = { has_dlc = "Waking the Tiger" }
		has_opinion_modifier = hostile_status
		OR = {
			divisions_in_state = {
				state = 744
				size > 0
			}
			divisions_in_state = {
				state = 607
				size > 0
			}
		}
		PRC = {
			divisions_in_state = {	
				state = 622	
				size > 0	
			}	
		}	
	}	
	
	mean_time_to_happen = {	
		days = 21	
	}	

	immediate = {
		hidden_effect = {
			PRC = { country_event = { id = china.18 } }
		}
	}
	
	option = {
		name = china.13.a
		CHI = {
			if = {
				limit = {
					divisions_in_state = {
						state = 744
						size > 0
					}
				}
				744 = { set_border_war = yes }
			}
			if = {
				limit = {
					divisions_in_state = {
						state = 607
						size > 0
					}
				}
				607 = { set_border_war = yes }
			}
		}
		622 = { set_border_war = yes }
	}
	option = {
		name = china.13.b
		ai_chance = { factor = 0 }
		add_political_power = -50
	}
}

# CHI loses Border War
country_event = {
	id = china.14
	title = china.14.t
	desc = china.14.d
	picture = GFX_report_event_chinese_soldiers_fighting
	
	is_triggered_only = yes

	trigger = {
		tag = CHI
	}

	immediate = {
		hidden_effect = {
			605 = {
				if = {
					limit = { is_border_conflict = yes }
					set_border_war = no
				}
			}
			620 = {
				if = {
					limit = { is_border_conflict = yes }
					set_border_war = no
				}
			}
			607 = {
				if = {
					limit = { is_border_conflict = yes }
					set_border_war = no
				}
			}
			622 = {
				if = {
					limit = { is_border_conflict = yes }
					set_border_war = no
				}
			}
		}
	}
	
	option = {
		name = china.14.a
		add_political_power = -100
		add_stability = -0.05
		PRC = { country_event = { id = china.15 } }
	}
}

# PRC wins Border War
country_event = {
	id = china.15
	title = china.15.t
	desc = china.15.d
	picture = GFX_report_event_chinese_soldiers_fighting
	
	is_triggered_only = yes

	option = {
		name = china.15.a
		add_political_power = 100
		add_stability = 0.05
		add_war_support = 0.1
	}
}

# PRC loses Border War
country_event = {
	id = china.16
	title = china.16.t
	desc = china.16.d
	picture = GFX_report_event_chinese_soldiers_fighting
	
	is_triggered_only = yes

	trigger = {
		tag = PRC
	}

	immediate = {
		hidden_effect = {
			605 = {
				if = {
					limit = { is_border_conflict = yes }
					set_border_war = no
				}
			}
			620 = {
				if = {
					limit = { is_border_conflict = yes }
					set_border_war = no
				}
			}
			607 = {
				if = {
					limit = { is_border_conflict = yes }
					set_border_war = no
				}
			}
			622 = {
				if = {
					limit = { is_border_conflict = yes }
					set_border_war = no
				}
			}
		}
	}
	
	option = {
		name = china.16.a
		add_political_power = -100
		add_stability = -0.05
		CHI = { country_event = { id = china.17 } }
	}
}

# CHI wins Border War
country_event = {
	id = china.17
	title = china.17.t
	desc = china.17.d
	picture = GFX_report_event_chinese_soldiers_fighting
	
	is_triggered_only = yes

	option = {
		name = china.17.a
		add_political_power = 100
		add_stability = 0.05
		add_war_support = 0.1
	}
}

# Border War Starts (PRC)
country_event = {
	id = china.18
	title = china.18.t
	desc = china.18.d
	picture = GFX_report_event_chinese_soldiers_fighting
	
	is_triggered_only = yes

	option = {
		name = china.18.a
		effect_tooltip = {
			622 = { set_border_war = yes }
			CHI = {
				if = {
					limit = {
						divisions_in_state = {
							state = 744
							size > 0
						}
					}
					744 = { set_border_war = yes }
				}
				if = {
					limit = {
						divisions_in_state = {
							state = 607
							size > 0
						}
					}
					607 = { set_border_war = yes }
				}
			}
		}
	}
}

# Japan attacks - Chinese Popular Front forms
country_event = {
	id = china.100
	title = china.100.t
	desc = china.100.d
	picture = GFX_report_event_chinese_officers

	fire_only_once = yes

	trigger = {
		NOT = {
			has_dlc = "Waking the Tiger"
		}
		tag = CHI
		has_war_with = JAP
		JAP = { has_offensive_war = yes }
		has_defensive_war = yes
		NOT = { owns_state = 622 }		
		NOT = { has_global_flag = CHI_unite }
		NOT = { has_global_flag = CHI_no_national_front_flag }
	}

	mean_time_to_happen = {
		days = 1
	}
	
	option = {
		ai_chance = { factor = 100 }
		name = china.100.a
		create_faction = chinese_united_front
		#load_oob = "CHI_united_front"
		set_global_flag = CHI_unite

	}
	#option = {
	#	name = china.100.b
	#	#Nothing
	#}
}

# Japan attacks - Chinese Popular Front forms
country_event = {
	id = china.101
	title = china.101.t
	desc = china.101.d
	picture = GFX_report_event_chinese_officers

	trigger = {
		NOT = {
			has_dlc = "Waking the Tiger"
		}
		NOT = { has_country_flag = china.101_fired }
		has_global_flag = CHI_unite
		OR = {
			tag = GXC
			tag = YUN
			tag = XSM
		}
		CHI = {
			has_war_with = JAP 
			has_defensive_war = yes
		}
		JAP = { has_offensive_war = yes }

		is_puppet = no
		NOT = { has_war_with = CHI }
		AND = {
			has_war = no
			is_in_faction = no
		}
	}

	immediate = {
		set_country_flag = china.101_fired
	}

	mean_time_to_happen = {
		days = 14
	}
	
	option = {
		ai_chance = { factor = 100 }
		name = china.101.a
		effect_tooltip = {
			CHI = { 
				annex_country = { target = ROOT transfer_troops = yes }
			}
		}
		custom_effect_tooltip = GAME_OVER_TT
		hidden_effect = {
			CHI = { country_event = china.103 }
		}
	}
	option = {
		ai_chance = { factor = 0 }
		name = china.101.b
		CHI = { 
			add_to_faction = ROOT 
			country_event = china.106
		}
		add_ai_strategy = {
			type = alliance
			id = "CHI"
			value = 200
		}
		#Nothing
	}
}

# Japan attack - Sinkiang can join if they want to
country_event = {
	id = china.102
	title = china.102.t
	desc = china.102.d
	picture = GFX_report_event_chinese_officers

	fire_only_once = yes

	trigger = {
		NOT = {
			has_dlc = "Waking the Tiger"
		}
		has_global_flag = CHI_unite
		tag = SIK
		GER = { has_war_with = SOV }
		CHI = {
			has_war_with = JAP 
			has_defensive_war = yes
		}
		NOT = { has_war_with = CHI }
		JAP = { has_offensive_war = yes }
		
		is_puppet = no
		AND = {
			has_war = no
			is_in_faction = no
		}
	}

	mean_time_to_happen = {
		days = 7
	}
	
	option = {
		name = china.102.a
		ai_chance = { 
			base = 0
			modifier = {
				add = 50
				SOV = {
					has_war_with = GER
				}
				GER = {
					is_in_faction_with = JAP
				}
			}
		}
		effect_tooltip = {
			CHI = { 
				annex_country = { target = ROOT transfer_troops = yes }				
			}
		}
		custom_effect_tooltip = GAME_OVER_TT
		hidden_effect = {
			CHI = { country_event = china.103 }
		}
	}
	option = {
		name = china.102.b
		ai_chance = { 
			base = 0
			modifier = {
				add = 50
				SOV = {
					has_war_with = GER
				}
				GER = {
					is_in_faction_with = JAP
				}
				is_in_faction = no
			}
		}
		CHI = { add_to_faction = ROOT }
		add_ai_strategy = {
			type = alliance
			id = "CHI"
			value = 200
		}
	}
	option = {
		ai_chance = { 
			factor = 10
		}
		name = china.102.c
		#Nothing
	}
}

# FROM joins China (annex)
country_event = {
	id = china.103
	title = china.103.t
	desc = china.103.d
	picture = GFX_report_event_chinese_army_training

	is_triggered_only = yes
	
	option = {
		name = china.103.a
		set_global_flag = CHI_unite_PRC
		annex_country = { target = FROM transfer_troops = yes }
	}
}

# PRC option to join China faction
country_event = {
	id = china.104
	title = china.104.t
	desc = china.104.d
	picture = GFX_report_event_chinese_army_training

	fire_only_once = yes

	trigger = {
		NOT = {
			has_dlc = "Waking the Tiger"
		}
		has_global_flag = CHI_unite_PRC
		tag = PRC
		CHI = {
			has_war_with = JAP 
			has_defensive_war = yes
		}
		JAP = { has_offensive_war = yes }
		CHI = { is_faction_leader = yes }
		NOT = {
			has_war_with = CHI
			is_puppet = yes
		}

		NOT = {
			AND = {
				has_war = yes
				is_in_faction = yes
			}
		}
	}

	mean_time_to_happen = {
		days = 10
	}
	
	option = {
		ai_chance = { factor = 100 }
		name = china.104.a
		set_country_flag = PRC_joined_CHI_against_JAP
		CHI = {
			country_event = china.106
			add_to_faction = ROOT
			PRC = { add_opinion_modifier = { target = CHI modifier = unstable_alliance } }
			CHI = { add_opinion_modifier = { target = PRC modifier = unstable_alliance } }			
		}
		add_ai_strategy = {
			type = alliance
			id = "CHI"
			value = 200
		}
		add_to_war = {
			targeted_alliance = CHI
			enemy = JAP
			hostility_reason = asked_to_join
		}
		if = {
			limit = { 
				NOT = { 
					OR = {
						SHX = { is_puppet_of = JAP } 
						SHX = { is_in_faction_with = JAP}
					}
				} 
			}
			SHX = { country_event = china.105 }
		}
		if = {
			limit = { NOT = { has_war_with = SOV } }
			custom_effect_tooltip = china.104_PRC_SOV_reinforcements
		}
		hidden_effect = {
			news_event = { id = news.288 hours = 6 }
			if = {
				limit = { 
					NOT = { has_war_with = SOV }
					any_country = {
						OR = {
							tag = ROOT
							is_in_faction_with = ROOT
						}
						has_full_control_of_state = 621
					}
				}
				load_oob = "PRC_SOV_reinforcements"
			}
		}
	}

	#Nothing
	option = {
		ai_chance = { factor = 0 }
		name = china.104.b
	}
}

# PRC annexs SHX (puppet option for player)
country_event = {
	id = china.105
	title = china.105.t
	desc = china.105.d
	picture = GFX_report_event_generic_sign_treaty2

	is_triggered_only = yes

	option = {
		ai_chance = { factor = 100 }
		name = china.105.a
		FROM = { annex_country = { target = ROOT transfer_troops = yes } }
		custom_effect_tooltip = GAME_OVER_TT
	}

	#Nothing
	option = {
		ai_chance = { factor = 0 }
		FROM = { puppet = ROOT }
		name = china.105.b
	}
}

# China - Info that PRX has joined faction
country_event = {
	id = china.106
	title = china.106.t
	desc = china.106.d
	picture = GFX_report_event_chinese_army_training

	is_triggered_only = yes

	option = {
		name = china.106.a
	}

}

# China and Japan no longer at war - Break up faction and Mao claims his part of China
country_event = {
	id = china.107
	title = china.107.t
	desc = {
		text = china.107.d_PRC_joined
		trigger = { 
			PRC = { 
				has_country_flag = PRC_joined_CHI_against_JAP 
			} 
		} 
	}
	desc = {
		text = china.107.d_PRC_refused
		trigger = { 
			PRC = { 
				NOT = { has_country_flag = PRC_joined_CHI_against_JAP } 
			} 
		}
	}

	picture = GFX_report_event_generic_sign_treaty1

	fire_only_once = yes

	trigger = {
		is_subject = no
		PRC = { is_subject = no }
		tag = CHI
		has_global_flag = CHI_unite
		NOT = { has_war_with = JAP }		
	}

	mean_time_to_happen = {
		days = 60
	}

	option = {
		name = china.107.a
		if = {
			limit = { NOT = { PRC = { has_country_flag = PRC_joined_CHI_against_JAP } } }
			dismantle_faction = yes
			PRC = { remove_opinion_modifier = { target = CHI modifier = unstable_alliance } }
			CHI = { remove_opinion_modifier = { target = PRC modifier = unstable_alliance } }			
		}

		if = {
			limit = {
				PRC = { has_country_flag = PRC_joined_CHI_against_JAP }
			}
			custom_effect_tooltip = china.107_tt
			effect_tooltip = {
				dismantle_faction = yes
				PRC = { remove_opinion_modifier = { target = CHI modifier = unstable_alliance } }
				CHI = { remove_opinion_modifier = { target = PRC modifier = unstable_alliance } }				
			}
		}
		hidden_effect = {
			PRC = { country_event = { id = china.111 } }
			PRC = { country_event = { id = china.108 days = 90 } }
		}
	}
}

# Restart Chinese civil war - Communist supporters reinforces the PRC army
country_event = {
	id = china.108
	title = china.108.t
	desc = china.108.d
	picture = GFX_report_event_chinese_army_training

	is_triggered_only = yes

	option = {
		name = china.108.a
		custom_effect_tooltip = china.108_PRC_SOV_reinforcements_2
		hidden_effect = {
			if = {
				limit = { 
					NOT = { has_war_with = SOV }
					any_country = {
						OR = {
							tag = ROOT
							is_in_faction_with = ROOT
						}
						has_full_control_of_state = 621
					}
				}
				load_oob = "PRC_SOV_reinforcements_2"
			}
			set_global_flag = PRC_restart_CHI_war
		}
	}
}

# Restart Chinese civil war
country_event = {
	id = china.109
	title = china.109.t
	desc = china.109.d
	picture = GFX_report_event_chinese_soldiers

	fire_only_once = yes

	trigger = {
		tag = PRC
		has_global_flag = PRC_restart_CHI_war
		NOT = { has_war_together_with = CHI }
		is_subject = no
		CHI = { is_subject = no }
	}

	mean_time_to_happen = { days = 360 }

	option = {
		name = china.109.a
		custom_effect_tooltip = china.109_tt		
		CHI = { country_event = { id = china.110 } }
		effect_tooltip = {
			declare_war_on = { target = CHI type = annex_everything }
		}
	}
}

country_event = {
	id = china.110
	title = china.110.t
	desc = china.110.d
	picture = GFX_report_event_chinese_soldiers

	is_triggered_only = yes
	
	immediate = {
		hidden_effect = {
			PRC = { declare_war_on = { target = CHI type = annex_everything } }
		}
	}

	option = {
		name = china.110.a
		add_timed_idea = { idea = CHI_civil_war_deserters days = 180 }
	}

}

# China and Japan no longer at war - Break up faction and Mao claims his part of China
country_event = {
	id = china.111
	title = china.111.t
	desc = china.111.d
	picture = GFX_report_event_generic_sign_treaty1

	is_triggered_only = yes

	option = {
		name = china.111.a
		CHI = { 
			dismantle_faction = yes
			hidden_effect = {
				remove_opinion_modifier = { target = PRC modifier = unstable_alliance }
			}
		}
		hidden_effect = {
			PRC = { remove_opinion_modifier = { target = CHI modifier = unstable_alliance } }
		}
		custom_effect_tooltip = china.107_tt
		hidden_effect = {
			every_state = {
				limit = {
					controller = {
						original_tag = CHI
						is_puppet_of = CHI
					}
					is_core_of = PRC
					OR = {
						region = 143
						region = 155
					}
					NOT = { state = 525 }
					NOT = { state = 527 }				
				}
				ROOT = { transfer_state = PREV }
			}			
		}
	}
}

# China turns communist / Communists break off from China
country_event = {
	id = china.200
	title = china.200.t
	desc = china.200.d
	picture = GFX_report_event_generic_sign_treaty1

	mean_time_to_happen = {
		days = 2
	}

	trigger = {
		original_tag = CHI
		has_government = communism
		Not = {
			has_dlc = "Waking the Tiger"
		}
		OR = {
			is_subject_of = PRC
			is_subject = no
		}
		PRC = {
			exists = yes
			has_government = communism
		}
	}

	option = {
		name = china.200.a
		hidden_effect = { PRC = { country_event = { id = china.201 } } }
		effect_tooltip = {
			PRC = {
				annex_country = { target = ROOT transfer_troops = yes }
			}
		}
		custom_effect_tooltip = GAME_OVER_TT
	}
}

# PRC annexes communist revolters from China
country_event = {
	id = china.201
	title = china.201.t
	desc = china.201.d
	picture = GFX_report_event_generic_sign_treaty1

	is_triggered_only = yes

	option = {
		name = china.201.a
		if = {
			limit = {
				FROM = {
					has_civil_war = yes
				}
			}
			random_other_country = {
				limit = {
					original_tag = CHI
					has_war_with = FROM
				}
				declare_war_on = { target = ROOT type = annex_everything }
			}
		}
		PRC = {
			annex_country = { target = FROM transfer_troops = yes }
		}
	}
}

#CHI event - PRC takes control of a CHI state - Communist uprising
country_event = {
	id = china.202
	title = china.202.t
	desc = china.202.d
	picture = GFX_report_event_chinese_soldiers

	trigger = {
		original_tag = CHI
		has_government = neutrality
		NOT = {
			has_dlc = "Waking the Tiger"
		}
		PRC = {
			exists = yes
			has_government = communism
		}
		communism > 0.3
	}

	mean_time_to_happen = {
		days = 270
		modifier = {
			factor = 0.5
			communism > 0.5
		}
	}

	immediate = {
		hidden_effect = {
			random_owned_controlled_state = {
				limit = {
					any_neighbor_state = {
						owner = { tag = PRC }
					}
				}
				save_event_target_as = CHI_communist_state
			}
		}
	}

	option = {
		name = china.202.a
		PRC = {
			transfer_state = event_target:CHI_communist_state
			country_event = { id = china.203 days = 1 }
		}
		add_popularity = {
			ideology = communism
			popularity = -0.15
		}
	}
}

#PRC event - takes control of a CHI state - Communist uprising
country_event = {
	id = china.203
	title = china.203.t
	desc = china.203.d
	picture = GFX_report_event_chinese_soldiers

	is_triggered_only = yes

	option = {
		name = china.203.a
		effect_tooltip = {
			CHI = {
				add_popularity = {
					ideology = communism
					popularity = -0.15
				}		
			}
		}
	}
}

#Move capital if PRC wins civil war
country_event = {
	id = china.204
	title = china.204.t
	desc = china.204.d
	picture = GFX_report_event_chinese_soldiers

	fire_only_once = yes

	trigger = {
		tag = PRC
		NOT = {
			has_dlc = "Waking the Tiger"
		}
		NOT = {
			country_exists = CHI
		}
		OR = {
			owns_state = 608 #Beijing
			owns_state = 1035 #Nanjing
		}
	}

	mean_time_to_happen = {
		days = 10
	}

	#Move to Beijing
	option = {
		name = china.204.a
		ai_chance = {
			base = 90
			modifier = {
				factor = 0
				NOT = { 608 = { is_controlled_by = PRC } }
			}
		}
		trigger = {
			owns_state = 608
		}
		set_capital = {
			state = 608
			remember_old_capital = no
		}

		custom_effect_tooltip = generic_skip_one_line_tt

		set_province_name = { id = 9843 name = PRC_beijing_capital_name }
		608 = {
			set_state_name = PRC_beijing_capital_name
		}
	}

	#Move to Nanjing
	option = {
		name = china.204.b
		ai_chance = {
			base = 10
			modifier = {
				factor = 0
				NOT = { 1035 = { is_controlled_by = PRC } }
			}
		}
		trigger = {
			owns_state = 1035
		}
		custom_effect_tooltip = CHI_nanjing_tt
		hidden_effect = {
			set_capital = { state = 1035 }
		}
	}

	#Stay where you are
	option = {
		name = china.204.c
		ai_chance = {
			base = 0
			modifier = {
				add = 1
				NOT = { 608 = { is_controlled_by = PRC } }
				NOT = { 613 = { is_controlled_by = PRC } }
			}			
		}
	}
}