
#MAF big collapse command
#Note that MAF isn't annexed and the player doesn't switch nation so if those are desired effects they must be done separately
increase_ruling_party_popularity_by_1 = {
	set_temp_variable = { ideology_change_var = 0.01 }
	add_popularity = {
		ideology = var:current_party_ideology_group
		popularity = ideology_change_var
	}
}
decrease_ruling_party_popularity_by_1 = {
	set_temp_variable = { ideology_change_var = -0.01 }
	add_popularity = {
		ideology = var:current_party_ideology_group
		popularity = ideology_change_var
	}
}
#Mittelafrika Collapse Event - KEY EFFECT
MAF_collapse = {
	MAF = {
		MAF_unit_leader_transfer = yes
	}
	every_country = {
		limit = { is_subject_of = MAF }
		separate_peace_all_wars = yes
	}
	separate_peace_all_wars = yes
	every_state = {
		limit = { is_core_of = MAF }
		set_state_flag = MAF_claim
	}
	every_state = {
		limit = { is_claimed_by = MAF }
		set_state_flag = MAF_claim
	}
	every_state = {
		limit = { is_core_of = CIV }
		set_state_flag = MAF_claim
	}
	every_state = {
		limit = { is_core_of = IVO }
		set_state_flag = MAF_claim
	}
	every_state = {
		limit = { is_core_of = BRT }
		set_state_flag = MAF_claim
	}
	every_state = {
		limit = { is_core_of = BSC }
		set_state_flag = MAF_claim
	}
	every_state = {
		limit = { is_core_of = UGA }
		set_state_flag = MAF_claim
	}
	every_state = {
		limit = { is_core_of = CEA }
		set_state_flag = MAF_claim
	}
	every_state = {
		limit = { is_core_of = MLW }
		set_state_flag = MAF_claim
	}
	every_state = {
		limit = { is_core_of = ZAM }
		set_state_flag = MAF_claim
	}
	every_state = {
		limit = { is_core_of = GHA }
		set_state_flag = MAF_claim
	}
	every_state = {
		limit = { is_core_of = KTG }
		set_state_flag = MAF_claim
	}
	every_state = {
		limit = { is_core_of = NGR }
		set_state_flag = MAF_claim
	}
	every_state = {
		limit = { is_core_of = KEN }
		set_state_flag = MAF_claim
	}
	every_state = {
		limit = { is_core_of = COG }
		set_state_flag = MAF_claim
	}

	#Set the global flag
	set_global_flag = MAF_collapse

	#World tension
	country_event = worldtension.13

	#News event
	random_other_country = {
		news_event = { id = worldnews.120 days = 1 }
	}
	
	#First give away any owned states to their controller, if we're at war
	every_owned_state = {
		limit = { NOT = { is_controlled_by = MAF } }
		save_event_target_as = giveaway
		controller = { transfer_state = event_target:giveaway }
	}

	#Now mark all existing breakaways
	every_country = {
		limit = {
			exists = yes
			is_in_africa = yes
		}
		set_country_flag = MAF_already_exists
	}

	#Special people
	MAF = {
		every_unit_leader = {
			limit = { has_unit_leader_flag = NMB_leader_flag }
			set_nationality = NMB
		}
	}
	NMB = {
		random_unit_leader = {
			limit = { has_id = 22992 }
			promote_leader = yes
		}
	}
	if = {
		limit = { owns_state = 541 }
		NMB = { transfer_state = 541 }
	}
	if = {
		limit = {
			country_exists = NMB
			NMB = { NOT = { has_country_flag = MAF_already_exists } }
		}
		MAF = { NMB = { transfer_technology = yes } }
		NMB = {
			add_to_array = { global.MAF_collapse_tags = THIS }
		}
	}
	
#Give events to neighbours
every_country = {
	limit = {
		OR = {
				tag = POR
				tag = PAF
				tag = SUD
				tag = EGY
				tag = NFA
				tag = SFA
				tag = LIB
				tag = SIE
				tag = ETH
				tag = SOM
				tag = SAF
				tag = ZIM
				tag = SFR
				tag = SFR
				tag = CAR
		}
	}
	country_event = {
		id = sharedafrika.70
		days = 1 random_days = 3
	}
}

#Release Congo
	if = {
		limit = {
			NOT = {
				country_exists = COG
			}
		}
		release = COG
	}
	COG = {
		country_event = {
			id = conbel.1
			days = 1 random_days = 3
		}
		random_owned_state = {
			add_building_construction = {
				type = industrial_complex
				level = -1
				instant_build = yes
			}
		}
		random_owned_state = {
			add_building_construction = {
				type = industrial_complex
				level = -1
				instant_build = yes
			}
		}
	}
	every_owned_state = {
		limit = {
			OR = {
				state = 546
				state = 899
				state = 918
				state = 965
				state = 1032
			}
		}
		TZN = { transfer_state = PREV }
	}
	MAF = {
		every_unit_leader = {
			limit = { has_unit_leader_flag = TZN_leader_flag }
			set_nationality = TZN
		}
	}
	if = {
		limit = {
			country_exists = TZN
			TZN = { NOT = { has_country_flag = MAF_already_exists } }
		}
		MAF = { TZN = { transfer_technology = yes } }
		TZN = {
			set_cosmetic_tag = TZN_GER
			load_oob = TZN
			load_oob = TZN_naval
			add_to_array = { global.MAF_collapse_tags = THIS }
		}
	}
	
	#Portugal stealing back their shit if MAF didn't take it all already
	if = {
		limit = {
			owns_state = 954
			PAF = { owns_state = 950 }
		}
		PAF = {
			transfer_state = 954
		}
	}
	if = {
		limit = {
			owns_state = 544
			PAF = { owns_state = 950 }
		}
		PAF = {
			transfer_state = 544
		}
	}
	if = {
		limit = {
			owns_state = 914
			PAF = { owns_state = 540 }
		}
		PAF = {
			transfer_state = 914
		}
	}
	if = {
		limit = {
			owns_state = 916
			PAF = { owns_state = 540 }
		}
		PAF = {
			transfer_state = 916
		}
	}
	if = {
		limit = {
			owns_state = 705
			PAF = { owns_state = 540 }
		}
		PAF = {
			transfer_state = 705
		}
	}
	if = {
		limit = {
			owns_state = 959
			PAF = { owns_state = 540 }
		}
		PAF = {
			transfer_state = 959
		}
	}
	
	#If at war with Liberia, they get their claims in the Ivory coast
	if = {
		limit = {
			IVO = { owns_state = 807 }
			LIB = {
				owns_state = 966
				has_war_with = IVO
			}
		}
		LIB = {
			transfer_state = 807
			country_event = mittel.188
		}
	}
	if = {
		limit = {
			IVO = { owns_state = 963 }
			LIB = {
				owns_state = 807
				has_war_with = IVO
			}
		}
		LIB = {
			transfer_state = 963
		}
	}
	
	if = {
		limit = {
			CIV = { owns_state = 807 }
			LIB = {
				owns_state = 966
				has_war_with = CIV
			}
		}
		LIB = {
			transfer_state = 807
			country_event = mittel.188
		}
	}
	if = {
		limit = {
			CIV = { owns_state = 963 }
			LIB = {
				owns_state = 807
				has_war_with = CIV
			}
		}
		LIB = {
			transfer_state = 963
		}
	}
	#Time to unleash chaos
	if = {
		limit = {
			owns_state = 274
		}
		GHA = { transfer_state = 274 }
	}
	if = {
		limit = {
			owns_state = 1321
		}
		GHA = { transfer_state = 1321 }
	}
	if = {
		limit = {
			owns_state = 1322
		}
		GHA = { transfer_state = 1322 }
	}
	if = {
		limit = {
			owns_state = 1323
		}
		GHA = { transfer_state = 1323 }
	}
	if = {
		limit = {
			country_exists = GHA
			GHA = { NOT = { has_country_flag = MAF_already_exists } }
		}
		GHA = {
			add_state_core = 963
			add_to_array = { global.MAF_collapse_tags = THIS }
		}
	}
	if = {
		limit = {
			country_exists = GHA #
			GHA = { has_country_flag = MAF_already_exists }
			GHA = { 
			NOT = {
				has_cosmetic_tag = GHA_GBR
				}
			}
		}
		GHA = {
			country_event = {
				id = sharedafrika.53 #collapse event as already independent
				days = 1
				random_days = 4
			}
		random_owned_state = {
			add_building_construction = {
				type = industrial_complex
				level = -1
				instant_build = yes
			}
		}
		random_owned_state = {
			add_building_construction = {
				type = industrial_complex
				level = -1
				instant_build = yes
			}
		}
		}
	}
	if = {
		limit = {
			country_exists = GHA #
			GHA = { has_country_flag = MAF_already_exists }
			GHA = { 
				has_cosmetic_tag = GHA_GBR
			}
		}
		GHA = {
			country_event = {
				id = sharedafrika.68 #collapse event as already independent
				days = 1
				random_days = 4
			}
		random_owned_state = {
			add_building_construction = {
				type = industrial_complex
				level = -1
				instant_build = yes
			}
		}
		random_owned_state = {
			add_building_construction = {
				type = industrial_complex
				level = -1
				instant_build = yes
			}
		}
		}
	}
	if = {
		limit = {
			owns_state = 877
		}
		TOG = { transfer_state = 877 }
	}
	if = {
		limit = {
			country_exists = TOG
			TOG = { NOT = { has_country_flag = MAF_already_exists } }
		}
		TOG = {
			load_oob = TOG
			add_to_array = { global.MAF_collapse_tags = THIS }
		}
	}
	if = {
		limit = {
			owns_state = 876
		}
		DAH = { transfer_state = 876 }
	}
	if = {
		limit = {
			country_exists = DAH
			DAH = { NOT = { has_country_flag = MAF_already_exists } }
		}
		DAH = {
			load_oob = DAH
			add_to_array = { global.MAF_collapse_tags = THIS }
		}
	}
	if = {
		limit = {
			country_exists = DAH #
			DAH = { has_country_flag = MAF_already_exists }
		}
		DAH = {
			country_event = {
				id = sharedafrika.53 #collapse event
				days = 1
				random_days = 4
			}
		}
	}
	if = {
		limit = {
			country_exists = CIV #
			CIV = { has_country_flag = MAF_already_exists }
		}
		CIV = {
			country_event = {
				id = sharedafrika.69 #collapse event
				days = 2
				random_days = 4
			}
			random_owned_state = {
				add_building_construction = {
					type = industrial_complex
					level = -1
					instant_build = yes
				}
			}
			random_owned_state = {
				add_building_construction = {
					type = industrial_complex
					level = -1
					instant_build = yes
				}
			}
		}
	}
	MAF = {
		every_unit_leader = {
			limit = { has_unit_leader_flag = CMR_leader_flag }
			set_nationality = CMR
		}
	}
	CMR = {
		random_unit_leader = {
			limit = { has_id = 21998 }
			promote_leader = yes
		}
	}
	if = {
		limit = {
			owns_state = 927
		}
		CMR = { transfer_state = 927 }
	}
	if = {
		limit = {
			country_exists = CMR
			CMR = { NOT = { has_country_flag = MAF_already_exists } }
		}
		CMR = {
			set_cosmetic_tag = CMR_GER
			add_to_array = { global.MAF_collapse_tags = THIS }
		}
	}
	if = {
		limit = {
			country_exists = ADW #
			ADW = { has_country_flag = MAF_already_exists }
		}
		ADW = {
			country_event = {
				id = sharedafrika.53 #collapse event
				days = 1
				random_days = 4
			}
		}
	}
	if = {
		limit = {
			country_exists = CMR #
			CMR = { has_country_flag = MAF_already_exists }
		}
		CMR = {
			country_event = {
				id = sharedafrika.73 #collapse event
				days = 1
				random_days = 4
			}
			random_owned_state = {
				add_building_construction = {
					type = industrial_complex
					level = -1
					instant_build = yes
				}
			}
			random_owned_state = {
				add_building_construction = {
					type = industrial_complex
					level = -1
					instant_build = yes
				}
			}
		}
	}
	if = {
		limit = {
			NOT = {
				has_global_flag = ADW_revolt_already_happened 
				country_exists = ADW
			}
		}
		ADW = {	#
		add_to_array = { global.MAF_collapse_tags = THIS }
			#State
			transfer_state = 952
			add_state_core = 952	
			transfer_state = 971
			add_state_core = 971
			transfer_state = 974
			add_state_core = 974
			transfer_state = 962
			add_state_core = 962
			set_cosmetic_tag = ADW
			load_oob = ADW
		}
	}
	if = {
		limit = {
			country_exists = CMR
			CMR = { NOT = { has_country_flag = MAF_already_exists } }
		}
		CMR = {
			add_state_core = 952
			add_state_core = 971
			add_state_core = 927
			add_to_array = { global.MAF_collapse_tags = THIS }
		}
	}
	every_owned_state = {
		limit = {
			OR = {
				state = 558 #Southern Nigeria
				state = 662 #Northern Nigeria
				state = 973 #Lagos
			}
		}
		NGR = { transfer_state = PREV }
	}
	if = {
		limit = {
			country_exists = NGR
			NGR = { NOT = { has_country_flag = MAF_already_exists } }
		}
		NGR = {
			add_to_array = { global.MAF_collapse_tags = THIS }
		}
	}
	if = {
		limit = {
			country_exists = NGR
			NGR = { has_country_flag = MAF_already_exists }
			NGR = {
				has_cosmetic_tag = NGR_IND
			}
		}
		NGR = {
			country_event = {
				id = nig.1 #happening
				days = 2
			}
		}
		NGR = {
			country_event = {
				id = sharedafrika.53 #
				days = 3
				random_days = 4
			}
		}
	}
	if = {
		limit = {
			country_exists = NGR
			NGR = { has_country_flag = MAF_already_exists }
			NGR = {
				NOT = {
					has_cosmetic_tag = NGR_IND
				}
			}
		}
		NGR = {
			country_event = {
				id = nig.1 #happening
				days = 2
			}
		random_owned_state = {
			add_building_construction = {
				type = industrial_complex
				level = -1
				instant_build = yes
			}
		}
		random_owned_state = {
			add_building_construction = {
				type = industrial_complex
				level = -1
				instant_build = yes
			}
		}
		}
		NGR = {
			country_event = {
				id = sharedafrika.52 #collapse event
				days = 3
				random_days = 4
			}
		}
	}
	if = {
		limit = {
			owns_state = 878
		}
		HAU = { transfer_state = 878 }
	}
	if = {
		limit = {
			country_exists = HAU
			HAU = { NOT = { has_country_flag = MAF_already_exists } }
			NGR = { NOT = { has_country_flag = NGR_no_collapse } }
		}
		HAU = {
			add_state_core = 878
			load_oob = HAU
			add_to_array = { global.MAF_collapse_tags = THIS }
		}
	}
	if = {
		limit = {
			country_exists = HAU
			HAU = { has_country_flag = MAF_already_exists }
		}
		HAU = {
			country_event = {
				id = sharedafrika.53 #collapse event
				days = 1
				random_days = 7
			}
		}
	}
	every_owned_state = {
		limit = {
			OR = {
				state = 539
				state = 297
			}
		}
		GAB = { transfer_state = PREV }
	}
	if = {
		limit = {
			country_exists = GAB
			GAB = { NOT = { has_country_flag = MAF_already_exists } }
		}
		GAB = {
			add_to_array = { global.MAF_collapse_tags = THIS }
		}
	}
	if = {
		limit = {
			country_exists = GAB
			GAB = { has_country_flag = MAF_already_exists }
		}
		GAB = {
			country_event = {
				id = sharedafrika.53 #collapse event
				days = 1
				random_days = 7
			}
		}
	}
	every_owned_state = {
		limit = {
			OR = {
				state = 962
				state = 913
			}
		}
		KBR = { transfer_state = PREV }
	}
	if = {
		limit = {
			country_exists = KBR
			KBR = { NOT = { has_country_flag = MAF_already_exists } }
		}
		KBR = {
			add_state_core = 962
			add_state_core = 913
			load_oob = KBR
			add_to_array = { global.MAF_collapse_tags = THIS }
		}
	}
	if = {
		limit = {
			country_exists = KBR
			KBR = { has_country_flag = MAF_already_exists }
		}
		KBR = {
			country_event = {
				id = sharedafrika.53 #collapse event
				days = 1
				random_days = 7
			}
		}
	}
	every_owned_state = {
		limit = {
			OR = {
				state = 881
				state = 928
				state = 295
				state = 914
				state = 916
				state = 953
			}
		}
		KOG = { transfer_state = PREV }
	}
	if = {
		limit = {
			country_exists = KOG
			KOG = { NOT = { has_country_flag = MAF_already_exists } }
		}
		KOG = {
		load_oob = KOG
			if = {
				limit = {
					owns_state = 914
				}
				add_state_core = 914
			}
			if = {
				limit = {
					owns_state = 916
				}
				add_state_core = 916
			}
			add_to_array = { global.MAF_collapse_tags = THIS }
		}
	}
	if = {
		limit = {
			country_exists = KOG
			KOG = { has_country_flag = MAF_already_exists }
			NOT = {
				KOG = {
					has_country_leader = { name = "Curt von Haase" }
				}
			}
		}
		KOG = {
			country_event = {
				id = sharedafrika.53 #collapse event
				days = 1
				random_days = 7
			}
		}
	}
	if = { #German Kongo
		limit = {
			country_exists = KOG
			KOG = { has_country_flag = MAF_already_exists }
			KOG = {
				has_country_leader = { name = "Curt von Haase" }
			}
		}
		KOG = {
			country_event = {
				id = sharedafrika.54 #collapse event
				days = 1
				random_days = 7
			}
		random_owned_state = {
			add_building_construction = {
				type = industrial_complex
				level = -1
				instant_build = yes
			}
		}
		random_owned_state = {
			add_building_construction = {
				type = industrial_complex
				level = -1
				instant_build = yes
			}
		}
		}
	}
	every_owned_state = {
		limit = {
			OR = {
				state = 953
				state = 974
			}
		}
		TKE = { transfer_state = PREV }
	}
	if = {
		limit = {
			country_exists = TKE
			TKE = { NOT = { has_country_flag = MAF_already_exists } }
		}
		TKE = {
			add_state_core = 953
			add_state_core = 974
			load_oob = TKE
			add_to_array = { global.MAF_collapse_tags = THIS }
		}
		MAF = { TKE = { transfer_technology_without_doctrines = yes } }
	}
	if = {
		limit = {
			country_exists = TKE
			TKE = { has_country_flag = MAF_already_exists }
		}
		TKE = {
			country_event = {
				id = sharedafrika.53 #collapse event
				days = 1
				random_days = 7
			}
		}
	}
	if = {
		limit = {
			country_exists = NBL
			NBL = { has_country_flag = MAF_already_exists }
		}
		NBL = {
			country_event = {
				id = sharedafrika.53 #collapse event
				days = 1
				random_days = 7
			}
		}
	}
	if = {
		limit = {
			country_exists = NMB
			NMB = { NOT = { has_country_flag = MAF_already_exists } }
		}
		MAF = { NMB = { transfer_technology = yes } }
		NMB = {
			set_cosmetic_tag = NMB_GER
			if = { 
				limit = { 
					NOT = { has_dlc = "No Step Back" }
				}
				load_oob = NMB
			}
			if = { 
				limit = { 
					has_dlc = "No Step Back"
				}
				load_oob = NMB_NSB
			}
			
			remove_state_core = 964
			add_state_claim = 964
			add_to_array = { global.MAF_collapse_tags = THIS }
		}
		MAF = { NMB = { transfer_technology_without_doctrines = yes } }
	}
	if = {
		limit = {
			country_exists = NMB
			NMB = { has_country_flag = MAF_already_exists }
		}
		NMB = {
			country_event = {
				id = sharedafrika.55 #collapse event
				days = 1
				random_days = 7
			}
		random_owned_state = {
			add_building_construction = {
				type = industrial_complex
				level = -1
				instant_build = yes
			}
		}
		random_owned_state = {
			add_building_construction = {
				type = industrial_complex
				level = -1
				instant_build = yes
			}
		}
		}
	}
	every_owned_state = {
		limit = {
			OR = {
				state = 660
				state = 975
			}
		}
		CEA = { transfer_state = PREV }
	}
	every_owned_state = {
		limit = {
			state = 971
		}
		CEA = { add_state_core = PREV }
	}
	if = {
		limit = {
			country_exists = CEA
			CEA = { NOT = { has_country_flag = MAF_already_exists } }
		}
		CEA = {
			add_to_array = { global.MAF_collapse_tags = THIS }
		}
		MAF = { CEA = { transfer_technology_without_doctrines = yes } }
	}
	if = {
		limit = {
			country_exists = CEA #all non-German CEAs
			CEA = {
				NOT = {
					has_country_flag = revoltsuppressed
				}
			}
			CEA = { has_country_flag = MAF_already_exists }
		}
		CEA = {
			country_event = {
				id = sharedafrika.53 #collapse event
				days = 1
				random_days = 7
			}
		}
	}
	if = {
		limit = {
			country_exists = CEA #German CEA
			CEA = {
				has_country_flag = revoltsuppressed
			}
			CEA = { has_country_flag = MAF_already_exists }
		}
		CEA = {
			country_event = {
				id = sharedafrika.56 #collapse event
				days = 1
				random_days = 7
			}
		random_owned_state = {
			add_building_construction = {
				type = industrial_complex
				level = -1
				instant_build = yes
			}
		}
		random_owned_state = {
			add_building_construction = {
				type = industrial_complex
				level = -1
				instant_build = yes
			}
		}
		}
	}
	every_owned_state = {
		limit = {
			OR = {
				state = 548
				state = 918
			}
		}
		UGA = { transfer_state = PREV }
	}
	if = {
		limit = {
			country_exists = UGA
			UGA = { NOT = { has_country_flag = MAF_already_exists } }
		}
		UGA = {
			add_state_core = 548
			add_state_core = 918
			add_to_array = { global.MAF_collapse_tags = THIS }
		}
		MAF = { UGA = { transfer_technology_without_doctrines = yes } }
	}
	if = {
		limit = {
			country_exists = UGA #Uganda
			UGA = { has_country_flag = MAF_already_exists }
		}
		UGA = {
			country_event = {
				id = sharedafrika.58 #collapse event
				days = 1
				random_days = 4
			}
		random_owned_state = {
			add_building_construction = {
				type = industrial_complex
				level = -1
				instant_build = yes
			}
		}
		random_owned_state = {
			add_building_construction = {
				type = industrial_complex
				level = -1
				instant_build = yes
			}
		}
		}
	}
	every_owned_state = {
		limit = {
			OR = {
				state = 547
				state = 925
				state = 969
				state = 970
				state = 892
			}
		}
		KEN = { transfer_state = PREV }
	}
	if = {
		limit = {
			country_exists = KEN #Kenya
			KEN = { has_country_flag = MAF_already_exists }
			KEN = {
				has_government = national_populist
			}
		}
		KEN = {
			country_event = {
				id = sharedafrika.53 #collapse event
				days = 1
				random_days = 4
			}
		}
	}
	if = {
		limit = {
			country_exists = KEN #Kenya
			NOT = {
				country_exists = KIK
			}
		}
		KEN = {
			country_event = {
				id = ugken.1 #Mau Mau second uprising
				days = 3 random_days = 3
			}
		}
	}
	if = {
		limit = {
			country_exists = BRD #BRD/Urundi
			BRD = { has_country_flag = MAF_already_exists }
			BRD = {
				has_cosmetic_tag = BRD_GERMAN
			}
		}
		BRD = {
			country_event = {
				id = sharedafrika.116 #collapse event
				days = 1
				random_days = 4
			}
		random_owned_state = {
			add_building_construction = {
				type = industrial_complex
				level = -1
				instant_build = yes
			}
		}
		random_owned_state = {
			add_building_construction = {
				type = industrial_complex
				level = -1
				instant_build = yes
			}
		}
		}
	}
	if = {
		limit = {
			country_exists = KEN #Kenya
			KEN = { has_country_flag = MAF_already_exists }
			KEN = {
				NOT = {
					has_government = national_populist
				}
			}
		}
		KEN = {
			country_event = {
				id = sharedafrika.59 #collapse event
				days = 1
				random_days = 4
			}
		random_owned_state = {
			add_building_construction = {
				type = industrial_complex
				level = -1
				instant_build = yes
			}
		}
		random_owned_state = {
			add_building_construction = {
				type = industrial_complex
				level = -1
				instant_build = yes
			}
		}
		}
	}
	every_owned_state = {
		limit = {
			OR = {
				state = 905
			}
		}
		ZZB = { transfer_state = PREV }
	}
	if = {
		limit = {
			country_exists = ZZB
			ZZB = { NOT = { has_country_flag = MAF_already_exists } }
		}
		ZZB = {
			add_state_core = 905
			add_state_core = 970
			load_oob = ZZB
			load_oob = ZZB_naval
			add_to_array = { global.MAF_collapse_tags = THIS }
		}
		MAF = { ZZB = { transfer_technology_without_doctrines = yes } }
	}
	if = {
		limit = {
			country_exists = ZZB #Zanzibar
			ZZB = { has_country_flag = MAF_already_exists }
			ZZB = {
				has_completed_focus = ZZB_thezanzadeclaration
			}
		}
		ZZB = {
			country_event = {
				id = sharedafrika.53 #collapse event
				days = 1
				random_days = 4
			}
		}
	}
	if = {
		limit = {
			country_exists = ZZB #Zanzibar
			ZZB = { has_country_flag = MAF_already_exists }
			ZZB = {
			NOT = {
				has_completed_focus = ZZB_thezanzadeclaration
				}
			}
		}
		ZZB = {
			country_event = {
				id = sharedafrika.61 #collapse event
				days = 1
				random_days = 4
			}
		random_owned_state = {
			add_building_construction = {
				type = industrial_complex
				level = -1
				instant_build = yes
			}
		}
		}
	}
	every_owned_state = {
		limit = {
			OR = {
				state = 869
				state = 948
			}
		}
		RWA = { transfer_state = PREV }
	}
	if = {
		limit = {
			country_exists = RWA
			RWA = { NOT = { has_country_flag = MAF_already_exists } }
		}
		RWA = {
			add_state_core = 948
			load_oob = RWA
			add_to_array = { global.MAF_collapse_tags = THIS }
		}
		MAF = { RWA = { transfer_technology_without_doctrines = yes } }
	}
	if = {
		limit = {
			country_exists = RWA #Rwanda
			RWA = { has_country_flag = MAF_already_exists }
		}
		RWA = {
			country_event = {
				id = sharedafrika.53 #collapse event
				days = 1
				random_days = 4
			}
		random_owned_state = {
			add_building_construction = {
				type = industrial_complex
				level = -1
				instant_build = yes
			}
		}
		}
	}
	if = {
		limit = {
			owns_state = 870
		}
		BRD = { transfer_state = 870 }
	}
	if = {
		limit = {
			country_exists = BRD
			BRD = { NOT = { has_country_flag = MAF_already_exists } }
		}
		BRD = {
			load_oob = BRD
			add_to_array = { global.MAF_collapse_tags = THIS }
		}
		MAF = { BRD = { transfer_technology_without_doctrines = yes } }
	}
	if = {
		limit = {
			country_exists = BRD #Burundi
			BRD = { has_country_flag = MAF_already_exists }
		}
		BRD = {
			country_event = {
				id = sharedafrika.53 #collapse event
				days = 1
				random_days = 4
			}
		}
	}
	every_owned_state = {
		limit = {
			OR = {
				state = 958
				state = 957
			}
		}
		BRT = { transfer_state = PREV }
	}
	if = {
		limit = {
			country_exists = BRT
			BRT = { NOT = { has_country_flag = MAF_already_exists } }
		}
		BRT = {
			add_state_core = 958
			add_state_core = 957
			add_to_array = { global.MAF_collapse_tags = THIS }
		}
		MAF = { BRT = { transfer_technology_without_doctrines = yes } }
	}
	if = {
		limit = {
			country_exists = BRT #Barotseland
			BRT = { has_country_flag = MAF_already_exists }
		}
		BRT = {
			country_event = {
				id = sharedafrika.53 #collapse event
				days = 1
				random_days = 4
			}
		}
	}
	every_owned_state = {
		limit = {
			OR = {
				state = 956
			}
		}
		BSC = { transfer_state = PREV }
	}
	if = {
		limit = {
			country_exists = BSC
			BSC = { NOT = { has_country_flag = MAF_already_exists } }
		}
		BSC = {
			add_state_core = 956
			add_to_array = { global.MAF_collapse_tags = THIS }
		}
	}
	if = {
		limit = {
			country_exists = BSC #BSAC
			BSC = { has_country_flag = MAF_already_exists }
		}
		BSC = {
			country_event = {
				id = sharedafrika.63 #collapse event
				days = 1
				random_days = 4
			}
			random_owned_state = {
				add_building_construction = {
					type = industrial_complex
					level = -1
					instant_build = yes
				}
			}
			random_owned_state = {
				add_building_construction = {
					type = industrial_complex
					level = -1
					instant_build = yes
				}
			}
		}
	}
	every_owned_state = {
		limit = {
			OR = {
				state = 813
			}
		}
		ZAM = { transfer_state = PREV }
	}
	ZAM = {
		country_event = {
			id = nrho.1
			days = 1
		}
	}
	if = {
		limit = {
			country_exists = ZAM
			ZAM = { NOT = { has_country_flag = MAF_already_exists } }
		}
		ZAM = {
			load_oob = ZAM
			add_to_array = { global.MAF_collapse_tags = THIS }
		}
		MAF = { ZAM = { transfer_technology_without_doctrines = yes } }
	}
	if = {
		limit = {
			country_exists = ZAM #ZAM
			ZAM = { has_country_flag = MAF_already_exists }
		}
		ZAM = {
			country_event = {
				id = sharedafrika.64 #collapse event
				days = 2
				random_days = 3
			}
		random_owned_state = {
			add_building_construction = {
				type = industrial_complex
				level = -1
				instant_build = yes
			}
		}
		random_owned_state = {
			add_building_construction = {
				type = industrial_complex
				level = -1
				instant_build = yes
			}
		}
		}
	}
	every_owned_state = {
		limit = {
			OR = {
				state = 955
				state = 871
				state = 954
			}
		}
		MLW = { transfer_state = PREV }
	}
	if = {
		limit = {
			country_exists = MLW
			MLW = { NOT = { has_country_flag = MAF_already_exists } }
		}
		MLW = {
			add_state_core = 813
			add_state_core = 954
			add_state_core = 955
			add_to_array = { global.MAF_collapse_tags = THIS }
		}
		MAF = { MLW = { transfer_technology_without_doctrines = yes } }
	}
	if = {
		limit = {
			country_exists = MLW #MLW
			MLW = { has_country_flag = MAF_already_exists }
			NOT = {
				has_country_leader = {
					name = "Shenton Thomas"
					ruling_only = yes
				}
			}
		}
		MLW = {
			country_event = {
				id = sharedafrika.53 #collapse event as already independent
				days = 1
				random_days = 4
			}
		}
	}
	if = {
		limit = {
			country_exists = MLW #MLW
			MLW = { has_country_flag = MAF_already_exists }
			has_country_leader = {
				name = "Shenton Thomas"
				ruling_only = yes
			}
		}
		MLW = {
			country_event = {
				id = sharedafrika.66 #collapse event if still colony
				days = 1
				random_days = 4
			}
		random_owned_state = {
			add_building_construction = {
				type = industrial_complex
				level = -1
				instant_build = yes
			}
		}
		random_owned_state = {
			add_building_construction = {
				type = industrial_complex
				level = -1
				instant_build = yes
			}
		}
		}
	}
	if = {
		limit = {
			owns_state = 807
			owns_state = 963
		}
		IVO = { transfer_state = 807 }
		IVO = { transfer_state = 963 }
	}
	if = {
		limit = {
			country_exists = IVO
			IVO = { NOT = { has_country_flag = MAF_already_exists } }
		}
		IVO = {
			add_to_array = { global.MAF_collapse_tags = THIS }
		}
		MAF = { IVO = { transfer_technology_without_doctrines = yes } }
	}
	if = {
		limit = {
			country_exists = IVO #
			IVO = { has_country_flag = MAF_already_exists }
				has_country_leader = {
				name = "Félix Houphouët-Boigny"
				ruling_only = yes
			}
		}
		IVO = {
			country_event = {
				id = sharedafrika.53 #collapse event as already independent
				days = 1
				random_days = 4
			}
		}
	}
	if = {
		limit = {
			country_exists = IVO #
			IVO = { has_country_flag = MAF_already_exists }
			NOT = {
				has_country_leader = {
					name = "Félix Houphouët-Boigny"
					ruling_only = yes
				}
			}
		}
		IVO = {
			country_event = {
				id = sharedafrika.67 #collapse event
				days = 1
				random_days = 4
			}
		random_owned_state = {
			add_building_construction = {
				type = industrial_complex
				level = -1
				instant_build = yes
			}
		}
		random_owned_state = {
			add_building_construction = {
				type = industrial_complex
				level = -1
				instant_build = yes
			}
		}
		}
	}

	#And the chaos from POR lands as well
	every_owned_state = {
		limit = {
			OR = {
				state = 950
				state = 954
				state = 544
			}
		}
		MZB = { transfer_state = PREV }
	}
	if = {
		limit = {
			country_exists = MZB
			MZB = { NOT = { has_country_flag = MAF_already_exists } }
		}
		MZB = {
			load_oob = MZB
			add_to_array = { global.MAF_collapse_tags = THIS }
		}
	}
	every_owned_state = {
		limit = {
			OR = {
				state = 540
				state = 917
				state = 959
			}
		}
		ANG = { transfer_state = PREV }
	}
	if = {
		limit = {
			country_exists = ANG
			ANG = { NOT = { has_country_flag = MAF_already_exists } }
		}
		ANG = {
			load_oob = ANG
			add_to_array = { global.MAF_collapse_tags = THIS }
		}
	}

	#Release LIB if they got annexed before
	every_owned_state = {
		limit = {
			OR = {
				state = 298
				state = 966
			}
		}
		LIB = {
			transfer_state = PREV
			random_owned_state = {
				add_building_construction = {
					type = industrial_complex
					level = -1
					instant_build = yes
				}
			}
		}
	}
	if = {
		limit = {
			country_exists = LIB
			LIB = { NOT = { has_country_flag = MAF_already_exists } }
		}
		LIB = {
			add_state_core = 298
			add_state_core = 966
			add_to_array = { global.MAF_collapse_tags = THIS }
		}
	}
	
	#Anything left, give it to a random neighbor
	every_owned_state = {
		limit = { any_neighbor_state = { NOT = { is_owned_by = MAF } } }
		save_event_target_as = giveaway
		random_neighbor_state = {
			limit = { NOT = { is_owned_by = MAF } }
			owner = { transfer_state = event_target:giveaway }
		}
	}
	every_owned_state = {
		limit = { any_neighbor_state = { NOT = { is_owned_by = MAF } } }
		save_event_target_as = giveaway
		random_neighbor_state = {
			limit = { NOT = { is_owned_by = MAF } }
			owner = { transfer_state = event_target:giveaway }
		}
	}

	#Extra Wars duct tape
	if = {
		limit = {
			country_exists = BRT
			}
		BRT = {
			declare_war_on = {
				target = ZAM
				type = annex_everything
			}
		}
	}
	if = {
		limit = {
			country_exists = BRT
			}
		BRT = {
			declare_war_on = {
				target = BSC
				type = annex_everything
			}
		}
	}
	
	MSF = {
		declare_war_on = {
			target = COG
			type = annex_everything
		}
	}
	
	KIV = {
		declare_war_on = {
			target = COG
			type = annex_everything
		}
	}
	if = {
		limit = {
		LPD = { NOT = { is_in_faction_with = COG } }
		}
	LPD = {
		declare_war_on = {
			target = COG
			type = annex_everything
			}
		}
	}
	
	if = {
		limit = {
		UMN = { NOT = { is_in_faction_with = COG } }
		}
	UMN = {
			declare_war_on = {
			target = COG
			type = annex_everything
			}
		}
	}
	
	if = {
	limit = {
	TZN = {
	has_war_with = COG
		}
	}
	TZN = {
	white_peace = COG
		}
	}

	#Still stuff left? Give it to GER
	if = {
		limit = { country_exists = GER }
		every_owned_state = {
			GER = { transfer_state = PREV }
		}
	}

#Duct tape
if = {
	limit = {
		country_exists = MZB
		}
		MZB = { declare_war_on = { target = ZIM type = annex_everything } }
		ZIM = { add_state_claim = 950 } #traditional claim by Rhodesia on Mozambique
	}
	
	KBR = { declare_war_on = { target = NGR type = annex_everything } }
	
	MSF = {
		declare_war_on = {
			target = COG
			type = annex_everything
		}
	}
	
	MSF = {
		declare_war_on = {
			target = KTG
			type = annex_everything
		}
	}

	MSF = {
		declare_war_on = {
			target = KIV
			type = annex_everything
		}
	}
	
	
	KIV = {
		declare_war_on = {
			target = COG
			type = annex_everything
		}
	}

	KAS = {
		declare_war_on = {
			target = COG
			type = annex_everything
		}
	}
	
	KAS = {
		declare_war_on = {
			target = LPD
			type = annex_everything
		}
	}
	
	KAS = {
		declare_war_on = {
			target = KTG
			type = annex_everything
		}
	}

	KAS = {
		declare_war_on = {
			target = MSF
			type = annex_everything
		}
	}
	
	ORT = {
		declare_war_on = {
			target = COG
			type = annex_everything
		}
	}

	ORT = {
		declare_war_on = {
			target = MSF
			type = annex_everything
		}
	}
	
	ORT = {
		declare_war_on = {
			target = LPD
			type = annex_everything
		}
	}

	ORT = {
		declare_war_on = {
			target = KTG
			type = annex_everything
		}
	}
	KIV = {
		declare_war_on = {
			target = KTG
			type = annex_everything
		}
	}
	
	if = {
		limit = {
		LPD = { NOT = { is_in_faction_with = COG } }
		}
	LPD = {
		declare_war_on = {
			target = COG
		type = annex_everything
		}
	}
}
	
	if = {
		limit = {
		LPD = { NOT = { is_in_faction_with = KTG } }
		}
	LPD = {
		declare_war_on = {
			target = KTG
		type = annex_everything
		}
	}
}
	
	if = {
		limit = {
		UMN = { NOT = { is_in_faction_with = COG } }
		}
	UMN = {
			declare_war_on = {
			target = COG
		type = annex_everything
		}
	}
}
	
	if = {
		limit = {
		UMN = { NOT = { is_in_faction_with = KTG } }
		}
	UMN = {
			declare_war_on = {
			target = KTG
		type = annex_everything
		}
	}
}
	
	if = {
		limit = {
		KTG = { NOT = { is_in_faction_with = COG } }
		}
	COG = {
			declare_war_on = {
			target = KTG
		type = annex_everything
		}
	}
}

		
	if = {
		limit = {
		KTG = { NOT = { is_in_faction_with = UMN } }
		}
	KTG = {
			declare_war_on = {
			target = UMN
		type = annex_everything
		}
	}
}

	if = {
		limit = {
		UMN = { NOT = { is_in_faction_with = KIV } }
		}
	UMN = {
			declare_war_on = {
			target = KIV
		type = annex_everything
		}
	}
}
	
	if = {
		limit = {
		UMN = { NOT = { is_in_faction_with = MSF } }
		}
	UMN = {
		declare_war_on = {
			target = MSF
			type = annex_everything
		}
	}
}
	
	#Still stuff left? Give it to GER
	if = {
		limit = { country_exists = GER }
		every_owned_state = {
			GER = { transfer_state = PREV }
		}
	}

	#Do the diplomatic relationships
		MAF = { declare_war_on = { target = TZN type = annex_everything } }
	
		TZN = { declare_war_on = { target = RWA type = annex_everything } }
	
		TZN = { declare_war_on = { target = BRD type = annex_everything } }
		
	if = {
		limit = {
			country_exists = ADW
			country_exists = CMR
		}
		CMR = { declare_war_on = { target = ADW type = annex_everything } }
	}
	if = {
		limit = {
			country_exists = ADW
			country_exists = CMR
		}
		CMR = { declare_war_on = { target = ADW type = annex_everything } }
	}
	if = {
		limit = {
			country_exists = CEA
			country_exists = CMR
		}
		CEA = { declare_war_on = { target = CMR type = annex_everything } }
	}
	if = {
		limit = {
			country_exists = CEA
			country_exists = ADW
		}
		CEA = { declare_war_on = { target = ADW type = annex_everything } }
	}
	if = {
		limit = {
			country_exists = HAU
			country_exists = NGR
			HAU = { NOT = { has_country_flag = MAF_already_exists } }
		}
		HAU = { declare_war_on = { target = NGR type = annex_everything } }
	}
	if = {
		limit = {
			country_exists = KBR
			country_exists = NGR
			KBR = { NOT = { has_country_flag = MAF_already_exists } }
		}
		KBR = { declare_war_on = { target = NGR type = annex_everything } }
	}
	if = {
		limit = {
			country_exists = GAB
			country_exists = KOG
			GAB = { NOT = { has_country_flag = MAF_already_exists } }
		}
		GAB = { declare_war_on = { target = KOG type = annex_everything } }
	}
	if = {
		limit = {
			country_exists = TZN
			country_exists = ZZB
			TZN = { NOT = { has_country_flag = MAF_already_exists } }
		}
		TZN = { declare_war_on = { target = ZZB type = annex_everything } }
	}
	if = {
		limit = {
			country_exists = KOG
			country_exists = TKE
			KOG = { NOT = { has_country_flag = MAF_already_exists } }
		}
		KOG = { declare_war_on = { target = TKE type = annex_everything } }
	}
	if = {
		limit = {
			country_exists = NBL
			country_exists = NMB
		}
		NBL = { declare_war_on = { target = NMB type = annex_everything } }
	}
	if = {
		limit = {
			country_exists = MZB
			country_exists = TZN
			MZB = { NOT = { has_country_flag = MAF_already_exists } }
		}
		MZB = { declare_war_on = { target = TZN type = annex_everything } }
	}
	if = {
		limit = {
			country_exists = MZB
			country_exists = MLW
			MZB = { NOT = { has_country_flag = MAF_already_exists } }
		}
		MZB = { declare_war_on = { target = MLW type = annex_everything } }
	}
	if = {
		limit = {
			country_exists = COG
			country_exists = KOG
			COG = { NOT = { has_country_flag = MAF_already_exists } }
			KOG = { NOT = { has_country_flag = MAF_already_exists } }
		}
		COG = { diplomatic_relation = { country = KOG relation = non_aggression_pact } }
	}

	#Give all the tags the post MAF collapse idea
	for_each_scope_loop = {
		array = global.MAF_collapse_tags
			if = {
				limit = {
					OR = {
						has_focus_tree = Africa_Shared
						has_focus_tree = african_republic_authoritarian
						has_focus_tree = African_Generic_Democracy
						has_focus_tree = african_monarchy
						has_focus_tree = islamic_generic
					}
				}
				add_ideas = MAF_post_collapse_army
			}
			if = {
				limit = {
					OR = {
						has_focus_tree = Africa_Shared
						has_focus_tree = african_republic_authoritarian
						has_focus_tree = African_Generic_Democracy
						has_focus_tree = african_monarchy
						has_focus_tree = islamic_generic
					}
				}
				add_ideas = AFR_post_collapse_instability
			}
		}

	every_country = {
		limit = { is_congo_tag = yes }
		remove_ideas = {
			AFR_post_collapse_instability
			MAF_post_collapse_army
		}
	}

	#Get rid of MAF cores/claims
	every_state = {
		limit = { is_core_of = MAF }
		if = {
			limit = {
				country_exists = NMB
				}
		add_claim_by = NMB
		}
		if = {
			limit = {
				country_exists = TZN
				}
		add_claim_by = TZN
		}
		if = {
			limit = {
				country_exists = CMR
				}
		add_claim_by = CMR
		}
		remove_core_of = MAF
	}
	every_state = {
		limit = { is_claimed_by = MAF }
		remove_claim_by = MAF
	}
	

	#Get rid of those flags
	every_country = {
		limit = { has_country_flag = MAF_already_exists }
		clr_country_flag = MAF_already_exists
	}
}
MAF_update_collapse_var = {
	add_to_variable = { MAF_collapse_var = 1 }
	if = {
		limit = {
			has_idea = MAF_corporate_blues
		}
		add_to_variable = { MAF_collapse_var = 1 }
	}
	if = {
		limit = {
			has_idea = MAF_disgruntled_farmers
		}
		add_to_variable = { MAF_collapse_var = 1 }
	}
	if = {
		limit = {
			has_idea = MAF_disgruntled_natives
		}
		add_to_variable = { MAF_collapse_var = 1 }
	}
	if = {
		limit = {
			has_idea = MAF_power_vacuum
		}
		add_to_variable = { MAF_collapse_var = 1 }
	}
	if = {
		limit = {
			has_idea = MAF_Debt
		}
		add_to_variable = { MAF_collapse_var = 1 }
	}
}

