﻿###########################
# Baltic Events
###########################

add_namespace = baltic

# Soviet Ultimatum (Estonia)
country_event = {
	id = baltic.1
	title = baltic.1.t
	desc = baltic.1.d
	picture = GFX_report_event_soviet_soldiers
	
	is_triggered_only = yes
	
	option = { # Accept demands
		name = baltic.1.a
		ai_chance = {
			base = 10
			modifier = { # Don't accept if in a faction that can protect them
				factor = 0
				NOT = { is_in_faction_with = FROM }
				OR = {
					any_other_country = {
						is_major = yes
						is_in_faction_with = EST
					}
					has_idea = anti_soviet_pact
					has_country_flag = baltic_entente_flag
					FROM = { surrender_progress > 0.5 }
				}
			}
			modifier = {
				factor = 0.5
				is_historical_focus_on = no
				any_other_country = {
					is_major = yes
					has_guaranteed = EST
				}
			}
			modifier = { #If Germany has given guarantee through a focus, don't fold
				factor = 0
				is_guaranteed_by = GER
				GER = {
					OR = {
						has_completed_focus = GER_tributes_for_guarantees
						has_completed_focus = GER_safeguard_the_baltic
					}
				}
			}

			modifier = { #To cover an edge case, should not happen
				factor = 0
				OR = {
					has_capitulated = yes
					exists = no
					is_subject = yes
				}
			}
		}
		FROM = {
			country_event = { days = 5 id = soviet.6 }
		}
		if = {
			limit = {
				has_country_flag = cave_to_enemy_pressure_flag
			}
			effect_tooltip = {
				FROM = { 
					puppet = {
						target = ROOT
						end_civil_wars = no
						end_wars = no
					}
				}
			}
		}
		else = {
			custom_effect_tooltip = GAME_OVER_TT
		}
	}
	option = { # Refuse
		name = baltic.1.b
		ai_chance = {
			base = 0
			modifier = {
				add = 1
				OR = {
					is_historical_focus_on = no
					any_other_country = {
						is_major = yes
						is_in_faction_with = EST
						NOT = { is_in_faction_with = FROM }
					}
				}
			}
			modifier = {
				add = 5
				is_historical_focus_on = no
				any_other_country = {
					is_major = yes
					has_guaranteed = EST
				}
			}
			modifier = {
				add = 100
				has_country_flag = soviet_sucks
			}
		}

		FROM = {
			country_event = { days = 5 id = soviet.7 }
			effect_tooltip = {
				create_wargoal = {
					type = annex_everything
					target = EST
				}	
			}
		}
	}
}

# Soviet Ultimatum (Latvia)
country_event = {
	id = baltic.2
	title = baltic.1.t
	desc = baltic.1.d
	picture = GFX_report_event_soviet_soldiers
	
	is_triggered_only = yes
	
	option = { # Accept demands
		name = baltic.1.a
		ai_chance = {
			base = 10
			modifier = { # Don't accept if in a faction that can protect them
				factor = 0
				NOT = { is_in_faction_with = FROM }
				OR = {
					any_other_country = {
						is_major = yes
						is_in_faction_with = LAT
					}
					has_idea = anti_soviet_pact
					has_country_flag = baltic_entente_flag
					FROM = { surrender_progress > 0.5 }
				}
			}
			modifier = {
				factor = 0.5
				is_historical_focus_on = no
				any_other_country = {
					is_major = yes
					has_guaranteed = LAT
				}
			}

			modifier = { #If Germany has given guarantee through a focus, don't fold
				factor = 0
				is_guaranteed_by = GER
				GER = {
					OR = {
						has_completed_focus = GER_tributes_for_guarantees
						has_completed_focus = GER_safeguard_the_baltic
					}
				}
			}

			modifier = { #To cover an edge case this should not happen
				factor = 0
				OR = {
					has_capitulated = yes
					exists = no
					is_subject = yes
				}
			}
		}

		FROM = {
			country_event = { days = 5 id = soviet.8 }
		}
		if = {
			limit = {
				has_country_flag = cave_to_enemy_pressure_flag
			}
			effect_tooltip = {
				FROM = { 
					puppet = {
						target = ROOT
						end_civil_wars = no
						end_wars = no
					}
				}
			}
		}
		else = {
			custom_effect_tooltip = GAME_OVER_TT
		}
	}
	option = { # Refuse
		name = baltic.1.b
		ai_chance = {
			base = 0
			modifier = {
				add = 1
				OR = {
					is_historical_focus_on = no
					any_other_country = {
						is_major = yes
						is_in_faction_with = LAT
						NOT = { is_in_faction_with = FROM }
					}
				}
			}
			modifier = {
				add = 5
				is_historical_focus_on = no
				any_other_country = {
					is_major = yes
					has_guaranteed = LAT
				}
			}
			modifier = {
				add = 100
				has_country_flag = soviet_sucks
			}
		}

		FROM = {
			country_event = { days = 5 id = soviet.9 }
			effect_tooltip = {
				create_wargoal = {
					type = annex_everything
					target = LAT
				}
			}
		}
	}
}

