GEA_collapse = {
set_global_flag = GEA_collapse
	#First give away any owned states to their controller, if we're at war
	every_owned_state = {
		limit = { NOT = { is_controlled_by = GEA } }
		save_event_target_as = giveaway
		controller = { transfer_state = event_target:giveaway }
	}
	#Now mark all existing breakaways
	every_country = {
		limit = {
			exists = yes
			is_in_asia = yes
		}
		set_country_flag = GEA_already_exists
	}
#Give events to neighbours
every_country = {
	limit = {
		OR = {
			tag = SIA
			tag = YUN
			tag = JAP
			tag = AST
			tag = PHI
			tag = INC
			tag = DEI
			tag = INS
			tag = PAF
		}
	}
	country_event = {
		id = sharedafrika.72
		days = 1 random_days = 3
	}
}
#Northern Islands - give to Micronesia
	if = {
		limit = {
			owns_state = 647 #Palau Islands
		}
		SSI = { transfer_state = 647 }
		647 = { add_core_of = SSI }
	}
	if = {
		limit = {
			owns_state = 684  #Caroline Islands
		}
		SSI = { transfer_state = 684 }
		684 = { add_core_of = SSI }
	}
	if = {
		limit = {
			owns_state = 643 #Ellice Islands
		}
		SSI = { transfer_state = 643 }
		643 = { add_core_of = SSI }
	}
	if = {
		limit = {
			owns_state = 633
		}
		SSI = { transfer_state = 633 } #Marshall Islands
		633 = { add_core_of = SSI }
	}
	if = {
		limit = {
			owns_state = 725 #Nauru
		}
		SSI = { transfer_state = 725 }
		725 = { add_core_of = SSI }
	}
	if = {
		limit = {
			owns_state = 639 #Gilbert and Sullivan Islands
		}
		SSI = { transfer_state = 639 }
		639 = { add_core_of = SSI }
	}
	if = {
		limit = {
			owns_state = 646 #Mariana Islands
		}
		SSI = { transfer_state = 646 }
		646 = { add_core_of = SSI }
	}
		SSI = { set_cosmetic_tag = SSI_MIC }
			SSI = {
				create_country_leader = {
					name = "Henry Nanpei"
					picture = "gfx/leaders/SSI/Portrait_SSI_Henry_Nanpei.png"
					expire = "1.1.1"
					ideology = tot_clientelism_subtype
				}
				create_country_leader = {
					name = "Henry Nanpei"
					picture = "gfx/leaders/SSI/Portrait_SSI_Henry_Nanpei.png"
					expire = "1.1.1"
					ideology = syn_clientelism_subtype
				}
				create_country_leader = {
					name = "Henry Nanpei"
					picture = "gfx/leaders/SSI/Portrait_SSI_Henry_Nanpei.png"
					expire = "1.1.1"
					ideology = radsoc_clientelism_subtype
				}
				create_country_leader = {
					name = "Antonio B. Won Pat"
					picture = "gfx/leaders/SSI/Portrait_SSI_Antonio_B_Won_Pat.png"
					expire = "1.1.1"
					ideology = socdem_humanistic_capitalism_subtype
				}
				create_country_leader = {
					name = "Joseph Flores"
					picture = "gfx/leaders/SSI/Portrait_SSI_Joseph_Flores.png"
					expire = "1.1.1"
					ideology = soclib_humanistic_capitalism_subtype
				}
				create_country_leader = {
					name = "Joachim DeBrum"
					picture = "gfx/leaders/SSI/Portrait_SSI_Joachim_DeBrum.png"
					expire = "1.1.1"
					ideology = free_market_capitalist_subtype
				}
				create_country_leader = {
					name = "Carl Heine"
					picture = "gfx/leaders/SSI/Portrait_SSI_Carl_Heine.png"
					expire = "1.1.1"
					ideology = christian_democracy_subtype
				}
				create_country_leader = {
					name = "Tem Tekinaiti"
					picture = "gfx/leaders/SSI/Portrait_SSI_Tem_Tekinaiti.png"
					expire = "1.1.1"
					ideology = tribal_chiefdom_subtype
				}
				create_country_leader = {
					name = "Kabua Kabua"
					picture = "gfx/leaders/SSI/Portrait_SSI_Kabua_Kabua.png"
					expire = "1.1.1"
					ideology = pataut_tribal_chiefdom_subtype
				}
				create_country_leader = {
					name = "Kabua Kabua"
					picture = "gfx/leaders/SSI/Portrait_SSI_Kabua_Kabua.png"
					expire = "1.1.1"
					ideology = natpop_tribal_chiefdom_subtype
				}
				set_party_name = {
					ideology = totalist
					name = SSI_MIC_totalist_party
					long_name = SSI_MIC_totalist_party_long
				}
				set_party_name = {
					ideology = syndicalist
					name = SSI_MIC_syndicalist_party
					long_name = SSI_MIC_syndicalist_party_long
				}
				set_party_name = {
					ideology = radical_socialist
					name = SSI_MIC_radical_socialist_party
					long_name = SSI_MIC_radical_socialist_party_long
				}
				set_party_name = {
					ideology = social_democrat
					name = SSI_MIC_social_democrat_party
					long_name = SSI_MIC_social_democrat_party_long
				}
				set_party_name = {
					ideology = social_liberal
					name = SSI_MIC_social_liberal_party
					long_name = SSI_MIC_social_liberal_party_long
				}
				set_party_name = {
					ideology = market_liberal
					name = SSI_MIC_market_liberal_party
					long_name = SSI_MIC_market_liberal_party_long
				}
				set_party_name = {
					ideology = social_conservative
					name = SSI_MIC_social_conservative_party
					long_name = SSI_MIC_social_conservative_party_long
				}
				set_party_name = {
					ideology = authoritarian_democrat
					name = SSI_MIC_authoritarian_democrat_party
					long_name = SSI_MIC_authoritarian_democrat_party_long
				}
				set_party_name = {
					ideology = paternal_autocrat
					name = SSI_MIC_paternal_autocrat_party
					long_name = SSI_MIC_paternal_autocrat_party_long
				}
				set_party_name = {
					ideology = national_populist
					name = SSI_MIC_national_populist_party
					long_name = SSI_MIC_national_populist_party_long
				}
			}
	if = {
		limit = {
			country_exists = SSI
			SSI = { NOT = { has_country_flag = GEA_already_exists } }
		}
		SSI = {
			load_oob = SSI_AFR
			add_to_array = { global.GEA_collapse_tags = THIS }
		}
		#Scramble for Oceania
		JAP = {
			country_event = {
				id = sharedafrika.135
				days = 3 random_days = 3
			}
		}
		PHI = {
			country_event = {
				id = sharedafrika.135
				days = 3 random_days = 3
			}
		}
		USA = {
			country_event = {
				id = sharedafrika.135
				days = 3 random_days = 3
			}
		}
	}

#Southern Islands - give to Papua and rename to Melanesia
	PNG = {
		add_state_core = 635
		add_state_core = 636
		add_state_core = 734
		add_state_core = 725
	}
	if = {
		limit = {
			owns_state = 634 #Solomons
		}
		PNG = { transfer_state = 634 }
	}
	if = {
		limit = {
			owns_state = 737 #Bismarck Archipelago
		}
		PNG = { transfer_state = 737 }
	}
	if = {
		limit = {
			owns_state = 757 #New Guinea
		}
		PNG = { transfer_state = 757 }
	}
	if = {
		limit = {
			owns_state = 734 #Nendo
		}
		PNG = { transfer_state = 734 }
	}
	if = {
		limit = {
			owns_state = 635 #New Caledonia
		}
		PNG = { transfer_state = 635 }
	}
	if = {
		limit = {
			owns_state = 636 #Fiji
		}
		PNG = { transfer_state = 636 }
	}
	if = {
		limit = {
			country_exists = PNG
			PNG = { NOT = { has_country_flag = GEA_already_exists } }
		}
		PNG = {
			set_cosmetic_tag = PNG_MEL
			set_country_flag = PNG_became_melanesia
			create_country_leader = {
				name = "Joe Nalpin"
				picture = "gfx/leaders/SSI/Portrait_SSI_Joe_Nalpin.png"
				expire = "1.1.1"
				ideology = radsoc_cargo_cult_subtype 
			}
			set_party_name = {
				ideology = totalist
				name = PNG_commune_party
				long_name = PNG_commune_party_long
			}
			load_oob = PNG_AFR
			add_to_array = { global.GEA_collapse_tags = THIS }
		}
		if = {
			limit = { tag = CHI }
			country_event = CHI.endgame.043
		}
		#Scramble for Oceania
		AST = {
			country_event = {
				id = sharedafrika.135
				days = 3 random_days = 3
			}
		}
		DEI = {
			country_event = {
				id = sharedafrika.135
				days = 3 random_days = 3
			}
		}
	}
#Hand over Polynesia to Australia
	if = {
		limit = {
			owns_state = 641 #German Polynesia - if New Zealand exists
			country_exists = NZL
		}
		NZL = { transfer_state = 641 }
	}
	if = {
		limit = {
			owns_state = 641 #German Polynesia
		}
		AST = { transfer_state = 641 }
	}
	if = {
		limit = {
			owns_state = 941 #German/western Samoa - if New Zealand exists
			country_exists = NZL
		}
		NZL = { transfer_state = 941 }
	}
	if = {
		limit = {
			owns_state = 941 #German/western Samoa
		}
		AST = { transfer_state = 941 }
	}
#Vietnam
	if = {
		limit = {
			owns_state = 856
		}
		VIN = { transfer_state = 856 }
	}
	if = {
		limit = {
			owns_state = 827
		}
		VIN = { transfer_state = 827 }
	}
	if = {
		limit = {
			owns_state = 857
		}
		VIN = { transfer_state = 857 }
	}
	if = {
		limit = {
			country_exists = VIN
			VIN = { NOT = { has_country_flag = GEA_already_exists } }
		}
		VIN = {
			load_oob = VIN_AFR
			add_to_array = { global.GEA_collapse_tags = THIS }
				country_event = {
					id = vietnam.0 #The Imperial Council Assembles
					days = 2
				}
				country_event = {
					id = sharedafrika.129 #The Emperor's Great Proclamation
					days = 24
				}
				country_event = {
					id = vietnam.27 #The 'End' of the War
					days = 90 random_days = 3
				}
				set_politics = {
					ruling_party = paternal_autocrat
					last_election = "1885.6.9"
					election_frequency = 48
					elections_allowed = no
				}
				unlock_national_focus = VIN_Create_New_Forces
				unlock_national_focus = VIN_Army_Reorganization
				unlock_national_focus = VIN_The_End_Of_War
				set_popularities = {
					totalist = 7
					radical_socialist = 24
					syndicalist = 5
					social_democrat = 18
					social_liberal = 1
					market_liberal = 1
					social_conservative = 11
					authoritarian_democrat = 11
					paternal_autocrat = 12
					national_populist = 10
				}
				retire_country_leader = yes
				create_country_leader = {
					name = "Bao Dai" #Dai Hoang De Be Ha, lol
					desc = "POLITICS_BAO_DAI_DESC"
					picture = "gfx/leaders/VIN/Portrait_Vietnam_Bao_Dai.png"
					expire = "1997.7.30"
					ideology = absolute_monarchy_subtype
				}
			}
		}
	#Indochina Rebels
	if = {
		limit = {
			owns_state = 671
		}
		INC = { transfer_state = 671 }
	}
	if = {
		limit = {
			owns_state = 286
		}
		INC = { transfer_state = 286 }
	}
	if = {
		limit = {
			country_exists = INC
			INC = { NOT = { has_country_flag = GEA_already_exists } }
		}
		delete_unit_template_and_units = {
			division_template = "Indochinesische Schützendivision"
		}
		INC = {
			add_state_core = 671
			add_state_core = 857
			add_state_core = 827
			add_state_core = 286
			add_state_core = 856
			add_state_core = 750
			add_state_core = 825
			load_oob = INC_tet_AFR
			add_to_array = { global.GEA_collapse_tags = THIS }
		}
		INC = {
			country_event = {
				id = viet.0
				days = 1 random_days = 3
			}
		}
	}
	#Laos
	if = {
		limit = {
			owns_state = 670
		}
		LAO = { transfer_state = 670 }
	}
	if = {
		limit = {
			country_exists = LAO
			LAO = { NOT = { has_country_flag = GEA_already_exists } }
		}
		LAO = {
			load_focus_tree = african_monarchy
			load_oob = LAO_AFR
			add_to_array = { global.GEA_collapse_tags = THIS }
			country_event = {
				id = sharedafrika.41
				days = 12 random_days = 3
			}
			country_event = {
				id = sharedafrika.91
				days = 17 random_days = 3
			}
		}
	}
	#Cambodia
	if = {
		limit = {
			owns_state = 826
		}
		CAM = { transfer_state = 826 }
	}
	if = {
		limit = {
			country_exists = CAM
			CAM = { NOT = { has_country_flag = GEA_already_exists } }
		}
		CAM = {
			load_focus_tree = african_monarchy
			add_state_core = 856
			add_state_claim = 286
			load_oob = CAM_AFR
			add_to_array = { global.GEA_collapse_tags = THIS }
			country_event = {
				id = sharedafrika.41
				days = 194 random_days = 3
			}
			country_event = {
				id = sharedafrika.92
				days = 367 random_days = 3
			}
		}
		SIA = {
			CAM = { transfer_state = 825 }
			CAM = { transfer_state = 750 }
		}
	}
	#Cambodia liberation war
	if = {
		limit = {
			country_exists = CAM
			country_exists = SIA
			CAM = { NOT = { has_country_flag = GEA_already_exists } }
		}
		SIA = {
			country_event = {
				id = sharedafrika.85
				days = 2 random_days = 3
			}
		}
		BRM = {
			country_event = {
				id = sharedafrika.87
				days = 6 random_days = 3
			}
		}
	}
	#Sarawak
	if = {
		limit = {
			owns_state = 333
		}
		SAR = { transfer_state = 333 }
		SAR = {
			set_cosmetic_tag = SAR_monarchy
			country_event = {
				id = sharedafrika.41
				days = 2 random_days = 3
			}
		}
	}
	if = {
		limit = {
			owns_state = 828
		}
		SAR = {
			transfer_state = 828
		}
		PHI = {
			add_state_claim = 828
		}
		DEI = {
			country_event = {
				id = sharedafrika.83
				days = 7 random_days = 3
			}
		}
	}
	if = {
		limit = {
			country_exists = SAR
			SAR = { NOT = { has_country_flag = GEA_already_exists } }
		}
		SAR = {
			load_oob = SAR_AFR
			add_to_array = { global.GEA_collapse_tags = THIS }
		}
	}
	#Malaya
	if = {
		limit = {
			owns_state = 830
		}
		SIA = { transfer_state = 830 }
	}
	if = {
		limit = {
			owns_state = 846
		}
		MLY = { transfer_state = 846 }
		MLY = {
			load_oob = MLY_AFR
			hidden_effect = {
				country_event = {
					id = sharedafrika.41
					days = 2
				}
			}
		}
	}
	if = {
		limit = {
			owns_state = 999
		}
		MLY = { transfer_state = 999 }
	}
	if = {
		limit = {
			owns_state = 751
		}
		MLY = { transfer_state = 751 }
	}
	SIA = {
		country_event = {
			id = sharedafrika.86
			days = 365 random_days = 3
		}
	}
	GER = {
		country_event = {
			id = sharedafrika.88
			days = 365 random_days = 3
		}
	}
	#China
	if = {
		limit = {
			country_exists = LEC
			GEA = {
				owns_state = 592
			}
		}
		LEC = { transfer_state = 592 }
		LEC = {
			add_state_core = 592
		}
	}
	if = {
		limit = {
		country_exists = LEC
			GEA = {
				owns_state = 728
			}
		}
		LEC = { transfer_state = 728 }
		LEC = {
			add_state_core = 728
		}
	}
	if = {
		limit = {
			country_exists = LEC
			GEA = {
				owns_state = 802
			}
		}
		LEC = { transfer_state = 802 }
		LEC = {
			add_state_core = 802
		}
	}
	if = {
		limit = {
			country_exists = LEC
			GEA = {
			owns_state = 803
			}
		}
		LEC = { transfer_state = 803 }
		LEC = {
			add_state_core = 803
		}
	}
	if = {
		limit = {
			country_exists = LEC
			GEA = {
				owns_state = 1075
			}
		}
		LEC = { transfer_state = 1075 }
		LEC = {
			add_state_core = 1075
		}
	}
	if = {
		limit = {
			country_exists = LEC
			GEA = {
				owns_state = 744
			}
		}
		LEC = { transfer_state = 744 }
		LEC = {
			add_state_core = 744
		}
	}
	if = {
		limit = {
		country_exists = LEC
			GEA = {
				owns_state = 996
			}
		}
		LEC = { transfer_state = 996 }
		LEC = {
			add_state_core = 996
		}
	}
	if = {
		limit = {
		country_exists = GEA
			GEA = {
				owns_state = 336
			}
		}
		GER = { transfer_state = 336 }
		GER = {
			add_state_claim = 336
		}
	}
	#Anything left, give it to a random neighbor
	every_owned_state = {
		limit = { 
			NOT = {
				state = 336
			}
			any_neighbor_state = {
				NOT = {
					is_owned_by = GEA
					}
				}
			}
		save_event_target_as = giveaway
		random_neighbor_state = {
			limit = { 
				NOT = { 
					is_owned_by = GEA
					}
				}
			owner = {
				transfer_state = event_target:giveaway
			}
		}
	}
	every_owned_state = {
		limit = { 
			NOT = {
				state = 336
			}
			any_neighbor_state = {
				NOT = { is_owned_by = GEA }
				}
			}
		save_event_target_as = giveaway
		random_neighbor_state = {
			limit = {
				NOT = {
					is_owned_by = GEA
					}
				}
			owner = {
				transfer_state = event_target:giveaway
			}
		}
	}
	#Still stuff left? Give it to GER
	if = {
		limit = {
			country_exists = GEA
		}
		every_owned_state = {
			GER = {
				transfer_state = PREV
			}
		}
	}
	#Indochina attacks south and tries to unify Indochina
	INC = {
		declare_war_on = {
			target = VIN
			type = annex_everything
		}
	}
	if = {
		limit = {
			country_exists = INC
			country_exists = CAM
			INC = { NOT = { has_country_flag = GEA_already_exists } }
		}
		INC = {
			country_event = {
				id = sharedafrika.89
				days = 3 random = 2
			}
		}
	}
	if = {
		limit = {
			country_exists = INC
			country_exists = LAO
			INC = { NOT = { has_country_flag = GEA_already_exists } }
		}
		INC = {
			country_event = {
				id = sharedafrika.90
				days = 2 random = 2
			}
		}
	}
	if = {
		limit = {
			country_exists = VIN
			country_exists = LAO
			VIN = { NOT = { has_country_flag = GEA_already_exists } }
		}
		VIN = {
			country_event = {
				id = sharedafrika.90
				days = 2 random = 2
			}
		}
	}
	if = {
		limit = {
			country_exists = VIN
			country_exists = CAM
			VIN = { NOT = { has_country_flag = GEA_already_exists } }
		}
		VIN = {
			country_event = {
				id = sharedafrika.89
				days = 3 random = 2
			}
		}
	}
	every_country = {
		limit = { has_country_flag = GEA_already_exists }
		clr_country_flag = GEA_already_exists
	}
	add_named_threat = {
		threat = 2
		name = Ostasien_collapse
	}
	every_state = {
		limit = { is_core_of = GEA }
		remove_core_of = GEA
	}
	every_state = {
		limit = { is_claimed_by = GEA }
		remove_claim_by = GEA
	}
}