MAF_click_effect = {
	if = {
		limit = {
			NOT = {
				has_country_flag = MAF_OPEN
			}
		}
		set_country_flag = MAF_OPEN
	}
	
	else_if = {
		limit = {
			has_country_flag = MAF_OPEN
		}
		clr_country_flag = MAF_OPEN
	}
}

COG_click_effect = {
	if = {
		limit = {
			NOT = {
				has_country_flag = COG_OPEN
			}
		}
		set_country_flag = COG_OPEN
	}
	
	else_if = {
		limit = {
			has_country_flag = COG_OPEN
		}
		clr_country_flag = COG_OPEN
	}
}

NGR_click_effect = {
	if = {
		limit = {
			NOT = {
				has_country_flag = NGR_OPEN
			}
		}
		set_country_flag = NGR_OPEN
	}
	
	else_if = {
		limit = {
			has_country_flag = NGR_OPEN
		}
		clr_country_flag = NGR_OPEN
	}
}

CIV_click_effect = {
	if = {
		limit = {
			NOT = {
				has_country_flag = CIV_OPEN
			}
		}
		set_country_flag = CIV_OPEN
	}
	
	else_if = {
		limit = {
			has_country_flag = CIV_OPEN
		}
		clr_country_flag = CIV_OPEN
	}
}

