﻿###########################
###########################

add_namespace = LSM_core_and_claim

country_event = {
	id = LSM_core_and_claim.1
	
	trigger = {
		is_subject = no
		is_historical_focus_on = no
		is_nordic_formable_countries = yes
		NOT = { has_country_flag = has_formed_nordic }
		all_state = {
			OR = {
				AND = {
					NOT = { is_core_of = DEN }
					NOT = { is_core_of = SWE }
					NOT = { is_core_of = NOR }
					NOT = { is_core_of = FIN }
					NOT = { is_core_of = ICE }
				}
				controller = {
					OR = {
						tag = ROOT
						AND = {
							is_in_faction_with = ROOT
							is_nordic_formable_countries = no
						}
					}
				}
			}
		}
	}

	mean_time_to_happen = { days = 7 }

	hidden = yes

	immediate = {
		set_country_flag = first_country_to_form_nordic
		every_state = {
			limit = {
				OR = {
					is_core_of = DEN
					is_core_of = SWE
					is_core_of = NOR
					is_core_of = FIN
					is_core_of = ICE
				}
				NOT = { is_core_of = ROOT }
				NOT = { is_claimed_by = ROOT }
				NOT = {
					any_other_country = {
						is_in_faction_with = ROOT
						OR = {
							PREV = { is_core_of = PREV }
							PREV = { is_claimed_by = PREV }
						}
					}
				}
			}
			add_core_of = ROOT
		}
	}
}


country_event = {
	id = LSM_core_and_claim.2
	
	trigger = {
		NOT = { has_country_flag = has_formed_cena }
		is_subject = no
		is_historical_focus_on = no
		is_cena_formable_countries = yes
		all_state = {
			OR = {
				AND = {
					NOT = { is_core_of = GUA }
					NOT = { is_core_of = NIC }
					NOT = { is_core_of = ELS }
					NOT = { is_core_of = COS }
					NOT = { is_core_of = HON }
					NOT = { is_core_of = PAN }
				}
				controller = {
					OR = {
						tag = ROOT
						AND = {
							is_in_faction_with = ROOT
							is_cena_formable_countries = no
						}
					}
				}
			}
		}
	}

	mean_time_to_happen = { days = 7 }

	hidden = yes

	immediate = {
		set_country_flag = has_formed_cena
		every_state = {
			limit = {
				OR = {
					is_core_of = GUA
					is_core_of = NIC
					is_core_of = ELS
					is_core_of = COS
					is_core_of = HON
					is_core_of = PAN
				}
				NOT = { is_core_of = ROOT }
				NOT = { is_claimed_by = ROOT }
				NOT = {
					any_other_country = {
						is_in_faction_with = ROOT
						OR = {
							PREV = { is_core_of = PREV }
							PREV = { is_claimed_by = PREV }
						}
					}
				}
			}
			add_core_of = ROOT
		}
	}
}