# Soviet Ultimatum (Lithuania)
country_event = {
	id = baltic.3
	title = baltic.1.t
	desc = baltic.1.d
	picture = GFX_report_event_soviet_soldiers
	
	is_triggered_only = yes
	
	option = { # Accept demands
		name = baltic.1.a
		ai_chance = {
			base = 10
			modifier = { # Don't accept if in a faction that can protect them
				factor = 0
				NOT = { is_in_faction_with = FROM }
				OR = {
					any_other_country = {
						is_major = yes
						is_in_faction_with = LIT
					}
					has_idea = anti_soviet_pact
					has_country_flag = baltic_entente_flag
					FROM = { surrender_progress > 0.5 }
				}
			}
			modifier = {
				factor = 0.5
				is_historical_focus_on = no
				any_other_country = {
					is_major = yes
					has_guaranteed = LIT
				}
			}

			modifier = { #If Germany has given guarantee through a focus, don't fold
				factor = 0
				is_guaranteed_by = GER
				GER = {
					OR = {
						has_completed_focus = GER_tributes_for_guarantees
						has_completed_focus = GER_safeguard_the_baltic
					}
				}
			}

			modifier = { #To cover an edge case this should not happen
				factor = 0
				OR = {
					has_capitulated = yes
					exists = no
					is_subject = yes
				}
			}
		}

		FROM = {
			country_event = { days = 5 id = soviet.10 }
		}
		if = {
			limit = {
				has_country_flag = cave_to_enemy_pressure_flag
			}
			effect_tooltip = {
				FROM = { 
					puppet = {
						target = ROOT
						end_civil_wars = no
						end_wars = no
					}
				}
			}
		}
		else = {
			custom_effect_tooltip = GAME_OVER_TT
		}
	}
	option = { # Refuse
		name = baltic.1.b
		ai_chance = {
			base = 0
			modifier = {
				add = 1
				OR = {
					is_historical_focus_on = no
					any_other_country = {
						is_major = yes
						is_in_faction_with = LIT
						NOT = { is_in_faction_with = FROM }
					}
				}
			}
			modifier = {
				add = 5
				is_historical_focus_on = no
				any_other_country = {
					is_major = yes
					has_guaranteed = LIT
				}
			}
			modifier = {
				add = 100
				has_country_flag = soviet_sucks
			}
		}

		FROM = {
			country_event = { days = 5 id = soviet.11 }
			effect_tooltip = {
				create_wargoal = {
				type = annex_everything
				target = LIT
				}		
			}
		}
	}
}