KEN_click_effect = {
	if = {
		limit = {
			NOT = {
				has_country_flag = KEN_OPEN
			}
		}
		set_country_flag = KEN_OPEN
	}
	
	else_if = {
		limit = {
			has_country_flag = KEN_OPEN
		}
		clr_country_flag = KEN_OPEN
	}
}

ZAM_click_effect = {
	if = {
		limit = {
			NOT = {
				has_country_flag = ZAM_OPEN
			}
		}
		set_country_flag = ZAM_OPEN
	}
	
	else_if = {
		limit = {
			has_country_flag = ZAM_OPEN
		}
		clr_country_flag = ZAM_OPEN
	}
}

MAG_click_effect = {
	if = {
		limit = {
			NOT = {
				has_country_flag = MAG_OPEN
			}
		}
		set_country_flag = MAG_OPEN
	}
	
	else_if = {
		limit = {
			has_country_flag = MAG_OPEN
		}
		clr_country_flag = MAG_OPEN
	}
}

MAF_unit_leader_transfer = {
	KOG = {
		set_variable = { MAF_generals_received = 0 }
	}
	TKE = {
		set_variable = { MAF_generals_received = 0 }
	}
	CEA = {
		set_variable = { MAF_generals_received = 0 }
	}
	RWA = {
		set_variable = { MAF_generals_received = 0 }
	}
	BRD = {
		set_variable = { MAF_generals_received = 0 }
	}
	random_list = { #George Kraut
		20 = { 
			random_unit_leader = {
				limit = { has_id = 22930 }			
				set_nationality = KOG
				set_unit_leader_flag = MAF_former_german
			}
			add_to_variable = { var = MAF_generals_received value = 1 }
		}
		20 = { 
			random_unit_leader = {
				limit = { has_id = 22930 }			
				set_nationality = CEA
				set_unit_leader_flag = MAF_former_german
			}
			add_to_variable = { var = MAF_generals_received value = 1 }
		}
		20 = { 
			random_unit_leader = {
				limit = { has_id = 22930 }			
				set_nationality = TKE
				set_unit_leader_flag = MAF_former_german
			}
			add_to_variable = { var = MAF_generals_received value = 1 }
		}
		20 = { 
			random_unit_leader = {
				limit = { has_id = 22930 }			
				set_nationality = BRD
				set_unit_leader_flag = MAF_former_german
			}
			add_to_variable = { var = MAF_generals_received value = 1 }
		}
		20 = { 
			random_unit_leader = {
				limit = { has_id = 22930 }			
				set_nationality = RWA
				set_unit_leader_flag = MAF_former_german
			}
			add_to_variable = { var = MAF_generals_received value = 1 }
		}
	}
	random_list = { #Kai-Uwe von Hassel
		20 = { 
			modifier = {
				add = -20
				KOG = {
					already_has_MAF_general = yes
				}
			}
			random_unit_leader = {
				limit = { has_id = 22932 }			
				set_nationality = KOG
				set_unit_leader_flag = MAF_former_german
			}
			add_to_variable = { var = MAF_generals_received value = 1 }
		}
		20 = {
			modifier = {
				add = -20
				CEA = {
					already_has_MAF_general = yes
				}
			}
			random_unit_leader = {
				limit = { has_id = 22932 }			
				set_nationality = CEA
				set_unit_leader_flag = MAF_former_german
			}
			add_to_variable = { var = MAF_generals_received value = 1 }
		}
		20 = { 
			modifier = {
				add = -20
				TKE = {
					already_has_MAF_general = yes
				}
			}
			random_unit_leader = {
				limit = { has_id = 22932 }			
				set_nationality = TKE
				set_unit_leader_flag = MAF_former_german
			}
			add_to_variable = { var = MAF_generals_received value = 1 }
		}
		20 = { 
			modifier = {
				add = -20
				BRD = {
					already_has_MAF_general = yes
				}
			}
			random_unit_leader = {
				limit = { has_id = 22932 }			
				set_nationality = BRD
				set_unit_leader_flag = MAF_former_german
			}
			add_to_variable = { var = MAF_generals_received value = 1 }
		}
		20 = { 
			modifier = {
				add = -20
				RWA = {
					already_has_MAF_general = yes
				}
			}
			random_unit_leader = {
				limit = { has_id = 22932 }			
				set_nationality = RWA
				set_unit_leader_flag = MAF_former_german
			}
			add_to_variable = { var = MAF_generals_received value = 1 }
		}
	}
	random_list = { #Erwin Rommel
		20 = {
			modifier = {
				add = -20
				KOG = {
					already_has_MAF_general = yes
				}
			}
			random_unit_leader = {
				limit = { has_id = 22933 }			
				set_nationality = KOG
				set_unit_leader_flag = MAF_former_german
			}
			add_to_variable = { var = MAF_generals_received value = 1 }
		}
		20 = { 
			modifier = {
				add = -20
				CEA = {
					already_has_MAF_general = yes
				}
			}
			random_unit_leader = {
				limit = { has_id = 22933 }			
				set_nationality = CEA
				set_unit_leader_flag = MAF_former_german
			}
			add_to_variable = { var = MAF_generals_received value = 1 }
		}
		20 = { 
			modifier = {
				add = -20
				TKE = {
					already_has_MAF_general = yes
				}
			}
			random_unit_leader = {
				limit = { has_id = 22933 }			
				set_nationality = TKE
				set_unit_leader_flag = MAF_former_german
			}
			add_to_variable = { var = MAF_generals_received value = 1 }
		}
		20 = { 
			modifier = {
				add = -20
				BRD = {
					already_has_MAF_general = yes
				}
			}
			random_unit_leader = {
				limit = { has_id = 22933 }			
				set_nationality = BRD
				set_unit_leader_flag = MAF_former_german
			}
			add_to_variable = { var = MAF_generals_received value = 1 }
		}
		20 = { 
			modifier = {
				add = -20
				RWA = {
					already_has_MAF_general = yes
				}
			}
			random_unit_leader = {
				limit = { has_id = 22933 }			
				set_nationality = RWA
				set_unit_leader_flag = MAF_former_german
			}
			add_to_variable = { var = MAF_generals_received value = 1 }
		}
	}
	random_list = { #Hermann Detzner
		20 = { 
			modifier = {
				add = -20
				KOG = {
					already_has_MAF_general = yes
				}
			}
			random_unit_leader = {
				limit = { has_id = 22935 }			
				set_nationality = KOG
				set_unit_leader_flag = MAF_former_german
			}
			add_to_variable = { var = MAF_generals_received value = 1 }
		}
		20 = { 
			modifier = {
				add = -20
				CEA = {
					already_has_MAF_general = yes
				}
			}
			random_unit_leader = {
				limit = { has_id = 22935 }			
				set_nationality = CEA
				set_unit_leader_flag = MAF_former_german
			}
			add_to_variable = { var = MAF_generals_received value = 1 }
		}
		20 = { 
			modifier = {
				add = -20
				TKE = {
					already_has_MAF_general = yes
				}
			}
			random_unit_leader = {
				limit = { has_id = 22935 }			
				set_nationality = TKE
				set_unit_leader_flag = MAF_former_german
			}
			add_to_variable = { var = MAF_generals_received value = 1 }
		}
		20 = { 
			modifier = {
				add = -20
				BRD = {
					already_has_MAF_general = yes
				}
			}
			random_unit_leader = {
				limit = { has_id = 22935 }			
				set_nationality = BRD
				set_unit_leader_flag = MAF_former_german
			}
			add_to_variable = { var = MAF_generals_received value = 1 }
		}
		20 = { 	
			modifier = {
				add = -20
				RWA = {
					already_has_MAF_general = yes
				}
			}
			random_unit_leader = {
				limit = { has_id = 22935 }			
				set_nationality = RWA
				set_unit_leader_flag = MAF_former_german
			}
			add_to_variable = { var = MAF_generals_received value = 1 }
		}
	}
	random_list = { #Berthold von Deimling
		20 = { 
			modifier = {
				add = -20
				KOG = {
					already_has_MAF_general = yes
				}
			}
			random_unit_leader = {
				limit = { has_id = 22934 }			
				set_nationality = KOG
				set_unit_leader_flag = MAF_former_german
			}
			add_to_variable = { var = MAF_generals_received value = 1 }
		}
		20 = { 
			modifier = {
				add = -20
				CEA = {
					already_has_MAF_general = yes
				}
			}
			random_unit_leader = {
				limit = { has_id = 22934 }			
				set_nationality = CEA
				set_unit_leader_flag = MAF_former_german
			}
			add_to_variable = { var = MAF_generals_received value = 1 }
		}
		20 = { 
			modifier = {
				add = -20
				TKE = {
					already_has_MAF_general = yes
				}
			}
			random_unit_leader = {
				limit = { has_id = 22934 }			
				set_nationality = TKE
				set_unit_leader_flag = MAF_former_german
			}
			add_to_variable = { var = MAF_generals_received value = 1 }
		}
		20 = { 
			modifier = {
				add = -20
				BRD = {
					already_has_MAF_general = yes
				}
			}
			random_unit_leader = {
				limit = { has_id = 22934 }			
				set_nationality = BRD
				set_unit_leader_flag = MAF_former_german
			}
			add_to_variable = { var = MAF_generals_received value = 1 }
		}
		20 = { 
			modifier = {
				add = -20
				RWA = {
					already_has_MAF_general = yes
				}
			}
			random_unit_leader = {
				limit = { has_id = 22934 }			
				set_nationality = RWA
				set_unit_leader_flag = MAF_former_german
			}
			add_to_variable = { var = MAF_generals_received value = 1 }
		}
	}
}