country_event = {
	id = LSM_core_and_claim.3
	
	trigger = {
		NOT = { has_country_flag = has_formed_baltic }
		is_subject = no
		is_historical_focus_on = no
		is_baltic_formable_countries = yes
		all_state = {
			OR = {
				AND = {
					NOT = { is_core_of = LIT }
					NOT = { is_core_of = LAT }
					NOT = { is_core_of = EST }		
				}
				controller = {
					OR = {
						tag = ROOT
						AND = {
							is_in_faction_with = ROOT
							is_baltic_formable_countries = no
						}
					}
				}
			}
		}
	}

	mean_time_to_happen = { days = 7 }

	hidden = yes

	immediate = {
		set_country_flag = has_formed_baltic
		every_state = {
			limit = {
				OR = {
					is_core_of = LIT
					is_core_of = LAT
					is_core_of = EST
				}
				NOT = { is_core_of = ROOT }
				NOT = { is_claimed_by = ROOT }
				NOT = {
					any_other_country = {
						is_in_faction_with = ROOT
						OR = {
							PREV = { is_core_of = PREV }
							PREV = { is_claimed_by = PREV }
						}
					}
				}
			}
			add_core_of = ROOT
		}
	}
}
country_event = {
	id = LSM_core_and_claim.4
	
	trigger = {
		NOT = { has_country_flag = has_formed_auh }
		is_subject = no
		is_historical_focus_on = no
		is_auh_formable_countries = yes
		all_state = {
			OR = {
				AND = {
					NOT = { is_core_of = HUN }
					NOT = { is_core_of = AUS }
					NOT = { is_core_of = CZE }
				}
				controller = {
					OR = {
						tag = ROOT
						AND = {
							is_in_faction_with = ROOT
							is_auh_formable_countries = no
						}
					}
				}
			}
		}
	}

	mean_time_to_happen = { days = 7 }

	hidden = yes

	immediate = {
		set_country_flag = has_formed_auh
		if = {
			limit = {
				OR = {
					AND = {
						NOT = { GER = { has_completed_focus = GER_anschluss } }
						NOT = { has_global_flag = GER_democratic_referendum_austria_flag }
					}
					NOT = { is_in_faction_with = GER }
					GER = { is_subject = yes }
					ROOT = { NOT = { original_tag = HUN } }
				}
			}
			every_state = {
				limit = {
					OR = {
						is_core_of = HUN
						is_core_of = CZE
						is_core_of = AUS
						is_claimed_by = HUN
						is_claimed_by = CZE
						is_claimed_by = AUS
					}
					NOT = { is_core_of = ROOT }
					NOT = { is_claimed_by = ROOT }
					NOT = {
						any_other_country = {
							is_in_faction_with = ROOT
							OR = {
								PREV = { is_core_of = PREV }
								PREV = { is_claimed_by = PREV }
							}
						}
					}
				}
				add_core_of = ROOT
			}
		}
		else_if = {
			limit = {
				is_in_faction_with = GER
				OR = {
					GER = { has_completed_focus = GER_anschluss }
					has_global_flag = GER_democratic_referendum_austria_flag
				}
				GER = { is_subject = no }
				ROOT = { original_tag = HUN }
			}
			every_state = {
				limit = {
					NOT = { 
						OR = {
							state = 69
							state = 9
							state = 74
							state = 75
							state = 72	
						}
					}
					OR = {
						is_core_of = HUN
						is_core_of = CZE
						is_core_of = AUS
						is_claimed_by = HUN
						is_claimed_by = CZE
						is_claimed_by = AUS
					}
					NOT = { is_core_of = ROOT }
					NOT = { is_claimed_by = ROOT }
					NOT = {
						any_other_country = {
							is_in_faction_with = ROOT
							OR = {
								PREV = { is_core_of = PREV }
								PREV = { is_claimed_by = PREV }
							}
						}
					}
				}
				add_core_of = ROOT
			}
			every_state = {
				limit = {
					OR = {
						state = 69
						state = 9
						state = 74
						state = 75
						state = 72
					}
					NOT = { is_core_of = GER }
				}
				add_core_of = GER
			}
		}
	}
}

