PAF_collapse = {
	set_global_flag = PAF_collapse
	#First give away any owned states to their controller, if we're at war
	every_owned_state = {
		limit = { NOT = { is_controlled_by = PAF } }
		save_event_target_as = giveaway
		controller = { transfer_state = event_target:giveaway }
	}
	MAF = {
		if = {
			limit = { has_idea = MAF_border_shit_show }
			country_event = portugal_exile.6
		}
	}
	#Now mark all existing breakaways
	every_country = {
		limit = {
			exists = yes
		}
		set_country_flag = PAF_already_exists
	}
	if = {
		limit = {
			owns_state = 321 #Goa
		}
		var:868.owner = { country_event = sharedafrika.131 } #neighbour offered to take
	}
	if = {
		limit = {
			owns_state = 721 #East Timor
		}
		var:1017.owner = { country_event = sharedafrika.131 } #neighbour offered to take
	}
	if = {
		limit = {
			owns_state = 729 #Macao
		}
		var:326.owner = { country_event = sharedafrika.131 } #neighbour offered to take
	}
	if = {
		limit = {
			owns_state = 544 #Northern Mozambique
		}
		var:965.owner = {
			country_event = {
				id = sharedafrika.130
				days = 2 random_days = 3
			}
		}
		MZB = { transfer_state = 544 }
	}
	if = {
		limit = {
			owns_state = 954 #Tete
		}
		var:871.owner = {
			country_event = {
				id = sharedafrika.130
				days = 2 random_days = 3
			}
		}
		MZB = { transfer_state = 954 }
	}
	if = {
		limit = {
			owns_state = 950 #Southern Mozambique
		}
		MZB = { transfer_state = 950 }
		var:545.owner = {
			country_event = {
				id = sharedafrika.130
				days = 2 random_days = 3
			}
		}
		var:275.owner = {
			country_event = {
				id = sharedafrika.130
				days = 2 random_days = 3
			}
		}
	}
	if = {
		limit = {
			owns_state = 738 #Swaziland
		}
		var:275.owner = { country_event = sharedafrika.131 } #neighbour offered to take
	}
	if = {
		limit = {
			owns_state = 914 #Cabinda
		}
		var:928.owner = { country_event = sharedafrika.131 } #neighbour offered to take
	}
	if = {
		limit = {
			owns_state = 916 #Old Kongo
		}
		var:881.owner = { country_event = sharedafrika.131 } #neighbour offered to take
	}
	if = {
		limit = {
			owns_state = 917 #Southern Angola
		}
		ANG= { transfer_state = 917 }
	}
	if = {
		limit = {
			owns_state = 540 #Angola
		}
		ANG = { transfer_state = 540 }
	}
	if = {
		limit = {
			owns_state = 959 #East Angola
		}
		ANG = { transfer_state = 959 }
	}
	if = {
		limit = {
			owns_state = 705 #Sao Tome
		}
		var:297.owner = { country_event = sharedafrika.131 } #neighbour offered to take
	}
	if = {
		limit = {
			owns_state = 296 #Guinea
		}
		var:806.owner = { country_event = sharedafrika.131 } #neighbour offered to take
	}
	if = {
		limit = {
			owns_state = 702 #Cape Verde
		}
		var:272.owner = { country_event = sharedafrika.131 } #neighbour offered to take
	}
	#Anything left, give it to a random neighbor
	every_owned_state = {
		limit = {
			any_neighbor_state = {
				NOT = {
					is_owned_by = PAF
					}
				}
			}
		save_event_target_as = giveaway
		random_neighbor_state = {
			limit = {
				NOT = {
					is_owned_by = PAF
					}
				}
			owner = {
				transfer_state = event_target:giveaway
			}
		}
	}
	every_owned_state = {
		limit = {
			any_neighbor_state = {
				NOT = { is_owned_by = PAF }
			}
		}
		save_event_target_as = giveaway
		random_neighbor_state = {
			limit = {
				NOT = {
					is_owned_by = PAF
					}
				}
			owner = {
				transfer_state = event_target:giveaway
			}
		}
	}
	#Still stuff left? Give it to POR
	if = {
		limit = {
			country_exists = PAF
		}
		every_owned_state = {
			POR = {
				transfer_state = PREV
			}
		}
	}
	every_country = {
		limit = { has_country_flag = PAF_already_exists }
		clr_country_flag = PAF_already_exists
	}
	every_state = {
		limit = { is_core_of = PAF }
		remove_core_of = PAF
	}
	every_state = {
		limit = { is_claimed_by = PAF }
		remove_claim_by = PAF
	}
}