AFR_increase_corruption = {
	if = {
		limit = { has_idea = AFR_corruption_1 }
		swap_ideas = {
			remove_idea = AFR_corruption_1
			add_idea = AFR_corruption_2
		}
	}
	else_if = {
		limit = { has_idea = AFR_corruption_2 }
		swap_ideas = {
			remove_idea =  AFR_corruption_2
			add_idea = AFR_corruption_3
		}
	}
	else_if = {
		limit = { has_idea = AFR_corruption_3 }
		swap_ideas = {
			remove_idea =  AFR_corruption_3
			add_idea = AFR_corruption_4
		}
	}
	else_if = {
		limit = { has_idea = AFR_corruption_4 }
		swap_ideas = {
			remove_idea =  AFR_corruption_4
			add_idea = AFR_corruption_5
		}
	}
	#else_if = {
		#limit = { has_idea = AFR_corruption_5 }
		#remove_ideas = AFR_corruption_5
	#}
}

AFR_decrease_corruption = {
	if = {
		limit = { has_idea = AFR_corruption_5 }
		swap_ideas = {
			remove_idea =  AFR_corruption_5
			add_idea = AFR_corruption_4
		}
	}
	else_if = {
		limit = { has_idea = AFR_corruption_4 }
		swap_ideas = {
			remove_idea =  AFR_corruption_4
			add_idea = AFR_corruption_3
		}
	}
	else_if = {
		limit = { has_idea = AFR_corruption_3 }
		swap_ideas = {
			remove_idea =  AFR_corruption_3
			add_idea = AFR_corruption_2
		}
	}
	else_if = {
		limit = { has_idea = AFR_corruption_2 }
		swap_ideas = {
			remove_idea = AFR_corruption_2
			add_idea = AFR_corruption_1
		}
	}
	else_if = {
		limit = { has_idea = AFR_corruption_1 }
		remove_ideas = AFR_corruption_1
	}
}

AFR_open_tree = {
	AFR_open_army_tree = yes
	AFR_open_economy_tree = yes
	AFR_open_political_tree = yes
}
	
AFR_open_army_tree = {
	set_country_flag = AFR_can_do_army
	custom_effect_tooltip = AFR_unlock_army_tt
}

AFR_open_economy_tree = {
	set_country_flag = AFR_can_do_economy
	custom_effect_tooltip = AFR_unlock_economy_tt
}
	
AFR_open_political_tree = {
	set_country_flag = AFR_can_do_politics
	custom_effect_tooltip = AFR_unlock_politics_tt
}
	