###########################
# Latvian Events
###########################

add_namespace = LAT_events

# Decide who is the true enemy
country_event = {
	id = LAT_events.1
	title = LAT_events.1.t
	desc = LAT_events.1.d
	picture = GFX_report_event_romania_parliament
	
	is_triggered_only = yes
	
	option = { #Soviets
		name = LAT_events.1.a
		trigger = {
			OR = {
				NOT = { is_in_faction_with = SOV }
				AND = {
					is_in_faction_with = GER
					is_in_faction_with = SOV
				}
			}
		}
		set_country_flag = soviets_true_enemy_flag
		if = {
			limit = {
			any_owned_state = {
				any_neighbor_state = {
						is_controlled_by = SOV
					}
				}
			}
			every_owned_state = {
				limit = {
					is_controlled_by = ROOT
					any_neighbor_state = {
						is_controlled_by = SOV
					}
					NOT = {
						state = 1062
						state = 1067
						state = 1068
					}
				}
				add_building_construction = {
					type = bunker
					level = 2
					instant_build = yes
					province = {
						all_provinces = yes
						limit_to_border = yes
					}
				}
			}
		}
		else = {
			if = {
				limit = { 
					controls_state = 810 
				}
				810 = {
					add_building_construction = { type = bunker province = 222 level = 2 instant_build = yes }
				}
				if = {
					limit = {
						controls_state = 810
						controls_state = 1059
						SOV = {
							controls_state = 1173
						}
					}
					810 = {
						add_building_construction = { type = bunker province = 310 level = 2 instant_build = yes }
					}
					1059 = {
						add_building_construction = { type = bunker province = 11358 level = 2 instant_build = yes }
					}
				}
			}
			
			if = {
				limit = { 
					controls_state = 1060
				}
				1060 = {
					add_building_construction = { type = bunker province = 13679 level = 2 instant_build = yes }
				}
			}
			
			if = {
				limit = { 
					controls_state = 1061
				}
				1061 = {
					add_building_construction = { type = bunker province = 9275 level = 2 instant_build = yes }
					add_building_construction = { type = bunker province = 6459 level = 2 instant_build = yes }
				}
			}
			
			if = {
				limit = {
					controls_state = 784
					GER = {
						NOT = {
							controls_state = 1248
							controls_state = 1244
							controls_state = 1247
							controls_state = 1243
							controls_state = 1238
							controls_state = 1173
						}
					}
				}
				784 = {
					add_building_construction = { type = bunker province = 9295 level = 2 instant_build = yes }
					add_building_construction = { type = bunker province = 3320 level = 2 instant_build = yes }
					add_building_construction = { type = bunker province = 11342 level = 2 instant_build = yes }
				}			
			}
			else = {
				if = {
					limit = { controls_state = 815 }
					815 = {	
						add_building_construction = { type = bunker province = 11226 level = 2 instant_build = yes }
						add_building_construction = { type = bunker province = 11498 level = 2 instant_build = yes }
					}
				}
				if = {
					limit = { controls_state = 11 }
					11 = {
						add_building_construction = { type = bunker province = 9404 level = 2 instant_build = yes }
						add_building_construction = { type = bunker province = 327 level = 2 instant_build = yes }
					}
				}
				if = {
					limit = { controls_state = 814 }
					814 = {
						add_building_construction = { type = bunker province = 6281 level = 2 instant_build = yes }
						add_building_construction = { type = bunker province = 11312 level = 2 instant_build = yes }
					}
				}
			}
		}
		if = {
			limit = { controls_state = 1069 }
			1069 = {
				add_building_construction = { type = bunker province = 13661 level = 4 instant_build = yes }
			}
		}
		if = {
			limit = { controls_state = 1071 }
			1071 = {
				add_building_construction = { type = bunker province = 4640 level = 4 instant_build = yes }
			}
		}
	}
	option = { #Germany
		name = LAT_events.1.b
		trigger = {
			OR = {
				NOT = { is_in_faction_with = GER }
				AND = {
					is_in_faction_with = GER
					is_in_faction_with = SOV
				}
			}
		}
		set_country_flag = germans_true_enemy_flag
		if = {
			limit = {
				any_owned_state = {
					any_neighbor_state = {
						is_controlled_by = GER 
					}
				}
			}
			every_owned_state = {
				limit = {
					is_controlled_by = ROOT
					any_neighbor_state = {
						is_controlled_by = GER
					}
					NOT = {
						state = 190 #Kurzeme (Latvia)
						state = 1559 #Ventspils (Latvia)
						state = 809 #Zemgale (Latvia)
						state = 1068
						state = 1067
						state = 1069
					}
				}
				add_building_construction = {
					type = bunker
					level = 2
					instant_build = yes
					province = {
						all_provinces = yes
						limit_to_border = yes
					}
				}
			}
		}
		if = {
			limit = { controls_state = 190 } #Kurzeme
			190 = { 
				add_building_construction = {
					type = bunker
					level = 2
					instant_build = yes
					province = {
						all_provinces = yes
						limit_to_border = yes
					}
				}
			}
		}
		if = {
			limit = { controls_state = 809 } #Zemgale (Latvia)
			809 = {
				add_building_construction = { type = bunker province = 265 level = 2 instant_build = yes }
				add_building_construction = { type = bunker province = 6342 level = 2 instant_build = yes }
			}
		}
		if = {
			limit = { controls_state = 1059 } #Selija (Latvia)
			1059 = {
				add_building_construction = { type = bunker province = 11358 level = 2 instant_build = yes }
				add_building_construction = { type = bunker province = 3255 level = 2 instant_build = yes }
			}
		}
		if = {
			limit = { controls_state = 1067 }
				
			1067 = {
				add_building_construction = { type = bunker province = 13660 level = 2 instant_build = yes }
				add_building_construction = { type = bunker province = 13659 level = 2 instant_build = yes }
			}
		}
		if = {
			limit = { controls_state = 1068 }
			1068 = { 
				add_building_construction = { type = bunker province = 308 level = 2 instant_build = yes }
				add_building_construction = { type = bunker province = 11291 level = 2 instant_build = yes }
			}
		}
	}
}

