#Fate of Asia and the Pacific - written by CSRZ
#Historically leaders of the Allies signed a Potsdam Declaration outlining the post-war borders in Asia for centuries to come. These borders are visible up to this day.
#This pack of events will simulate the agreement signed by China, USA, UK and the Soviet Union to produce historical borders when on historical focus.

#To trigger the peace conference Japan will need to be at war with USA and UK while China is either at war with Japan or a puppet of Japan (also independent Soviet Union, Netherlands and at least Free France must exist for this to trigger)

#Conference will seal a fate of Japanese isles (including Okinawa and Iwo Jima) becoming a puppet of USA, the pacific isles becoming US mandate, Korea being divided between the Soviet Union and United States of America, Guangzhouwan becoming Chinese and northern China becoming Communist Chinese while Vietnam, Laos and Kambodia are to be liberated by France + Thailand will become American supervised state


#Fate of Asia and the Pacific

add_namespace = potconf

#Allied declaration
news_event = {
	id = potconf.0
	title = potconf.0.t
	desc = potconf.0.d
	picture = GFX_news_event_potsdam_declaration
	
	major = yes
	
	#fire_only_once = yes

	is_triggered_only =  yes 

	option = {
		name = potconf.0.a
		trigger = {
			OR = {
				has_government = fascism
			}
		}
	}

	option = {
		name = potconf.0.b
		trigger = {
			NOT = {
				has_government = fascism
			}
		}
	}	
}

#Fate of Asia and the Pacific

country_event = {
	id = potconf.1
	title = potconf.1.t
	desc = potconf.1.d
	picture = GFX_report_potsdam_declaration

	fire_only_once = yes

	trigger = {
		tag = USA
		NOT = { has_global_flag = disable_peace_conference_potsdam }
		USA = { has_war_with = JAP }
		#SOV = { has_war_with = GER }
		ENG = { has_war_with = JAP }
		OR = {
			CHI = { has_war_with = JAP }
			NOT = { country_exists = CHI }
			CHI = { is_subject = yes }
		}
		USA = { is_in_faction_with = ENG }
		country_exists = SOV
		SOV = { is_subject = no }
		JAP = { has_government = fascism }
		#country_exists = HOL
		#HOL = { is_subject = no }
		#country_exists = FRA
		#FRA = { is_subject = no }		
	}

	mean_time_to_happen = {
		days = 2
	}

	#propose peace in asia to everyone
	option = {
		name = potconf.1.a 
		ai_chance = { factor = 100 }
		set_global_flag = postdam_usa_yesman
		#hidden_effect = {
		#	news_event = { id = potconf.0 hours = 6 }
		#}
		ENG = {
			country_event = { id = potconf.2 }
		}
		if = {
			limit = {
				OR = {
					NOT = { country_exists = SOV }
					SOV = { is_subject = yes }
				}
			}
			set_global_flag = postdam_sov_yesman
		}	
		if = {
			limit = {
				NOT = {
					OR = {
						NOT = { country_exists = SOV }
						SOV = { is_subject = yes }
					}
				}
			}
			SOV = {
				country_event = { id = potconf.3 }
			}	
		}
		if = {
			limit = {
				OR = {
					NOT = { country_exists = CHI }
					CHI = { is_subject = yes }
				}
			}
			set_global_flag = postdam_chi_yesman
		}	
		if = {
			limit = {
				NOT = {
					OR = {
						NOT = { country_exists = CHI }
						CHI = { is_subject = yes }
					}
				}
			}
			CHI = {
				country_event = { id = potconf.4 }
			}	
		}
		if = {
			limit = {
				OR = {
					NOT = { country_exists = PRC }
					PRC = { is_subject = yes }
				}
			}
			set_global_flag = postdam_prc_yesman
		}	
		if = {
			limit = {
				NOT = {
					OR = {
						NOT = { country_exists = PRC }
						PRC = { is_subject = yes }
					}
				}
			}
			PRC = {
				country_event = { id = potconf.5 }
			}	
		}
		if = {
			limit = {
				OR = {
					NOT = { country_exists = HOL }
					HOL = { is_subject_of = JAP }
				}
			}
			set_global_flag = postdam_hol_yesman
		}	
		if = {
			limit = {
				NOT = {
					OR = {
						NOT = { country_exists = HOL }
						HOL = { is_subject = yes }
					}
				}
			}
			HOL = {
				country_event = { id = potconf.6 }
			}	
		}
		if = {
			limit = {
				OR = {
					NOT = { country_exists = FRA }
					FRA = { is_subject_of = JAP }
				}
			}
			set_global_flag = postdam_fra_yesman
		}	
		if = {
			limit = {
				NOT = {
					OR = {
						NOT = { country_exists = FRA }
						FRA = { is_subject = yes }
					}
				}
			}
			FRA = {
				country_event = { id = potconf.7 }
			}	
		}
	}

	#the fate of asia is to be eternal bordergore
	option = {
		name = potconf.1.b
	}	
}