# Germany Claims Memel (Lithuania)
country_event = {
	id = baltic.4
	title = baltic.4.t
	desc = baltic.4.d
	picture = GFX_report_event_generic_read_write
	
	is_triggered_only = yes
	
	option = { # Accept demands
		name = baltic.4.a
		ai_chance = { 
			factor = 90
			modifier = {
				factor = 0
				NOT = {
					OR = {
						is_puppet_of = GER
						is_in_faction_with = GER
					}
				}
				GER = {
					surrender_progress > 0.09
				}
			}
			modifier = {
				factor = 0
				any_other_country = {
					is_in_faction_with = ROOT
					has_war_with = GER
				}
			}
			modifier = {
				factor = 0
				any_other_country = {
					NOT = {
						tag = GER
					}
					ROOT = {
						is_puppet_of = PREV
					}
					NOT = {
						is_in_faction_with = GER
					}
				}
			}
		}
		GER = {
			effect_tooltip = {
				transfer_state = 188
				add_state_core = 188
			}
			country_event = { days = 1 id = germany.22 }
		}
		hidden_effect = {
			hidden_effect = {
				every_country = {
					limit = {
						capital_scope = {
							is_on_continent = europe
						}
					}
					news_event = { 
						id = news.19
						days = 1 
					}	
				}
			}
		}
	}
	option = { # Refuse
		name = baltic.4.b		
		ai_chance = { 
			factor = 10
			modifier = {
				factor = 0
				is_historical_focus_on = yes
				NOT = {
					GER = {
						surrender_progress > 0.09
					}
				}
				NOT = {
					any_other_country = {
						is_in_faction_with = ROOT
						has_war_with = GER
					}
				}
				NOT = {
					any_other_country = {
						NOT = {
							tag = GER
						}
						ROOT = {
							is_puppet_of = PREV
						}
						NOT = {
							is_in_faction_with = GER
						}
					}
				}
			}
			modifier = {
				factor = 0
				OR = {
					is_in_faction_with = GER
					ROOT = {
						is_puppet_of = GER
					}
				}
			}
		}
		effect_tooltip = {
			GER = {
				create_wargoal = {
				type = take_state_focus
				target = ROOT
				generator = { 188 }
				}
				country_event = { days = 1 id = germany.23 }
			}
		}
		hidden_effect = {
			GER = {
				country_event = { days = 1 id = germany.23 }
			}
			hidden_effect = {
				every_country = {
					limit = {
						capital_scope = {
							is_on_continent = europe
						}
					}
					news_event = { 
						id = news.20
						days = 1 
					}	
				}
			}
		}		
	}
}

# Country becomes communist. Get's event to become part of the Soviet Union
country_event = {
	id = baltic.5
	title = baltic.5.t
	desc = baltic.5.d
	picture = GFX_report_event_worker_protests

	trigger = {
		SOV = { has_government = communism }
		NOT = { has_country_flag = baltic.5_fired }
		has_war = no
		always = no # Removed this event due to it causing issues with the Baltic Focus Tree. May re-enable at some point, or may just delete completely.
		OR = {
			tag = LIT
			tag = FIN
			tag = EST
			tag = LAT
		} 
		has_government = communism
	}

	immediate = {
		FROM = { set_country_flag = baltic.5_fired }
		save_event_target_as = baltic_annexation
	}
	
	option = { # Annexed by SOV
		name = baltic.5.a
		ai_chance = {
			factor = 40
			modifier =  {
				factor = 2
				OR = {
					tag = LIT
					tag = LAT
					tag = EST
				}
			}
			modifier = {
				factor = 0.5
				is_puppet = yes
			}
		}
		SOV =	{ country_event = { id = soviet.35 days = 1 } }
	}
	option = { # Become Puppet state
		name = baltic.5.b
		ai_chance = { factor = 55
			modifier = {
				factor = 2
				tag = FIN
			}
		}
		SOV = { country_event = { id = soviet.36 days = 1 } }
	}
	option = { # Stay as own communist state
		name = baltic.5.c
		trigger = {
			is_puppet = no
		}
		ai_chance = { factor = 5 }
	}

	mean_time_to_happen = {
		days = 2
	}
}

# Hidden event to be annexed. Needed because of problem with FROM and events in annexed countries (JH)
country_event = {
	id = baltic.6

	hidden = yes
	
	is_triggered_only = yes

	immediate = {
		news_event = { id = news.69 }
		news_event = { id = news.71 hours = 1 }
	}
}

#Poland Seeks Alliance With ROOT  
#Event fired by Poland seeking to make a Baltic faction
country_event = {
	id = baltic.7
	title = baltic.7.t
	desc = baltic.7.d
	picture = GFX_report_event_polish_tanks_01

	is_triggered_only = yes

	option = { #Enter alliance
		name = baltic.7.a
		ai_chance = {
			factor = 90
		}
		POL = {
			add_to_faction = ROOT
			ROOT = {
				add_ai_strategy = {
					type = alliance
					id = "POL"
					value = 200
				}
			}
			country_event = { id = poland.10 days = 1 }
		}
	}

	option = {
		name = baltic.7.b
		ai_chance = {
			factor = 10
		}
		effect_tooltip = {
			POL = {
				create_wargoal = {
					type = puppet_wargoal_focus
					target = ROOT
				}
			}
		}
		POL = {
			country_event = { id = poland.11 days = 1 }
		}
	}
}