#Latvia demands Lithuanian annexation
country_event = {
	id = LAT_events.2
	title = LAT_events.2.t
	desc = LAT_events.2.d
	picture = GFX_report_event_communist_leader
	
	is_triggered_only = yes

	option = { #Sure!
		name = LAT_events.2.a
		ai_chance = {
			base = 30
			modifier = {
				add = -25
				FROM = { has_army_size = { size < 40 } }
			}
			modifier = {
				add = 100
				FROM = { has_army_size = { size > 39 } }
			}
			modifier = {
				add = 20
				is_in_faction_with = FROM
			}
			modifier = {
				factor = 0.1
				is_in_faction = yes
			}
		}
		FROM = {
			country_event = { hours = 2 id = LAT_events.201 }
		}
		custom_effect_tooltip = GAME_OVER_TT
	}

	option = { #No thank you
		name = LAT_events.2.b
		ai_chance = {
			base = 10
			modifier = {
				FROM = { has_army_size = { size > 39 } }
				factor = 0.5
			}
			modifier = {
				add = 20
				FROM = { has_army_size = { size < 30 } }
			}
			modifier = {
				factor = 2
				is_in_faction = yes
				NOT = { is_in_faction_with = FROM }
			}
			modifier = {
				any_other_country = {
					has_guaranteed = ROOT
				}
				factor = 5 #i've got friends
			}
			modifier = {
				any_other_country = {
					is_major = yes
					has_guaranteed = ROOT
				}
				factor = 5 #i've got big friends
			}
		}
		FROM = {
			add_opinion_modifier = { target = PREV modifier = POL_annexation_refused }
			country_event = { hours = 2 id = LAT_events.202 }
			if = { limit = { is_in_faction_with = ROOT }
				remove_from_faction = ROOT
			}
		}
	}
}