#UK agrees
country_event = {
	id = potconf.2
	title = potconf.2.t
	desc = potconf.2.d
	picture = GFX_report_potsdam_declaration

	fire_only_once = yes

	is_triggered_only = yes
	
	option = {
		name = potconf.2.a
		ai_chance = { factor = 100 }
		set_global_flag = postdam_eng_yesman
	}

	option = {
		name = potconf.2.b
	}
}

#Soviets agree
country_event = {
	id = potconf.3
	title = potconf.3.t
	desc = potconf.3.d
	picture = GFX_report_potsdam_declaration

	fire_only_once = yes

	is_triggered_only = yes
	
	option = {
		name = potconf.3.a
		ai_chance = { factor = 100 }
		set_global_flag = postdam_sov_yesman
	}

	option = {
		name = potconf.3.b
	}
}

#KMT agree
country_event = {
	id = potconf.4
	title = potconf.4.t
	desc = potconf.4.d
	picture = GFX_report_potsdam_declaration

	fire_only_once = yes

	is_triggered_only = yes
	
	option = {
		name = potconf.4.a
		ai_chance = { factor = 100 }
		set_global_flag = postdam_chi_yesman
	}

	option = {
		name = potconf.4.b
	}
}

#PRC agree
country_event = {
	id = potconf.5
	title = potconf.5.t
	desc = potconf.5.d
	picture = GFX_report_potsdam_declaration

	fire_only_once = yes

	is_triggered_only = yes
	
	option = {
		name = potconf.5.a
		ai_chance = { factor = 100 }
		set_global_flag = postdam_prc_yesman
	}

	option = {
		name = potconf.5.b
	}
}

#Netherlands agree
country_event = {
	id = potconf.6
	title = potconf.6.t
	desc = potconf.6.d
	picture = GFX_report_potsdam_declaration

	fire_only_once = yes

	is_triggered_only = yes
	
	option = {
		name = potconf.6.a
		ai_chance = { factor = 100 }
		set_global_flag = postdam_hol_yesman
	}

	option = {
		name = potconf.6.b
	}
}

#France agrees
country_event = {
	id = potconf.7
	title = potconf.7.t
	desc = potconf.7.d
	picture = GFX_report_potsdam_declaration

	fire_only_once = yes

	is_triggered_only = yes
	
	option = {
		name = potconf.7.a
		ai_chance = { factor = 100 }
		set_global_flag = postdam_fra_yesman
	}

	option = {
		name = potconf.7.b
	}
}

#maybe other nations like Portugal, Australia, New Zealand, India etc.? In the future...

#the peace event flag
country_event = {
	id = potconf.10
	title = potconf.10.t
	desc = potconf.10.d
	picture = GFX_report_potsdam_declaration_3

	fire_only_once = yes

	trigger = {
		tag = USA
		has_global_flag = postdam_usa_yesman
		has_global_flag = postdam_eng_yesman
		has_global_flag = postdam_sov_yesman
		has_global_flag = postdam_chi_yesman
		has_global_flag = postdam_prc_yesman
		has_global_flag = postdam_hol_yesman
		has_global_flag = postdam_fra_yesman
	}

	mean_time_to_happen = {
		days = 2
	}

	option = {
		name = potconf.10.a 
		ai_chance = { factor = 100 }
		clr_global_flag = postdam_usa_yesman
		clr_global_flag = postdam_eng_yesman
		clr_global_flag = postdam_sov_yesman
		clr_global_flag = postdam_chi_yesman
		clr_global_flag = postdam_prc_yesman
		clr_global_flag = postdam_hol_yesman
		clr_global_flag = postdam_fra_yesman
		set_global_flag = postdam_all_clear
		hidden_effect = {
			news_event = { id = potconf.0 hours = 6 }
		}
		ENG = {
			country_event = { id = potconf.11 }
		}
		SOV = {
			country_event = { id = potconf.11 }
		}
		FRA = {
			country_event = { id = potconf.11 }
		}
		CHI = {
			country_event = { id = potconf.11 }
		}
		PRC = {
			country_event = { id = potconf.11 }
		}
		HOL = {
			country_event = { id = potconf.11 }
		}
	}
}

