﻿###########################
# 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 = 12
						state = 191
					}
				}
				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 = 6459 level = 2 instant_build = yes }
					add_building_construction = { type = bunker province = 9275 level = 2 instant_build = yes }
					add_building_construction = { type = bunker province = 222 level = 2 instant_build = yes }
					add_building_construction = { type = bunker province = 319 level = 2 instant_build = yes }
					add_building_construction = { type = bunker province = 3298 level = 2 instant_build = yes }
				}
				if = {
					limit = {
						controls_state = 810
						SOV = {
							controls_state = 96
						}
					}
					810 = {
						add_building_construction = { type = bunker province = 310 level = 2 instant_build = yes }
						add_building_construction = { type = bunker province = 11358 level = 2 instant_build = yes }
					}
				}
			}
			if = {
				limit = {
					controls_state = 784
					GER = {
						NOT = {
							controls_state = 96
							controls_state = 95
						}
					}
				}
				784 = {
					add_building_construction = { type = bunker province = 784 level = 2 instant_build = yes }
					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 = 9274 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 = 191 }
			191 = {
				add_building_construction = { type = bunker province = 592 level = 4 instant_build = yes }
			}
		}
		if = {
			limit = { controls_state = 813 }
			813 = {
				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 = 809 #Zemgale (Latvia)
						state = 13 #Parnu (Estonia)
						state = 191 #Tartu (Estonia)
					}
				}
				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 }
				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 = 191 } #Tartu (Estonia)
				
			191 = {
				add_building_construction = { type = bunker province = 592 level = 2 instant_build = yes }
				add_building_construction = { type = bunker province = 9485 level = 2 instant_build = yes }
				add_building_construction = { type = bunker province = 6408 level = 2 instant_build = yes }
			}
		}
		if = { #Parnu (Estonia)
			limit = { controls_state = 13 }
			13 = { 
				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
				strength_ratio = {
					tag = LAT
					ratio > 0.75
				}
			}
			modifier = {
				add = 100
				strength_ratio = {
					tag = LAT
					ratio < 0.33
				}
			}
			modifier = {
				add = 100
				any_other_country = {
					OR = {
						tag = LIT
						tag = EST
					}
					is_ai = no
				}
			}
			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 = {
				strength_ratio = {
					tag = LAT
					ratio < 0.33
				}
				factor = 0.5
			}
			modifier = {
				add = 20
				strength_ratio = {
					tag = LAT
					ratio > 0.75
				}
			}
			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
		}	
		every_state = {
			limit = {
				is_core_of = FROM 
			}
			add_claim_by = LAT
		}
	}
}

#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
						#Estonia States
						state = 811
						state = 812
						state = 13
						state = 813
						state = 191
						#Belarus/East Poland States
						state = 784
						state = 96
						state = 95
						state = 94
					}
				}
				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
						#Estonia States
						state = 811
						state = 812
						state = 13
						state = 813
						state = 191
						#Belarus States
						state = 784
						state = 96
						state = 95
						state = 94
					}
				}
				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 809
				}
			}
		}
		
		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
			}
		}
	}
}