on_actions = {
	on_new_term_election = {
		random_events = {
			100 = ukraine.342 # 1st Ukrainian democratic election
			100 = ukraine.369 # 2st Ukrainian democratic election
			100 = ukraine.343 # Ukrainian socialist election
			100 = ukraine.635 # Ukrainian nationalists election
		}
	}

	on_startup = {
		effect = {
			UKR = {
				#Intro Event
				country_event = ukr_lor.800
				if = { 
					limit = { is_historical_focus_on = yes } 
					country_event = ukraine.548
				}
				#AI path selector
				if = {
					limit = {
						has_start_date < 1936.01.02
						OR = {
							has_game_rule = {
								rule = UKR_ai_behavior
								option = DEFAULT
							}
							has_game_rule = {
								rule = UKR_ai_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						5 = {
							UKR = {
								set_country_flag = UKR_AI_RANDOM_NATCOM
							}
						}
						5 = {
							UKR = {
								set_country_flag = UKR_AI_RANDOM_COMMUNIST
							}
						}
						5 = {
							UKR = {
								set_country_flag = UKR_AI_RANDOM_COMMUNIST_ALTERNATE
							}
						}
						10 = {
							UKR = {
								set_country_flag = UKR_AI_RANDOM_DEMOCRATIC
							}
						}
						5 = {
							UKR = {
								set_country_flag = UKR_AI_RANDOM_ALTDEM
							}
						}
						5 = {
							UKR = {
								set_country_flag = UKR_AI_RANDOM_INTERMARIUM
							}
						}
						5 = {
							UKR = {
								set_country_flag = UKR_AI_RANDOM_NEUTRALITY
							}
						}
						5 = {
							UKR = {
								set_country_flag = UKR_AI_RANDOM_NEUTRALITY_MONARCHY
							}
						}
						5 = {
							UKR = {
								set_country_flag = UKR_AI_RANDOM_NEUTRALITY_ALTMONARCHY
							}
						}
						5 = {
							UKR = {
								set_country_flag = UKR_AI_RANDOM_NEUTRALITY_REPUBLIC
							}
						}
						5 = {
							UKR = {
								set_country_flag = UKR_AI_RANDOM_FASCIST_TRUE
							}
						}
						5 = {
							UKR = {
								set_country_flag = UKR_AI_RANDOM_FASCIST_ALTERNATE
							}
						}
						5 = {
							UKR = {
								set_country_flag = UKR_AI_RANDOM_FASCIST
							}
						}
						5 = {
							UKR = {
								set_country_flag = UKR_AI_RANDOM_ANARCHY_LEFT
							}
						}
						5 = {
							UKR = {
								set_country_flag = UKR_AI_RANDOM_ANARCHY_RIGHT
							}
						}
					}
				}
				if = {
					limit = {
						has_start_date < 1936.01.02
						OR = {
							has_game_rule = {
								rule = CRM_ai_behavior
								option = DEFAULT
							}
							has_game_rule = {
								rule = CRM_ai_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						10 = {
							CRM = {
								set_country_flag = CRM_AI_RANDOM_COMMUNIST
							}
						}
						10 = {
							CRM = {
								set_country_flag = CRM_AI_RANDOM_AUTONOM_SSR
							}
						}
						20 = {
							CRM = {
								set_country_flag = CRM_AI_RANDOM_TATAR
							}
						}
						20 = {
							CRM = {
								set_country_flag = CRM_AI_RANDOM_DEMOCRATIC
							}
						}
						20 = {
							CRM = {
								set_country_flag = CRM_AI_RANDOM_NEUTRALITY
							}
						}
						20 = {
							CRM = {
								set_country_flag = CRM_AI_RANDOM_FASCIST
							}
						}
					}
				}
				if = {
					limit = {
						has_start_date < 1936.01.02
						OR = {
							has_game_rule = {
								rule = CRI_ai_behavior
								option = DEFAULT
							}
							has_game_rule = {
								rule = CRI_ai_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						25 = {
							CRI = {
								set_country_flag = CRI_AI_RANDOM_COMMUNIST
							}
						}
						25 = {
							CRI = {
								set_country_flag = CRI_AI_RANDOM_DEMOCRATIC
							}
						}
						25 = {
							CRI = {
								set_country_flag = CRI_AI_RANDOM_NEUTRALITY
							}
						}
						25 = {
							CRI = {
								set_country_flag = CRI_AI_RANDOM_FASCIST
							}
						}
					}
				}
				#Support for anarchists
				if = {
					limit = { 
						OR = {
							has_game_rule = {
								rule = UKR_ai_behavior
								option = ANARCHY_LEFT
							}
							has_game_rule = {
								rule = UKR_ai_behavior
								option = ANARCHY_RIGHT
							}
						}
					}
					add_ai_strategy = {
						type = build_building
						id = arms_factory
						target = 227
						value = 3
					}
					add_ai_strategy = {
						type = build_building
						id = industrial_complex
						target = 226
						value = 3
					}
				}
				#Support for altdem
				if = {
					limit = { 
						has_game_rule = {
							rule = UKR_ai_behavior
							option = ALTDEM
						}
					}
					add_ai_strategy = {
						type = build_building
						id = industrial_complex
						target = 202
						value = 3
					}
				}
			}
			#Crimean events
			CRM = {
				if = {
					limit = { 
						has_start_date > 1939.01.01
						has_game_rule = {
							rule = CRM_ai_behavior
							option = TATAR
						}
					}
					country_event = qirimlar.50
				}
				else_if = {
					limit = { has_start_date > 1939.01.01 }
					add_days_mission_timeout = {
						mission = CRM_gain_foreign_recognition 
						days = -500
					}
				}
			}
			# water system of Crimea
			set_variable = { south_crimea_water = 3000 } 
			set_variable = { south_crimea_water_coming = 1200 }
			set_variable = { south_crimea_water_flow = 1400 }
			set_variable = { north_crimea_water = 2500 }
			set_variable = { north_crimea_water_coming = 1000 }
			set_variable = { north_crimea_water_flow = 1150 }
			# POL fragmentation
			if = {
				limit = {
					has_game_rule = {
						rule = pol_fragmentation_status
						option = POL_FRAGMENTED
					}
				}
				89 = { add_core_of = WUA }
				91 = { add_core_of = WUA }
				93 = { add_core_of = WUA }
				987 = { add_core_of = WUA }
				POL = {
					release = WUA
					release = BLR
					release = KSH
					release = SIL
				}
				LIT = { transfer_state = 784 }
			}
			else = {
				POL = { add_ideas = POL_ethnic_minorities }
			}
			# CZE fragmentation
			if = {
				limit = {
					has_game_rule = {
						rule = cze_fragmentation_status
						option = CZE_FRAGMENTED
					}
				}
				70 = { add_core_of = SLO }
				71 = { add_core_of = SLO }
				664 = { add_core_of = SLO }
				984 = { add_core_of = SLO }
				CZE = {
					release = SLO
					release = CUA
					set_cosmetic_tag = CZE_ONLY
				}
			}
			#add release tags in SOV
			if = {
				limit = {
					has_game_rule = {
						rule = sov_fragmentation_status
						option = SOV_UTTERLY_FRAGMENTED
					}
				}
				ZKL = {
					transfer_state = 408
					transfer_state = 409
					transfer_state = 560
					transfer_state = 657
					transfer_state = 655
				}
				SKL = {
					add_state_core = 882
					add_state_core = 583
					add_state_core = 590
					add_state_core = 571
					add_state_core = 570
					add_state_core = 40
					transfer_state = 882
					transfer_state = 583
					transfer_state = 590
					transfer_state = 571
					transfer_state = 570
					transfer_state = 40
					set_capital = { state = 571 }
				}
				SOV = {
					235 = { add_core_of = KUB }
					release = KUB
					release = DON
				}
			}
		}
	}
	# water problems for White Crimea
	on_monthly_CRM = {
		effect = {
			if = {
				limit = { 
					137 = { 
						is_owned_and_controlled_by = CRM
					}
				}
				set_temp_variable = { crm_weekly_water = global.south_crimea_water_coming }
				subtract_from_temp_variable = { crm_weekly_water = global.south_crimea_water_flow } 
				add_to_variable = { global.south_crimea_water = crm_weekly_water }
				clamp_variable = { var = global.south_crimea_water min = 0 max = 9999 }
				if = {
					limit = { 
						check_variable = { global.south_crimea_water < 1 }
						check_variable = { crm_weekly_water < 0 }
						NOT = { 137 = { has_dynamic_modifier = { modifier = CRI_no_water } } }
						NOT = { has_global_flag = north_crimean_canal_is_built } 
					}
					137 = { add_dynamic_modifier = { modifier = CRI_no_water } }
				}
				else_if = {
					limit = {
						OR = { 
							check_variable = { global.south_crimea_water > 0 }
							check_variable = { crm_weekly_water > -1 }
						}
						137 = { has_dynamic_modifier = { modifier = CRI_no_water } } 
					}
					137 = {	remove_dynamic_modifier = {	modifier = CRI_no_water } }
				}
			}
			if = {
				limit = { 
					986 = { 
						is_owned_and_controlled_by = CRM
					}
				}
				set_temp_variable = { crm_weekly_water = global.north_crimea_water_coming }
				subtract_from_temp_variable = { crm_weekly_water = global.north_crimea_water_flow } 
				add_to_variable = { global.north_crimea_water = crm_weekly_water }
				clamp_variable = { var = global.north_crimea_water min = 0 max = 9999 }
				if = {
					limit = { 
						check_variable = { global.north_crimea_water < 1 }
						check_variable = { crm_weekly_water < 0 }
						NOT = { 986 = { has_dynamic_modifier = { modifier = CRI_no_water } } }
						NOT = { has_global_flag = north_crimean_canal_is_built } 
					}
					986 = { add_dynamic_modifier = { modifier = CRI_no_water } }
				}
				else_if = {
					limit = { 
						OR = { 
							check_variable = { global.north_crimea_water > 0 }
							check_variable = { crm_weekly_water > -1 }
						}
						986 = { has_dynamic_modifier = { modifier = CRI_no_water } } 
					}
					986 = {	remove_dynamic_modifier = {	modifier = CRI_no_water } }
				}
			}
		}
	}
	# water problems for Crimean Tatars
	on_monthly_CRI = {
		effect = {
			if = {
				limit = { 
					137 = { 
						is_owned_and_controlled_by = CRI
					}
				}
				set_temp_variable = { crm_weekly_water = global.south_crimea_water_coming }
				subtract_from_temp_variable = { crm_weekly_water = global.south_crimea_water_flow } 
				add_to_variable = { global.south_crimea_water = crm_weekly_water }
				clamp_variable = { var = global.south_crimea_water min = 0 max = 9999 }
				if = {
					limit = { 
						check_variable = { global.south_crimea_water < 1 }
						check_variable = { crm_weekly_water < 0 }
						NOT = { 137 = { has_dynamic_modifier = { modifier = CRI_no_water } } }
						NOT = { has_global_flag = north_crimean_canal_is_built } 
					}
					137 = { add_dynamic_modifier = { modifier = CRI_no_water } }
				}
				else_if = {
					limit = { 
						OR = { 
							check_variable = { global.south_crimea_water > 0 }
							check_variable = { crm_weekly_water > -1 }
						}
						137 = { has_dynamic_modifier = { modifier = CRI_no_water } } 
					}
					137 = {	remove_dynamic_modifier = {	modifier = CRI_no_water } }
				}
			}
			if = {
				limit = { 
					986 = { 
						is_owned_and_controlled_by = CRI
					}
				}
				set_temp_variable = { crm_weekly_water = global.north_crimea_water_coming }
				subtract_from_temp_variable = { crm_weekly_water = global.north_crimea_water_flow } 
				add_to_variable = { global.north_crimea_water = crm_weekly_water }
				clamp_variable = { var = global.north_crimea_water min = 0 max = 9999 }
				if = {
					limit = { 
						check_variable = { global.north_crimea_water < 1 }
						check_variable = { crm_weekly_water < 0 }
						NOT = { 986 = { has_dynamic_modifier = { modifier = CRI_no_water } } } 
						NOT = { has_global_flag = north_crimean_canal_is_built }
					}
					986 = { add_dynamic_modifier = { modifier = CRI_no_water } }
				}
				else_if = {
					limit = { 
						OR = { 
							check_variable = { global.north_crimea_water > 0 }
							check_variable = { crm_weekly_water > -1 }
						}
						986 = { has_dynamic_modifier = { modifier = CRI_no_water } } 
					}
					986 = {	remove_dynamic_modifier = {	modifier = CRI_no_water } }
				}
			}
		}
	}
	# for achievement Master of the Brains
	on_daily_DKR = {
		effect = {
			if = {
				limit = {
					NOT = { has_country_flag = cua_brain_drain_flag }
					has_idea = DKR_brain_drain_incoming
				}
				add_to_variable = { var_days_of_brain_drain = 1 }
			}
			if = {
				limit = {
					check_variable = { var_days_of_brain_drain > 365 }
				}
				set_country_flag = cua_brain_drain_flag
			}
		}
	}	

	on_puppet = {
		effect = {
			if = {
				limit = { 
					AND = { 
						TAG = CRM
						is_subject_of = UKR
					}
				}
				set_cosmetic_tag = CRM_AUT
			}
			if = {
				limit = { 
					AND = { 
						TAG = CRI
						is_subject_of = SOV
						SOV = { has_government = communism }
					}
				}
				set_cosmetic_tag = CRI_SOV
			}
			if = {
				limit = { 
					AND = { 
						TAG = MOL
						is_subject_of = UKR
					}
				}
				set_cosmetic_tag = MOL_AUT
			}
			if = {
				limit = { 
					AND = { 
						TAG = SOV
						is_subject_of = UKR
						219 = { is_owned_and_controlled_by = SOV }
					}
				}
				set_cosmetic_tag = SOV_UKR
			}
			if = {
				limit = { 
					AND = { 
						TAG = UKR
						is_subject_of = SOV
						SOV = { has_government = communism }
						UKR = { NOT = { has_completed_focus = UKR_communism_propaganda } }
					}
				}
				UKR = {
					load_focus_tree = { tree = ukraine_focus keep_completed = no }
					unlock_national_focus = UKR_political_effort
					unlock_national_focus = UKR_communism_propaganda
					complete_national_focus = UKR_road_to_world_revolution
					complete_national_focus = UKR_purge
					set_country_flag = UKR_AI_RANDOM_COMMUNIST
				}
			}
			if = {
				limit = { 
					tag = UKR
					has_global_flag = trotsky_came_back_in_ukraine 
					has_character = UKR_lev_trotsky
					is_subject_of = SOV
					SOV = { has_government = communism }
				}
				retire_character = UKR_lev_trotsky
			}
			if = {
				limit = { 
					tag = UKR
					is_subject_of = SOV
				}
				if = {
					limit = { has_character = UKR_yevhen_konovalets }
					retire_character = UKR_yevhen_konovalets
				}
				if = {
					limit = { has_character = UKR_roman_shukhevych }
					retire_character = UKR_roman_shukhevych
				}
				if = {
					limit = { has_character = UKR_petro_bolbochan }
					retire_character = UKR_petro_bolbochan
				}
			}
			if = {
				limit = { 
					AND = { 
						TAG = GER
						has_government = fascism
					}
				}
				retire_country_leader = yes
				set_cosmetic_tag = GER_NHF
			}
		}
	}

	on_release_as_puppet = {
		effect = {
			if = {
				limit = { 
					AND = { 
						TAG = CRM
						is_subject_of = UKR
					}
				}
				set_cosmetic_tag = CRM_AUT
			}
			if = {
				limit = { 
					AND = { 
						TAG = CRI
						is_subject_of = SOV
						SOV = { has_government = communism }
					}
				}
				set_cosmetic_tag = CRI_SOV
			}
			if = {
				limit = { 
					AND = { 
						TAG = SOV
						is_subject_of = UKR
						219 = { is_owned_and_controlled_by = SOV }
					}
				}
				set_cosmetic_tag = SOV_UKR
			}
			if = {
				limit = { 
					AND = { 
						TAG = UKR
						is_subject_of = SOV
						UKR_lev_trotsky = {
							is_country_leader = yes
						}
						SOV = { has_government = communism }
					}
				}
				kill_country_leader = yes
			}
			if = {
				limit = { 
					AND = { 
						TAG = GER
						has_government = fascism
					}
				}
				kill_country_leader = yes
				set_cosmetic_tag = GER_NHF
			}
		}
	}

	on_subject_free = {
		effect = {
			if = {
				limit = {
					original_tag = CRI
				}
				drop_cosmetic_tag = yes
			}
		}
	}
	
	on_subject_annexed = { 
		effect = {
			if = {
				limit = {
					ROOT = { tag = DKR }
					FROM = { tag = UKR }
					UKR = {
						has_government = communism
						has_completed_focus = UKR_negotiations_with_opposition
					}
				}
				FROM = { country_event = ukraine.592 }
			}
		} 
	}

	on_capitulation = {
		effect = {
			# rebellion in West Ukraine after fall of Poland
			if = {
				limit = { 
					original_tag = POL
					GER = { has_war_with = POL }
					NOT = { country_exists = WUA }
					UKR = { 
						exists = yes
						NOT = { is_in_faction_with = POL } 
						NOT = { has_war_with = GER }
						NOT = { has_war_with = POL }
						is_puppet = no
					}
					NOT = {
						89 = {
							is_controlled_by = UKR
						}
						91 = {
							is_controlled_by = UKR
						}
						93 = {
							is_controlled_by = UKR
						}
						987 = {
							is_controlled_by = UKR
						}
						991 = {
							is_controlled_by = UKR
						}
					}
					#has_global_flag = fall_of_warsaw_ger
				}
				UKR = { country_event = { id = ukraine.44 days = 1 } }
			} 
			# victory anarchists in civil war
			if = {
				limit = { 
					original_tag = UKR
					has_war_with = DKR
					DKR = { 
						has_government = neutrality
						has_country_flag = UKR_anarchy_uprising_go
						has_capitulated = no
					}
				}
				DKR = {
					annex_country = { target = UKR }
					clr_country_flag = UKR_anarchy_uprising_go
					if = {
						limit = { has_country_flag = DKR_has_long_civil_war }
						add_timed_idea = {
							idea = DKR_recovering_from_civil_war
							days = 730
						}
					}
					else = {
						add_timed_idea = {
							idea = DKR_recovering_from_civil_war
							days = 500
						}
					}
					if = {
						limit = { has_idea = DKR_bonus_for_AI }	
						hidden_effect = {
							remove_ideas = DKR_bonus_for_AI
						}
					}
					every_owned_state = {
						limit = {
							is_owned_and_controlled_by = DKR
							is_core_of = UKR
							is_core_of = DKR
						}
						remove_core_of = UKR
					}
					country_event = { id = makhno.68 days = 5 random_days = 3 }
				}
				89 = { remove_core_of = UKR }
				91 = { remove_core_of = UKR }
				93 = { remove_core_of = UKR }
				987 = { remove_core_of = UKR }
				89 = { add_core_of = WUA }
				91 = { add_core_of = WUA }
				93 = { add_core_of = WUA }
				987 = { add_core_of = WUA }
				137 = { remove_claim_by = UKR }
				986 = { remove_claim_by = UKR }
				#news_event = { id = news.563 days = 1 } #it is not working
			}
			# victory of UPR in civil war
			if = {
				limit = { 
					original_tag = DKR
					has_war_with = UKR
					DKR = { 
						has_government = neutrality
						has_country_flag = UKR_anarchy_uprising_go
					}
				}
				UKR = {
					annex_country = { target = DKR }
					every_owned_state = {
						limit = {
							is_owned_and_controlled_by = UKR
							is_core_of = UKR
							is_core_of = DKR
						}
						remove_core_of = DKR
					}
					country_event = { id = ukraine.681 hours = 3 }
				}
			}
			# capitulation of Ukraine - go to future fight
			if = {
				limit = { 
					original_tag = UKR
					NOT = { has_government = communism }
					any_other_country = {
						is_in_faction_with = ROOT
						is_faction_leader = yes
						has_capitulated = no
					}
				}
				ROOT = { country_event = ukraine.677 }
			}	
		}
	}

	on_civil_war_end = {
		effect = {
			if = { #Victory of rebels
				limit = {
					original_tag = SOV
					NOT = { has_government = communism }
					UKR = { has_country_flag = participation_in_sov_civ_war }
				}
				#add_timed_idea = {
				#	idea = RUS_postwar_ruins
				#	days = 365
				#}
				country_event = { id = ukraine.202 days = 2 }
				random_other_country = {
					limit = { has_country_flag = UKR_first_in_intervetion_faction }
					dismantle_faction = yes
				}
			}
			if = {
				limit = { #Victory of communists
					original_tag = SOV
					has_government = communism
					UKR = { has_country_flag = participation_in_sov_civ_war }
				}
				#add_timed_idea = {
				#	idea = RUS_postwar_ruins
				#	days = 365
				#}
				every_other_country = {
					limit = {
						has_country_flag = participation_in_sov_civ_war
						has_war_with = SOV
					}
					country_event = ukraine.206
				}
				random_other_country = {
					limit = { has_country_flag = UKR_first_in_intervetion_faction }
					dismantle_faction = yes
				}
			}
			#Puppet Poland when monarchist civil war ends
			if = {
				limit = {
					has_country_flag = UKR_poland_personal_union_flag
					UKR = { 
						is_subject = no
						has_government = neutrality 
					}
				}
				UKR = {
					if = {
						limit = { ROOT = { has_war_with = WUA } }
						puppet = WUA
					}
					puppet = PREV
				}
			}
		}
	}
	on_declare_war = {
		effect = {
			#Call Anti-Soviet pact members to war
			if = {
				limit = {
					ROOT = { tag = SOV }
					FROM = { has_idea = member_of_sanitary_cordon }
				}
				FROM = {
					country_event = { id = ukraine.210 days = 1 }
				}
			}
			#Call democratic defense initiative members to war
			if = {
				limit = {
					FROM = { has_idea = UKR_member_of_defence_initiative }
				}
				FROM = { save_event_target_as = ukraine_victim_of_warmonger }
				ROOT = { save_event_target_as = ukraine_great_warmonger }
				every_country = {
					limit = {
						NOT = { tag = FROM }
						NOT = { tag = ROOT }
						has_idea = UKR_member_of_defence_initiative
					}
					country_event = { id = ukraine.508 days = 1 }	
				}
			}
			#Call Germany or Ukraine for natcom pact
			if = {
				limit = {
					ROOT = { tag = SOV }
					FROM = { has_idea = UKR_GER_natcom_pact }
				}
				every_country = {
					limit = {
						NOT = { tag = FROM }
						NOT = { tag = ROOT }
						has_idea = UKR_GER_natcom_pact
					}
					country_event = { id = ukraine.571 days = 1 }	
				}
			}
			# History makers - call to war Hungary, Bulgaria or Lithuania
			if = {
				limit = {
					ROOT = { tag = UKR }
					FROM = { 
						tag = ROM 
						has_country_flag = UKR_hm_hungary_agree
					}
					HUN = {
						exists = yes
						is_puppet = no
						NOT = { has_war_with = ROOT }
						NOT = { has_war_with = ROM }
						NOT = { is_in_faction_with = ROOT }
						NOT = { is_in_faction_with = ROM }
					}
					76 = { is_owned_and_controlled_by = ROM }
				}
				HUN = { country_event = ukraine.611 }
			}
			if = {
				limit = {
					ROOT = { tag = UKR }
					FROM = { 
						tag = ROM 
						has_country_flag = UKR_hm_bulgaria_agree
					}
					BUL = {
						exists = yes
						is_puppet = no
						NOT = { has_war_with = ROOT }
						NOT = { has_war_with = ROM }
						NOT = { is_in_faction_with = ROOT }
						NOT = { is_in_faction_with = ROM }
					}
					77 = { is_owned_and_controlled_by = ROM }
				}
				BUL = { country_event = ukraine.611 }
			}
			if = {
				limit = {
					ROOT = { tag = UKR }
					FROM = { 
						tag = CZE 
						has_country_flag = UKR_hm_hungary_agree
					}
					HUN = {
						exists = yes
						is_puppet = no
						NOT = { has_war_with = ROOT }
						NOT = { has_war_with = CZE }
						NOT = { is_in_faction_with = ROOT }
						NOT = { is_in_faction_with = CZE }
					}
					664 = { is_owned_and_controlled_by = CZE }
				}
				HUN = { country_event = ukraine.612 }
			}
			if = {
				limit = {
					ROOT = { tag = UKR }
					FROM = { 
						tag = POL 
						has_country_flag = UKR_hm_lithuania_agree
					}
					LIT = {
						exists = yes
						is_puppet = no
						NOT = { has_war_with = ROOT }
						NOT = { has_war_with = POL }
						NOT = { is_in_faction_with = ROOT }
						NOT = { is_in_faction_with = POL }
					}
					784 = { is_owned_and_controlled_by = POL }
				}
				LIT = { country_event = ukraine.613 }
			}
			# Soviet-Finnish war
			if = {
				limit = {
					ROOT = { tag = SOV }
					FROM = { tag = FIN }
					FIN = { is_in_faction = no }
					UKR = {
						exists = yes
						NOT = { is_in_faction_with = SOV }
						NOT = { has_completed_focus = UKR_purge }
						NOT = { has_war_with = SOV }
						NOT = { has_war_with = FIN }
					}
				}
				UKR = {
					country_event = { id = ukraine.674 days = 1 }
				}
			}
		}
	}
	on_government_change = {
		effect = {			
			if = {
				limit = {
					original_tag = UKR
					has_government = democratic
				}
				set_variable = { ukr_sr_stability = 0 }
				set_variable = { ukr_sr_polit_power = 0 }
				set_variable = { ukr_sr_democratic = 0.02 }
				add_dynamic_modifier = {
					modifier = UKR_support_in_rada_mod
				}
				country_event = ukraine.358
			}
			if = {
				limit = {
					original_tag = UKR
					has_country_flag = UKR_cossack_republic
					NOT = { has_government = neutrality }
				}
				clr_country_flag = UKR_cossack_republic
			}
		}	
	}
	on_join_faction = {
		effect = {
			if = {
				limit = {
					FROM = { 
						original_tag = UKR 
						has_completed_focus = UKR_socialistic_science
					}
				}
				add_to_tech_sharing_group = UKR_socialistic_research
			}
			if = {
				limit = {
					FROM = { 
						original_tag = UKR 
						has_completed_focus = UKR_technical_cooperation
					}
				}
				add_ideas = UKR_soc_cooperation
			}
		}
	}
	on_offer_join_faction = {
		effect = {
			if = {
				limit = {
					original_tag = UKR 
					has_completed_focus = UKR_socialistic_science
				}
				FROM = { add_to_tech_sharing_group = UKR_socialistic_research }
			}
			if = {
				limit = {
					original_tag = UKR 
					has_completed_focus = UKR_technical_cooperation
				}
				FROM = { add_ideas = UKR_soc_cooperation }
			}
		}
	}
	on_nuke_drop = {

		effect = {

			if = {
				limit = {
					FROM = { state = 219 }
				}
				set_country_flag = cua_radioactive_ash_flag
			}
		}
	}
	on_war = { 
		effect = {
			if = {
				limit = {
					tag = UKR
				}
				set_country_flag = UKR_have_any_war_flag
			}
		}
	}
	on_pride_of_the_fleet_sunk = {
		effect = {
			if = {
				limit = {
					tag = SOV
				}
				FROM = { set_country_flag = cua_moscow_pride_flag }
			}
		}
	}
	# called when a country send volunteers to another
	# ROOT is sender, FROM is receiver
	on_send_volunteers = {
		effect = {
			if = { 
				limit = {
					original_tag = UKR
					has_completed_focus = UKR_humane_communism
					NOT = { has_country_flag = UKR_send_vol_to_soviet_opposition } # only once 
					FROM = { 
						original_tag = SOV
						OR = {
							has_completed_focus = SOV_the_left_opposition
							has_completed_focus = SOV_the_right_opposition
						}
						has_government = communism
						has_civil_war = yes
					}
				}
				add_to_variable = { var_ukr_relations_with_new_ussr = 1 }
				set_country_flag = UKR_send_vol_to_soviet_opposition
			}	
		}
	}
	on_state_control_changed = {
		effect = {
			if = {
				limit = {
					SOV = { has_civil_war = yes } 
					FROM.FROM = {
						OR = {
							state = 570
							state = 571
							state = 40	
						}
					}
					ROOT = {
						tag = SKL
					}
				}
				FROM.FROM = { 
					add_core_of = SKL 
					set_state_owner_to = SKL
				}
				SKL = { country_event = grayukraine.10 }
			}
			# military devastation for states in war of Natcoms after eastern separatists
			if = {
				limit = {
					UKR = { 
						has_war_with = DKR 
						has_completed_focus = UKR_war_answer_for_dksr
					} 
					FROM.FROM = {
						is_core_of = DKR
					}
					ROOT = {
						tag = UKR
					}
				}
				FROM.FROM = { 
					add_dynamic_modifier = {
						modifier = UKR_dksr_military_devastation
						days = 120
						scope = UKR
					}
				}
			}
			# Kherson volunteers in ukrainian civil war against anarchists
			if = {
				limit = {
					UKR = { 
						has_war_with = DKR 
						has_country_flag = UKR_altdem_branch_is_available
						NOT = { has_country_flag = UKR_kherson_selfdefence_activate }
					} 
					FROM.FROM = {
						state = 196
					}
					ROOT = {
						tag = UKR
					}
				}
				UKR = {
					set_country_flag = UKR_kherson_selfdefence_activate
					if = {
						limit = { NOT = { has_template = "Nacionalna samooborona" } }
						division_template = {
							name = "Nacionalna samooborona" 
							template_counter = 0
							is_locked = yes		
							regiments = {
								militia = { x = 0 y = 0 }
								militia = { x = 0 y = 1 }
								militia = { x = 1 y = 0 }
								militia = { x = 1 y = 1 }
							}
						}
					}
					country_event = ukraine.683
				}
				FROM.FROM = { 
					create_unit = {
						division = "name = \"Khersonski dobrovoltsi\" division_template = \"Nacionalna samooborona\" start_experience_factor = 0.1 start_equipment_factor = 0.5"
						owner = UKR
					}
				}
			}
			# Kharkiv volunteers in ukrainian civil war against anarchists
			if = {
				limit = {
					UKR = { 
						has_war_with = DKR 
						has_country_flag = UKR_altdem_branch_is_available
						NOT = { has_country_flag = UKR_kharkiv_selfdefence_activate }
					} 
					FROM.FROM = {
						state = 221
					}
					ROOT = {
						tag = UKR
					}
				}
				UKR = {
					set_country_flag = UKR_kharkiv_selfdefence_activate
					if = {
						limit = { NOT = { has_template = "Nacionalna samooborona" } }
						division_template = {
							name = "Nacionalna samooborona" 
							template_counter = 0
							is_locked = yes		
							regiments = {
								militia = { x = 0 y = 0 }
								militia = { x = 0 y = 1 }
								militia = { x = 1 y = 0 }
								militia = { x = 1 y = 1 }
							}
						}
					}
					country_event = ukraine.684
				}
				FROM.FROM = { 
					create_unit = {
						division = "name = \"Slobozhanski dobrovoltsi\" division_template = \"Nacionalna samooborona\" start_experience_factor = 0.1 start_equipment_factor = 0.5"
						owner = UKR
					}
				}
			}
		}
	}
}