country_event = {
	id = potconf.11
	title = potconf.11.t
	desc = potconf.11.d
	picture = GFX_report_potsdam_declaration

	#fire_only_once = yes #will fire for all participants

	is_triggered_only = yes
	
	option = {
		name = potconf.11.a
	}
}



#Failsafe - if USA gets annexed or puppeted Potsdam won't trigger
country_event = {
	id = potconf.12

	trigger = {
		tag = USA
		is_subject = yes
	}

	mean_time_to_happen = {
		days = 1
	}

	hidden = yes

	immediate = {
		clr_global_flag = postdam_all_clear
	}
}

country_event = {
	id = potconf.13

	trigger = {
		tag = JAP
		NOT = { country_exists = USA }
	}

	mean_time_to_happen = {
		days = 1
	}

	hidden = yes

	immediate = {
		clr_global_flag = postdam_all_clear
	}
}

country_event = {
	id = potconf.14

	trigger = {
		tag = JAP
		USA = { NOT = { owns_state = 638 } } #USA may exist but lost the war and Guam
	}

	mean_time_to_happen = {
		days = 1
	}

	hidden = yes

	immediate = {
		clr_global_flag = postdam_all_clear
	}
}

#failsafe - The war somehow ended, but Japan prevailed, is still fascist and is not a puppet and controls Tokyo, but didn't puppet USA or took Guam
country_event = {
	id = potconf.15

	trigger = {
		tag = JAP
		JAP = { has_government = fascism }
		JAP = { has_war = no }
		JAP = { is_subject = no }
		JAP = { owns_state = 282 }
	}

	mean_time_to_happen = {
		days = 1
	}

	hidden = yes

	immediate = {
		clr_global_flag = postdam_all_clear
	}
}

