#events simulating the Soviet Invasion of Poland in 1939

add_namespace = polsovwar

#Cosmetic event
news_event = {
	id = polsovwar.0
	title = polsovwar.0.t
	desc = polsovwar.0.d
	picture = GFX_news_event_poland_soviet_war

	major = yes

	#fire_only_once = yes

	is_triggered_only = yes

	#positive event
	option = {
		name = polsovwar.0.a
		trigger = {
			OR = {
				has_government = communism
				has_war_with = POL
			}
		}
	}

	#negative event if you're neither at war with Poland nor communist
	option = {
		name = polsovwar.0.b
		trigger = {
			AND = {
				NOT = { has_government = communism }
				NOT = { has_war_with = POL }
			}
		}
	}	
}

#Soviet Union attacks Poland
country_event = {
	id = polsovwar.1
	title = polsovwar.1.t
	desc = polsovwar.1.d
	picture = GFX_report_event_poland_soviet_war

	fire_only_once = yes

	trigger = {
		tag = SOV
		has_war = no
		has_government = communism
		GER = { has_government = fascism }
		POL = { has_war_with = GER }
		OR = {
			POL = { owns_state = 96 }	
			POL = { owns_state = 784 }
			POL = { owns_state = 95 }	
			POL = { owns_state = 94 }
			POL = { owns_state = 93 }	
			#POL = { owns_state = 91 } #Lviv
			#POL = { owns_state = 89 } #Stanislawow	
			#POL = { owns_state = 97 } #Bialystok
		}
		AND = {
			SOV = { owns_state = 202 }	
			SOV = { owns_state = 206 }
		}
		is_subject = no
		date > 1939.6.6
		NOT = { is_in_faction_with = POL }
		NOT = { POL = { is_subject_of = SOV } }
	}

	option = {
		name = polsovwar.1.a
		ai_chance = { factor = 100 }
		POL = { country_event = { id = polsovwar.2 } }
	}

	option = {
		name = polsovwar.1.b
	}
}

#Poland can choose to either order it's troops to not engage the Soviets (historical) or to fight them and leave the Allies
country_event = {
	id = polsovwar.2
	title = polsovwar.2.t
	desc = polsovwar.2.d
	picture = GFX_report_event_poland_soviet_war

	#fire_only_once = yes

	is_triggered_only = yes

	#choice to focus on Germany
	option = {
		name = polsovwar.2.a
		ai_chance = { factor = 100 }
		SOV = { country_event = { id = polsovwar.3 } }
	}

	#choice to go to war with the Soviets
	option = {
		name = polsovwar.2.b
		if = {
			limit = {
				OR = {
					is_in_faction_with = ENG
					is_in_faction_with = FRA
					is_in_faction_with = USA
					is_in_faction = no
				}
			}
			create_faction = POLAND_STANDS_ALONE_FACTION
		}
		SOV = { country_event = { id = polsovwar.4 } }
	}
}

#Poland chose to capitulate
country_event = {
	id = polsovwar.3
	title = polsovwar.3.t
	desc = polsovwar.3.d
	picture = GFX_report_event_poland_soviet_war_capitulate

	#fire_only_once = yes

	is_triggered_only = yes

	option = {
		name = polsovwar.3.a
		news_event = { id = polsovwar.0 }	
		if = {
			limit = {
				96 = {
					OR = {
						is_controlled_by = POL
						any_other_country = {
							controls_state = 96
							is_in_faction_with = POL
						}
					}
				}
			}
			SOV = { transfer_state = 96 }
		}
		if = {
			limit = {
				784 = {
					OR = {
						is_controlled_by = POL
						any_other_country = {
							controls_state = 784
							is_in_faction_with = POL
						}
					}
				}
			}
			SOV = { transfer_state = 784 }
		}
		if = {
			limit = {
				95 = {
					OR = {
						is_controlled_by = POL
						any_other_country = {
							controls_state = 95
							is_in_faction_with = POL
						}
					}
				}
			}
			SOV = { transfer_state = 95 }
		}
		if = {
			limit = {
				94 = {
					OR = {
						is_controlled_by = POL
						any_other_country = {
							controls_state = 94
							is_in_faction_with = POL
						}
					}
				}
			}
			SOV = { transfer_state = 94 }
		}
		if = {
			limit = {
				93 = {
					OR = {
						is_controlled_by = POL
						any_other_country = {
							controls_state = 93
							is_in_faction_with = POL
						}
					}
				}
			}
			SOV = { transfer_state = 93 }
		}
		#if = {
		#	limit = {
		#		91 = {
		#			OR = {
		#				is_controlled_by = POL
		#				any_other_country = {
		#					controls_state = 91
		#					is_in_faction_with = POL
		#				}
		#			}
		#		}
		#	}
		#	SOV = { transfer_state = 91 }
		#}
		#if = {
		#	limit = {
		#		89 = {
		#			OR = {
		#				is_controlled_by = POL
		#				any_other_country = {
		#					controls_state = 89
		#					is_in_faction_with = POL
		#				}
		#			}
		#		}
		#	}
		#	SOV = { transfer_state = 89 }
		#}
		#if = {
		#	limit = {
		#		97 = {
		#			OR = {
		#				is_controlled_by = POL
		#				any_other_country = {
		#					controls_state = 97
		#					is_in_faction_with = POL
		#				}
		#			}
		#		}
		#	}
		#	SOV = { transfer_state = 97 }
		#}
		add_manpower = -3000
	}
}