country_event = {
	id = LSM_core_and_claim.5
	
	trigger = {
		is_subject = no
		is_historical_focus_on = no
		is_benelux_formable_countries = yes
		all_state = {
			OR = {
				AND = {
					NOT = { is_core_of = BEL }
					NOT = { is_core_of = HOL }
					NOT = { is_core_of = LUX }
				}
				controller = {
					OR = {
						tag = ROOT
						AND = {
							is_in_faction_with = ROOT
							is_benelux_formable_countries = no
						}
					}
				}
			}
		}
		NOT = { has_country_flag = has_formed_benelux }
	}

	mean_time_to_happen = { days = 7 }

	hidden = yes

	immediate = {
		set_country_flag = has_formed_benelux
		every_state = {
			limit = {
				OR = {
					is_core_of = BEL
					is_core_of = HOL
					is_core_of = LUX
				}
				NOT = { is_core_of = ROOT }
				NOT = { is_claimed_by = ROOT }
				NOT = {
					any_other_country = {
						is_in_faction_with = ROOT
						OR = {
							PREV = { is_core_of = PREV }
							PREV = { is_claimed_by = PREV }
						}
					}
				}
			}
			add_core_of = ROOT
		}
	}
}
country_event = {
	id = LSM_core_and_claim.6
	
	trigger = {
		is_subject = no
		is_historical_focus_on = no
		OR = {
			AND = {
				has_government = democratic
				is_eu_formable_countries = yes
			}
			AND = {
				has_government = neutrality
				tag = FRA
			}
			AND = {
				has_government = fascism
				tag = ENG
				has_completed_focus = ENG_the_british_path_to_fascism
			}
		}
		all_state = {
			OR = {
				AND = {
					NOT = { is_core_of = BEL }
					NOT = { is_core_of = HOL }
					NOT = { is_core_of = LUX }
					NOT = { is_core_of = FRA }
					NOT = { is_core_of = ITA }
					NOT = { is_core_of = GER }
				}
				controller = {
					OR = {
						tag = ROOT
						AND = {
							is_in_faction_with = ROOT
							is_eu_formable_countries = no
						}
					}
				}
			}
		}
		NOT = { has_country_flag = has_formed_eu }
	}

	mean_time_to_happen = { days = 7 }

	hidden = yes

	immediate = {
		set_country_flag = has_formed_eu
		if = {
			limit = { has_government = democratic }
			set_cosmetic_tag = EUR_UNIFIED
		}
		every_state = {
			limit = {
				OR = {
					is_core_of = BEL
					is_core_of = HOL
					is_core_of = LUX
					is_core_of = GER
					is_core_of = ITA
					is_core_of = FRA
				}
				NOT = { is_core_of = ROOT }
				NOT = {
					any_other_country = {
						is_in_faction_with = ROOT
						OR = {
							PREV = { is_core_of = PREV }
							PREV = { is_claimed_by = PREV }
						}
					}
				}
				is_on_continent = europe
			}
			add_core_of = ROOT
		}
	}
}
country_event = {
	id = LSM_core_and_claim.7
	
	trigger = {
		NOT = { has_country_flag = has_formed_iberia }
		is_historical_focus_on = no
		OR = {
			AND = {
				original_tag = SPR
				has_war_with = POR
				POR = { has_civil_war = no }
				POR = { surrender_progress > 0.8 }
				any_state = {
					is_core_of = POR
					controller = { 
						OR = {
							original_tag = SPR
							is_in_faction_with = SPR
						}
					}
				}
			}
			AND = {
				original_tag = POR
				has_war_with = SPR
				SPR = { has_civil_war = no }
				SPR = { surrender_progress > 0.8 }
				any_state = {
					is_core_of = SPR
					controller = { 
						OR = {
							original_tag = POR
							is_in_faction_with = POR
						}
					}
				}
			}
		}		
	}

	mean_time_to_happen = { days = 7 }

	hidden = yes

	immediate = {
		set_country_flag = has_formed_iberia
		if = {
			limit = {
				original_tag = SPR
			}
			every_state = {
				limit = {
					is_core_of = POR
					NOT = { is_core_of = SPR }
					NOT = { is_claimed_by = SPR }
				}
				add_core_of = SPR
			}
		}
		if = {
			limit = {
				original_tag = POR
			}
			every_state = {
				limit = {
					is_core_of = SPR
					NOT = { is_core_of = POR }
					NOT = { is_claimed_by = POR }
				}
				add_core_of = POR
			}
		}
	}
}
country_event = {
	id = LSM_core_and_claim.8
	
	trigger = {
		NOT = { has_country_flag = has_formed_greater_germany_in_bohemia }
		is_historical_focus_on = no
		original_tag = GER
		69 = {
			owner = {
				OR = {
					tag = GER
					is_subject_of = GER
				}
			}
		}	
		74 = {
			owner = {
				OR = {
					tag = GER
					is_subject_of = GER
				}
			}
		}
		9 = {
			owner = {
				OR = {
					tag = GER
					is_subject_of = GER
				}
			}
		}
		75 = {
			owner = {
				OR = {
					tag = GER
					is_subject_of = GER
				}
			}
		}
		72 = {
			owner = {
				OR = {
					tag = GER
					is_subject_of = GER
				}
			}
		}
	}

	mean_time_to_happen = { days = 7 }

	hidden = yes

	immediate = {
		set_country_flag = has_formed_greater_germany_in_bohemia
		every_state = {
			limit = {
				OR = {
					state = 72
					state = 75
					state = 9
				}
				owner = {
					NOT = { tag = CZE }
				}
				NOT = { is_core_of = GER }
			}
			add_core_of = GER
			GER = { transfer_state = PREV }
		}
		every_state = {
			limit = {
				OR = {
					state = 69
					state = 74
				}
				NOT = { is_core_of = GER }
			}
			add_core_of = GER
			GER = { transfer_state = PREV }
		}
	}
}
country_event = {
	id = LSM_core_and_claim.9
	
	trigger = {
		NOT = { has_country_flag = has_formed_greater_germany_in_austria }
		is_historical_focus_on = no
		original_tag = GER
		848 = {
			owner = {
				OR = {
					tag = GER
					is_subject_of = GER
				}
			}
		}	
		153 = {
			owner = {
				OR = {
					tag = GER
					is_subject_of = GER
				}
			}
		}
		152 = {
			owner = {
				OR = {
					tag = GER
					is_subject_of = GER
				}
			}
		}
		4 = {
			owner = {
				OR = {
					tag = GER
					is_subject_of = GER
				}
			}
		}
	}

	mean_time_to_happen = { days = 7 }

	hidden = yes

	immediate = {
		set_country_flag = has_formed_greater_germany_in_austria
		if = {
			limit = {
				AUS = { is_subject_of = GER }
			}
			GER = { annex_country = { target = AUS transfer_troops = yes } }
		}	
		every_state = {
			limit = {
				OR = {
					state = 848
					state = 153
					state = 152
					state = 4
				}
				NOT = { is_core_of = GER }
			}
			add_core_of = GER
			GER = { transfer_state = PREV }
		}
	}
}
country_event = {
	id = LSM_core_and_claim.10
	
	trigger = {
		NOT = { has_country_flag = has_formed_greater_germany_in_poland }
		is_historical_focus_on = no
		original_tag = GER
		85 = {
			owner = {
				OR = {
					tag = GER
					is_subject_of = GER
				}
			}
		}	
		807 = {
			owner = {
				OR = {
					tag = GER
					is_subject_of = GER
				}
			}
		}
		86 = {
			owner = {
				OR = {
					tag = GER
					is_subject_of = GER
				}
			}
		}
		762 = {
			owner = {
				OR = {
					tag = GER
					is_subject_of = GER
				}
			}
		}
		87 = {
			owner = {
				OR = {
					tag = GER
					is_subject_of = GER
				}
			}
		}
		98 = {
			owner = {
				OR = {
					tag = GER
					is_subject_of = GER
				}
			}
		}
	}

	mean_time_to_happen = { days = 7 }

	hidden = yes

	immediate = {
		set_country_flag = has_formed_greater_germany_in_poland
		every_state = {
			limit = {
				OR = {
					state = 85
					state = 807
					state = 86
					state = 762
				}
				NOT = { is_core_of = GER }
			}
			add_core_of = GER
			GER = { transfer_state = PREV }
		}
		every_state = {
			limit = {
				OR = {
					state = 87
					state = 98
				}
				NOT = { is_claimed_by = GER }
				NOT = { is_core_of = GER }
			}
			add_claim_by = GER
			GER = { transfer_state = PREV }
		}
	}
}
country_event = {
	id = LSM_core_and_claim.11
	
	trigger = {
		has_country_flag = has_formed_greater_germany_in_austria
		NOT = { has_country_flag = has_formed_greater_germany_in_yugoslavia }
		is_historical_focus_on = no
		original_tag = GER
		102 = {
			owner = {
				OR = {
					tag = GER
					is_subject_of = GER
				}
			}
		}	
		853 = {
			owner = {
				OR = {
					tag = GER
					is_subject_of = GER
				}
			}
		}
	}

	mean_time_to_happen = { days = 7 }

	hidden = yes

	immediate = {
		set_country_flag = has_formed_greater_germany_in_yugoslavia
		every_state = {
			limit = {
				OR = {
					state = 102
					state = 853
				}
				NOT = { is_core_of = GER }
			}
			add_core_of = GER
			GER = { transfer_state = PREV }
		}
	}
}
country_event = {
	id = LSM_core_and_claim.12
	
	trigger = {
		has_country_flag = has_formed_greater_germany_in_austria
		NOT = { has_country_flag = has_formed_greater_germany_in_italy }
		is_historical_focus_on = no
		original_tag = GER
		39 = {
			owner = {
				OR = {
					tag = GER
					is_subject_of = GER
				}
			}
		}	
		850 = {
			owner = {
				OR = {
					tag = GER
					is_subject_of = GER
				}
			}
		}	
		736 = {
			owner = {
				OR = {
					tag = GER
					is_subject_of = GER
				}
			}
		}	
		852 = {
			owner = {
				OR = {
					tag = GER
					is_subject_of = GER
				}
			}
		}
	}

	mean_time_to_happen = { days = 7 }

	hidden = yes

	immediate = {
		set_country_flag = has_formed_greater_germany_in_italy
		every_state = {
			limit = {
				OR = {
					state = 39
					state = 850
					state = 736
					state = 852
				}
				NOT = { is_core_of = GER }
			}
			add_core_of = GER
			GER = { transfer_state = PREV }
		}
	}
}
country_event = {
	id = LSM_core_and_claim.13
	
	trigger = {
		NOT = { has_country_flag = has_formed_bolivia_paraguay }
		is_historical_focus_on = no
		OR = {
			original_tag = BOL
			original_tag = PAR
		}
		302 = {
			owner = {
				OR = {
					tag = ROOT
					is_subject_of = ROOT
				}
			}
		}	
		301 = {
			owner = {
				OR = {
					tag = ROOT
					is_subject_of = ROOT
				}
			}
		}	
		688 = {
			owner = {
				OR = {
					tag = ROOT
					is_subject_of = ROOT
				}
			}
		}	
		487 = {
			owner = {
				OR = {
					tag = ROOT
					is_subject_of = ROOT
				}
			}
		}
	}

	mean_time_to_happen = { days = 7 }

	hidden = yes

	immediate = {
		set_country_flag = has_formed_bolivia_paraguay
		every_state = {
			limit = {
				OR = {
					state = 302
					state = 301
					state = 688
					state = 487
				}
				NOT = { is_core_of = GER }
			}
			add_core_of = ROOT
			ROOT = { transfer_state = PREV }
		}
	}
}