#Border Gore exterminator event - may take a while to process - checks many tags and states
country_event = {
	id = potconf.21
	title = potconf.21.t
	desc = potconf.21.d
	picture = GFX_report_potsdam_declaration_4

	fire_only_once = yes

	trigger = {
		tag = USA
		has_global_flag = postdam_all_clear
		282 = {
			OR = {
				is_owned_by = USA
				any_other_country = {
					owns_state = 282
					is_in_faction_with = USA
				}
				is_owned_by = PRC
				any_other_country = {
					owns_state = 282
					is_in_faction_with = PRC
				}
				is_owned_by = CHI
				any_other_country = {
					owns_state = 282
					is_in_faction_with = CHI
				}
				is_owned_by = ENG
				any_other_country = {
					owns_state = 282
					is_in_faction_with = ENG
				}
				is_owned_by = SOV
				any_other_country = {
					owns_state = 282
					is_in_faction_with = SOV
				}
				is_owned_by = HOL
				any_other_country = {
					owns_state = 282
					is_in_faction_with = HOL
				}
				is_owned_by = FRA
				any_other_country = {
					owns_state = 282
					is_in_faction_with = FRA
				}
			}
		}
		OR = {
			JAP = {
				is_subject = yes
			}
			NOT = {
				282 = {
					is_owned_by = JAP
				}
			}
		}
	}

	mean_time_to_happen = {
		days = 10
	}

	#fire exterminator event
	option = {
		name = potconf.21.a 
		ai_chance = { factor = 100 }
		set_global_flag = postdam_usa_yesman
		hidden_effect = {
			news_event = { id = potconf.22 hours = 6 }
		}
		transfer_state = 282
		release = JAP
		puppet = JAP
		set_autonomy = {
    			target = JAP
			autonomy_state = autonomy_supervised_state
		}
		JAP = {
			transfer_state = 536
			transfer_state = 533
			transfer_state = 534
			transfer_state = 535
			transfer_state = 532
			transfer_state = 531
			transfer_state = 529
			transfer_state = 530
			transfer_state = 528
			transfer_state = 526 #Okinawa
			transfer_state = 645 #Iwo Jima
			transfer_state = 1020
			transfer_state = 1019
			transfer_state = 1018	
		}
		PHI = {
			transfer_state = 1027
			transfer_state = 1026
			transfer_state = 1025
			transfer_state = 628
			transfer_state = 627
			transfer_state = 626
			transfer_state = 625
			transfer_state = 624
			transfer_state = 623
			transfer_state = 327	
		}
		USA = {
			transfer_state = 525 #South Korea
			transfer_state = 1029 #South Korea
			transfer_state = 1030 #South Korea
			transfer_state = 1031 #South Korea		
			transfer_state = 648
			transfer_state = 646
			transfer_state = 638
			transfer_state = 647
			transfer_state = 684
			transfer_state = 633
			release = CHI
		}	
		FRA = {
			transfer_state = 741
			transfer_state = 670
			transfer_state = 671
			transfer_state = 286
			release_puppet = VIN
			release_puppet = CAM
			release_puppet = LAO
			#release = CHI # return of Guangzhouwan was made a part of GXC code
		}
		SIA = {
			transfer_state = 289
			transfer_state = 724
		}
		if = {
			limit = { 
				SIA = { 
					is_ai = yes #If you took Siam and it for ex. gone communist then you won't be affected by this peace
				}
			}
			USA = {
				puppet = SIA
				set_autonomy = {
    					target = SIA
					autonomy_state = autonomy_supervised_state
				}
			}
		}
		if = {
			limit = { 
				country_exists = SOV
			}
			SOV = {
				transfer_state = 537 #Kuriles
				transfer_state = 555	
				transfer_state = 527 #North Korea
				transfer_state = 1028 #North Korea
				release = PRC		
			}
		}
		537 = { add_core_of = SOV } #South Sakhalin
		537 = { remove_core_of = JAP }
		if = {
			limit = { country_exists = SHX }
			SHX = { 
				transfer_state = 611 #Megjiang
				transfer_state = 1043
				transfer_state = 612 
				transfer_state = 610 #Manchukuo
				transfer_state = 716 
				transfer_state = 745 
				transfer_state = 328 
				transfer_state = 717 
				transfer_state = 715 
				transfer_state = 714 
				transfer_state = 761 
			}
		}
		if = {
			limit = { 
				AND = { 
					NOT = { country_exists = SHX }
					country_exists = PRC
				}
			}
			PRC = { 
				transfer_state = 611 #Megjiang
				transfer_state = 1043
				transfer_state = 612 
				transfer_state = 610 #Manchukuo
				transfer_state = 716 
				transfer_state = 745 
				transfer_state = 328 
				transfer_state = 717 
				transfer_state = 715 
				transfer_state = 714 
				transfer_state = 761 
			}
		}
		if = {
			limit = { 
				AND = { 
					NOT = { country_exists = SHX }
					NOT = { country_exists = PRC }
					country_exists = CHI
				}
			}
			CHI = { 
				transfer_state = 611 #Megjiang
				transfer_state = 1043
				transfer_state = 612 
				transfer_state = 610 #Manchukuo
				transfer_state = 716 
				transfer_state = 745 
				transfer_state = 328 
				transfer_state = 717 
				transfer_state = 715 
				transfer_state = 714 
				transfer_state = 761 
			}
		}
		if = {
			limit = { 
				AND = { 
					NOT = { country_exists = SHX }
					NOT = { country_exists = PRC }
					NOT = { country_exists = CHI }
					country_exists = GXC
				}
			}
			GXC = { 
				transfer_state = 611 #Megjiang
				transfer_state = 1043
				transfer_state = 612 
				transfer_state = 610 #Manchukuo
				transfer_state = 716 
				transfer_state = 745 
				transfer_state = 328 
				transfer_state = 717 
				transfer_state = 715 
				transfer_state = 714 
				transfer_state = 761 
			}
		}
		if = {
			limit = { 
				AND = { 
					NOT = { country_exists = SHX }
					NOT = { country_exists = PRC }
					NOT = { country_exists = CHI }
					NOT = { country_exists = GXC }
					country_exists = YUN
				}
			}
			YUN = { 
				transfer_state = 611 #Megjiang
				transfer_state = 1043
				transfer_state = 612 
				transfer_state = 610 #Manchukuo
				transfer_state = 716 
				transfer_state = 745 
				transfer_state = 328 
				transfer_state = 717 
				transfer_state = 715 
				transfer_state = 714 
				transfer_state = 761 
			}
		}
		if = {
			limit = { 
				AND = { 
					NOT = { country_exists = SHX }
					NOT = { country_exists = PRC }
					NOT = { country_exists = CHI }
					NOT = { country_exists = GXC }
					NOT = { country_exists = YUN }
					country_exists = XSM
				}
			}
			XSM = { 
				transfer_state = 611 #Megjiang
				transfer_state = 1043
				transfer_state = 612 
				transfer_state = 610 #Manchukuo
				transfer_state = 716 
				transfer_state = 745 
				transfer_state = 328 
				transfer_state = 717 
				transfer_state = 715 
				transfer_state = 714 
				transfer_state = 761 
			}
		}
		if = {
			limit = { 
				AND = { 
					NOT = { country_exists = SHX }
					NOT = { country_exists = PRC }
					NOT = { country_exists = CHI }
					NOT = { country_exists = GXC }
					NOT = { country_exists = YUN }
					NOT = { country_exists = XSM }
					country_exists = SIK
				}
			}
			SIK = { 
				transfer_state = 611 #Megjiang
				transfer_state = 1043
				transfer_state = 612 
				transfer_state = 610 #Manchukuo
				transfer_state = 716 
				transfer_state = 745 
				transfer_state = 328 
				transfer_state = 717 
				transfer_state = 715 
				transfer_state = 714 
				transfer_state = 761 
			}
		}

######
#
#    MAINLAND CHINA - scirpt removed - WILL NOT WORK
#
######



######
#
#    TAIWAN
#
######


		if = {
			limit = { 
				AND = { 
					country_exists = CHI
				}
			}
			CHI = { 
				transfer_state = 524 #Taiwan
			}
		}
		if = {
			limit = { 
				AND = { 
					NOT = { country_exists = CHI }
					country_exists = GXC
				}
			}
			GXC = { 
				transfer_state = 524 #Taiwan
			}
		}
		if = {
			limit = { 
				AND = { 
					NOT = { country_exists = CHI }
					NOT = { country_exists = GXC }
					country_exists = YUN
				}
			}
			YUN = { 
				transfer_state = 524 #Taiwan
			}
		}
		if = {
			limit = { 
				AND = { 
					NOT = { country_exists = CHI }
					NOT = { country_exists = GXC }
					NOT = { country_exists = YUN }
					country_exists = SHX
				}
			}
			SHX = { 
				transfer_state = 524 #Taiwan
			}
		}
		if = {
			limit = { 
				AND = { 
					NOT = { country_exists = SHX }
					NOT = { country_exists = CHI }
					NOT = { country_exists = GXC }
					NOT = { country_exists = YUN }
					country_exists = XSM
				}
			}
			XSM = { 
				transfer_state = 524 #Taiwan
			}
		}
		if = {
			limit = { 
				AND = { 
					NOT = { country_exists = SHX }
					NOT = { country_exists = CHI }
					NOT = { country_exists = GXC }
					NOT = { country_exists = YUN }
					NOT = { country_exists = XSM }
					country_exists = SIK
				}
			}
			SIK = { 
				transfer_state = 524 #Taiwan
			}
		}
		if = {
			limit = { 
				AND = { 
					NOT = { country_exists = SHX }
					NOT = { country_exists = SIK }
					NOT = { country_exists = CHI }
					NOT = { country_exists = GXC }
					NOT = { country_exists = YUN }
					NOT = { country_exists = XSM }
				}
			}
			CHI = { 
				transfer_state = 524 #Taiwan
			}
			USA = { 
				puppet = CHI
				set_autonomy = {
    					target = CHI
					autonomy_state = autonomy_supervised_state
				}
			}
		}
	}

	#the fate of asia is to be eternal bordergore
	#option = {
	#	name = potconf.21.b
	#}	
}

news_event = {
	id = potconf.22
	title = potconf.22.t
	desc = potconf.22.d
	picture = GFX_news_event_potsdam_declaration_4
	
	major = yes
	
	#fire_only_once = yes

	is_triggered_only =  yes 

	option = {
		name = potconf.0.a
		trigger = {
			OR = {
				has_government = fascism
			}
		}
	}

	option = {
		name = potconf.0.b
		trigger = {
			NOT = {
				has_government = fascism
			}
		}
	}	
}