on_actions = {
	on_declare_war = {
		effect = {
			if = {
				limit = {
					FROM = { has_idea = GER_SOV_hitler_stalin_pact }
					has_idea = GER_SOV_hitler_stalin_pact
				}
				FROM = { add_timed_idea = { idea = doomed_by_hitler_stalin_pact days = 180 } }
				add_timed_idea = { idea = doomed_by_hitler_stalin_pact_2 days = 365 }
				FROM = { remove_ideas = GER_SOV_hitler_stalin_pact }
				remove_ideas = GER_SOV_hitler_stalin_pact
				hidden_effect = {
					news_event = { hours = 12 id = lsm_news.1110 }
				}
			}
			if = {
				limit = {
					FROM = { has_idea = GER_SOV_hitler_stalin_pact }
					NOT = { has_idea = GER_SOV_hitler_stalin_pact }
				}
				FROM = { add_timed_idea = { idea = doomed_by_hitler_stalin_pact days = 180 } }
				FROM = { remove_ideas = GER_SOV_hitler_stalin_pact }
				hidden_effect = {
					news_event = { hours = 12 id = lsm_news.1110 }
				}
			}
			if = {
				limit = {
					FROM = { 
						OR = { 
							tag = GER
							tag = SOV
						}
						NOT = { has_idea = GER_SOV_hitler_stalin_pact } 
					}
					has_idea = GER_SOV_hitler_stalin_pact
				}
				add_timed_idea = { idea = doomed_by_hitler_stalin_pact_2 days = 365 }
				remove_ideas = GER_SOV_hitler_stalin_pact
				hidden_effect = {
					news_event = { hours = 12 id = lsm_news.1110 }
				}
			}
		}
	}
	on_monthly = {
		effect = {
			every_state = {
				limit = { 
					has_resistance = yes
					has_state_flag = separatist_state	
					NOT = { has_dynamic_modifier = { modifier = anti_soviet_separatism_0 } }
				}
				force_disable_resistance = yes
				if = {
					limit = { 
						NOT = { is_core_of = SOV }
						is_claimed_by = SOV 
					}
					add_core_of = SOV
				}
			}
		}
	}
	on_state_control_changed = {
		effect = {
			if = {
				limit = {
					ROOT = { tag = SOV }
					FROM.FROM = {
						OR = {
							has_dynamic_modifier = { modifier = anti_soviet_separatism_3 } 
							has_dynamic_modifier = { modifier = anti_soviet_separatism_2 }  
							has_dynamic_modifier = { modifier = anti_soviet_separatism_2a }
							has_dynamic_modifier = { modifier = anti_soviet_separatism_1 }
						}
					}
				}
				FROM.FROM = { 
					if = {
						limit = { has_dynamic_modifier = { modifier = anti_soviet_separatism_3 } }
						remove_dynamic_modifier = { modifier = anti_soviet_separatism_3 }
					} 
					if = {
						limit = { has_dynamic_modifier = { modifier = anti_soviet_separatism_2 } }
						remove_dynamic_modifier = { modifier = anti_soviet_separatism_2 }
					} 
					if = {
						limit = { has_dynamic_modifier = { modifier = anti_soviet_separatism_2a } }
						remove_dynamic_modifier = { modifier = anti_soviet_separatism_2a }
					} 
					if = {
						limit = { has_dynamic_modifier = { modifier = anti_soviet_separatism_1 } }
						remove_dynamic_modifier = { modifier = anti_soviet_separatism_1 }
					}
					add_dynamic_modifier = { modifier = anti_soviet_separatism_0 days = 730 }
					set_state_flag = separatist_state
					if = {
						limit = {
							FROM.FROM = { is_core_of = UKR }
							FROM.FROM = { is_core_of = SOV }
						}
						force_enable_resistance = {
							occupier = SOV
							occupied = UKR
						}
						start_resistance = UKR
						set_resistance = 30
						set_compliance = 0
					}
					if = {
						limit = {
							FROM.FROM = { is_core_of = BLR }
							FROM.FROM = { is_core_of = SOV }
						}
						force_enable_resistance = {
							occupier = SOV
							occupied = BLR
						}
						start_resistance = BLR
						set_resistance = 15
						set_compliance = 0
					}	
					if = {
						limit = {
							FROM.FROM = { is_core_of = LIT }
							FROM.FROM = { is_core_of = SOV }
						}
						force_enable_resistance = {
							occupier = SOV
							occupied = LIT
						}
						start_resistance = LIT
						set_resistance = 25
						set_compliance = 0
					}
					if = {
						limit = {
							FROM.FROM = { is_core_of = LAT }
							FROM.FROM = { is_core_of = SOV }
						}
						force_enable_resistance = {
							occupier = SOV
							occupied = LAT
						}
						start_resistance = LAT
						set_resistance = 25
						set_compliance = 0
					}
					if = {
						limit = {
							FROM.FROM = { is_core_of = EST }
							FROM.FROM = { is_core_of = SOV }
						}
						force_enable_resistance = {
							occupier = SOV
							occupied = EST
						}
						start_resistance = EST
						set_resistance = 25
						set_compliance = 0
					}
					if = {
						limit = {
							FROM.FROM = { is_core_of = POL }
							FROM.FROM = { is_core_of = SOV }
						}
						force_enable_resistance = {
							occupier = SOV
							occupied = POL
						}
						start_resistance = POL
						set_resistance = 50
						set_compliance = 0
					}
					if = {
						limit = {
							FROM.FROM = { is_core_of = FIN }
							FROM.FROM = { is_core_of = SOV }
						}
						force_enable_resistance = {
							occupier = SOV
							occupied = FIN
						}
						start_resistance = FIN
						set_resistance = 40
						set_compliance = 0
					}
				}
			}
		}
		effect = {
			if = {
				limit = {
					FROM = { tag = SOV }
					FROM.FROM = { 
						OR = {
							is_core_of = SOV 
							owner = { tag = SOV }
						}
						NOT = { is_core_of = ROOT }
					}
					OR = {
						FROM.FROM = { is_core_of = LIT }
						FROM.FROM = { is_core_of = LAT }
						FROM.FROM = { is_core_of = UKR }
						FROM.FROM = { is_core_of = BLR }
						FROM.FROM = { is_core_of = EST }
						FROM.FROM = { is_core_of = POL }
						FROM.FROM = { is_core_of = FIN }
						FROM.FROM = { is_core_of = ROM }
						FROM.FROM = { is_core_of = TUR }
						FROM.FROM = { is_core_of = HUN }
					}
					ROOT = { has_war_with = SOV }
					NOT = { 
						FROM.FROM = {
							OR = {
								has_dynamic_modifier = { modifier = anti_soviet_separatism_3 } 
								has_dynamic_modifier = { modifier = anti_soviet_separatism_2 }  
								has_dynamic_modifier = { modifier = anti_soviet_separatism_2a }
								has_dynamic_modifier = { modifier = anti_soviet_separatism_1 } 
								has_dynamic_modifier = { modifier = pro_soviet_sentiment_1 } 
							}
						}
					}
				}
				if = {
					limit = {
						NOT = {
							SOV = {
								has_country_flag = {
									flag = days_since_last_change_on_the_map
									days > 28
								}
							}
						}
						FROM.FROM = {  
							NOT = { 
								OR = {
									has_dynamic_modifier = { modifier = anti_soviet_separatism_3 } 
									has_dynamic_modifier = { modifier = anti_soviet_separatism_2 }   
									has_dynamic_modifier = { modifier = anti_soviet_separatism_2a }
									has_dynamic_modifier = { modifier = anti_soviet_separatism_1 } 
									has_dynamic_modifier = { modifier = pro_soviet_sentiment_1 } 
								}
							}
							NOT = { has_state_flag = pro_soviet_state }
							OR = {
								has_state_flag = separatist_state
								SOV = {
									divisions_in_state = { state = FROM.FROM size < 2 }
								}
								SOV = {
									has_country_flag = {
										flag = days_since_last_change_on_the_map
										days < 1
									}
								}
								NOT = {
									any_neighbor_state = { 
										SOV = {
											divisions_in_state = { state = FROM.FROM size > 2 }
										}
									}
								}
							}
						}
					}
					FROM.FROM = {
						if = {
							limit = { has_dynamic_modifier = { modifier = anti_soviet_separatism_0 } }
							remove_dynamic_modifier = { modifier = anti_soviet_separatism_0 }
							set_resistance = 0
						}
						add_dynamic_modifier = { modifier = anti_soviet_separatism_3 }
						set_compliance = 65
						SOV = { 
							add_stability = -0.01
							add_war_support = -0.01
						}
						if = {
							limit = {
								NOT = {
									SOV = { has_idea = SOV_recovery_from_the_shock }
								}
							}
							SOV = { add_timed_idea = { idea = SOV_recovery_from_the_shock days = 14 } }
						}
						if = {
							limit = {
								SOV = { has_idea = SOV_recovery_from_the_shock }
							}
							SOV = { modify_timed_idea = { idea = SOV_recovery_from_the_shock days = 14 } }
						}
					}
				}
				if = {
					limit = {
						NOT = {
							SOV = {
								has_country_flag = {
									flag = days_since_last_change_on_the_map
									days > 28
								}
							}
						}
						FROM.FROM = {  
							NOT = { 
								OR = {
									has_dynamic_modifier = { modifier = anti_soviet_separatism_3 } 
									has_dynamic_modifier = { modifier = anti_soviet_separatism_2 }   
									has_dynamic_modifier = { modifier = anti_soviet_separatism_2a }
									has_dynamic_modifier = { modifier = anti_soviet_separatism_1 } 
									has_dynamic_modifier = { modifier = pro_soviet_sentiment_1 } 
								}
							}
							NOT = { has_state_flag = pro_soviet_state }
							OR = {
								SOV = {
									divisions_in_state = { state = FROM.FROM size > 1 }
									divisions_in_state = { state = FROM.FROM size < 4 }
								}
								SOV = {
									has_country_flag = {
										flag = days_since_last_change_on_the_map
										days < 1
									}
								}
								NOT = {
									any_neighbor_state = { 
										SOV = {
											divisions_in_state = { state = FROM.FROM size > 3 }
										}
									}
								}
							}
						}
					}
					FROM.FROM = {
						add_dynamic_modifier = { modifier = anti_soviet_separatism_2 }
						set_compliance = 50
						SOV = { 
							add_stability = -0.01
							add_war_support = -0.01
						}
						if = {
							limit = {
								NOT = {
									SOV = { has_idea = SOV_recovery_from_the_shock }
								}
							}
							SOV = { add_timed_idea = { idea = SOV_recovery_from_the_shock days = 31 } }
						}
						if = {
							limit = {
								SOV = { has_idea = SOV_recovery_from_the_shock }
							}
							SOV = { modify_timed_idea = { idea = SOV_recovery_from_the_shock days = 31 } }
						}
					}
				}
				if = {
					limit = {
						NOT = {
							SOV = {
								has_country_flag = {
									flag = days_since_last_change_on_the_map
									days > 28
								}
							}
						}
						FROM.FROM = {  
							NOT = { 
								OR = {
									has_dynamic_modifier = { modifier = anti_soviet_separatism_3 } 
									has_dynamic_modifier = { modifier = anti_soviet_separatism_2 }   
									has_dynamic_modifier = { modifier = anti_soviet_separatism_2a }
									has_dynamic_modifier = { modifier = anti_soviet_separatism_1 } 
									has_dynamic_modifier = { modifier = pro_soviet_sentiment_1 } 
								}
							}  
							NOT = { has_state_flag = pro_soviet_state }
							OR = {
								SOV = {
									divisions_in_state = { state = FROM.FROM size > 3 }
									divisions_in_state = { state = FROM.FROM size < 8 }
								}
								NOT = {
									any_neighbor_state = { 
										SOV = {
											divisions_in_state = { state = FROM.FROM size > 11 }
										}
									}
								}
							}
						}
					}
					FROM.FROM = {
						add_dynamic_modifier = { modifier = anti_soviet_separatism_2a }
						set_compliance = 35
					}
				}
				if = {
					limit = {
						NOT = {
							SOV = {
								has_country_flag = {
									flag = days_since_last_change_on_the_map
									days > 28
								}
							}
						}
						FROM.FROM = {   
							NOT = { 
								OR = {
									has_dynamic_modifier = { modifier = anti_soviet_separatism_3 } 
									has_dynamic_modifier = { modifier = anti_soviet_separatism_2 }   
									has_dynamic_modifier = { modifier = anti_soviet_separatism_2a }
									has_dynamic_modifier = { modifier = anti_soviet_separatism_1 } 
									has_dynamic_modifier = { modifier = pro_soviet_sentiment_1 } 
								}
							}
							NOT = { has_state_flag = pro_soviet_state }
							OR = {
								SOV = {
									divisions_in_state = { state = FROM.FROM size > 7 }
									divisions_in_state = { state = FROM.FROM size < 12 }
								}
								NOT = {
									any_neighbor_state = { 
										SOV = {
											divisions_in_state = { state = FROM.FROM size > 17 }
										}
									}
								}
							}
						}
					}
					FROM.FROM = {
						add_dynamic_modifier = { modifier = anti_soviet_separatism_1 }
						set_compliance = 20
					}
				}
				if = {
					limit = {
						FROM.FROM = { 
							NOT = { has_state_flag = separatist_state }  
							NOT = { 
								OR = {
									has_dynamic_modifier = { modifier = anti_soviet_separatism_3 } 
									has_dynamic_modifier = { modifier = anti_soviet_separatism_2 }   
									has_dynamic_modifier = { modifier = anti_soviet_separatism_2a }
									has_dynamic_modifier = { modifier = anti_soviet_separatism_1 } 
									has_dynamic_modifier = { modifier = pro_soviet_sentiment_1 } 
								}
							}
							OR = {
								SOV = {
									divisions_in_state = { state = FROM.FROM size > 11 }
								}
								any_neighbor_state = { 
									SOV = {
										divisions_in_state = { state = FROM.FROM size > 17 }
									}
								}
								SOV = {
									has_country_flag = {
										flag = days_since_last_change_on_the_map
										days > 28
									}
								}
								has_state_flag = pro_soviet_state
							}
						}
					}
					FROM.FROM = {
						add_dynamic_modifier = { modifier = pro_soviet_sentiment_1 }
						SOV = { 
							add_war_support = 0.01
						}
						set_resistance = 35
						set_state_flag = pro_soviet_state
						if = { 
							limit = {
								FROM.FROM = {
									NOT = { is_core_of = SOV }
									is_claimed_by = SOV
								}
							}
							FROM.FROM = { add_core_of = SOV }
						}
					}
				}
			}
		}
		effect = {
			if = {
				limit = {
					FROM = { has_war = yes }
					FROM.FROM = { is_core_of = FROM }
					ROOT = { has_war_with = FROM }
				}
				FROM.FROM = {
					set_temp_variable = { var_population_displacement_recruitment = FROM.party_popularity@ruling_party }
					set_temp_variable = { var_state_population_recruitment = state_population_k }
					multiply_temp_variable = { var_state_population_recruitment = 30 }
					multiply_temp_variable = { var_population_displacement_recruitment = var_state_population_recruitment }
					multiply_temp_variable = { var_population_displacement_recruitment = FROM.stability  }
					set_temp_variable = { var_population_displacement_recruitment_lost = var_population_displacement_recruitment }
					multiply_temp_variable = { var_population_displacement_recruitment_lost = -1 }
				}
				FROM = { 
					add_manpower = var_population_displacement_recruitment
				}
				FROM.FROM = {
					add_manpower = var_population_displacement_recruitment_lost
				}
			}
			if = {
				limit = {
					ROOT = { original_tag = SOV }
					FROM = { has_war_with = SOV }
					SOV = { has_country_flag = SOV_patriotic_counterattack_enabled }
				}
				if = { 
					limit = {
						SOV = { has_idea = SOV_patriotic_offensive_5 }
					}
					SOV = { remove_ideas = SOV_patriotic_offensive_5 }
					SOV = { add_timed_idea = { idea = SOV_patriotic_offensive_5 days = 30 } }
				}
				if = { 
					limit = {
						SOV = { has_idea = SOV_patriotic_offensive_4 }
					}
					SOV = { remove_ideas = SOV_patriotic_offensive_4 }
					SOV = { add_timed_idea = { idea = SOV_patriotic_offensive_5 days = 30 } }
				}
				if = { 
					limit = {
						SOV = { has_idea = SOV_patriotic_offensive_3 }
					}
					SOV = { remove_ideas = SOV_patriotic_offensive_3 }
					SOV = { add_timed_idea = { idea = SOV_patriotic_offensive_4 days = 16 } }
				}
				if = { 
					limit = {
						SOV = { has_idea = SOV_patriotic_offensive_2 }
					}
					SOV = { remove_ideas = SOV_patriotic_offensive_2 }
					SOV = { add_timed_idea = { idea = SOV_patriotic_offensive_3 days = 16 } }
				}
				if = { 
					limit = {
						SOV = { has_idea = SOV_patriotic_offensive_1 }
					}
					SOV = { remove_ideas = SOV_patriotic_offensive_1 }
					SOV = { add_timed_idea = { idea = SOV_patriotic_offensive_2 days = 34 } }
				}
			}
			if = {
				limit = {
					FROM = { has_war_with = ROOT }
					FROM.FROM = {
						arms_factory > 0
						is_owned_by = FROM
						any_neighbor_state = {
							is_controlled_by = FROM 
							is_owned_by = FROM
							free_building_slots = {
								building = arms_factory
								size > 0
								include_locked = yes
							}
						}
					}
				}
				FROM.FROM = {
					remove_building = {
						type = arms_factory
						level = 1
					}
					if = {
						limit = {
							NOT = { FROM.FROM = { has_state_flag = removed_mil_flag } }
						}
						FROM.FROM = { set_state_flag = removed_mil_flag }
					}
					if = {
						limit = {
							FROM.FROM = { has_state_flag = removed_mil_flag }
						}
						FROM.FROM = { modify_state_flag = { flag = removed_mil_flag value = 1 } }
					}
					if = {
						limit = {
							FROM.FROM = {
								any_neighbor_state = {
									is_controlled_by = FROM 
									is_owned_by = FROM
									free_building_slots = {
										building = arms_factory
										size > 0
										include_locked = yes
									}
								}
							}
						}
						FROM.FROM = {
							random_neighbor_state = {
								limit = {
									is_controlled_by = FROM
									is_owned_by = FROM
									free_building_slots = {
										building = arms_factory
										size > 0
										include_locked = yes
									}
								}
								if = {
									limit = {
										free_building_slots = {
											building = arms_factory
											size < 1
											include_locked = no
										}
									}
									add_extra_state_shared_building_slots = 1
								}
								add_building_construction = {
									type = arms_factory
									level = 1
									instant_build = yes
								}
								damage_building = { type = arms_factory damage = 0.3 }
								if = {
									limit = { 
										NOT = { has_state_flag = added_mil_flag }
									}
									set_state_flag = added_mil_flag
								}
								if = {
									limit = {
										has_state_flag = added_mil_flag
									}
									modify_state_flag = { flag = add_mil_flag value = 1 }
								}
							}
						}
					}
				}
			}
			if = {
				limit = {
					FROM = { has_war_with = ROOT }
					FROM.FROM = { has_state_flag = added_mil_flag }
					FROM.FROM = { arms_factory > added_mil_flag }
					FROM.FROM = { is_owned_by = FROM }
					FROM.FROM = { 
						any_neighbor_state = {
							is_controlled_by = FROM
							is_owned_by = FROM
							free_building_slots = {
								building = arms_factory
								size > 0
								include_locked = yes
							}
						}
					}
				}
				FROM.FROM = {
					set_temp_variable = { var_mil_flag = added_mil_flag }
					divide_temp_variable = { var_mil_flag = 2 }
					set_temp_variable = { var_remove_mil_flag = 0 }
					while_loop_effect = {
						limit = {
							FROM.FROM = { check_variable = { var_remove_mil_flag = var_mil_flag compare = less_than_or_equals } }
							FROM.FROM = { 
								any_neighbor_state = {
									is_controlled_by = FROM
									is_owned_by = FROM
									free_building_slots = {
										building = arms_factory
										size > 0
										include_locked = yes
									}
								}
							}
						}
						FROM.FROM = { 
							remove_building = {
								type = arms_factory
								level = 1
							}
							modify_state_flag = { flag = add_mil_flag value = -1 }
							add_to_temp_variable = { var_remove_mil_flag = 1 }
						}
						FROM.FROM = {
							random_neighbor_state = {
								limit = {
									is_controlled_by = FROM
									is_owned_by = FROM
									free_building_slots = {
										building = arms_factory
										size > 0
										include_locked = yes
									}
								}
								if = {
									limit = {
										free_building_slots = {
											building = arms_factory
											size < 1
											include_locked = no
										}
									}
									add_extra_state_shared_building_slots = 1
								}
								add_building_construction = {
									type = arms_factory
									level = 1
									instant_build = yes
								}
								damage_building = { type = arms_factory damage = 0.3 }
								if = {
									limit = { 
										NOT = { has_state_flag = added_mil_flag }
									}
									set_state_flag = added_mil_flag
								}
								if = {
									limit = {
										has_state_flag = added_mil_flag
									}
									modify_state_flag = { flag = add_mil_flag value = 1 }
								}
							}
						}
					}
				}
			}
			if = {
				limit = {
					FROM = { has_war_with = ROOT }
					FROM.FROM = {
						industrial_complex > 0
						is_owned_by = FROM
						any_neighbor_state = {
							is_controlled_by = FROM 
							is_owned_by = FROM
							free_building_slots = {
								building = industrial_complex
								size > 0
								include_locked = yes
							}
						}
					}
				}
				FROM.FROM = {
					remove_building = {
						type = industrial_complex
						level = 1
					}
					if = {
						limit = {
							NOT = { FROM.FROM = { has_state_flag = removed_civ_flag } }
						}
						FROM.FROM = { set_state_flag = removed_civ_flag }
					}
					if = {
						limit = {
							FROM.FROM = { has_state_flag = removed_civ_flag }
						}
						FROM.FROM = { modify_state_flag = { flag = removed_civ_flag value = 1 } }
					}
					if = {
						limit = {
							FROM.FROM = {
								any_neighbor_state = {
									is_controlled_by = FROM 
									is_owned_by = FROM
									free_building_slots = {
										building = industrial_complex
										size > 0
										include_locked = yes
									}
								}
							}
						}
						FROM.FROM = {
							random_neighbor_state = {
								limit = {
									is_controlled_by = FROM
									is_owned_by = FROM
									free_building_slots = {
										building = industrial_complex
										size > 0
										include_locked = yes
									}
								}
								if = {
									limit = {
										free_building_slots = {
											building = industrial_complex
											size < 1
											include_locked = no
										}
									}
									add_extra_state_shared_building_slots = 1
								}
								add_building_construction = {
									type = industrial_complex
									level = 1
									instant_build = yes
								}
								damage_building = { type = industrial_complex damage = 0.3 }
								if = {
									limit = { 
										NOT = { has_state_flag = added_civ_flag }
									}
									set_state_flag = added_civ_flag
								}
								if = {
									limit = {
										has_state_flag = added_civ_flag
									}
									modify_state_flag = { flag = add_civ_flag value = 1 }
								}
							}
						}
					}
				}
			}
			if = {
				limit = {
					FROM = { has_war_with = ROOT }
					FROM.FROM = { has_state_flag = added_civ_flag }
					FROM.FROM = { industrial_complex > added_civ_flag }
					FROM.FROM = { is_owned_by = FROM }
					FROM.FROM = { 
						any_neighbor_state = {
							is_controlled_by = FROM
							is_owned_by = FROM 
							free_building_slots = {
								building = industrial_complex
								size > 0
								include_locked = yes
							}
						}
					}
				}
				FROM.FROM = {
					set_temp_variable = { var_civ_flag = added_civ_flag }
					divide_temp_variable = { var_civ_flag = 2 }
					set_temp_variable = { var_remove_civ_flag = 0 }
					while_loop_effect = {
						limit = {
							FROM.FROM = { check_variable = { var_remove_civ_flag = var_civ_flag compare = less_than_or_equals } }
							FROM.FROM = { 
								any_neighbor_state = {
									is_controlled_by = FROM
									is_owned_by = FROM
									free_building_slots = {
										building = industrial_complex 
										size > 0
										include_locked = yes
									}
								}
							}
						}
						FROM.FROM = { 
							remove_building = {
								type = industrial_complex
								level = 1
							}
							modify_state_flag = { flag = add_civ_flag value = -1 }
							add_to_temp_variable = { var_remove_civ_flag = 1 }
						}
						FROM.FROM = {
							random_neighbor_state = {
								limit = {
									is_controlled_by = FROM
									is_owned_by = FROM
									free_building_slots = {
										building = industrial_complex
										size > 0
										include_locked = yes
									}
								}
								if = {
									limit = {
										free_building_slots = {
											building = industrial_complex
											size < 1
											include_locked = no
										}
									}
									add_extra_state_shared_building_slots = 1
								}
								add_building_construction = {
									type = industrial_complex
									level = 1
									instant_build = yes
								}
								damage_building = { type = industrial_complex damage = 0.3 }
								if = {
									limit = { 
										NOT = { has_state_flag = added_civ_flag }
									}
									set_state_flag = added_civ_flag
								}
								if = {
									limit = {
										has_state_flag = added_civ_flag
									}
									modify_state_flag = { flag = add_civ_flag value = 1 }
								}
							}
						}
					}
				}
			}
			if = {
				limit = {
					FROM = { has_war_with = ROOT }
					FROM = { tag = SOV }
					FROM.FROM = {
						arms_factory > 0
						is_owned_by = FROM
						any_neighbor_state = {
							is_controlled_by = FROM 
							is_owned_by = FROM
							free_building_slots = {
								building = arms_factory
								size > 0
								include_locked = yes
							}
						}
					}
				}
				FROM.FROM = {
					remove_building = {
						type = arms_factory
						level = 1
					}
					if = {
						limit = {
							NOT = { FROM.FROM = { has_state_flag = removed_mil_flag } }
						}
						FROM.FROM = { set_state_flag = removed_mil_flag }
					}
					if = {
						limit = {
							FROM.FROM = { has_state_flag = removed_mil_flag }
						}
						FROM.FROM = { modify_state_flag = { flag = removed_mil_flag value = 1 } }
					}
					if = {
						limit = {
							FROM.FROM = {
								any_neighbor_state = {
									is_controlled_by = FROM 
									is_owned_by = FROM
									free_building_slots = {
										building = arms_factory
										size > 0
										include_locked = yes
									}
								}
							}
						}
						FROM.FROM = {
							random_neighbor_state = {
								limit = {
									is_controlled_by = FROM
									is_owned_by = FROM
									free_building_slots = {
										building = arms_factory
										size > 0
										include_locked = yes
									}
								}
								if = {
									limit = {
										free_building_slots = {
											building = arms_factory
											size < 1
											include_locked = no
										}
									}
									add_extra_state_shared_building_slots = 1
								}
								add_building_construction = {
									type = arms_factory
									level = 1
									instant_build = yes
								}
								damage_building = { type = arms_factory damage = 0.3 }
								if = {
									limit = { 
										NOT = { has_state_flag = added_mil_flag }
									}
									set_state_flag = added_mil_flag
								}
								if = {
									limit = {
										has_state_flag = added_mil_flag
									}
									modify_state_flag = { flag = add_mil_flag value = 1 }
								}
							}
						}
					}
				}
			}
			if = {
				limit = {
					FROM = { has_war_with = ROOT }
					FROM = { tag = SOV }
					FROM.FROM = { has_state_flag = added_mil_flag }
					FROM.FROM = { arms_factory > added_mil_flag }
					FROM.FROM = { is_owned_by = FROM }
					FROM.FROM = { 
						any_neighbor_state = {
							is_controlled_by = FROM
							is_owned_by = FROM
							free_building_slots = {
								building = arms_factory
								size > 0
								include_locked = yes
							}
						}
					}
				}
				FROM.FROM = {
					set_temp_variable = { var_mil_flag = added_mil_flag }
					divide_temp_variable = { var_mil_flag = 3 }
					set_temp_variable = { var_remove_mil_flag = 0 }
					while_loop_effect = {
						limit = {
							FROM.FROM = { check_variable = { var_remove_mil_flag = var_mil_flag compare = less_than_or_equals } }
							FROM.FROM = { 
								any_neighbor_state = {
									is_controlled_by = FROM
									is_owned_by = FROM
									free_building_slots = {
										building = arms_factory
										size > 0
										include_locked = yes
									}
								}
							}
						}
						FROM.FROM = { 
							remove_building = {
								type = arms_factory
								level = 1
							}
							modify_state_flag = { flag = add_mil_flag value = -1 }
							add_to_temp_variable = { var_remove_mil_flag = 1 }
						}
						FROM.FROM = {
							random_neighbor_state = {
								limit = {
									is_controlled_by = FROM
									is_owned_by = FROM
									free_building_slots = {
										building = arms_factory
										size > 0
										include_locked = yes
									}
								}
								if = {
									limit = {
										free_building_slots = {
											building = arms_factory
											size < 1
											include_locked = no
										}
									}
									add_extra_state_shared_building_slots = 1
								}
								add_building_construction = {
									type = arms_factory
									level = 1
									instant_build = yes
								}
								damage_building = { type = arms_factory damage = 0.3 }
								if = {
									limit = { 
										NOT = { has_state_flag = added_mil_flag }
									}
									set_state_flag = added_mil_flag
								}
								if = {
									limit = {
										has_state_flag = added_mil_flag
									}
									modify_state_flag = { flag = add_mil_flag value = 1 }
								}
							}
						}
					}
				}
			}
			if = {
				limit = {
					FROM = { has_war_with = ROOT }
					FROM.FROM = { 
						ROOT = { divisions_in_state = { state = PREV size > 1 } }
						ROOT = { divisions_in_state = { state = PREV size < 6 } }
					}
				}
				FROM.FROM = {
					set_temp_variable = { arms_factory_damage_base = building_level@arms_factory }
					set_temp_variable = { arms_factory_damage_real = 0 }
					while_loop_effect = {
						limit = {
							FROM.FROM = { check_variable = { arms_factory_damage_real = arms_factory_damage_base compare = less_than_or_equals } }
						}
						FROM.FROM = { 
							damage_building = { type = arms_factory damage = 0.15 }
							add_to_temp_variable = { arms_factory_damage_real = 1 }		
						}
					}		
				}
				FROM.FROM = {
					set_temp_variable = { industrial_complex_damage_base = building_level@industrial_complex }
					set_temp_variable = { industrial_complex_damage_real = 0 }
					while_loop_effect = {
						limit = {
							FROM.FROM = { check_variable = { industrial_complex_damage_real = industrial_complex_damage_base compare = less_than_or_equals } }
						}
						FROM.FROM = { 
							damage_building = { type = industrial_complex damage = 0.25 }
							add_to_temp_variable = { industrial_complex_damage_real = 1 }
						}
					}		
				}
			}
			if = {
				limit = {
					FROM = { has_war_with = ROOT }
					FROM.FROM = { 
						ROOT = { divisions_in_state = { state = PREV size > 5 } }
						ROOT = { divisions_in_state = { state = PREV size < 11 } }
					}
				}
				FROM.FROM = {
					set_temp_variable = { arms_factory_damage_base = building_level@arms_factory }
					set_temp_variable = { arms_factory_damage_real = 0 }
					while_loop_effect = {
						limit = {
							FROM.FROM = { check_variable = { arms_factory_damage_real = arms_factory_damage_base compare = less_than_or_equals } }
						}
						FROM.FROM = {	
							damage_building = { type = arms_factory damage = 0.25 }
							add_to_temp_variable = { arms_factory_damage_real = 1 }
						}	
					}	
				}
				FROM.FROM = {
					set_temp_variable = { industrial_complex_damage_base = building_level@industrial_complex }
					set_temp_variable = { industrial_complex_damage_real = 0 }
					while_loop_effect = {
						limit = {
							FROM.FROM = { check_variable = { industrial_complex_damage_real = industrial_complex_damage_base compare = less_than_or_equals } }
						}
						FROM.FROM = { 
							damage_building = { type = industrial_complex damage = 0.35 }
							add_to_temp_variable = { industrial_complex_damage_real = 1 }
						}
					}		
				}
				FROM.FROM = {
					set_temp_variable = { dockyard_damage_base = building_level@dockyard }
					set_temp_variable = { dockyard_damage_real = 0 }
					while_loop_effect = {
						limit = {
							FROM.FROM = { check_variable = { dockyard_damage_real = dockyard_damage_base compare = less_than_or_equals } }
						}
						FROM.FROM = { 
							damage_building = { type = dockyard damage = 0.35 }
							add_to_temp_variable = { dockyard_damage_real = 1 }
						}
					}		
				}
			}
			if = {
				limit = {
					FROM = { has_war_with = ROOT }
					FROM.FROM = { 
						ROOT = { divisions_in_state = { state = PREV size > 10 } }
					}
				}
				FROM.FROM = {
					set_temp_variable = { arms_factory_damage_base = building_level@arms_factory }
					set_temp_variable = { arms_factory_damage_real = 0 }
					while_loop_effect = {
						limit = {
							FROM.FROM = { check_variable = { arms_factory_damage_real = arms_factory_damage_base compare = less_than_or_equals } }
						}
						FROM.FROM = { 
							damage_building = { type = arms_factory damage = 0.4 }
							add_to_temp_variable = { arms_factory_damage_real = 1 }	
						 }
					}		
				}
				FROM.FROM = {
					set_temp_variable = { industrial_complex_damage_base = building_level@industrial_complex }
					set_temp_variable = { industrial_complex_damage_real = 0 }
					while_loop_effect = {
						limit = {
							FROM.FROM = { check_variable = { industrial_complex_damage_real = industrial_complex_damage_base compare = less_than_or_equals } }
						}
						FROM.FROM = { 
							damage_building = { type = industrial_complex damage = 0.5 }
							add_to_temp_variable = { industrial_complex_damage_real = 1 }
						}
					}		
				}
				FROM.FROM = {
					set_temp_variable = { dockyard_damage_base = building_level@dockyard }
					set_temp_variable = { dockyard_damage_real = 0 }
					while_loop_effect = {
						limit = {
							FROM.FROM = { check_variable = { dockyard_damage_real = dockyard_damage_base compare = less_than_or_equals } }
						}
						FROM.FROM = { 
							damage_building = { type = dockyard damage = 0.5 }
							add_to_temp_variable = { dockyard_damage_real = 1 }
						}
					}		
				}
			}
			if = {
				limit = {
					FROM = { has_war_with = ROOT }
					ROOT = {
						OR = {
							has_idea = d_day_preparation_2
							has_idea = d_day_preparation_3
						}
					}
					FROM.FROM = { 
						ROOT = { divisions_in_state = { state = PREV size > 0 } }
					}
				}
				FROM.FROM = {
					set_temp_variable = { arms_factory_damage_base = building_level@arms_factory }
					set_temp_variable = { arms_factory_damage_real = 0 }
					while_loop_effect = {
						limit = {
							FROM.FROM = { check_variable = { arms_factory_damage_real = arms_factory_damage_base compare = less_than_or_equals } }
						}
						FROM.FROM = { damage_building = { type = arms_factory damage = 0.5 } }
						add_to_temp_variable = { arms_factory_damage_real = 1 }
					}		
				}
				FROM.FROM = {
					set_temp_variable = { industrial_complex_damage_base = building_level@industrial_complex }
					set_temp_variable = { industrial_complex_damage_real = 0 }
					while_loop_effect = {
						limit = {
							FROM.FROM = { check_variable = { industrial_complex_damage_real = industrial_complex_damage_base compare = less_than_or_equals } }
						}
						FROM.FROM = { damage_building = { type = industrial_complex damage = 0.5 } }
						add_to_temp_variable = { industrial_complex_damage_real = 1 }
					}		
				}
				FROM.FROM = {
					set_temp_variable = { dockyard_damage_base = building_level@dockyard }
					set_temp_variable = { dockyard_damage_real = 0 }
					while_loop_effect = {
						limit = {
							FROM.FROM = { check_variable = { dockyard_damage_real = dockyard_damage_base compare = less_than_or_equals } }
						}
						FROM.FROM = { damage_building = { type = dockyard damage = 0.5 } }
						add_to_temp_variable = { dockyard_damage_real = 1 }
					}		
				}
			}
		}
	}
}