#Poland chose to fight us
country_event = {
	id = polsovwar.4
	title = polsovwar.4.t
	desc = polsovwar.4.d
	picture = GFX_report_event_poland_soviet_war_full

	#fire_only_once = yes

	is_triggered_only = yes

	option = {
		name = polsovwar.4.a
		declare_war_on = {
			target = POL
			type = annex_everything
		}
		news_event = { id = polsovwar.0 }	
	}
}

#New MR pact event
country_event = {
	id = polsovwar.5
	title = germany.14.t
	desc = germany.14.d
	picture = GFX_report_event_german_troops

	fire_only_once = yes

	trigger = {
		tag = GER
		has_global_flag = sov_yes_pact
		SOV = { exists = yes }
		NOT =  { has_war_with = SOV }
		OR = {
			POL = { has_capitulated = yes }
			POL = { exists = no }
		}
		OR = {
			OR = {
				GER = { owns_state = 10 }
				any_other_country = {
					is_in_faction_with = GER
					GER = {
						is_faction_leader = yes
					}
					owns_state = 10
				}
			}
			OR = {
				GER = { controls_state = 10 }
				any_other_country = {
					is_in_faction_with = GER
					GER = {
						is_faction_leader = yes
					}
					controls_state = 10
				}
			}
		}
	}


	mean_time_to_happen = {
		days = 2
	}

	option = {
		ai_chance = {
			base = 1
			modifier = {
				factor = 0
				AND = {
					POL = {
						is_ai = no
						has_civil_war = no
					}
					is_in_faction_with = POL
				}
			}
		}
		name = germany.14.a
		if = { #MR Pact if ally has taken some of Poland
			limit = {
				GER = { is_faction_leader = yes }
				any_allied_country = {
					NOT = { is_subject_of = GER }
					NOT = { tag = SOU }
					OR = {
						controls_state = 96
						controls_state = 95
						controls_state = 94
						controls_state = 93
						controls_state = 91
						controls_state = 97
						controls_state = 89
						controls_state = 784
					}
				}
			}
			random_country = {
				limit = {
					is_in_faction_with = ROOT
					NOT = { is_subject_of = GER }
					NOT = { tag = SOU }
					OR = {
						controls_state = 96
						controls_state = 95
						controls_state = 94
						controls_state = 93
						controls_state = 91
						controls_state = 97
						controls_state = 89
						controls_state = 784
					}
				}
				if = {
					limit = {
						is_subject = yes
					}
					OVERLORD = { country_event = germany.1002 }
				}
				else = {
					country_event = { id = germany.1002 hours = 3 }
				}
			}
		}
		else = { #MR Pact as normal
			MR_pact_transfer_state_effect = yes
			SOU = { country_event = { id = germany.15 hours = 3 } }
		}
	}
	option = {
		name = germany.14.b
		ai_chance = {
			base = 1
			modifier = {
				add = -1
				is_historical_focus_on = yes
				NOT = {
					AND = {
						POL = {
							is_ai = no
							has_civil_war = no
						}
						is_in_faction_with = POL
					}
				}
			}
		}
		SOU = { country_event = germany.16 }
		clr_global_flag = sov_yes_pact
		diplomatic_relation = {
			country = SOV
			relation = non_aggression_pact
			active = no
		}
		SOU = {
			if = {
				limit = {
					NOT = { owns_state = 146 }
				}
				add_state_claim = 146 #KARELIA (FIN)
			}
			if = {
				limit = {
					NOT = { owns_state = 147 }
				}
				add_state_claim = 147 #SALLA (FIN)
			}
			if = {
				limit = {
					NOT = { owns_state = 722 }
				}
				add_state_claim = 722 #PETSAMO (FIN)
			}
			if = {
				limit = {
					NOT = { owns_state = 13 }
				}
				add_state_claim = 13 #PÄRNU (EST)
			}
			if = {
				limit = {
					NOT = { owns_state = 191 }
				}
				add_state_claim = 191 #TARTU (EST)
			}
			if = {
				limit = {
					NOT = { owns_state = 811 }
				}
				add_state_claim = 811 #SAAREMAA (EST)
			}
			if = {
				limit = {
					NOT = { owns_state = 813 }
				}
				add_state_claim = 813 #VIRUMAA (EST)
			}
			if = {
				limit = {
					NOT = { owns_state = 812 }
				}
				add_state_claim = 812 #TALLIN (EST)
			}
			if = {
				limit = {
					NOT = { owns_state = 12 }
				}
				add_state_claim = 12 #VIDZEME (LAT)
			}
			if = {
				limit = {
					NOT = { owns_state = 190 }
				}
				add_state_claim = 190 #KURZEME (LAT)
			}
			if = {
				limit = {
					NOT = { owns_state = 808 }
				}
				add_state_claim = 808 #RIGA (LAT)
			}
			if = {
				limit = {
					NOT = { owns_state = 809 }
				}
				add_state_claim = 809 #ZEMGALE (LAT)
			}
			if = {
				limit = {
					NOT = { owns_state = 810 }
				}
				add_state_claim = 810 #LATGALE (LAT)
			}
			if = {
				limit = {
					NOT = { owns_state = 11 }
				}
				add_state_claim = 11 #KAUNAS (LIT)
			}
			if = {
				limit = {
					NOT = { owns_state = 784 }
				}
				add_state_claim = 784 #WILNO (LIT)
			}
			if = {
				limit = {
					NOT = { owns_state = 189 }
				}
				add_state_claim = 189 #ZEMAITIJA (LIT)
			}
			if = {
				limit = {
					NOT = { owns_state = 814 }
				}
				add_state_claim = 814 #SUDUVA (LIT)
			}
			if = {
				limit = {
					NOT = { owns_state = 815 }
				}
				add_state_claim = 815 #AUKSTAITIJA (LIT)
			}
			if = {
				limit = {
					NOT = { owns_state = 89 }
				}
				add_state_claim = 89 #STANISLAWOW (POL)
			}
			if = {
				limit = {
					NOT = { owns_state = 91 }
				}
				add_state_claim = 91 #LWOW (POL)
			}
			if = {
				limit = {
					NOT = { owns_state = 93 }
				}
				add_state_claim = 93 #WOLYN (POL)
			}
			if = {
				limit = {
					NOT = { owns_state = 94 }
				}
				add_state_claim = 94 #POLESIE (POL)
			}
			if = {
				limit = {
					NOT = { owns_state = 95 }
				}
				add_state_claim = 95 #NOWOGRODEK (POL)
			}
			if = {
				limit = {
					NOT = { owns_state = 96 }
				}
				add_state_claim = 96 #WILEJKA (POL)
			}
			if = {
				limit = {
					NOT = { owns_state = 97 }
				}
				add_state_claim = 97 #BIALYSTOK (POL)
			}
			if = {
				limit = {
					NOT = { owns_state = 78 }
				}
				add_state_claim = 78 #BESSARABIA (ROM)
			}
			if = {
				limit = {
					NOT = { owns_state = 80 }
				}
				add_state_claim = 80 #BUCOVINA (ROM)
			}
			if = {
				limit = {
					NOT = { owns_state = 766 }
				}
				add_state_claim = 766 #SOUTHERN BESSARABIA (ROM)
			}
			effect_tooltip = {
				create_wargoal = {
					type = annex_everything
					target = GER
				}
			}
		}
	}
}