on_actions = {
	on_new_term_election = {
		random_events = {
			100 = mexico.18 # 1940 Mexican election
		}
	}
	
	#Root is exile
	#From is new host
	#FromFrom is old host
	on_host_changed_from_capitulation = {
		effect = {
			#Transfer exile leaders to new host
			From.From = {
				every_army_leader = {
					limit = { is_exiled_leader_from = Root }
					set_nationality = Root.From
				}
			}
		}
	}

	#Root is exile
	#From is old host 
	on_exile_government_reinstated = {
		effect = {
			From = {
				every_army_leader = {
					limit = { is_exiled_leader_from = Root }
					set_nationality = Root
				}
			}
			Root = {
				every_army_leader = {
					limit = { is_exiled_leader_from = Root }
					remove_unit_leader_trait = exiled_leader
					remove_exile_tag = yes
				}
			}
		}
	}

	on_unit_leader_created = {
		effect = {
			if = {
				limit = { is_exiled_leader = yes }
				From.From = { save_event_target_as = exile_nation }
				add_unit_leader_trait = exiled_leader
				
				add_random_trait = {
					old_guard
					brilliant_strategist
					inflexible_strategist
					war_hero
					trait_cautious
					trait_reckless
					media_personality
					harsh_leader
					infantry_officer
					cavalry_officer
					armor_officer
				}

				add_random_trait = {
					organizer
					panzer_leader
					cavalry_leader
					trait_engineer
					infantry_leader
					naval_invader						
					commando
					skilled_staffer
					trickster					
				}

				unit_leader_event = { id = mtg_exile_leader_added.1 }
			}
		}
	}

	#ROOT is winner #FROM gets annexed - This will also fire on_annex
	on_civil_war_end = {
		effect = {
			#End of British Fascist Civil War
			if = {
				limit = {
					original_tag = ENG
					has_government = fascism
					has_completed_focus = ENG_organize_the_blackshirts
				}
				set_country_flag = { flag = won_british_civil_war value = 1 days = 365 }
				country_event = { id = mtg_britain.34 }
			}
			#End of British Fascist Civil War - Democrats won
			if = {
				limit = {
					original_tag = ENG
					has_government = democratic
					FROM = {
						has_government = fascism
						has_completed_focus = ENG_organize_the_blackshirts
					}
				}
				delete_unit_template_and_units = { division_template = "Loyalist Brigade" }
				load_focus_tree = { tree = british_focus keep_completed = no }
				unlock_national_focus = ENG_steady_as_she_goes
				unlock_national_focus = limited_rearmament_focus
				unlock_national_focus = shadow_scheme_focus
				unlock_national_focus = uk_industrial_focus
				unlock_national_focus = royal_ordnance_factories
				if = {
					limit = {
						amount_research_slots > 4
					}
					unlock_national_focus = uk_extra_tech_slot
				}
			}
			# Give back ENG focus tree to Communist ENG if they win a civil war.
			if = {
				limit = {
					original_tag = ENG
					has_government = communism
					has_focus_tree = generic_focus
					FROM = {
						original_tag = ENG
						has_government = communism
					}
				}
				load_focus_tree = { tree = british_focus keep_completed = yes }
			}
			# Give back MEX focus tree to rebel MEX if they win a civil war.
			if = {
				limit = {
					has_dlc = "Man the Guns"
					original_tag = MEX
					has_focus_tree = generic_focus
					FROM = {
						original_tag = MEX
					}
				}
				load_focus_tree = { tree = mexico_focus_tree keep_completed = yes }
			}
			# Give back USA focus tree to CSA if they win a civil war.
			if = {
				limit = {
					original_tag = USA
					has_government = democratic
					FROM = {
						original_tag = USA
						OR = {
							has_government = neutrality
							has_government = fascism
						}
					}
				}
				drop_cosmetic_tag = yes # we are done here
				set_country_flag = democratic_usa_won_civil_war
			}
			#End of British Communist Civil War
			if = {
				limit = {
					original_tag = ENG
					has_government = democratic
					has_completed_focus = ENG_concessions_to_the_trade_unions
				}
				country_event = { id = mtg_britain.56 }
			}
			#End of Imperialist Loyalist civil war
			if = {
				limit = {
					OR = {
						original_tag = CAN
						original_tag = SAF
						original_tag = AST
						original_tag = NZL
					}
					has_government = neutrality
					ENG = { has_completed_focus = ENG_appeal_to_imperial_loyalists }
					NOT = { is_subject_of = ENG }
				}
				ENG = { country_event = { id = mtg_britain.113 hours = 6 } }
			}
			if = {
				limit = {
					has_template = "Silver Legion"
				}
				delete_unit_template_and_units = { division_template = "Silver Legion" }
			}
			# Cleaning up anti-exploiter divisions
			delete_unit_template_and_units = { division_template = "Anti-Exploit Punitive Brigade" }
		}
	}

	#ROOT is winner #FROM gets annexed - This fires just before FROM gets annexed, meaning the country and everything it owns still exists. It will also fire on_annex and on_civil_war_end
	on_civil_war_end_before_annexation = {
		effect = {
			#End of British Fascist Civil War - moving the fleet back to the Fascists because they won
			if = {
				limit = {
					original_tag = ENG
					has_government = fascism
					has_completed_focus = ENG_organize_the_blackshirts
				}
				random_other_country = {
					limit = {
						original_tag = ENG
						has_government = democratic
					}
					transfer_navy = { target = ENG }
					every_unit_leader = {
						limit = {
							OR = {
								has_id = 983
								has_id = 984
								has_id = 985
								has_id = 986
								has_id = 987
								has_id = 988
								has_id = 989
								has_id = 990
								has_id = 991
								has_id = 992
							}
						}
						set_nationality = ENG
					}
				}
			}
		}
	}

	#FROM is war target
	on_declare_war = {
		effect = {
			# In case of HOL being declared war on and still having Shell-shocked Spectator of the Great War, remove the spirit
			if = {
				limit = {
					FROM = {
						original_tag = HOL
						OR = {
							has_idea = HOL_shell_shocked_spectator_1
							has_idea = HOL_shell_shocked_spectator_2
							has_idea = HOL_shell_shocked_spectator_3
							has_idea = HOL_shell_shocked_spectator_4
							has_idea = HOL_shell_shocked_spectator_5
						}
					}
				}
				FROM = {
					hidden_effect = {
						remove_ideas = HOL_shell_shocked_spectator_1
						remove_ideas = HOL_shell_shocked_spectator_2
						remove_ideas = HOL_shell_shocked_spectator_3
						remove_ideas = HOL_shell_shocked_spectator_4
						remove_ideas = HOL_shell_shocked_spectator_5
					}
				}
			}
			# In case of HOL being declared war on and still having Aloof Neutrality, remove the spirit
			if = {
				limit = {
					FROM = {
						original_tag = HOL
						has_idea = HOL_aloof_neutrality
					}
				}
				FROM = {
					hidden_effect = {
						remove_ideas = HOL_aloof_neutrality
					}
				}
			}
			# In case of HOL being declared war on and having taken the "Share intelligence" decision, they get a temporary buff to defense and attack
			if = {
				limit = {
					tag = FRA
					NOT = { is_in_faction_with = ENG }
					FROM = { has_country_flag = secret_staff_talks_british_intelligence }
				}
				hidden_effect = {
					FROM = { add_timed_idea = { idea = HOL_shared_intelligence_eng_fra days = 180 } }
				}
			}
			if = {
				limit = {
					tag = GER
					NOT = { is_in_faction_with = ENG }
					FROM = { has_country_flag = secret_staff_talks_british_intelligence }
				}
				hidden_effect = {
					FROM = { add_timed_idea = { idea = HOL_shared_intelligence_eng_ger days = 180 } }
				}
			}
			if = {
				limit = {
					tag = ENG
					NOT = { is_in_faction_with = FRA }
					FROM = { has_country_flag = secret_staff_talks_french_intelligence }
				}
				hidden_effect = {
					FROM = { add_timed_idea = { idea = HOL_shared_intelligence_fra_eng days = 180 } }
				}
			}
			if = {
				limit = {
					tag = GER
					NOT = { is_in_faction_with = FRA }
					FROM = { has_country_flag = secret_staff_talks_french_intelligence }
				}
				hidden_effect = {
					FROM = { add_timed_idea = { idea = HOL_shared_intelligence_fra_ger days = 180 } }
				}
			}
			if = {
				limit = {
					tag = FRA
					NOT = { is_in_faction_with = GER }
					FROM = { has_country_flag = secret_staff_talks_german_intelligence }
				}
				hidden_effect = {
					FROM = { add_timed_idea = { idea = HOL_shared_intelligence_ger_fra days = 180 } }
				}
			}
			if = {
				limit = {
					tag = ENG
					NOT = { is_in_faction_with = GER }
					FROM = { has_country_flag = secret_staff_talks_german_intelligence }
				}
				hidden_effect = {
					FROM = { add_timed_idea = { idea = HOL_shared_intelligence_ger_eng days = 180 } }
				}
			}
			# In case of GER/ENG/FRA going to war they get a minor buff if they shared intelligence
			if = {
				limit = {
					tag = FRA
					NOT = { is_in_faction_with = HOL }
					FROM = { has_country_flag = secret_staff_talks_dutch_intelligence }
				}
				hidden_effect = { FROM = { add_timed_idea = { idea = HOL_shared_intelligence_hol_fra days = 180 } } }
			}
			if = {
				limit = {
					FROM = { tag = FRA }
					FROM = { NOT = { is_in_faction_with = HOL } }
					has_country_flag = secret_staff_talks_french_intelligence
				}
				hidden_effect = { add_timed_idea = { idea = HOL_shared_intelligence_hol_fra days = 180 } }
			}
			if = {
				limit = {
					tag = ENG
					NOT = { is_in_faction_with = HOL }
					FROM = { has_country_flag = secret_staff_talks_dutch_intelligence }
				}
				hidden_effect = { FROM = { add_timed_idea = { idea = HOL_shared_intelligence_hol_eng days = 180 } } }
			}
			if = {
				limit = {
					FROM = { tag = ENG }
					FROM = { NOT = { is_in_faction_with = HOL } }
					has_country_flag = secret_staff_talks_french_intelligence
				}
				hidden_effect = { add_timed_idea = { idea = HOL_shared_intelligence_hol_eng days = 180 } }
			}
			if = {
				limit = {
					tag = GER
					NOT = { is_in_faction_with = HOL }
					FROM = { has_country_flag = secret_staff_talks_dutch_intelligence }
				}
				hidden_effect = { FROM = { add_timed_idea = { idea = HOL_shared_intelligence_hol_ger days = 180 } } }
			}
			if = {
				limit = {
					FROM = { tag = GER }
					FROM = { NOT = { is_in_faction_with = HOL } }
					has_country_flag = secret_staff_talks_french_intelligence
				}
				hidden_effect = { add_timed_idea = { idea = HOL_shared_intelligence_hol_ger days = 180 } }
			}
			# In case of HOL being declared war on and having taken the "draw up shared staff plan" decision, they get a temporary buff to core defense and max entrenchment
			if = {
				limit = {
					OR = {
						tag = FRA
						tag = GER
					}
					NOT = { is_in_faction_with = ENG }
					FROM = { has_country_flag = secret_staff_talks_british_staff_plan }
				}
				hidden_effect = { FROM = { add_timed_idea = { idea = HOL_staff_plan_eng days = 180 } } }
			}
			if = {
				limit = {
					OR = {
						tag = ENG
						tag = GER
					}
					NOT = { is_in_faction_with = FRA }
					FROM = { has_country_flag = secret_staff_talks_french_staff_plan }
				}
				hidden_effect = { FROM = { add_timed_idea = { idea = HOL_staff_plan_fra days = 180 } } }
			}
			if = {
				limit = {
					OR = {
						tag = FRA
						tag = ENG
					}
					NOT = { is_in_faction_with = GER }
					FROM = { has_country_flag = secret_staff_talks_german_staff_plan }
				}
				hidden_effect = { FROM = { add_timed_idea = { idea = HOL_staff_plan_ger days = 180 } } }
			}
			# In case of Turkish civil war with field marshal Ataturk out on the field
			if = { 
        	    limit = { 
        	        original_tag = TUR
        	        has_civil_war = yes
        	        FROM = {
        	            original_tag = TUR
        	            has_civil_war = yes
        	        }
        	    }
        	    hidden_effect = { 
        	        if = { 
        	            limit = {
        	            	FROM = { has_government = neutrality } 
        	            }
        	            every_unit_leader = {
        	                limit = { 
        	                    has_id = 59
        	                }
        	                set_nationality = FROM
        	            }
        	        }
        	    }
        	}
		}
	}	

	on_government_exiled = {
		effect = {
			if = {
				limit = {
					original_tag = HOL
					has_country_flag = HOL_prepared_evacuation_of_gold_reserves_flag
				}
				country_event = { id = mtg_netherlands.63 days = 1 }
			}
		}
	}

	#ROOT = nation being puppeted, FROM = overlord
	on_puppet = {
		effect = {
			#if = { #-------------------------------------> No longer happening (NSB)
			#	limit = {
			#		original_tag = SOV
			#		has_government = communism
			#		has_country_leader = { character = SOV_iosif_stalin }
			#		is_puppet_of = MEX
			#		MEX = {
			#			OR = {
			#				has_country_leader = { ruling_only = yes character = MEX_hernan_laborde }
			#				has_country_leader = { ruling_only = yes character = MEX_leon_trotsky }
			#				has_country_leader = { ruling_only = yes character = MEX_valentin_campa }
			#			}
			#		}
			#	}
			#	SOV = { #TODO william check if works as intended or recreate Trotsky independently, also remove Trotsky from Mexico? What about puppet relationship? Look for another Soviet Trotskyist?
			#		country_event = soviet.28
			#	}
			#}
			if = {
				limit = {
					original_tag = MEX
					has_government = communism
					OR = {
						has_country_leader = { ruling_only = yes character = MEX_hernan_laborde }
						has_country_leader = { ruling_only = yes character = MEX_leon_trotsky }
						has_country_leader = { ruling_only = yes character = MEX_valentin_campa }
					}					
					is_puppet_of = SOV
					SOV = {
						has_country_leader_ideology = stalinism 
					}
				}
				MEX = { 
					add_country_leader_role = {
						character = MEX_dionisio_encina
						country_leader ={
							expire = "1965.1.1"
							ideology = stalinism
							traits = {
								staunch_stalinist
							}
						}
						promote_leader = yes
					}
				}
			}
			if = {
				limit = {
					FROM = {
						original_tag = ENG
						NOT = { has_government = communism }
					}
					has_completed_focus = MEX_focus_nationalize_the_oil_fields
				}
				set_cosmetic_tag = ENG_MEX_dominion
			}	
		}
	}

	on_startup = {
		effect = {
			#Mexican oil concessions
			if = {
				limit = {
					has_dlc = "Man the Guns"
				}
				MEX = {
					give_resource_rights = { receiver = ENG state = 476 }
					give_resource_rights = { receiver = ENG state = 477 }
					give_resource_rights = { receiver = USA state = 479 }
					give_resource_rights = { receiver = USA state = 480 }
				}
			}
			# Game Rules - Decolonization
			if = {
				limit = {
					has_game_rule = {
						rule = americas_colonization_status
						option = AMERICAS_DECOLONIZED
					}
				}
				696 = { add_core_of = CAN }
				299 = { add_core_of = GYA }
				720 = { add_core_of = GYA }
				270 = { add_core_of = GYA }
				ENG = {
					release = BLZ
					release = BAH
					release = GYA
					release = JAM
					release = TRI
					release = BAS
					release = CAN
				}
				HOL = {
					release = CRC
					release = SUR
				}
				730 = { add_core_of = CAN }
				FRA = {
					release = GDL
					release = CAY
					release = CAN
				}
				USA = {
					delete_unit = { state = 686 }
					release = PUE
				}
				PAN = {
					transfer_state = 685
				}
				ENG = {
					set_autonomy = { target = CAN autonomy_state = autonomy_free }
				}
				CAN = {
					abandon_colony_tag = yes
					transfer_state = 332
					transfer_state = 331
				}
			}
			IF = {
				limit = {
					has_game_rule = {
						rule = americas_colonization_status
						option = AMERICAS_DEIMPERIALIZED
					}
				}

				### North America ###

				# Canadian First Nations
				ENG = {
					set_autonomy = { target = CAN autonomy_state = autonomy_free }
					dismantle_faction = yes
				}
				CAN = {
					abandon_colony_tag = yes
					drop_cosmetic_tag = yes
					set_cosmetic_tag = first_nations_canada
					CAN_first_nations_council = {
						add_country_leader_role = {
							promote_leader = yes
							country_leader = {
								ideology = despotism
								traits = { non_aligned_council_trait }
								expire = "1980.1.1.1"
								id = -1
							}
						}
						add_country_leader_role = {
							promote_leader = yes
							country_leader = {
								ideology = conservatism
								traits = { democratic_council_trait }
								expire = "1980.1.1.1"
								id = -1
							}
						}
						add_country_leader_role = {
							promote_leader = yes
							country_leader = {
								ideology = marxism
								traits = { communist_council_trait }
								expire = "1980.1.1.1"
								id = -1
							}
						}
						add_country_leader_role = {
							promote_leader = yes
							country_leader = {
								ideology = falangism
								traits = { fascist_council_trait }
								expire = "1980.1.1.1"
								id = -1
							}
						}
					}
				}
				every_state = {
					limit = {
						OR = {
							state = 860
							state = 863
							state = 862
							state = 468
							state = 465
							state = 464
							state = 276
							state = 682
							state = 866
							state = 867
							state = 467
							state = 865
							state = 469
							state = 470
							state = 473
							state = 471
							state = 740
							state = 739
							state = 331
							state = 730
						}
					}
					add_core_of = CAN
					transfer_state_to = CAN
				} 
				MEX = {
					release = RIG
				}

				# Inuit
				every_state = {
					limit = {
						OR = {
							state = 463
							state = 864
							state = 472
							state = 683
							state = 466
							state = 332
							state = 101
							state = 861
							state = 650
							state = 875
						}
					}
					add_core_of = INU
					transfer_state_to = INU
				}

				# Native North America
				USA = {
					set_autonomy = { target = PHI autonomy_state = autonomy_free }
					delete_unit = { state = 686 }
					release = HAW 
					release = PUE 
					drop_cosmetic_tag = yes
					set_cosmetic_tag = native_american_usa
					USA_native_american_council = {
						add_country_leader_role = {
							promote_leader = yes
							country_leader = {
								ideology = despotism
								traits = { non_aligned_council_trait }
								expire = "1980.1.1.1"
								id = -1
							}
						}
						add_country_leader_role = {
							promote_leader = yes
							country_leader = {
								ideology = conservatism
								traits = { democratic_council_trait }
								expire = "1980.1.1.1"
								id = -1
							}
						}
						add_country_leader_role = {
							promote_leader = yes
							country_leader = {
								ideology = marxism
								traits = { communist_council_trait }
								expire = "1980.1.1.1"
								id = -1
							}
						}
						add_country_leader_role = {
							promote_leader = yes
							country_leader = {
								ideology = falangism
								traits = { fascist_council_trait }
								expire = "1980.1.1.1"
								id = -1
							}
						}
					}
				}

				# Indigenista Mexico
				MEX = {
					drop_cosmetic_tag = yes
					set_cosmetic_tag = indigenous_mexico
					MEX_indigenous_council = {
						add_country_leader_role = {
							promote_leader = yes
							country_leader = {
								ideology = despotism
								traits = { non_aligned_council_trait }
								expire = "1980.1.1.1"
								id = -1
							}
						}
						add_country_leader_role = {
							promote_leader = yes
							country_leader = {
								ideology = conservatism
								traits = { democratic_council_trait }
								expire = "1980.1.1.1"
								id = -1
							}
						}
						add_country_leader_role = {
							promote_leader = yes
							country_leader = {
								ideology = marxism
								traits = { communist_council_trait }
								expire = "1980.1.1.1"
								id = -1
							}
						}
						add_country_leader_role = {
							promote_leader = yes
							country_leader = {
								ideology = falangism
								traits = { fascist_council_trait }
								expire = "1980.1.1.1"
								id = -1
							}
						}
					}
				}

				### Central America ###

				# Maya
				every_state = {
					limit = {
						OR = {
							state = 313
							state = 475
							state = 476
							state = 474
						}
					}
					add_core_of = MAY
					transfer_state_to = MAY
				} 

				# Itza
				311 = {
					add_victory_points = {
						province = 2077
						value = 2
					}	
					set_province_name = {
					    id = 2077
					    name = 2077_indigenous_city_name
					}
				}

				every_state = {
					limit = {
						state = 311
					}
					add_core_of = ITZ
					transfer_state_to = ITZ
				} 

				# Nahua
				every_state = {
					limit = {
						state = 314
					}
					add_core_of = NAH
					transfer_state_to = NAH
				} 

				# Miskito
				317 = {
					add_victory_points = {
						province = 2075
						value = 4
					}	
				}

				every_state = {
					limit = {
						OR = {
							state = 312
							state = 317
						}
					}
					add_core_of = MIS
					transfer_state_to = MIS
				} 

				### South America ###

				# Isthmo-Amerindia
				every_state = {
					limit = {
						OR = {
							state = 316
							state = 304
							state = 493
							state = 306
							state = 486
							state = 307
							state = 489
							state = 685
							state = 695
							state = 691
						}
					}
					add_core_of = IAS
					transfer_state_to = IAS
				} 

				# El Dorado
				every_state = {
					limit = {
						OR = {
							state = 310
							state = 309
							state = 687
							state = 488
							state = 939
							state = 969
							state = 968
						}
					}
					add_core_of = SUR
					transfer_state_to = SUR
				} 

				SUR = {
					drop_cosmetic_tag = yes
					set_cosmetic_tag = united_guiana
					SUR_guianan_indigenous_council = {
						add_country_leader_role = {
							promote_leader = yes
							country_leader = {
								ideology = despotism
								traits = { non_aligned_council_trait }
								expire = "1980.1.1.1"
								id = -1
							}
						}
						add_country_leader_role = {
							promote_leader = yes
							country_leader = {
								ideology = conservatism
								traits = { democratic_council_trait }
								expire = "1980.1.1.1"
								id = -1
							}
						}
						add_country_leader_role = {
							promote_leader = yes
							country_leader = {
								ideology = marxism
								traits = { communist_council_trait }
								expire = "1980.1.1.1"
								id = -1
							}
						}
						add_country_leader_role = {
							promote_leader = yes
							country_leader = {
								ideology = falangism
								traits = { fascist_council_trait }
								expire = "1980.1.1.1"
								id = -1
							}
						}
					}
					set_politics = {
						ruling_party = neutrality
						elections_allowed = no
					}
				}

				# Inca
				every_state = {
					limit = {
						OR = {
							state = 494
							state = 492
							state = 947
							state = 303
							state = 951
							state = 506
							state = 491
							state = 490
							state = 305
							state = 940
							state = 649
						}
					}
					add_core_of = INC
					transfer_state_to = INC
				} 

				# Pindorama
				every_state = {
					limit = {
						OR = {
							state = 495
							state = 938
							state = 280
							state = 497
							state = 941
							state = 937
							state = 935
							state = 498
							state = 936
							state = 499
							state = 505
							state = 496
							state = 943
							state = 500
							state = 501
							state = 967
							state = 961
							state = 964
							state = 963
							state = 962
							state = 965
							state = 966
						}
					}
					add_core_of = BRA
					transfer_state_to = BRA
				} 

				BRA = {
					drop_cosmetic_tag = yes
					set_cosmetic_tag = indigenous_brazil
					BRA_indigenous_council = {
						add_country_leader_role = {
							promote_leader = yes
							country_leader = {
								ideology = despotism
								traits = { non_aligned_council_trait }
								expire = "1980.1.1.1"
								id = -1
							}
						}
						add_country_leader_role = {
							promote_leader = yes
							country_leader = {
								ideology = conservatism
								traits = { democratic_council_trait }
								expire = "1980.1.1.1"
								id = -1
							}
						}
						add_country_leader_role = {
							promote_leader = yes
							country_leader = {
								ideology = marxism
								traits = { communist_council_trait }
								expire = "1980.1.1.1"
								id = -1
							}
						}
						add_country_leader_role = {
							promote_leader = yes
							country_leader = {
								ideology = falangism
								traits = { fascist_council_trait }
								expire = "1980.1.1.1"
								id = -1
							}
						}
					}
				}

				# Bolivia
				every_state = {
					limit = {
						OR = {
							state = 487
							state = 302
							state = 942
						}
					}
					add_core_of = BOL
				}
				
				BOL = {
					drop_cosmetic_tag = yes
					set_cosmetic_tag = true_plurinational_bolivia
					BOL_indigenous_council = {
						add_country_leader_role = {
							promote_leader = yes
							country_leader = {
								ideology = despotism
								traits = { non_aligned_council_trait }
								expire = "1980.1.1.1"
								id = -1
							}
						}
						add_country_leader_role = {
							promote_leader = yes
							country_leader = {
								ideology = conservatism
								traits = { democratic_council_trait }
								expire = "1980.1.1.1"
								id = -1
							}
						}
						add_country_leader_role = {
							promote_leader = yes
							country_leader = {
								ideology = marxism
								traits = { communist_council_trait }
								expire = "1980.1.1.1"
								id = -1
							}
						}
						add_country_leader_role = {
							promote_leader = yes
							country_leader = {
								ideology = falangism
								traits = { fascist_council_trait }
								expire = "1980.1.1.1"
								id = -1
							}
						}
					}
				}

				# Guarani
				every_state = {
					limit = {
						OR = {
							state = 301
							state = 688
							state = 957
							state = 510
							state = 504
							state = 944
							state = 503
							state = 502
						}
					}
					add_core_of = GAR
					transfer_state_to = GAR
				} 

				# Charrua
				every_state = {
					limit = {
						OR = {
							state = 300
							state = 945
							state = 946
						}
					}
					add_core_of = CHR
					transfer_state_to = CHR
				} 

				# Rapa Nui
				every_state = {
					limit = {
						OR = {
							state = 948
							state = 270
						}
					}
					add_core_of = RAP
					transfer_state_to = RAP
				}

				### Caribbean ###

				ENG = {
					release = BLZ
					release = BAH
					release = JAM
					release = BAS
				}
				FRA = {
					release = GDL
				}


				### Chile ###
				CHL = {
					set_politics = {
						ruling_party = neutrality
						elections_allowed = no
					}	
					add_popularity = {
						ideology = neutrality
						popularity = 0.8
					}
					set_cosmetic_tag = CHL_mapuche_state	
					add_country_leader_role  = {
						character = CHL_manuel_manquilef
					    country_leader = {
					        ideology = despotism
					        expire = "1965.1.1.1"
					        traits = { JUNO_defender_of_araucania }
					    }
					}
					promote_character = {
						character = CHL_manuel_manquilef 
						ideology = despotism 
					}
					### Removing the now irrelevant Mapuche Conflict
					IF = {
						limit = {
							has_idea = CHL_the_mapuche_conflict_rebellion
						}
						remove_ideas = CHL_the_mapuche_conflict_rebellion
					}
					ELSE_IF = {
						limit = {
							has_idea = CHL_the_mapuche_conflict_much_worse
						}
						remove_ideas = CHL_the_mapuche_conflict_much_worse
					}
					ELSE_IF = {
						limit = {
							has_idea = CHL_the_mapuche_conflict_worse
						}
						remove_ideas = CHL_the_mapuche_conflict_worse
					}
					ELSE_IF = {
						limit = {
							has_idea = CHL_the_mapuche_conflict
						}
						remove_ideas = CHL_the_mapuche_conflict
					}
					ELSE_IF = {
						limit = {
							has_idea = CHL_the_mapuche_conflict_calmed
						}
						remove_ideas = CHL_the_mapuche_conflict_calmed
					}
					ELSE_IF = {
						limit = {
							has_idea = CHL_the_mapuche_conflict_near_gone
						}
						remove_ideas = CHL_the_mapuche_conflict_near_gone
					}
					ELSE_IF = {
						limit = {
							has_idea = CHL_mapuche_conflict_done
						}
						remove_ideas = CHL_mapuche_conflict_done
					}

					set_country_flag = CHL_no_more_mapuche_conflict

					set_capital = {
						state = 950
						remember_old_capital = no
					}

					add_victory_points = {
						province = 5121
						value = 8
					}

					set_party_name = {
					    ideology = neutrality
					    long_name = CHL_mapuche_party_long
					    name = CHL_mapuche_party
					}

					division_template = {
					    name = "Los Insurgentes Mapuche de Esteban Romero Sandoval"
					    is_locked = no
					    division_names_group = SPR_INF_01
					    override_model = CHL_infantry_alt_0_entity
					    priority = 1
					    template_counter = 83
					    regiments = {
					        infantry = { x = 0 y = 0 } 
					        infantry = { x = 0 y = 1 } 
					        infantry = { x = 0 y = 2 }
					        infantry = { x = 1 y = 0 }  
					        infantry = { x = 1 y = 1 } 
					        infantry = { x = 1 y = 2 } 
					    }
					} 
					random_state = {
						limit = {
							OR = {
								state = 950
								state = 949
								state = 507
								state = 953
								state = 954
								state = 955
								state = 512
							}
							is_controlled_by = ROOT
						}
						create_unit = {
						    division = "name = \"Los Insurgentes Primeros de Mapuche de Esteban Romero Sandoval\" division_template = \"Los Insurgentes Mapuche de Esteban Romero Sandoval\" start_experience_factor = 0.5 start_equipment_factor = 0.8"
						    owner = ROOT 
						}
						create_unit = {
						    division = "name = \"Los Insurgentes Segundo de Mapuche de Esteban Romero Sandoval\" division_template = \"Los Insurgentes Mapuche de Esteban Romero Sandoval\" start_experience_factor = 0.5 start_equipment_factor = 0.8"
						    owner = ROOT 
						}
					}

					division_template = {
					    name = "Guerreros Abajinos"
					    is_locked = no
					    division_names_group = SPR_INF_01
					    override_model = CHL_infantry_alt_1_entity
					    priority = 1
					    template_counter = 85
					    regiments = {
					        infantry = { x = 0 y = 0 } 
					        infantry = { x = 0 y = 1 } 
					        infantry = { x = 1 y = 0 }  
					        infantry = { x = 1 y = 1 } 
					    }
					} 
					random_state = {
						limit = {
							OR = {
								state = 950
								state = 949
								state = 507
								state = 953
								state = 954
								state = 955
								state = 512
							}
							is_controlled_by = ROOT
						}
						create_unit = {
						    division = "name = \"Guerreros Abajinos\" division_template = \"Guerreros Abajinos\" start_experience_factor = 0.5 start_equipment_factor = 1"
						    owner = ROOT 
						}
					}

					every_state = {
						limit = {
							OR = {
								state = 953
								state = 299
								state = 720
								state = 954
								state = 955
								state = 512
							}
						}
						add_core_of = CHL
						transfer_state_to = CHL
					}

					every_state = {
						limit = {
							OR = {
								state = 511
								state = 958
								state = 278
								state = 956
								state = 960
								state = 508
								state = 509
								state = 959
							}
						}
						transfer_state_to = CHL
					}

				}



			}

			if = {
				limit = {
					has_game_rule = {
						rule = africa_colonization_status
						option = AFRICA_DECOLONIZED
					}
				}
				713 = { add_core_of = MAD }
				FRA = {
					delete_unit = { state = 272 }
					delete_unit = { state = 539 }
					delete_unit = { state = 543 }
					delete_unit = { state = 461 }
					delete_unit = { state = 458 }
					delete_unit = { state = 459 }
					release = MOR
					release = ALG
					release = TUN
					release = DJI
					release = MAD
					release = GAB
					release = RCG
					release = CMR
					release = CAR
					release = CHA
					release = DAH
					release = TOG
					release = IVO
					release = VOL
					release = MLI
					release = GNA
					release = SEN
					release = NGR
					release = MRT
				}
				ITA = {
					release = ETH #For 1939 bookmark
					release = LBA
					release = ERI
					release = SOM
					transfer_units_fraction = {
						target = SOM
						size = 1
					}

					LBA = {
					drop_cosmetic_tag = yes
					retire_country_leader = yes
					add_popularity = {ideology = neutrality popularity = 0.35}
					set_politics = {
					ruling_party = neutrality
					}
					remove_ideas = LBA_italian_libya_idea
					remove_ideas = ALL_colonial_militia
					add_ideas = civilian_economy
					load_focus_tree = {tree = generic_focus}
					}

					#Delete all BBA extra templates
					if = {
						limit = {
							has_dlc = "By Blood Alone"
						}
						LBA = { #Some left on purpose because kinda fitting
							delete_unit_template_and_units = {
								division_template = "Camicie Nere"
							}
							delete_unit_template_and_units = {
								division_template = "Divisione Coloniale"
							}
							delete_unit_template_and_units = {
								division_template = "Banda Indigena Irregolare"
							}
							delete_unit_template_and_units = {
								division_template = "Truppe Irregolari a Cavallo"
							}
							delete_unit_template_and_units = {
								division_template = "Divisione Ascari Libica"
							}
							delete_unit_template_and_units = {
								division_template = "Divisione Ascari Eritrea"
							}
							delete_unit_template_and_units = {
								division_template = "Divisione Ascari Somala"
							}
							delete_unit_template_and_units = {
								division_template = "Banda Irregolare Libica"
							}
							delete_unit_template_and_units = {
								division_template = "Banda Irregolare Eritrea"
							}
							delete_unit_template_and_units = {
								division_template = "Banda Irregolare Somala"
							}
						}

						ERI = { #Some left on purpose because kinda fitting
							delete_unit_template_and_units = {
								division_template = "Camicie Nere"
							}
							delete_unit_template_and_units = {
								division_template = "Divisione Coloniale"
							}
							delete_unit_template_and_units = {
								division_template = "Banda Indigena Irregolare"
							}
							delete_unit_template_and_units = {
								division_template = "Truppe Irregolari a Cavallo"
							}
							delete_unit_template_and_units = {
								division_template = "Divisione Ascari Libica"
							}
							delete_unit_template_and_units = {
								division_template = "Divisione Ascari Eritrea"
							}
							delete_unit_template_and_units = {
								division_template = "Divisione Ascari Somala"
							}
							delete_unit_template_and_units = {
								division_template = "Banda Irregolare Libica"
							}
							delete_unit_template_and_units = {
								division_template = "Banda Irregolare Eritrea"
							}
							delete_unit_template_and_units = {
								division_template = "Banda Irregolare Somala"
							}
						}

						SOM = {
							delete_unit_template_and_units = {
								division_template = "Camicie Nere"
							}
							delete_unit_template_and_units = {
								division_template = "Divisione Coloniale"
							}
							delete_unit_template_and_units = {
								division_template = "Banda Indigena Irregolare"
							}
							delete_unit_template_and_units = {
								division_template = "Truppe Irregolari a Cavallo"
							}
							delete_unit_template_and_units = {
								division_template = "Divisione Ascari Libica"
							}
							delete_unit_template_and_units = {
								division_template = "Divisione Ascari Eritrea"
							}
							delete_unit_template_and_units = {
								division_template = "Divisione Ascari Somala"
							}
							delete_unit_template_and_units = {
								division_template = "Banda Irregolare Libica"
							}
							delete_unit_template_and_units = {
								division_template = "Banda Irregolare Eritrea"
							}
							delete_unit_template_and_units = {
								division_template = "Banda Irregolare Somala"
							}
						}

						ETH = {
							delete_unit_template_and_units = {
								division_template = "Camicie Nere"
							}
							delete_unit_template_and_units = {
								division_template = "Divisione Coloniale"
							}
							delete_unit_template_and_units = {
								division_template = "Banda Indigena Irregolare"
							}
							delete_unit_template_and_units = {
								division_template = "Truppe Irregolari a Cavallo"
							}
							delete_unit_template_and_units = {
								division_template = "Divisione Ascari Libica"
							}
							delete_unit_template_and_units = {
								division_template = "Divisione Ascari Eritrea"
							}
							delete_unit_template_and_units = {
								division_template = "Divisione Ascari Somala"
							}
							delete_unit_template_and_units = {
								division_template = "Banda Irregolare Libica"
							}
							delete_unit_template_and_units = {
								division_template = "Banda Irregolare Eritrea"
							}
							delete_unit_template_and_units = {
								division_template = "Banda Irregolare Somala"
							}
						}
					}
				}
				SOM = {
					transfer_state = 269
					transfer_units_fraction = {
						target = ITA
						size = 1
					}
				}
				707 = { add_core_of = MAD }
				709 = { add_core_of = MAD }
				703 = { add_core_of = SAF }
				704 = { add_core_of = SAF }
				ENG = {
					delete_unit = { state = 447 }
					delete_unit = { state = 446 }
					delete_unit = { state = 453 }
					delete_unit = { state = 551 }
					delete_unit = { state = 547 }
					delete_unit = { state = 546 }
					delete_unit = { state = 558 }
					delete_unit = { state = 274 }
					release = EGY
					release = SUD
					release = UGA
					release = TZN
					release = BAR
					release = ZAM
					release = MLW
					release = KEN
					release = ZIM
					release = BOT
					release = BIA
					release = NGA
					release = GHA
					release = SIE
					release = GAM
					release = MAD
					release = SAF
				}
				BIA = {
					set_politics = {
						ruling_party = neutrality
						elections_allowed = no
					}	
				}
				GHA = {
					set_politics = {
						ruling_party = democratic
						elections_allowed = yes
						last_election = "1936.1.1"
					}	
				}
				IF = {
					limit = {
						has_dlc = "Gotterdammerung"
					}
					BEL = {
						set_autonomy = { target = COG autonomy_state = autonomy_free }
						delete_unit = { state = 295 }
					}
					COG = {
						drop_cosmetic_tag = yes
						set_politics = {
							ruling_party = democratic
							elections_allowed = yes
							last_election = "1936.1.1"
						}	
						remove_ideas = COG_the_invisible_roof
						remove_ideas = BEL_albert_de_vleeschauwer
						retire_character = BEL_albert_de_vleeschauwer
						set_party_name = {
							ideology = neutrality
							long_name = house_of_agua_rosada_long
							name = house_of_agua_rosada
						}
						add_country_leader_role = {
							character =  COG_pedro_vii_alfonso
							promote_leader = yes
							country_leader = {
								ideology = despotism
								expire = "1969.1.1.1"
								traits = { manikongo_of_kongo } 
							}
						}
						add_popularity = {
							ideology = democratic
							popularity = 0.3
						}	
						add_popularity = {
							ideology = communism
							popularity = 0.4
						}	
						delete_unit_template_and_units = { 
						 	division_template = "Troupes du Katanga"
						 	disband = yes
						}
						release = KAT
						release = RWA
						release = BRD
					}
					
					set_global_flag = COG_uprising_happened_flag

					768 = {
						remove_dynamic_modifier = {
							modifier = COG_rwandan_separatism_modifier
						}	
					}

					769 = {
						remove_dynamic_modifier = {
							modifier = COG_burundian_separatism_modifier
						}	
					}
				}
				ELSE_IF = {
					limit = {
						NOT = {
							has_dlc = "Gotterdammerung"
						}
					}
					BEL = {
						delete_unit = { state = 295 }
						release = RWA
						release = BRD
						release = KAT
						release = COG
					}
				}

				SAF = {
					release = NMB
				}
				702 = { add_core_of = GNB }
				POR = {
					delete_unit = { state = 540 }
					delete_unit = { state = 544 }
					release = MZB
					release = ANG
					release = CBV
					release = GNB
				}
				SPR = {
					delete_unit = { state = 290 }
					release = WES
					release = EQG
					release = MRT
				}
				ITA = { ITA_peace_out_eth_on_startup_effect = yes }
				MOR = {
					transfer_state = 290
					transfer_state = 783
				}
				ENG = {
					set_autonomy = { target = SAF autonomy_state = autonomy_free }
				}
				SAF = {
					retire_country_leader = yes
				}
			}
			if = {
				limit = {
					has_game_rule = {
						rule = oceania_colonization_status
						option = OCEANIA_DECOLONIZED
					}
				}
				ENG = {
					release = FIJ
				}
				USA = {
					delete_unit = { state = 629 }
					delete_unit = { state = 630 }
					delete_unit = { state = 631 }
					delete_unit = { state = 632 }
					delete_unit = { state = 638 }
					delete_unit = { state = 642 }
					delete_unit = { state = 727 }
					release = HAW
					release = GUM
				}
				JAP = {
					delete_unit = { state = 684 }
					delete_unit = { state = 633 }
					delete_unit = { state = 647 }
					delete_unit = { state = 646 }
					delete_unit = { state = 648 }
					delete_unit = { state = 645 }
					release = GUM
					release = FSM
				}
				FRA = {
					release = TAH
				}
				AST = {
					release = PNG
					release = SOL
				}
				NZL = {
					release = SAM
				}
				ENG = {
					set_autonomy = { target = AST autonomy_state = autonomy_free }
					set_autonomy = { target = NZL autonomy_state = autonomy_free }
				}
			}
			if = {
				limit = {
					has_game_rule = {
						rule = oceania_colonization_status
						option = OCEANIA_UNITED
					}
				}
				284 = { 
					add_core_of = HAW
				}
				629 = {
					add_core_of = HAW
				}
				630 = {
					add_core_of = HAW
				}
				631 = {
					add_core_of = HAW
				}
				632 = {
					add_core_of = HAW
				}
				633 = {
					add_core_of = HAW
				}
				634 = {
					add_core_of = HAW
				}
				635 = {
					add_core_of = HAW
				}
				636 = {
					add_core_of = HAW
				}
				638 = {
					add_core_of = HAW
				}
				639 = {
					add_core_of = HAW
				}
				641 = {
					add_core_of = HAW
				}
				642 = {
					add_core_of = HAW
				}
				643 = {
					add_core_of = HAW
				}
				646 = {
					add_core_of = HAW
				}
				647 = {
					add_core_of = HAW
				}
				648 = { 
					add_core_of = HAW 
				}
				684 = {
					add_core_of = HAW
				}
				723 = {
					add_core_of = HAW
				}
				725 = {
					add_core_of = HAW
				}
				726 = {
					add_core_of = HAW
				}
				727 = {
					add_core_of = HAW
				}
				734 = {
					add_core_of = HAW
				}
				645 = {
					add_core_of = HAW
				} #Iwo Jima
				ENG = {
					release = HAW
					set_autonomy = { target = AST autonomy_state = autonomy_free }
				}
				USA = {
					delete_unit = { state = 629 }
					delete_unit = { state = 630 }
					delete_unit = { state = 631 }
					delete_unit = { state = 632 }
					delete_unit = { state = 638 }
					delete_unit = { state = 642 }
					delete_unit = { state = 727 }
					release = HAW
				}
				JAP = {
					delete_unit = { state = 684 }
					delete_unit = { state = 633 }
					delete_unit = { state = 647 }
					delete_unit = { state = 646 }
					delete_unit = { state = 648 }
					delete_unit = { state = 645 }
					release = HAW
				}
				FRA = {
					release = HAW
				}
				AST = {
					release = HAW
					release = PNG
				}
				HAW = {
					change_tag_from = NZL
				}
				set_global_flag = form_polynesia_flag
				
				524 = { add_core_of = HAW } #Taiwan
				
				284 = { 
					add_extra_state_shared_building_slots = 1
					add_building_construction = {
						type = industrial_complex
						level = 1
						instant_build = yes
					}
				}
				629 = {
					add_extra_state_shared_building_slots = 4
					add_building_construction = {
						type = industrial_complex
						level = 3
						instant_build = yes
					}
					add_building_construction = {
						type = arms_factory
						level = 1
						instant_build = yes
					}
				}
				631 = {
					add_extra_state_shared_building_slots = 1
					add_building_construction = {
						type = industrial_complex
						level = 1
						instant_build = yes
					}
				}
				633 = {
					add_extra_state_shared_building_slots = 1
					add_building_construction = {
						type = industrial_complex
						level = 1
						instant_build = yes
					}
				}
				634 = {
					add_extra_state_shared_building_slots = 1
					add_building_construction = {
						type = industrial_complex
						level = 1
						instant_build = yes
					}
				}
				635 = {
					add_extra_state_shared_building_slots = 1
					add_building_construction = {
						type = arms_factory
						level = 1
						instant_build = yes
					}
				}
				636 = {
					add_extra_state_shared_building_slots = 1
					add_building_construction = {
						type = dockyard
						level = 1
						instant_build = yes
					}
				}
				638 = {
					add_extra_state_shared_building_slots = 1
					add_building_construction = {
						type = arms_factory
						level = 1
						instant_build = yes
					}
				}
				639 = {
					add_extra_state_shared_building_slots = 1
					add_building_construction = {
						type = industrial_complex
						level = 1
						instant_build = yes
					}
				}
				641 = {
					add_extra_state_shared_building_slots = 1
					add_building_construction = {
						type = dockyard
						level = 1
						instant_build = yes
					}
				}
				642 = {
					add_extra_state_shared_building_slots = 1
					add_building_construction = {
						type = dockyard
						level = 1
						instant_build = yes
					}
				}
				643 = {
					add_extra_state_shared_building_slots = 1
					add_building_construction = {
						type = industrial_complex
						level = 1
						instant_build = yes
					}
				}
				646 = {
					add_extra_state_shared_building_slots = 1
					add_building_construction = {
						type = dockyard
						level = 1
						instant_build = yes
					}
				}
				647 = {
					add_extra_state_shared_building_slots = 1
					add_building_construction = {
						type = dockyard
						level = 1
						instant_build = yes
					}
				}
				684 = {
					add_extra_state_shared_building_slots = 1
					add_building_construction = {
						type = arms_factory
						level = 1
						instant_build = yes
					}
				}
				723 = {
					add_extra_state_shared_building_slots = 1
					add_building_construction = {
						type = arms_factory
						level = 1
						instant_build = yes
					}
				}
				725 = {
					add_extra_state_shared_building_slots = 1
				}
				726 = {
					add_extra_state_shared_building_slots = 1
					add_building_construction = {
						type = industrial_complex
						level = 1
						instant_build = yes
					}
				}
				727 = {
					add_extra_state_shared_building_slots = 1
					add_building_construction = {
						type = industrial_complex
						level = 1
						instant_build = yes
					}
				}
				734 = {
					add_extra_state_shared_building_slots = 1
					add_building_construction = {
						type = industrial_complex
						level = 1
						instant_build = yes
					}
				}
				645 = {
					add_extra_state_shared_building_slots = 2
					add_building_construction = {
						type = dockyard
						level = 1
						instant_build = yes
					}
				} #Iwo Jima
				
				HAW = {
					set_cosmetic_tag = united_polynesia
					country_event = tfv_new_zealand.8
				}
			}
			if = {
				limit = {
					has_game_rule = {
						rule = asia_colonization_status
						option = ASIA_DECOLONIZED
					}
				}
				710 = { add_core_of = MLD }
				711 = { add_core_of = AST }
				712 = { add_core_of = AST }
				733 = { add_core_of = RAJ }
				659 = { add_core_of = FSA }
				ENG = {
					delete_unit = { state = 454 }
					delete_unit = { state = 659 }
					delete_unit = { state = 422 }
					delete_unit = { state = 326 }
					delete_unit = { state = 336 }
					release = MLD
					release = MAL
					release = SRL
					release = QAT
					release = UAE
					release = FSA
					release = BHR
				}
				RAJ = {
					release = KAS
					release = BAN
					release = PAK
					release = FSA
					release = SKK
					release = MPU
				}
				ENG = {
					set_autonomy = { target = RAJ autonomy_state = autonomy_free }
					set_autonomy = { target = MAL autonomy_state = autonomy_free }
					set_autonomy = { target = BRM autonomy_state = autonomy_free }
					set_autonomy = { target = PAL autonomy_state = autonomy_free }
					set_autonomy = { target = JOR autonomy_state = autonomy_free }
					set_autonomy = { target = KUW autonomy_state = autonomy_free }
					set_autonomy = { target = OMA autonomy_state = autonomy_free }
				}
				MAL = {
					abandon_colony_tag = yes
					retire_country_leader = yes
				}
				RAJ = {
					abandon_colony_tag = yes
					retire_country_leader = yes
				}
				HOL = {
					set_autonomy = { target = INS autonomy_state = autonomy_free }
				}
				BRM = {
					drop_cosmetic_tag = yes
					retire_country_leader = yes
				}
				PAL = {
					drop_cosmetic_tag = yes
					retire_country_leader = yes
				}
				LEB = {
					drop_cosmetic_tag = yes
				}
				SYR = {
					drop_cosmetic_tag = yes
				}
				JOR = {
					drop_cosmetic_tag = yes
				}
				INS = {
					abandon_colony_tag = yes
					retire_country_leader = yes
					transfer_state = 721
				}
				USA = {
					delete_unit = { state = 327 }
					set_autonomy = { target = PHI autonomy_state = autonomy_free }
				}
				FRA = {
					delete_unit = { state = 553 }
					delete_unit = { state = 741 }
					delete_unit = { state = 286 }
					delete_unit = { state = 671 }
					release = VIN
					release = CAM
					release = LAO
					set_autonomy = { target = LEB autonomy_state = autonomy_free }
					set_autonomy = { target = SYR autonomy_state = autonomy_free }
				}
				OMA = {
					release = IMO  
				}
				1015 = { add_core_of = OMA }
				RAJ = {
					transfer_state = 321
					transfer_state = 320
					transfer_state = 733
				}
				AST = {
					transfer_state = 712
					transfer_state = 711
				}
				728 = { add_core_of = GXC }
				729 = { add_core_of = GXC }
				326 = { add_core_of = GXC }
				GXC = {
					transfer_state = 728
					transfer_state = 729
					transfer_state = 326
				}
				JAP = {
					set_autonomy = { target = MAN autonomy_state = autonomy_free }
					set_autonomy = { target = MEN autonomy_state = autonomy_free }
					release = KOR
					transfer_units_fraction = {
						target = KOR
						size = 1
					}
				}
				MAN = {
					transfer_state = 745
				}
				CHI = {
					transfer_state = 609
					transfer_state = 524
				}
				KOR = {
					transfer_units_fraction = {
						target = JAP
						size = 1
					}
				}
			}
			# Game Rules - Fragmentation
			if = {
				limit = {
					has_game_rule = {
						rule = eng_fragmentation_status
						option = ENG_FRAGMENTED
					}
				}
				ENG = {
					delete_unit = { state = 116 }
					release = SCO
					release = WLS
					release = NIR
					release = MLT
					release = CYP
					set_cosmetic_tag = ENG_england
					set_global_flag = ENG_became_england
				}
			}
			if = {
				limit = {
					has_game_rule = {
						rule = spr_fragmentation_status
						option = SPR_EU4
					}
				}
				173 = { add_core_of = ADU }
				118 = { add_core_of = ADU }
				167 = { add_core_of = CAT }
				177 = { add_core_of = CAT }
				794 = { add_core_of = CAT }
				166 = { add_core_of = CAT }
				114 = { add_core_of = CAT }
				115 = { add_core_of = CAT }
				116 = { add_core_of = CAT }
				792 = { remove_core_of = NAV }
				SPR = {
					delete_unit = { state = 177 }
					release = CAT
					release = NAV
					release = GLC
					release = ADU
					set_cosmetic_tag = SPR_castille
					set_politics = {
						ruling_party = neutrality
						elections_allowed = yes
					}
					set_political_party = {
						ideology = neutrality
						popularity = 85
					}
					transfer_units_fraction = {
						target = CAT
						size = 0.2
					}
					transfer_units_fraction = {
						target = GLC
						size = 0.025
					}
					transfer_units_fraction = {
						target = NAV
						size = 0.025
					}
					transfer_units_fraction = {
						target = ADU
						size = 0.1
					}
				}
				SPA = {
					set_cosmetic_tag = SPR_nationalist_castille
				}
				SPB = {
					set_cosmetic_tag = SPR_carlist_castille
				}
				SPC = {
					set_cosmetic_tag = SPR_anarchist_castille
				}
				#SPD = { #MM: Never worked since SPD is not set up until CW so this will cause error
				#	set_cosmetic_tag = SPR_republican_castille
				#}
				ENG = {
					delete_unit = { state = 118 }
					release = ADU
					release = CAT
				}
				ITA = {
					release = CAT
				}
				CAT = {
					set_politics = {
						ruling_party = neutrality
						elections_allowed = no
					}
					set_political_party = {
						ideology = neutrality
						popularity = 85
					}
					set_cosmetic_tag = CAT_aragon
				}
				NAV = {
					set_politics = {
						ruling_party = neutrality
					}
					set_political_party = {
						ideology = neutrality
						popularity = 85
					}
				}
				GLC = {
					set_politics = {
						ruling_party = neutrality
					}
					set_political_party = {
						ideology = neutrality
						popularity = 85
					}
				}
				ADU = {
					set_country_flag = country_formed_andalusia_flag
				}
				set_global_flag = form_andalusia_flag
				792 = { add_core_of = NAV }
				165 = { add_core_of = ADU }
				171 = { add_core_of = ADU }
				792 = { add_core_of = ADU }
				172 = { add_core_of = ADU }
				790 = { add_core_of = ADU }
				789 = { add_core_of = ADU }
				41 = { add_core_of = ADU }
				169 = { add_core_of = ADU }
				168 = { add_core_of = ADU }
				167 = { add_core_of = ADU }
				794 = { add_core_of = ADU }
				793 = { add_core_of = ADU }
				791 = { add_core_of = ADU }
				788 = { add_core_of = ADU }
				178 = { add_core_of = ADU }
				177 = { add_core_of = ADU }
				176 = { add_core_of = ADU }
				175 = { add_core_of = ADU }
				174 = { add_core_of = ADU }
				170 = { add_core_of = ADU }
				166 = { add_core_of = ADU }
				112 = { add_core_of = ADU }
				179 = { add_core_of = ADU }
				180 = { add_core_of = ADU }
				181 = { add_core_of = ADU }
				697 = { add_core_of = ADU }
				698 = { add_core_of = ADU }
				795 = { add_core_of = ADU }
				173 = { add_core_of = ADU }
				118 = { add_core_of = ADU }
				
				165 = { add_core_of = SPR }
				167 = { add_core_of = SPR }
				177 = { add_core_of = SPR }
				171 = { add_core_of = SPR }
				172 = { add_core_of = SPR }
				173 = { add_core_of = SPR }
				794 = { add_core_of = SPR }
				166 = { add_core_of = SPR }
				
				#Italy should keep their cores on the Med. Islands
				114 = { add_core_of = ITA }
				115 = { add_core_of = ITA }
				
				#Kingdom of Naples
				117 = { add_core_of = CAT }
				156 = { add_core_of = CAT }
				849 = { add_core_of = CAT }
			}
			if = {
				limit = {
					has_game_rule = {
						rule = spr_fragmentation_status
						option = SPR_FRAGMENTED
					}
				}
				SPR = {
					release = CAT
					release = NAV
					release = GLC
				}
				165 = { add_core_of = SPR }
				171 = { add_core_of = SPR }
				172 = { add_core_of = SPR }
				792 = { add_core_of = SPR }
			}
			if = {
				limit = {
					has_game_rule = {
						rule = fra_fragmentation_status
						option = FRA_FRAGMENTED
					}
				}
				FRA = {
					release = OCC
					release = BRI
					release = COR
					release = NAV
					transfer_units_fraction = {
						target = OCC
						size = 0.4
					}
					transfer_units_fraction = {
						target = BRI
						size = 0.1
					}
					transfer_units_fraction = {
						target = COR
						size = 0.001
					}
					transfer_units_fraction = {
						target = NAV
						size = 0.001
					}
				}
				1 = { add_core_of = FRA }
				14 = { add_core_of = FRA }
				19 = { add_core_of = FRA }
				20 = { add_core_of = FRA }
				21 = { add_core_of = FRA }
				851 = { add_core_of = FRA }
				22 = { add_core_of = FRA }
				25 = { add_core_of = FRA }
				26 = { add_core_of = FRA }
				31 = { add_core_of = FRA }
				32 = { add_core_of = FRA }
				735 = { add_core_of = FRA }
				806 = { add_core_of = FRA }
			}
			if = {
				limit = {
					has_game_rule = {
						rule = yug_fragmentation_status
						option = YUG_FRAGMENTED
					}
				}
				764 = {
					remove_core_of = YUG
				}
				736 = {
					remove_core_of = YUG
				}
				852 = {
					remove_core_of = YUG
				}
				YUG = {
					release = SLV
					release = BOS
					release = MAC
					release = SER
					transfer_units_fraction = {
						target = SER
						size = 1
					}
					release = CRO
					release = MNT
				}
				SER = {
					change_tag_from = YUG
				}
				#SER = {
				#	country_event = DOD_yugoslavia.166 # MM: Commented since it is a NON-EXISTENT EVENT
				#}
				CRO = {
					set_political_party = {
						ideology = democratic
						popularity = 50
					}
					set_politics = {
						ruling_party = democratic
						last_election = "1936.1.1"
						election_frequency = 48
						elections_allowed = yes
					}
				}
			}
			if = {
				limit = {
					has_game_rule = {
						rule = sov_fragmentation_status
						option = SOV_FRAGMENTED
					}
				}
				SOV = {
					release = UKR
					release = BLR
					release = GEO
					release = AZR
					release = ARM
					release = UZB
					release = TAJ
					release = KYR
					release = TMS
					release = KAZ
					# retire_country_leader = yes
                    set_cosmetic_tag = SOV_russia
                    set_global_flag = SOV_became_russia
				}
			}
			if = {
				limit = {
					has_game_rule = {
						rule = sov_fragmentation_status
						option = SOV_UTTERLY_FRAGMENTED
					}
				}
				#Add Repola and Uhtua VPs
				add_victory_points = {
					province = 6098 #Repola
					value = 1
				}
				add_victory_points = {
					province = 3067 #Uhtua
					value = 1
				}
				#Add Porajärvi VP
				add_victory_points = {
					province = 2998 #Porajärvi
					value = 1
				}
				566 = {
					add_core_of = BYA
				}
				567 = {
					add_core_of = EVE
				}
				568 = {
					add_core_of = EVE
				}
				236 = {
					add_core_of = KAL
				}
				DON = {
					add_state_core = 218
					add_state_core = 245
					add_state_core = 238
				}
				KUB = {
					add_state_core = 234
					add_state_core = 233
					add_state_core = 235
				}
				SOV = {
					release = CRI
					release = MOL
					release = UKR
					release = BLR
					release = KAR
					release = ABK
					release = GEO
					release = AZR
					release = ARM
					release = CIN
					release = DAG
					release = NOA
					release = KBK
					release = KAL
					release = KHI
					release = KKP
					release = TAJ
					release = BUK
					release = UZB
					release = KYR
					release = TMS
					release = KAZ
					release = ALT
					release = KAZ
					release = VGE
					release = TAT
					release = BSK
					release = NEN
					release = KOM
					release = YAM
					release = OVO
					release = TAY
					release = BYA
					release = YAK
					release = CKK
					release = VLA
					release = FER
					release = UDM
					release = MEL
					release = CHU
					release = KHA
					release = EVE
					release = SMI
					release = KUB
					release = DON
					# retire_country_leader = yes
                    set_cosmetic_tag = SOV_russia
                    set_global_flag = SOV_became_russia
				}
			}
			if = {
				limit = {
					has_game_rule = {
						rule = raj_fragmentation_status
						option = RAJ_FRAGMENTED
					}
				}
				RAJ = {
					release = BAN
					release = PAK
					drop_cosmetic_tag = yes
				}
			}
			if = {
				limit = {
					has_game_rule = {
						rule = raj_fragmentation_status
						option = RAJ_PRINCELY_STATES_FREE
					}
				}
				RAJ = {
					release = PSH
					release = HYD
					release = MYS
					release = RJP
					release = CIP
					release = RAS
					release = NWF
					release = KAS
					release = MPU
					release = WIS
					release = KOL
					release = KHL
					release = SIN
					release = KLT
					release = SKK
					release = BLC
					release = BAN
					release = PAK
					drop_cosmetic_tag = yes
				}
			}
			if = {
				limit = {
					has_game_rule = {
						rule = nordics_fragmentation_status
						option = SAPMI_RELEASED
					}
				}
				148 = {
					add_victory_points = {
						province = 6142
						value = 4
					}
				}
				FIN = {
					release = SMI
				}
				SWE = {
					release = SMI
				}
				NOR = {
					release = SMI
				}
			}
			if = {
				limit = {
					has_game_rule = {
						rule = nordics_fragmentation_status
						option = NORDICS_FRAGMENTED
					}
				}
				148 = {
					add_victory_points = {
						province = 6142
						value = 4
					}
				}
				#Add Repola and Uhtua VPs
				add_victory_points = {
					province = 6098 #Repola
					value = 1
				}
				add_victory_points = {
					province = 3067 #Uhtua
					value = 1
				}
				#Add Porajärvi VP
				add_victory_points = {
					province = 2998 #Porajärvi
					value = 1
				}
				101 = {
					add_core_of = GRN
				}
				FIN = {
					release = SMI
					release = KAR
				}
				SWE = {
					release = SMI
				}
				NOR = {
					release = SMI
				}
				DEN = {
					set_autonomy = {
						target = ICE
						autonomy_state = autonomy_free
						end_wars  = yes
						end_civil_wars = yes
					}	
					release = GRN	
				}
				101 = {
					set_state_controller_to = GRN
				}
				ICE = {
					drop_cosmetic_tag = yes
					IF = {
						limit = {
							has_idea = ICE_christian_x
						}
						remove_ideas = ICE_christian_x
					}
				}
			}

			if = {
				limit = {
					has_game_rule = {
						rule = quebec_colonization_status
						option = FREE_QUEBEC
					}
				}
				CAN = {
					release = QUE
					transfer_units_fraction = {
						target = QUE
						size = 0.3
					}
				}
				468 = {
					set_victory_points = {
						province = 4345
						value = 15
					}

					set_victory_points = {
						province = 12149
						value = 20
					}
				}
			}
			if = {
				limit = {
					has_game_rule = {
						rule = eth_fragmentation_status
						option = ETH_FRAGMENTED
					}
				}
				ETH = {
					release = AFA
					release = TIG
					release = QEM
					release = BEG
					release = GBA
					release = SID
					release = HAR
					release = ORO
					transfer_units_fraction = {
						target = AFA
						size = 0.15
					}
					transfer_units_fraction = {
						target = TIG
						size = 0.1
					}
					transfer_units_fraction = {
						target = QEM
						size = 0.1
					}
					transfer_units_fraction = {
						target = BEG
						size = 0.1
					}
					transfer_units_fraction = {
						target = GBA
						size = 0.1
					}
					transfer_units_fraction = {
						target = SID
						size = 0.1
					}
					transfer_units_fraction = {
						target = HAR
						size = 0.15
					}
					transfer_units_fraction = {
						target = ORO
						size = 0.2
					}
				}
				ITA_peace_out_eth_on_startup_effect = yes
			}
			if = {
				limit = {
					has_game_rule = {
						rule = ita_fragmentation_status
						option = ITA_FRAGMENTED
					}
				}
				ITA = {
					delete_unit_template_and_units = {
						division_template = "Camicie Nere"
					}
					delete_unit_template_and_units = {
						division_template = "Divisione Coloniale"
					}
					delete_unit_template_and_units = {
						division_template = "Banda Indigena Irregolare"
					}
					delete_unit_template_and_units = {
						division_template = "Truppe Irregolari a Cavallo"
					}
					delete_unit_template_and_units = {
						division_template = "Divisione Ascari Libica"
					}
					delete_unit_template_and_units = {
						division_template = "Divisione Ascari Eritrea"
					}
					delete_unit_template_and_units = {
						division_template = "Divisione Ascari Somala"
					}
					delete_unit_template_and_units = {
						division_template = "Banda Irregolare Libica"
					}
					delete_unit_template_and_units = {
						division_template = "Banda Irregolare Eritrea"
					}
					delete_unit_template_and_units = {
						division_template = "Banda Irregolare Somala"
					}

					ITA = {
						ITA_vittorio_emanuele_iii = { set_nationality = SPM }
						ITA_papa_pio_xii = { set_nationality = PAP }
					}
					
					release = PAP
					
					PAP = {
					drop_cosmetic_tag = yes
					retire_character = PAP_generic_ruler_of_vatican
					set_capital = {state = 2}
					remove_ideas = fascist_influence_weak
					remove_ideas = ALL_microstate_idea
					}
					
					release = LBV
					release = TOS
					release = SPM
					release = TTS
					
					LBA = {
					drop_cosmetic_tag = yes
					retire_country_leader = yes
					add_popularity = {ideology = neutrality popularity = 0.35}
					set_politics = {
					ruling_party = neutrality
					}
					remove_ideas = LBA_italian_libya_idea
					remove_ideas = ALL_colonial_militia
					add_ideas = civilian_economy
					load_focus_tree = {tree = generic_focus}
					}
					
					transfer_units_fraction = {
						target = LBV
						size = 0.1
					}
					transfer_units_fraction = {
						target = PAP
						size = 0.1
					}
					transfer_units_fraction = {
						target = TOS
						size = 0.1
					}
					transfer_units_fraction = {
						target = SPM
						size = 0.1
					}
					#transfer_units_fraction = {
					#	target = TTS
					#	size = 0.2
					#}

					SPM = {
						promote_character = {
							character = ITA_vittorio_emanuele_iii 
							ideology = despotism
						}
					}

					PAP = {
						add_country_leader_role = {
							character =  ITA_papa_pio_xii # optional if inside character scope
							promote_leader = yes
							country_leader = {
								ideology = oligarchism
								expire = 1958.12.16
								traits = { supreme_pontiff grand_master_of_the_equestrian_order_of_the_holy_sepulcher_of_jerusalem }
							}
						}
					}

					release = GRE #Last one so that ITA still has states during the transfer_units process, otherwise it will fail. But below we need to teleport armies from GRE to TTS

				}

				TTS =  {
					change_tag_from = ITA
				}
				TTS = {
					annex_country = {
						target = ITA
						transfer_troops = yes
					}

					164 = { #RHODES - Italian state that get's transferred to GRE with ITA fragmentation rule (above)
						teleport_armies = { # Unfortunately navies won't be transferred, they will have to sail back home :(
							limit = {
								tag = TTS
							}
							to_state_array = TTS.owned_controlled_states
						}
					}
				}

				if = {
					limit = {
						NOT = {
							has_game_rule = {
								rule = africa_colonization_status
								option = AFRICA_DECOLONIZED
							}
						}
					}
					TTS = { load_oob = ITA_1936_african_oob_for_fragmentation }
				}

				if = {
					limit = {
						NOT = {
							has_game_rule = {
								rule = eth_fragmentation_status
								option = ETH_FRAGMENTED
							}
						}
						NOT = {
							has_game_rule = {
								rule = africa_colonization_status
								option = AFRICA_DECOLONIZED
							}
						}
					}
					TTS = {
						declare_war_on = {
							target = ETH
							type = annex_everything
						}
					}
				}
			}
			if = {
				limit = {
					has_game_rule = {
						rule = germany_fragmentation_status
						option = GERMANY_FRAGMENTED
					}
				}
				GER = {

					release = SIL
					release = SAX
					release = MEK
					release = HAN
					release = THU
					release = HES
					release = RHI
					release = WUR
					release = BAY

					transfer_units_fraction = {
						target = SAX
						size = 0.1
					}
					transfer_units_fraction = {
						target = MEK
						size = 0.1
					}
					transfer_units_fraction = {
						target = HES
						size = 0.1
					}
					transfer_units_fraction = {
						target = HAN
						size = 0.1
					}
					transfer_units_fraction = {
						target = THU
						size = 0.1
					}
					transfer_units_fraction = {
						target = RHI
						size = 0.1
					}
					transfer_units_fraction = {
						target = BAY
						size = 0.2
					}

					release = PRE
					
					978 = {
						set_demilitarized_zone = no
					}
					42 = {
						set_demilitarized_zone = no
					}
					51 = {
						set_demilitarized_zone = no
					}
				}

				PRE =  {
					change_tag_from = GER
				}

				PRE = {
					annex_country = {
						target = GER
						transfer_troops = yes
					}
					release = SHL
				}

				every_state = {
					limit = {
						is_core_of = GER
					}
					remove_core_of = GER
				}

			}
		}
	}

	# ROOT is capitulated country, FROM is winner
	on_capitulation = {
		effect = {
			if = {
				limit = {
					tag = CSA
					FROM = {
						OR = {
							tag = USA
							is_in_faction_with = USA
						}
					}
				}
				USA = {
					annex_country = { target = CSA } #cleaner than hoping that the peace conference AI will sort it out
				}
			}
		}
		effect = {
			if = { # Reducing the Crisisjaren idea to level 1 when capitulated (in case player didn't manage to finish the mainland industrial focuses), but still needs Liberation to remove it fully
				limit = {
					original_tag = HOL
					has_idea = HOL_de_crisisjaren_4
				}
				swap_ideas = {
					remove_idea = HOL_de_crisisjaren_4
					add_idea = HOL_de_crisisjaren_1
				}
			}
			if = {
				limit = {
					original_tag = HOL
					has_idea = HOL_de_crisisjaren_3
				}
				swap_ideas = {
					remove_idea = HOL_de_crisisjaren_3
					add_idea = HOL_de_crisisjaren_1
				}
			}
			if = {
				limit = {
					original_tag = HOL
					has_idea = HOL_de_crisisjaren_2
				}
				swap_ideas = {
					remove_idea = HOL_de_crisisjaren_2
					add_idea = HOL_de_crisisjaren_1
				}
			}
			if = { # Only possible if Abandon the Gold Standard hasn't been taken yet, this can be taken later so should be reduced to level 2 rather than 1
				limit = {
					original_tag = HOL
					has_idea = HOL_de_crisisjaren_5
				}
				swap_ideas = {
					remove_idea = HOL_de_crisisjaren_5
					add_idea = HOL_de_crisisjaren_2
				}
			}
			if = {
				limit = {
					tag = GER
					FROM = {
						tag = HOL
						has_completed_focus = HOL_wilhelminism
					}
				}
				HOL = { country_event = { id = mtg_netherlands.76 } }
			}
		}
	}

	#ROOT is winner #FROM is loser
	on_peaceconference_ended = {
		effect = {
			if = {
				limit = {
					original_tag = GER
					FROM = { original_tag = HOL }
				}
				remove_ideas = HOL_german_defectors_2
			}
			# USA 'civil war' ends
			if = {
				limit = {
					tag = CSA
					FROM = { original_tag = USA }
				}
				load_focus_tree = { tree = usa_focus keep_completed = no }
				unlock_national_focus = USA_reestablish_the_gold_standard
				complete_national_focus = USA_america_first
				unlock_national_focus = USA_ally_with_the_silver_shirts
				unlock_national_focus = USA_invite_foreign_support
			}
			if = {
				limit = {
					OR = {
						AND = {
							FROM = { original_tag = PAK }
							ROOT = { original_tag = RAJ }
						}
						AND = {
							FROM = { original_tag = RAJ }
							ROOT = { original_tag = PAK }
						}
					}
				}
				FROM = {
					delete_unit_template_and_units = {
						division_template = "Pakistani Liberation Army"
					}
					delete_unit_template_and_units = {
						division_template = "Hindu Militia"
					}
				}
				ROOT = {
					delete_unit_template_and_units = {
						division_template = "Pakistani Liberation Army"
					}
					delete_unit_template_and_units = {
						division_template = "Hindu Militia"
					}
				}
			}
		}
	}

	#ROOT is new controller #FROM is old controller #FROM.FROM is state ID
	on_state_control_changed = {
		effect = {
			if = {
				limit = {
					original_tag = HOL
					has_completed_focus = HOL_wilhelminism
					FROM = {
						original_tag = GER
						has_government = fascism
						has_civil_war = no
					}
					FROM.FROM = {
						is_core_of = GER
					}
				}
				FROM.FROM = { 
					set_state_flag = HOL_german_states_kaiser
				}
				country_event = { id = mtg_netherlands.73 }
			}
			if = {
				limit = {
					FROM.FROM = {
						OR = {
							state = 7
							state = 35
							state = 36
						}
					}
				}
				FROM = {
					set_country_flag = HOL_lost_starting_state
				}
			}
		}
	}

	on_nuke_drop = {
		effect = {			
			if = {
				limit = {
					tag = USA
					FROM = {
						state = 16
					}
				}
				set_country_flag = achievement_team_america
			}
		}
	}

	# FROM is the sinker, ROOT is the owner of the ship being sunk
	on_pride_of_the_fleet_sunk = {
		effect = {
			if = {
				limit = {
					tag = ENG
				}
				FROM = { set_country_flag = achievements_pride_and_extreme_prejudice }
			}
		}
	}
	# FROM is the faction Leader, ROOT is the country leaving the faction 
	on_leave_faction = {
		effect = {
			if = {
				limit = { 
					original_tag = HOL
					has_country_flag = HOL_joined_germany_flag
				}
				FROM = {
					create_wargoal = {
						type = take_state_focus
						target = ROOT
						generator = { 7 }
					}
				}
			}
		}
	}

	# ROOT is the new faction leader FROM is the old faction leader
	on_assume_faction_leadership = {
		effect = {
			if = {
				limit = {
					FROM = {
						OR = {
							tag = GER
							tag = ENG
							tag = SOV
						}
					}
					NOT = {
						OR = {
							tag = USA
							tag = ENG
							tag = GER
							tag = ITA
							tag = FRA
							tag = SOV
							tag = JAP
							tag = CHI
						}
					}
				}
				set_country_flag = assuming_direct_control_achievement_flag
			}
		}
	}
	on_monthly_MEX = {
		effect = { # Effect to make Trotsky appear in Mexico if the player doesn't have AAT 
			if = {
				limit = {
					has_aat = no
					NOT = { has_country_flag = MEX_trotsky_event_triggered }
				}
				if = {
					limit = {
						date > 1937.01.01 # Historically arrived in January 9th 1937
					}
					MEX = { # I know I don't need to do this but I don't want to take my chances 
						set_country_flag = MEX_trotsky_event_triggered
						country_event = {
							id = mexico.17
							days = 8
						}
					}
				}
			}
		}
	}
}
