namespace = dvg_russian_unification

# Annex a Russian country (Novgorod)
dvg_russian_unification.2 = {
	type = country_event
	placement = ROOT

	title = dvg_russian_unification.2.t
	desc = dvg_russian_unification.2.d
	flavor = dvg_russian_unification.2.f

	event_image = {
		video = "gfx/event_pictures/unspecific_signed_contract.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/unspecific/signed_contract"

	icon = "gfx/interface/icons/event_icons/event_portrait.dds"

	duration = 3

	cooldown = { months = 4 }

	trigger = {
		has_variable = nov_complete #Novgorod that succeeds its journal
		root.infamy < infamy_threshold:infamous
		OR = {
			country_tier = empire
			country_tier = kingdom
			country_tier = principality
		}
		any_country = {
			trigger_if = {
				limit = {
					has_technology_researched = pan-nationalism
				}
				OR = {
					country_has_primary_culture = cu:russian
					country_has_primary_culture = cu:north_russian
				}
			}
			trigger_else_if = {
				limit = {
					ROOT = {
						country_has_primary_culture = cu:russian
					}
				}
				country_has_primary_culture = cu:russian
			}
			trigger_else_if = {
				limit = {
					ROOT = {
						country_has_primary_culture = cu:north_russian
					}
				}
				country_has_primary_culture = cu:north_russian
			}
			has_diplomatic_pact = {
				who = ROOT
				type = customs_union
			}
			OR = {
				is_subject = no
				is_subject_of = ROOT
			}
			country_rank < rank_value:major_power
			relations:root >= relations_threshold:amicable
			is_player = no
			NOT = { has_variable = russian_minor_dont_annex }
		}
	}

	immediate = {
		random_country = {
			limit = {
				trigger_if = {
					limit = {
						has_technology_researched = pan-nationalism
					}
					OR = {
						country_has_primary_culture = cu:russian
						country_has_primary_culture = cu:north_russian
					}
				}
				trigger_else_if = {
					limit = {
						ROOT = {
							country_has_primary_culture = cu:russian
						}
					}
					country_has_primary_culture = cu:russian
				}
				trigger_else_if = {
					limit = {
						ROOT = {
							country_has_primary_culture = cu:north_russian
						}
					}
					country_has_primary_culture = cu:north_russian
				}
				has_diplomatic_pact = {
					who = ROOT
					type = customs_union
				}
				OR = {
					is_subject = no
					is_subject_of = ROOT
				}
				country_rank < rank_value:major_power
				relations:root >= relations_threshold:amicable
				is_player = no
				NOT = { has_variable = russian_minor_dont_annex }
			}
			save_scope_as = russian_annex_country
		}
	}

	option = {
		name = dvg_russian_unification.2.a
		default_option = yes
		annex = scope:russian_annex_country
		ai_chance = {
			base = 1
		}
	}
	option = {
		name = dvg_russian_unification.2.b
		change_relations = {
			country = scope:russian_annex_country
			value = 20
		}
		scope:russian_annex_country = {
			set_variable = {
				name = russian_minor_dont_annex
				days = 1825
			}
		}
		ai_chance = {
			base = 0
		}
	}
}

# Russian Unification
dvg_russian_unification.4 = {
	type = country_event
	placement = ROOT

	title = dvg_russian_unification.4.t
	desc = dvg_russian_unification.4.d
	flavor = dvg_russian_unification.4.f

	event_image = {
		video = "gfx/event_pictures/unspecific_military_parade.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/unspecific/military_parade"

	icon = "gfx/interface/icons/event_icons/event_portrait.dds"

	duration = 3

	trigger = {
	}

	option = {
		name = dvg_russian_unification.4.a
		default_option = yes
		give_claims_on_russia = yes

		ruler = {
			add_modifier = {
				name = russian_unifier_ruler
			}
		}
	}
	option = {
		name = dvg_russian_unification.4.b
		give_claims_on_russia = yes

		add_loyalists = {
			value = 0.1
			culture = cu:russian
		}
		add_loyalists = {
			value = 0.1
			culture = cu:north_russian
		}
	}
}

dvg_russian_unification.10 = {
	type = country_event
	placement = ROOT

	event_image = {
		video = "gfx/event_pictures/europenorthamerica_capitalists_meeting.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/europenorthamerica/capitalists_meeting"

	icon = "gfx/interface/icons/event_icons/event_default.dds"

	title = dvg_russian_unification.10.t
	desc = dvg_russian_unification.10.d
	flavor = dvg_russian_unification.10.f

	duration = 3

	trigger = {
		NOT = { has_global_variable = rus_annex_nov }
		exists = c:MUS
		this = c:MUS
		exists = c:NOV
		has_global_variable = failstate_NOV
		has_technology_researched = nationalism
		is_at_war = no
	}

	immediate = {
		set_global_variable = rus_annex_nov
	}

	option = {
		name = dvg_russian_unification.10.a
		default_option = yes

		annex = c:NOV
		add_journal_entry = {
			type = je_russian_unification
		}
	}
}