#Lithuania says yes
country_event = {
	id = LAT_events.201
	title = EST_events.401.t
	desc = EST_events.401.d
	picture = GFX_report_event_military_planning
	
	is_triggered_only = yes

	option = { #Awesome!
		name = EST_events.401.a
		ai_chance = {
			base = 30
		}
		annex_country = { target = FROM transfer_troops = yes }
	}
}

#Lithuania says no
country_event = {
	id = LAT_events.202
	title = EST_events.402.t
	desc = EST_events.402.d
	picture = GFX_report_event_generic_panzer_attack
	
	is_triggered_only = yes

	option = { #How 'bout I do anyway
		name = EST_events.402.a
		ai_chance = {
			base = 30
		}
		create_wargoal = {
			type = annex_everything
			target = FROM
		}
	}
}

#Latvia supports fascism in Baltic states, gain opinion
country_event = {
	id = LAT_events.3
	title = LAT_events.3.t
	desc = LAT_events.3.d
	picture = GFX_report_event_generic_rally
	
	is_triggered_only = yes

	fire_only_once = yes

	option = { #Cool
		name = LAT_events.3.a
		ai_chance = {
			base = 30
		}
		add_opinion_modifier = {
			target = FROM
			modifier = BALTIC_supported_fascism
		}
	}
}

#Latvia demands puppet's annexation
country_event = {
	id = LAT_events.4
	title = EST_events.4.t
	desc = EST_events.4.d
	picture = GFX_report_event_lithuanian_ultimatum
	
	is_triggered_only = yes

	fire_only_once = no

	option = { #Sure!
		name = EST_events.4.a
		ai_chance = {
			base = 30
		}
		FROM = {
			country_event = { hours = 2 id = LAT_events.201 }
		}
		custom_effect_tooltip = GAME_OVER_TT
	}

	option = { #No thank you, option available for players.
		name = EST_events.4.b
		ai_chance = {
			base = 0
		}
		FROM = {
			add_opinion_modifier = { target = PREV modifier = POL_annexation_refused }
			country_event = { hours = 2 id = LAT_events.202 }
			if = { limit = { is_in_faction_with = ROOT }
				remove_from_faction = ROOT
			}
		}
	}
}

#Latvia asks for Ostland occupation
country_event = {
	id = LAT_events.5
	title = LAT_events.5.t
	desc = LAT_events.5.d
	picture = GFX_report_event_SOV_demands
	
	is_triggered_only = yes
	
	option = { #Sure!
		name = LAT_events.5.a
		ai_chance = {
			base = 30
		}
		effect_tooltip = {
			every_controlled_state = {
				limit = {
					NOT = { owner = { tag = ROOT } }
					OR = {
						#Lithuania States
						state = 814
						state = 11
						state = 815
						state = 189
						state = 188
						state = 1236
						state = 1237
						state = 1058
						state = 1172
						#Estonia States
						state = 811
						state = 812
						state = 13
						state = 813
						state = 191
						state = 1066
						state = 1067
						state = 1068
						state = 1069
						state = 1070
						state = 1071
						state = 1072
						#Belarus/East Poland States
						state = 784
						state = 1247
						state = 1248
						state = 96
						state = 95
						state = 1243
						state = 1244
						state = 1246
						state = 1261
						state = 1610
						state = 1173
					}
				}
				LAT = { set_state_controller = PREV }
			}
		}
		hidden_effect = {
			LAT = { country_event = LAT_events.501 }
		}
	}
	
	option = { #No way!
		name = LAT_events.5.b
		ai_chance = {
			base = 0
		}
		hidden_effect = {
			LAT = { country_event = LAT_events.502 }
		}
	}
}
#Latvia informed that they are approved to become Ostland
country_event = {
	id = LAT_events.501
	title = LAT_events.501.t
	desc = LAT_events.501.d
	picture = GFX_report_event_nazis_in_danzig
	
	is_triggered_only = yes
	
	option = { #Awesome!
		name = LAT_events.501.a
		ai_chance = {
			base = 30
		}
		FROM = {
			every_controlled_state = {
				limit = {
					NOT = { owner = { tag = ROOT } }
					OR = {
						#Lithuania States
						state = 814
						state = 11
						state = 815
						state = 189
						state = 188
						state = 1236
						state = 1237
						state = 1058
						state = 1172
						#Estonia States
						state = 811
						state = 812
						state = 13
						state = 813
						state = 191
						state = 1066
						state = 1067
						state = 1068
						state = 1069
						state = 1070
						state = 1071
						state = 1072
						#Belarus/East Poland States
						state = 784
						state = 1247
						state = 1248
						state = 96
						state = 95
						state = 1243
						state = 1244
						state = 1246
						state = 1261
						state = 1610
						state = 1173
					}
				}
				LAT = { set_state_controller = PREV }
			}
		}
	}
}
#Latvia informed that they are not allowed to form Ostland
country_event = {
	id = LAT_events.502
	title = LAT_events.502.t
	desc = LAT_events.502.d
	picture = GFX_report_event_danzig_joins_nazis
	
	is_triggered_only = yes
	
	option = { #You win a few you lose a lot
		name = LAT_events.502.a
		ai_chance = {
			base = 30
		}
	}
}

#Asks faction leader to invite Baltic States to faction
country_event = {
	id = LAT_events.6
	title = {
		text = LAT_events.6.t_both
		trigger = {
			EST = {
				exists = yes
				has_government = fascism
				NOT = {
					is_in_faction_with = ROOT
				}
			}
			LIT = {
				exists = yes
				has_government = fascism
				NOT = {
					is_in_faction_with = ROOT
				}
			}
		}
	}
	title = {
		text = LAT_events.6.t_estonia
		trigger = {
			EST = {
				exists = yes
				has_government = fascism
				NOT = {
					is_in_faction_with = ROOT
				}
			}
			LIT = {
				NOT = {
					OR = {
						exists = yes
						has_government = fascism
					}
				}
			}
		}
	}
	title = {
		text = LAT_events.6.t_lithuania
		trigger = {
			LIT = {
				exists = yes
				has_government = fascism
				NOT = {
					is_in_faction_with = ROOT
				}
			}
			EST = {
				NOT = {
					OR = {
						exists = yes
						has_government = fascism
					}
				}
			}
		}
	}
	
	desc = {
		text = LAT_events.6.d_both
		trigger = {
			EST = {
				exists = yes
				has_government = fascism
				NOT = {
					is_in_faction_with = ROOT
				}
			}
			LIT = {
				exists = yes
				has_government = fascism
				NOT = {
					is_in_faction_with = ROOT
				}
			}
		}
	}
	desc = {
		text = LAT_events.6.d_estonia
		trigger = {
			EST = {
				exists = yes
				has_government = fascism
				NOT = {
					is_in_faction_with = ROOT
				}
			}
			LIT = {
				NOT = {
					OR = {
						exists = yes
						has_government = fascism
					}
				}
			}
		}
	}
	desc = {
		text = LAT_events.6.d_lithuania
		trigger = {
			LIT = {
				exists = yes
				has_government = fascism
				NOT = {
					is_in_faction_with = ROOT
				}
			}
			EST = {
				NOT = {
					OR = {
						exists = yes
						has_government = fascism
					}
				}
			}
		}
	}
	picture = GFX_report_event_generic_conference
	
	is_triggered_only = yes

	option = { #Sounds good to me.
		name = LAT_events.6.a
		ai_chance = {
			factor = 10
		}
		every_other_country = {
			limit = {
				OR = {
					original_tag = LIT
					original_tag = EST
				}
				has_government = fascism
			}
			country_event = generic.2
		}
	}

	option = { #Sounds bad to me.
		name = LAT_events.6.b
		ai_chance = {
			factor = 0
		}
		LIT = { country_event = LAT_events.601 }
	}
}
#Latvia informed that the faction leader said no.
country_event = {
	id = LAT_events.601
	title = LAT_events.601.t
	desc = LAT_events.601.d
	picture = GFX_report_event_generic_read_write
	
	is_triggered_only = yes
	
	option = { #Dangit!
		name = LAT_events.601.a
		ai_chance = {
			factor = 10
		}
	}
}

#Latvia ignites a Fascist civil war
country_event = {
	id = LAT_events.7
	title = LAT_events.7.t
	desc = LAT_events.7.d
	picture = GFX_report_event_generic_riot
	
	is_triggered_only = yes

	option = { #War it is then I guess
		name = LAT_events.7.a
		ai_chance = {
			factor = 10
		}
		start_civil_war = {
			ideology = fascism
			size = party_popularity@fascism
		}
	}

	option = { #Y'know what, I thought about it and maybe Latvia has the right idea tbh
		name = LAT_events.7.b
		ai_chance = {
			factor = 0
		}
		set_politics = {
			ruling_party = fascism
			elections_allowed = no
		}
	}
}

#Latvia fails to curb Perkonkrusts - civil war
country_event = {
	id = LAT_events.8
	title = LAT_events.8.t
	desc = LAT_events.8.d
	picture = GFX_report_event_ger_civil_war
	
	is_triggered_only = yes

	option = { #Fight against the fascists
		name = LAT_events.8.a
		ai_chance = {
			factor = 10
		}
		if = { #Easier civil war for AI on historical since we don't want historical Latvian AI to do weird stuff
			limit = {
				is_ai = yes
				OR = {
					AND = {
						is_historical_focus_on = yes
						has_game_rule = {
							rule = LAT_ai_behavior
							option = DEFAULT
						}
					}
					has_country_flag = LAT_AI_RANDOM_HISTORICAL
					has_game_rule = {
						rule = LAT_ai_behavior
						option = HISTORICAL
					}
				}
			}
			start_civil_war = {
				ideology = fascism
				size = 0.2
				capital = 282
			}
		}
		else = { #Regular CW
			start_civil_war = {
				ideology = fascism
				size = party_popularity@fascism
				states = {
					190 1559 809 1059
				}
			}
		}
		
		random_other_country = {
			limit = { original_tag = LAT }
			set_capital = { state = 809 } #Move the capital to Zemgale
		}
		hidden_effect = {
			if = {
				limit = { has_completed_focus = LAT_latvia_for_latvians }
				uncomplete_national_focus = {
					focus = LAT_latvia_for_latvians
					uncomplete_children = yes
				}
				complete_national_focus = LAT_the_sun_shines_equally
			}
			if = {
				limit = {
					has_idea = LAT_neopaganism_idea
				}
				remove_ideas = { LAT_neopaganism_idea }
			}
			if = {
				limit = {
					has_idea = LAT_militarisation_idea
				}
				remove_ideas = { LAT_militarisation_idea }
			}
			if = {
				limit = {
					has_idea = LAT_militarisation_idea
				}
				remove_ideas = { LAT_paramilitary_fasc_idea }
				add_ideas = { LAT_paramilitary_idea }
			}
			if = {
				limit = {
					has_idea = perkonkrust_fas_idea_1
				}
				remove_ideas = { perkonkrust_fas_idea_1 }
			}
			if = {
				limit = {
					has_idea = LAT_perkonkrust_idea
				}
				remove_ideas = { LAT_perkonkrust_idea }
			}
		}
	}

	option = { #Fight as the fascists
		name = LAT_events.8.b
		ai_chance = {
			factor = 0
		}
		set_capital = { state = 809 } #Move the capital to Zemgale
		start_civil_war = {
			ruling_party = fascism
			ideology = neutrality
			size = 0.45
			states = {
				808 12 810 1060 1061 1062 1063
			}
		}
	}
}