##################
#### CONSTANTS ###
##################
# Used for the Merge Plant traits for easier maintenance

### TANKS
#POSITION
@tank_1_X = 9
@tank_1_Y = 2
@tank_2_X = 9
@tank_2_Y = 3
@tank_3_X = 9
@tank_3_Y = 4
#BONUSES
@tank_max_speed = 0.05
@tank_production_capacity_factor = 0.05
@tank_soft_attack = 0.05


### SHIPS
#POISTION
@ship_1_X = 9
@ship_1_Y = 3
@ship_2_X = 9
@ship_2_Y = 4
@ship_3_X = 8
@ship_3_Y = 4
#BONUSES
@ship_cruiser_production_cost_factor = -0.1
@ship_destroyer_production_cost_factor = -0.1
@ship_submarine_production_cost_factor = -0.1
@ship_production_capacity_factor = -0.05
@ship_mines_sweeping = 0.1
@ship_mines_planting = 0.1

### AIRCRAFT
#POSITION
@aircraft_1_X = 9
@aircraft_1_Y = 2
@aircraft_2_X = 9
@aircraft_2_Y = 3
@aircraft_3_X = 9
@aircraft_3_Y = 4
#BONUSES
@aircraft_production_cost_factor = -0.05
@aircraft_air_agility = 0.05
@aircraft_air_defence = 0.1
@aircraft_surface_detection = 0.15
@aircraft_sub_detection = 0.15

### MATERIEL
#POSITION
@materiel_1_X = 9
@materiel_1_Y = 2
@materiel_2_X = 9
@materiel_2_Y = 3
@materiel_3_X = 9
@materiel_3_Y = 4
#BONUSES
@artillery_production_cost_factor = -0.1
@infantry_equipment_production_cost_factor = -0.1
@motorized_production_cost_factor = -0.1
@materiel_production_efficiency_cap_factor = 0.1
@materiel_production_capacity_factor = 0.1


########    ###    ##    ## ##    ##  ######  
   ##      ## ##   ###   ## ##   ##  ##    ## 
   ##     ##   ##  ####  ## ##  ##   ##       
   ##    ##     ## ## ## ## #####     ######  
   ##    ######### ##  #### ##  ##         ## 
   ##    ##     ## ##   ### ##   ##  ##    ## 
   ##    ##     ## ##    ## ##    ##  ######  


SOV_morozov_design_bureau_organization = {
	include = generic_mobile_tank_organization
	icon = GFX_idea_morozov_design_bureau
	
	allowed = {	
		OR = {
			tag = SOV
			AND = {
				tag = MEX 
				has_dlc = "Man the Guns"
			}
			AND = {
				OR = {
					is_literally_china = yes
					tag = MAN
				} 
				has_dlc = "Waking the Tiger"
			}
			NOR_AAT = yes
		}
	}

	available = {
		# When in a Foreign MIO, countries need to be at peace with original country
		IF = {
			limit = {
				FROM = { NOT = { original_tag = SOV } }
			}
			FROM = { NOT = { has_war_with = SOV } }
		}

		IF = {
			limit = {
				FROM = { tag = MEX }
			}
			FROM = { is_in_faction_with = SOV }
		}
		ELSE_IF = {
			limit = {
				FROM = {
					OR = {
						is_literally_china = yes
						tag = MAN
						tag = MEN
					}
				} 
			}
			FROM = { has_completed_focus = CHI_hire_soviet_designer }
		}
		ELSE_IF = {
			limit = {
				FROM = { original_tag = NOR }
			}
			FROM = { has_completed_focus = NOR_invite_soviet_designers }
		}
	}

	add_trait = { 
		token = SOV_mio_trait_merge_plant_no_174
		name = SOV_merge_tank_plant
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_maximum_speed
		special_trait_background = yes

		position = { x=@tank_1_X y=@tank_1_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		available = { #Three FROM blocs to provide two different check marks in the UI
			FROM = {
				has_full_control_of_state = 195 #LENINGRAD
			}
			FROM = {
				has_completed_focus = SOV_merge_tank_and_materiel_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_plant_no_174_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_plant_no_174_flag
			}
		}

		equipment_bonus = {
			maximum_speed = @tank_max_speed
		}
	}

	add_trait = { 
		token = SOV_mio_trait_merge_plant_no_112
		name = SOV_merge_tank_plant_2
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_production_capacity
		special_trait_background = yes

		position = { x=@tank_2_X y=@tank_2_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		available = {
			FROM = {
				has_full_control_of_state = 252 #GORKY
			}
			FROM = {
				has_completed_focus = SOV_merge_tank_and_materiel_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_plant_no_112_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_plant_no_112_flag
			}
		}

		production_bonus = {
			production_capacity_factor = @tank_production_capacity_factor
		}
	}

	add_trait = { 
		token = SOV_mio_trait_merge_ural_heavy_machine_building_plant
		name = SOV_merge_tank_plant_3
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_soft_attack
		special_trait_background = yes

		position = { x=@tank_3_X y=@tank_3_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		available = {
			FROM = {
				has_full_control_of_state = 653 #SVERDLOVSK
			}
			FROM = {
				has_completed_focus = SOV_merge_tank_and_materiel_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_ural_heavy_machine_building_plant_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_ural_heavy_machine_building_plant_flag
			}
		}

		equipment_bonus = {
			soft_attack = @tank_soft_attack
		}
	}
}

SOV_astrov_design_bureau_organization = {
	include = generic_medium_tank_organization
	icon = GFX_idea_astrov_design_bureau
	
	allowed = {	
		original_tag = SOV
	}

	add_trait = { 
		token = SOV_mio_trait_merge_plant_no_174
		name = SOV_merge_tank_plant
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_maximum_speed
		special_trait_background = yes

		position = { x=@tank_1_X y=@tank_1_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		available = { #Two FROM blocs to provide two different check marks in the UI
			FROM = {
				has_full_control_of_state = 195 #LENINGRAD
			}
			FROM = {
				has_completed_focus = SOV_merge_tank_and_materiel_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_plant_no_174_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_plant_no_174_flag
			}
		}

		equipment_bonus = {
			maximum_speed = @tank_max_speed
		}
	}

	add_trait = { 
		token = SOV_mio_trait_merge_plant_no_112
		name = SOV_merge_tank_plant_2
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_production_capacity
		special_trait_background = yes

		position = { x=@tank_2_X y=@tank_2_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		available = {
			FROM = {
				has_full_control_of_state = 252 #GORKY
			}
			FROM = {
				has_completed_focus = SOV_merge_tank_and_materiel_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_plant_no_112_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_plant_no_112_flag
			}
		}

		production_bonus = {
			production_capacity_factor = @tank_production_capacity_factor
		}
	}

	add_trait = { 
		token = SOV_mio_trait_merge_ural_heavy_machine_building_plant
		name = SOV_merge_tank_plant_3
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_soft_attack
		special_trait_background = yes

		position = { x=@tank_3_X y=@tank_3_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		available = {
			FROM = {
				has_full_control_of_state = 653 #SVERDLOVSK
			}
			FROM = {
				has_completed_focus = SOV_merge_tank_and_materiel_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_ural_heavy_machine_building_plant_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_ural_heavy_machine_building_plant_flag
			}
		}

		equipment_bonus = {
			soft_attack = @tank_soft_attack
		}
	}
}

SOV_okmo_organization = {
	include = generic_infantry_tank_organization
	icon = GFX_idea_okmo
	
	allowed = {	
		OR = {
			tag = SOV 
			AND = {
				tag = BUL
				has_dlc = "Battle for the Bosporus"
			}
		}
	}

	available = {
		# When in a Foreign MIO, countries need to be at peace with original country
		IF = {
			limit = {
				FROM = { NOT = { original_tag = SOV } }
			}
			FROM = { NOT = { has_war_with = SOV } }
		}

		IF = {
			limit = { FROM = { original_tag = BUL } }
			custom_trigger_tooltip = {
				tooltip = has_invited_mio_tt
				FROM = {
					has_country_flag = has_invited_okmo_mio_flag
				}
			}
			FROM = {
				OR = {
					is_subject = no
					is_subject_of = SOV
				}
				#is_in_faction_with = SOV
				NOT = { has_completed_focus = BUL_nationalization }
			}
		}
	}

	add_trait = { 
		token = SOV_mio_trait_merge_plant_no_174
		name = SOV_merge_tank_plant
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_maximum_speed
		special_trait_background = yes

		position = { x=@tank_1_X y=@tank_1_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		available = { #Two FROM blocs to provide two different check marks in the UI
			FROM = {
				has_full_control_of_state = 195 #LENINGRAD
			}
			FROM = {
				has_completed_focus = SOV_merge_tank_and_materiel_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_plant_no_174_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_plant_no_174_flag
			}
		}

		equipment_bonus = {
			maximum_speed = @tank_max_speed
		}
	}

	add_trait = { 
		token = SOV_mio_trait_merge_plant_no_112
		name = SOV_merge_tank_plant_2
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_production_capacity
		special_trait_background = yes

		position = { x=@tank_2_X y=@tank_2_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		available = {
			FROM = {
				has_full_control_of_state = 252 #GORKY
			}
			FROM = {
				has_completed_focus = SOV_merge_tank_and_materiel_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_plant_no_112_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_plant_no_112_flag
			}
		}

		production_bonus = {
			production_capacity_factor = @tank_production_capacity_factor
		}
	}

	add_trait = { 
		token = SOV_mio_trait_merge_ural_heavy_machine_building_plant
		name = SOV_merge_tank_plant_3
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_soft_attack
		special_trait_background = yes

		position = { x=@tank_3_X y=@tank_3_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		available = {
			FROM = {
				has_full_control_of_state = 653 #SVERDLOVSK
			}
			FROM = {
				has_completed_focus = SOV_merge_tank_and_materiel_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_ural_heavy_machine_building_plant_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_ural_heavy_machine_building_plant_flag
			}
		}

		equipment_bonus = {
			soft_attack = @tank_soft_attack
		}
	}
}

SOV_mytishchy_machine_building_plant_organization = {
	include = generic_tank_refurbishment_plant_organization
	icon = GFX_idea_SOV_mytishchy_machine_building_plant
	
	allowed = {	
		OR = {
			tag = SOV
			AND = {
				tag = ETH 
				has_dlc = "By Blood Alone"
			}
		}
	}

	visible = {
		IF = { 
			limit = { FROM = { original_tag = ETH } } 
			FROM = { has_completed_focus = ETH_mytishchi-ababa_plant }
		}
	}

	available = {
		# When in a Foreign MIO, countries need to be at peace with original country
		IF = {
			limit = {
				FROM = { NOT = { original_tag = SOV } }
			}
			FROM = { NOT = { has_war_with = SOV } }
		}
	}

	add_trait = { 
		token = SOV_mio_trait_merge_plant_no_174
		name = SOV_merge_tank_plant
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_maximum_speed
		special_trait_background = yes

		position = { x=@tank_1_X y=@tank_1_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		available = { #Two FROM blocs to provide two different check marks in the UI
			FROM = {
				has_full_control_of_state = 195 #LENINGRAD
			}
			FROM = {
				has_completed_focus = SOV_merge_tank_and_materiel_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_plant_no_174_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_plant_no_174_flag
			}
		}

		equipment_bonus = {
			maximum_speed = @tank_max_speed
		}
	}

	add_trait = { 
		token = SOV_mio_trait_merge_plant_no_112
		name = SOV_merge_tank_plant_2
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_production_capacity
		special_trait_background = yes

		position = { x=@tank_2_X y=@tank_2_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		available = {
			FROM = {
				has_full_control_of_state = 252 #GORKY
			}
			FROM = {
				has_completed_focus = SOV_merge_tank_and_materiel_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_plant_no_112_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_plant_no_112_flag
			}
		}

		production_bonus = {
			production_capacity_factor = @tank_production_capacity_factor
		}
	}

	add_trait = { 
		token = SOV_mio_trait_merge_ural_heavy_machine_building_plant
		name = SOV_merge_tank_plant_3
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_soft_attack
		special_trait_background = yes

		position = { x=@tank_3_X y=@tank_3_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		available = {
			FROM = {
				has_full_control_of_state = 653 #SVERDLOVSK
			}
			FROM = {
				has_completed_focus = SOV_merge_tank_and_materiel_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_ural_heavy_machine_building_plant_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_ural_heavy_machine_building_plant_flag
			}
		}

		equipment_bonus = {
			soft_attack = @tank_soft_attack
		}
	}
}

SOV_kirov_organization = {
	include = generic_heavy_tank_organization
	icon = GFX_idea_SOV_kirov
	
	allowed = {	
		OR = {
			original_tag = SOV
			AND = {
				tag = BEL
				has_dlc = "Gotterdammerung"
			}
		}
	}

	available = {
		IF = {
			limit = {
				FROM = { NOT = { original_tag = SOV } }
			}
			FROM = { NOT = { has_war_with = SOV } }
		}

		IF = {
			limit = { 
				FROM = { 
					original_tag = BEL 
				} 
			}

			FROM = { has_completed_focus = BEL_invite_soviet_tank_makers }
		}
	}

	override_trait = {
		token = generic_mio_trait_wide_tracks

		position = { x=0 y=0 }
	}

	add_trait = { 
		token = SOV_mio_trait_merge_plant_no_174
		name = SOV_merge_tank_plant
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_maximum_speed
		special_trait_background = yes

		position = { x=@tank_1_X y=@tank_1_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		available = { #Two FROM blocs to provide two different check marks in the UI
			FROM = {
				has_full_control_of_state = 195 #LENINGRAD
			}
			FROM = {
				has_completed_focus = SOV_merge_tank_and_materiel_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_plant_no_174_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_plant_no_174_flag
			}
		}

		equipment_bonus = {
			maximum_speed = @tank_max_speed
		}
	}

	add_trait = { 
		token = SOV_mio_trait_merge_plant_no_112
		name = SOV_merge_tank_plant_2
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_production_capacity
		special_trait_background = yes

		position = { x=@tank_2_X y=@tank_2_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		available = {
			FROM = {
				has_full_control_of_state = 252 #GORKY
			}
			FROM = {
				has_completed_focus = SOV_merge_tank_and_materiel_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_plant_no_112_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_plant_no_112_flag
			}
		}

		production_bonus = {
			production_capacity_factor = @tank_production_capacity_factor
		}
	}

	add_trait = { 
		token = SOV_mio_trait_merge_ural_heavy_machine_building_plant
		name = SOV_merge_tank_plant_3
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_soft_attack
		special_trait_background = yes

		position = { x=@tank_3_X y=@tank_3_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		available = {
			FROM = {
				has_full_control_of_state = 653 #SVERDLOVSK
			}
			FROM = {
				has_completed_focus = SOV_merge_tank_and_materiel_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_ural_heavy_machine_building_plant_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_ural_heavy_machine_building_plant_flag
			}
		}

		equipment_bonus = {
			soft_attack = @tank_soft_attack
		}
	}
}





 ######  ##     ## #### ########   ######  
##    ## ##     ##  ##  ##     ## ##    ## 
##       ##     ##  ##  ##     ## ##       
 ######  #########  ##  ########   ######  
      ## ##     ##  ##  ##              ## 
##    ## ##     ##  ##  ##        ##    ## 
 ######  ##     ## #### ##         ######  

SOV_nevskoye_design_bureau_organization = {
	include = generic_battle_line_ship_organization
	icon = GFX_idea_nevskoye_design_bureau
	
	allowed = {	
		OR = {
			tag = SOV 
			AND = {
				tag = BUL
				has_dlc = "Battle for the Bosporus"
			}
		}
	}
	
	available = {
		# When in a Foreign MIO, countries need to be at peace with original country
		IF = {
			limit = {
				FROM = { NOT = { original_tag = SOV } }
			}
			FROM = { NOT = { has_war_with = SOV } }
		}

		IF = {
			limit = { FROM = { original_tag = BUL } }
			custom_trigger_tooltip = {
				tooltip = has_invited_mio_tt
				FROM = {
					has_country_flag = has_invited_nevskoye_mio_flag
				}
			}
			FROM = {
				OR = {
					is_subject = no
					is_subject_of = SOV
				}
				#is_in_faction_with = SOV
				NOT = { has_completed_focus = BUL_nationalization }
			}
		}
	}

	add_trait = { #MTG version
		token = SOV_mio_trait_merge_plant_no_370
		name = SOV_merge_ship_plant_4_baltic
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_mines
		special_trait_background = yes

		position = { x=@ship_1_X y=@ship_1_Y }
		
		visible = {
			FROM = { original_tag = SOV }
			has_dlc = "Man the Guns"
		}

		available = {
			FROM = {
				has_full_control_of_state = 195 #LENINGRAD
			}
			FROM = {
				has_completed_focus = SOV_merge_naval_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_plant_no_370_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_plant_no_370_flag
				add_tech_bonus = {
					name = SOV_merge_ship_plant_2_baltic
					bonus = 1
					uses = 1
					category = naval_mines
				}
			}
		}

		limit_to_equipment_type = { mio_cat_eq_all_cruiser }
		
		production_bonus = {
			production_cost_factor = @ship_production_capacity_factor
		}

		equipment_bonus = {
			mines_planting = @ship_mines_planting
		}
	}

	add_trait = { #No-MTG version
		token = SOV_mio_trait_merge_plant_no_370_no_mtg
		name = SOV_merge_ship_plant_4_baltic
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_mines
		special_trait_background = yes

		position = { x=@ship_1_X y=@ship_1_Y }
		
		visible = {
			FROM = { original_tag = SOV }
			NOT = { has_dlc = "Man the Guns" }
		}

		available = {
			FROM = {
				has_full_control_of_state = 195 #LENINGRAD
			}
			FROM = {
				has_completed_focus = SOV_merge_naval_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_plant_no_370_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_plant_no_370_flag
			}
		}

		limit_to_equipment_type = { mio_cat_eq_all_cruiser }
		
		production_bonus = {
			production_cost_factor = @ship_production_capacity_factor
		}
	}

	add_trait = { 
		token = SOV_mio_trait_merge_plant_no_5
		name = SOV_merge_ship_plant_1_baltic
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_department_icon_ship_screen_ship_production
		special_trait_background = yes

		position = { x=@ship_2_X y=@ship_2_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		available = {
			FROM = {
				has_full_control_of_state = 195 #LENINGRAD
			}
			FROM = {
				has_completed_focus = SOV_merge_naval_plants
			}
			#Only exists in this MIO
		}

		limit_to_equipment_type = { mio_cat_eq_all_cruiser }

		production_bonus = {
			production_cost_factor = @ship_cruiser_production_cost_factor
		}
	}
}

SOV_rubin_design_bureau_organization = {
	include = generic_raider_ship_organization
	icon = GFX_idea_SOV_rubin_design_bureau
	
	allowed = {	
		OR = {
			tag = SOV
			AND = {
				tag = ETH 
				has_dlc = "By Blood Alone"
			}
			AND = {
				tag = ARG
				has_dlc = "Trial of Allegiance"
			}
			AND = {
				tag = BRA
				has_dlc = "Trial of Allegiance"
			}
			NOR_AAT = yes
		}
	}

	visible = {
		IF = { 
			limit = { FROM = { original_tag = ETH } } 
			FROM = { has_completed_focus = ETH_soviet-ethiopian_trade_agreement }
		}
	}

	available = {
		# When in a Foreign MIO, countries need to be at peace with original country
		IF = {
			limit = {
				FROM = { NOT = { original_tag = SOV } }
			}
			FROM = { NOT = { has_war_with = SOV } }
		}

		IF = {
			limit = {
				FROM = { original_tag = NOR }
			}
			FROM = { has_completed_focus = NOR_invite_soviet_designers }
		}

		IF = {
			limit = {
				FROM = { original_tag = ARG }
			}
			FROM = { has_completed_focus = ARG_russian_manufacturers }
		}

		IF = {
			limit = {
				FROM = { original_tag = BRA }
			}
			FROM = { has_completed_focus = BRA_soviet_arms_industry }
		}
	}

	add_trait = { #MTG version
		token = SOV_mio_trait_merge_plant_no_370
		name = SOV_merge_ship_plant_4_baltic
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_mines
		special_trait_background = yes

		position = { x=@ship_1_X y=@ship_1_Y }
		
		visible = {
			FROM = { original_tag = SOV }
			has_dlc = "Man the Guns"
		}

		available = {
			FROM = {
				has_full_control_of_state = 195 #LENINGRAD
			}
			FROM = {
				has_completed_focus = SOV_merge_naval_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_plant_no_370_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_plant_no_370_flag
				add_tech_bonus = {
					name = SOV_merge_ship_plant_2_baltic
					bonus = 1
					uses = 1
					category = naval_mines
				}
			}
		}

		limit_to_equipment_type = { mio_cat_eq_all_cruiser mio_cat_eq_all_destroyer ship_hull_submarine }
		
		production_bonus = {
			production_cost_factor = @ship_production_capacity_factor
		}

		equipment_bonus = {
			mines_planting = @ship_mines_planting
		}
	}

	add_trait = { #No-MTG version
		token = SOV_mio_trait_merge_plant_no_370_no_mtg
		name = SOV_merge_ship_plant_4_baltic
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_mines
		special_trait_background = yes

		position = { x=@ship_1_X y=@ship_1_Y }
		
		visible = {
			FROM = { original_tag = SOV }
			NOT = { has_dlc = "Man the Guns" }
		}

		available = {
			FROM = {
				has_full_control_of_state = 195 #LENINGRAD
			}
			FROM = {
				has_completed_focus = SOV_merge_naval_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_plant_no_370_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_plant_no_370_flag
			}
		}

		limit_to_equipment_type = { mio_cat_eq_all_cruiser mio_cat_eq_all_destroyer ship_hull_submarine }
		
		production_bonus = {
			production_cost_factor = @ship_production_capacity_factor
		}
	}

	add_trait = { 
		token = SOV_mio_trait_merge_plant_no_363
		name = SOV_merge_ship_plant_2_baltic
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_department_icon_ship_screen_ship_production
		special_trait_background = yes

		position = { x=@ship_2_X y=@ship_2_Y }

		mutually_exclusive = { SOV_mio_trait_merge_plant_no_190 }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		available = {
			FROM = {
				has_full_control_of_state = 195 #LENINGRAD
			}
			FROM = {
				has_completed_focus = SOV_merge_naval_plants
				has_completed_focus = SOV_surface_warfare
			}
			#Only exists in this MIO
		}

		limit_to_equipment_type = { mio_cat_eq_all_destroyer }

		production_bonus = {
			production_cost_factor = @ship_destroyer_production_cost_factor
		}
	}

	add_trait = { 
		token = SOV_mio_trait_merge_plant_no_190
		name = SOV_merge_ship_plant_3_baltic
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_department_icon_ship_submarine_production
		special_trait_background = yes

		position = { x=@ship_3_X y=@ship_3_Y }

		mutually_exclusive = { SOV_mio_trait_merge_plant_no_363 }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		available = {
			FROM = {
				has_full_control_of_state = 195 #LENINGRAD
			}
			FROM = {
				has_completed_focus = SOV_merge_naval_plants
				has_completed_focus = SOV_submarine_warfare
			}
			#Only exists in this MIO
		}

		limit_to_equipment_type = { ship_hull_submarine }
		
		production_bonus = {
			production_cost_factor = @ship_submarine_production_cost_factor
		}
	}
}

SOV_black_sea_shipyard_organization = {
	include = generic_black_sea_fleet_organization
	icon = GFX_idea_SOV_black_sea_shipyard
	
	allowed = {	
		original_tag = SOV
	}

	tree_header_text = {
		text = mio_header_systems
		x = 1
	}

	tree_header_text = {
		text = mio_header_weapons
		x = 4
	}

	tree_header_text = {
		text = mio_header_production
		x = 7
	}

	override_trait = {
		token = generic_mio_advanced_periscope

		position = { x=1 y=1 }
		relative_position_id = generic_mio_trait_anti_air_defense
	}

	override_trait = {
		token = generic_mio_trait_state_sponsored_growth

		position = { x=3 y=0 }
		relative_position_id = generic_mio_trait_anti_air_defense
	}

	add_trait = { #MTG version
		token = SOV_mio_trait_merge_mariupol_plant
		name = SOV_merge_ship_plant_4_black_sea
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_mines
		special_trait_background = yes

		position = { x=@ship_1_X y=@ship_1_Y }
		
		visible = {
			FROM = { original_tag = SOV }
			has_dlc = "Man the Guns"
		}

		available = {
			FROM = {
				has_full_control_of_state = 227 #STALINO
			}
			FROM = {
				has_completed_focus = SOV_merge_naval_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_mariupol_plant_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_mariupol_plant_flag
				add_tech_bonus = {
					name = SOV_merge_ship_plant_2_baltic
					bonus = 1
					uses = 1
					category = naval_mines
				}
			}
		}

		limit_to_equipment_type = { mio_cat_eq_all_cruiser mio_cat_eq_all_destroyer ship_hull_submarine }
		
		production_bonus = {
			production_cost_factor = @ship_production_capacity_factor
		}

		equipment_bonus = {
			mines_planting = @ship_mines_planting
		}
	}

	add_trait = { #No-MTG version
		token = SOV_mio_trait_merge_mariupol_plant_no_mtg
		name = SOV_merge_ship_plant_4_black_sea
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_mines
		special_trait_background = yes

		position = { x=@ship_1_X y=@ship_1_Y }
		
		visible = {
			FROM = { original_tag = SOV }
			NOT = { has_dlc = "Man the Guns" }
		}

		available = {
			FROM = {
				has_full_control_of_state = 227 #STALINO
			}
			FROM = {
				has_completed_focus = SOV_merge_naval_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_mariupol_plant_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_mariupol_plant_flag
			}
		}

		limit_to_equipment_type = { mio_cat_eq_all_cruiser mio_cat_eq_all_destroyer ship_hull_submarine }
		
		production_bonus = {
			production_cost_factor = @ship_production_capacity_factor
		}
	}

	add_trait = { 
		token = SOV_mio_trait_merge_leninskaya_kuznitsa_plant
		name = SOV_merge_ship_plant_2_black_sea
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_department_icon_ship_screen_ship_production
		special_trait_background = yes

		position = { x=@ship_2_X y=@ship_2_Y }

		mutually_exclusive = { SOV_mio_trait_merge_plant_no_340 }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		available = {
			FROM = {
				has_full_control_of_state = 202 #KIEV
			}
			FROM = {
				has_completed_focus = SOV_merge_naval_plants
				has_completed_focus = SOV_surface_warfare
			}
			#Only exists in this MIO
		}

		limit_to_equipment_type = { mio_cat_eq_all_destroyer }

		production_bonus = {
			production_cost_factor = @ship_destroyer_production_cost_factor
		}
	}

	add_trait = { 
		token = SOV_mio_trait_merge_plant_no_340
		name = SOV_merge_ship_plant_3_black_sea
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_department_icon_ship_submarine_production
		special_trait_background = yes

		position = { x=@ship_3_X y=@ship_3_Y }

		mutually_exclusive = { SOV_mio_trait_merge_leninskaya_kuznitsa_plant }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		available = {
			FROM = {
				has_full_control_of_state = 227 #STALINO
			}
			FROM = {
				has_completed_focus = SOV_merge_naval_plants
				has_completed_focus = SOV_submarine_warfare
			}
			#Only exists in this MIO
		}

		limit_to_equipment_type = { ship_hull_submarine }
		
		production_bonus = {
			production_cost_factor = @ship_submarine_production_cost_factor
		}
	}
}

SOV_sevastopol_marine_plant_organization = {
	include = generic_refurbishment_repair_organization
	icon = GFX_idea_SOV_sevastopol_marine_plant
	
	allowed = {	
		original_tag = SOV
	}

	tree_header_text = {
		text = mio_header_protection
		x = 3
	}

	tree_header_text = {
		text = mio_header_weapons
		x = 7
	}

	override_trait = {
		token = generic_mio_trait_foam_fire_extinguishers
		
		position = { x=4 y=0 }
		relative_position_id = generic_mio_trait_heavy_armored_hull
	}

	override_trait = {
		token = generic_mio_trait_counter_flooding_system
		
		position = { x=2 y=0 }
		relative_position_id = generic_mio_trait_isolated_firemains
	}

	add_trait = { #MTG version
		token = SOV_mio_trait_merge_mariupol_plant
		name = SOV_merge_ship_plant_4_black_sea
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_mines
		special_trait_background = yes

		position = { x=@ship_1_X y=@ship_1_Y }
		
		visible = {
			FROM = { original_tag = SOV }
			has_dlc = "Man the Guns"
		}

		available = {
			FROM = {
				has_full_control_of_state = 227 #STALINO
			}
			FROM = {
				has_completed_focus = SOV_merge_naval_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_mariupol_plant_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_mariupol_plant_flag
				add_tech_bonus = {
					name = SOV_merge_ship_plant_2_baltic
					bonus = 1
					uses = 1
					category = naval_mines
				}
			}
		}

		limit_to_equipment_type = { mio_cat_eq_all_cruiser }
		
		production_bonus = {
			production_cost_factor = @ship_production_capacity_factor
		}

		equipment_bonus = {
			mines_planting = @ship_mines_planting
		}
	}

	add_trait = { #No-MTG version
		token = SOV_mio_trait_merge_mariupol_plant_no_mtg
		name = SOV_merge_ship_plant_4_black_sea
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_mines
		special_trait_background = yes

		position = { x=@ship_1_X y=@ship_1_Y }
		
		visible = {
			FROM = { original_tag = SOV }
			NOT = { has_dlc = "Man the Guns" }
		}

		available = {
			FROM = {
				has_full_control_of_state = 227 #STALINO
			}
			FROM = {
				has_completed_focus = SOV_merge_naval_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_mariupol_plant_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_mariupol_plant_flag
			}
		}

		limit_to_equipment_type = { mio_cat_eq_all_cruiser }
		
		production_bonus = {
			production_cost_factor = @ship_production_capacity_factor
		}
	}

	add_trait = { 
		token = SOV_mio_trait_merge_plant_no_200
		name = SOV_merge_ship_plant_1_black_sea
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_department_icon_ship_screen_ship_production
		special_trait_background = yes

		position = { x=@ship_2_X y=@ship_2_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		available = {
			FROM = {
				has_full_control_of_state = 197 #MYKOLAIV
			}
			FROM = {
				has_completed_focus = SOV_merge_naval_plants
			}
			#Only exists in this MIO
		}

		limit_to_equipment_type = { mio_cat_eq_all_cruiser }

		production_bonus = {
			production_cost_factor = @ship_cruiser_production_cost_factor
		}
	}
}




########  ##          ###    ##    ## ########  ######  
##     ## ##         ## ##   ###   ## ##       ##    ## 
##     ## ##        ##   ##  ####  ## ##       ##       
########  ##       ##     ## ## ## ## ######    ######  
##        ##       ######### ##  #### ##             ## 
##        ##       ##     ## ##   ### ##       ##    ## 
##        ######## ##     ## ##    ## ########  ######  

SOV_mig_design_bureau_organization = {
	include = generic_light_aircraft_organization
	icon = GFX_idea_mig_design_bureau
	
	allowed = {	
		OR = {
			tag = SOV
			AND = {
				tag = ETH 
				has_dlc = "By Blood Alone"
			}
			AND = {
				tag = ARG
				has_dlc = "Trial of Allegiance" 
			}
			AND = {
				tag = BRA
				has_dlc = "Trial of Allegiance" #TODO MH Change DLC
			}
		}
	}
	
	visible = {
		IF = { 
			limit = { FROM = { original_tag = ETH } } 
			FROM = { has_completed_focus = ETH_soviet-ethiopian_trade_agreement }
		}
		IF = { 
			limit = {
				FROM = { tag = BRA }
				has_dlc = "Trial of Allegiance"
			}
		}
	}

	available = {
		IF = { #Dissolve Bureau Purge
			limit = {
				FROM = { original_tag = SOV }
			}
			FROM = { NOT = { has_country_flag = SOV_mig_design_bureau_dissolved_flag } }
		}
		# When in a Foreign MIO, countries need to be at peace with original country
		IF = {
			limit = {
				FROM = { NOT = { original_tag = SOV } }
			}
			FROM = { NOT = { has_war_with = SOV } }
		}
		IF = {
			limit = {
				FROM = { original_tag = ARG }
			}
			FROM = { has_completed_focus = ARG_russian_manufacturers }
		}
		IF = {
			limit = {
				FROM = { original_tag = BRA }
			}
			FROM = { has_completed_focus = BRA_soviet_arms_industry }
		}
	}

	add_trait = { 
		token = SOV_mio_trait_merge_plant_no_28
		name = SOV_merge_aircraft_plant_1
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_build_cost_ic
		special_trait_background = yes

		position = { x=@aircraft_1_X y=@aircraft_1_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		available = {
			FROM = {
				has_full_control_of_state = 251 #KUYBYSHEV
			}
			FROM = {
				has_completed_focus = SOV_merge_aircraft_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_plant_no_28_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_plant_no_28_flag
			}
		}

		production_bonus = {
			production_cost_factor = @aircraft_production_cost_factor
		}
	}

	add_trait = { 
		token = SOV_mio_trait_merge_plant_no_150
		name = SOV_merge_aircraft_plant_2
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_air_agility
		special_trait_background = yes

		position = { x=@aircraft_2_X y=@aircraft_2_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		available = {
			FROM = {
				has_full_control_of_state = 219 #MOSCOW
			}
			FROM = {
				has_completed_focus = SOV_merge_aircraft_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_plant_no_150_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_plant_no_150_flag
				add_resource = {
					type = aluminium
					amount = 3
					state = 219
				}
			}
		}

		equipment_bonus = {
			air_agility = @aircraft_air_agility
		}
	}

	add_trait = { 
		token = SOV_mio_trait_merge_vef_plant
		name = SOV_merge_aircraft_plant_3
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_detection
		special_trait_background = yes

		position = { x=@aircraft_3_X y=@aircraft_3_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		available = {
			FROM = {
				has_full_control_of_state = 808 #RIGA
			}
			FROM = {
				has_completed_focus = SOV_merge_aircraft_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_vef_plant_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_vef_plant_flag
				add_tech_bonus = {
					name = SOV_mio_trait_merge_vef_plant
					bonus = 1
					uses = 1
					category = radar_tech
				}
			}
		}

		equipment_bonus = {
			air_defence = @aircraft_air_defence
			surface_detection = @aircraft_surface_detection
			sub_detection = @aircraft_sub_detection
		}
	}
}

SOV_ilyushin_design_bureau_organization = {
	include = generic_medium_aircraft_organization
	icon = GFX_idea_ilyushin_design_bureau
	
	allowed = {	
		OR = {
			tag = SOV 
			AND = {
				tag = BUL
				has_dlc = "Battle for the Bosporus"
			}
		}
	}
	
	available = {
		IF = { #Dissolve Bureau Purge
			limit = {
				FROM = { original_tag = SOV }
			}
			FROM = { NOT = { has_country_flag = SOV_ilyushin_design_bureau_dissolved_flag } }
		}
		# When in a Foreign MIO, countries need to be at peace with original country
		IF = {
			limit = {
				FROM = { NOT = { original_tag = SOV } }
			}
			FROM = { NOT = { has_war_with = SOV } }
		}

		IF = {
			limit = { FROM = { original_tag = BUL } }
			custom_trigger_tooltip = {
				tooltip = has_invited_mio_tt
				FROM = {
					has_country_flag = has_invited_ilyushin_mio_flag
				}
			}
			FROM = {
				OR = {
					is_subject = no
					is_subject_of = SOV
				}
				#is_in_faction_with = SOV
				NOT = { has_completed_focus = BUL_nationalization }
			}
		}
	}

	add_trait = { 
		token = SOV_mio_trait_merge_plant_no_28
		name = SOV_merge_aircraft_plant_1
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_build_cost_ic
		special_trait_background = yes

		position = { x=@aircraft_1_X y=@aircraft_1_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}
		
		available = {
			FROM = {
				has_full_control_of_state = 251 #KUYBYSHEV
			}
			FROM = {
				has_completed_focus = SOV_merge_aircraft_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_plant_no_28_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_plant_no_28_flag
			}
		}

		production_bonus = {
			production_cost_factor = @aircraft_production_cost_factor
		}
	}

	add_trait = { 
		token = SOV_mio_trait_merge_plant_no_150
		name = SOV_merge_aircraft_plant_2
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_air_agility
		special_trait_background = yes

		position = { x=@aircraft_2_X y=@aircraft_2_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}
		
		available = {
			FROM = {
				has_full_control_of_state = 219 #MOSCOW
			}
			FROM = {
				has_completed_focus = SOV_merge_aircraft_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_plant_no_150_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_plant_no_150_flag
				add_resource = {
					type = aluminium
					amount = 3
					state = 219
				}
			}
		}

		equipment_bonus = {
			air_agility = @aircraft_air_agility
		}
	}

	add_trait = { 
		token = SOV_mio_trait_merge_vef_plant
		name = SOV_merge_aircraft_plant_3
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_detection
		special_trait_background = yes

		position = { x=@aircraft_3_X y=@aircraft_3_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}
		
		available = {
			FROM = {
				has_full_control_of_state = 808 #RIGA
			}
			FROM = {
				has_completed_focus = SOV_merge_aircraft_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_vef_plant_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_vef_plant_flag
				add_tech_bonus = {
					name = SOV_mio_trait_merge_vef_plant
					bonus = 1
					uses = 1
					category = radar_tech
				}
			}
		}

		equipment_bonus = {
			air_defence = @aircraft_air_defence
			surface_detection = @aircraft_surface_detection
			sub_detection = @aircraft_sub_detection
		}
	}
}

SOV_yakovlev_design_bureau_organization = {
	include = generic_naval_aircraft_organization
	icon = GFX_idea_yakovlev_design_bureau
	
	allowed = {	
		original_tag = SOV
	}

	available = {
		IF = { #Dissolve Bureau Purge
			limit = {
				FROM = { original_tag = SOV }
			}
			FROM = { NOT = { has_country_flag = SOV_yakovlev_design_bureau_dissolved_flag } }
		}
	}

	add_trait = { 
		token = SOV_mio_trait_merge_plant_no_28
		name = SOV_merge_aircraft_plant_1
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_build_cost_ic
		special_trait_background = yes

		position = { x=@aircraft_1_X y=@aircraft_1_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}
		
		available = {
			FROM = {
				has_full_control_of_state = 251 #KUYBYSHEV
			}
			FROM = {
				has_completed_focus = SOV_merge_aircraft_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_plant_no_28_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_plant_no_28_flag
			}
		}

		production_bonus = {
			production_cost_factor = @aircraft_production_cost_factor
		}
	}

	add_trait = { 
		token = SOV_mio_trait_merge_plant_no_150
		name = SOV_merge_aircraft_plant_2
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_air_agility
		special_trait_background = yes

		position = { x=@aircraft_2_X y=@aircraft_2_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}
		
		available = {
			FROM = {
				has_full_control_of_state = 219 #MOSCOW
			}
			FROM = {
				has_completed_focus = SOV_merge_aircraft_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_plant_no_150_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_plant_no_150_flag
				add_resource = {
					type = aluminium
					amount = 3
					state = 219
				}
			}
		}

		equipment_bonus = {
			air_agility = @aircraft_air_agility
		}
	}

	add_trait = { 
		token = SOV_mio_trait_merge_vef_plant
		name = SOV_merge_aircraft_plant_3
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_detection
		special_trait_background = yes

		position = { x=@aircraft_3_X y=@aircraft_3_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}
		
		available = {
			FROM = {
				has_full_control_of_state = 808 #RIGA
			}
			FROM = {
				has_completed_focus = SOV_merge_aircraft_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_vef_plant_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_vef_plant_flag
				add_tech_bonus = {
					name = SOV_mio_trait_merge_vef_plant
					bonus = 1
					uses = 1
					category = radar_tech
				}
			}
		}

		equipment_bonus = {
			air_defence = @aircraft_air_defence
			surface_detection = @aircraft_surface_detection
			sub_detection = @aircraft_sub_detection
		}
	}
}

SOV_tupolev_design_bureau_organization = {
	include = generic_heavy_aircraft_organization
	icon = GFX_idea_tupolev_design_bureau
	allowed = {	
		original_tag = SOV
	}

	available = {
		IF = { #Dissolve Bureau Purge
			limit = {
				FROM = { original_tag = SOV }
			}
			FROM = { NOT = { has_country_flag = SOV_tupolev_design_bureau_dissolved_flag } }
		}
	}

	tree_header_text = {
		text = mio_header_design_department
		x = 2
	}

	tree_header_text = {
		text = mio_header_operational_department
		x = 7
	}

	override_trait = {
		token = generic_mio_trait_pressurized_cockpit
		
		position = { x=2 y=1 }
		relative_position_id = generic_mio_trait_reinforced_frames
	}

	override_trait = {
		token = generic_mio_trait_extended_rear_fuselage
		
		position = { x=5 y=0 }
		relative_position_id = generic_mio_trait_reinforced_frames
	}

	add_trait = { 
		token = SOV_mio_trait_gas_tank_protection
		name = SOV_mio_trait_gas_tank_protection
		icon = GFX_generic_mio_trait_icon_anti_air_attack
		special_trait_background = yes

		position = { x=-1 y=1 }
		relative_position_id = generic_mio_trait_pressurized_cockpit

		any_parent = { generic_mio_trait_pressurized_cockpit }
		
		available = {
		}

		equipment_bonus = {
			air_defence = 0.05
			reliability = 0.03
		}
	}

	add_trait = { 
		token = SOV_mio_trait_lightened_reduction_gear
		name = SOV_mio_trait_lightened_reduction_gear
		icon = GFX_generic_mio_trait_icon_fuel_consumption
		special_trait_background = yes

		position = { x=1 y=1 }
		relative_position_id = generic_mio_trait_pressurized_cockpit

		any_parent = { generic_mio_trait_pressurized_cockpit }
		
		available = {
		}

		equipment_bonus = {
			fuel_consumption = -0.05
			reliability = 0.03
		}
	}

	add_trait = { 
		token = SOV_mio_trait_merge_plant_no_28
		name = SOV_merge_aircraft_plant_1
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_build_cost_ic
		special_trait_background = yes

		position = { x=@aircraft_1_X y=@aircraft_1_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		available = {
			FROM = {
				has_full_control_of_state = 251 #KUYBYSHEV
			}
			FROM = {
				has_completed_focus = SOV_merge_aircraft_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_plant_no_28_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_plant_no_28_flag
			}
		}

		production_bonus = {
			production_cost_factor = @aircraft_production_cost_factor
		}
	}

	add_trait = { 
		token = SOV_mio_trait_merge_plant_no_150
		name = SOV_merge_aircraft_plant_2
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_air_agility
		special_trait_background = yes

		position = { x=@aircraft_2_X y=@aircraft_2_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		available = {
			FROM = {
				has_full_control_of_state = 219 #MOSCOW
			}
			FROM = {
				has_completed_focus = SOV_merge_aircraft_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_plant_no_150_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_plant_no_150_flag
				add_resource = {
					type = aluminium
					amount = 3
					state = 219
				}
			}
		}

		equipment_bonus = {
			air_agility = @aircraft_air_agility
		}
	}

	add_trait = { 
		token = SOV_mio_trait_merge_vef_plant
		name = SOV_merge_aircraft_plant_3
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_detection
		special_trait_background = yes

		position = { x=@aircraft_3_X y=@aircraft_3_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		available = {
			FROM = {
				has_full_control_of_state = 808 #RIGA
			}
			FROM = {
				has_completed_focus = SOV_merge_aircraft_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_vef_plant_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_vef_plant_flag
				add_tech_bonus = {
					name = SOV_mio_trait_merge_vef_plant
					bonus = 1
					uses = 1
					category = radar_tech
				}
			}
		}

		equipment_bonus = {
			air_defence = @aircraft_air_defence
			surface_detection = @aircraft_surface_detection
			sub_detection = @aircraft_sub_detection
		}
	}
}






##     ##    ###    ######## ######## ########  #### ######## ##       
###   ###   ## ##      ##    ##       ##     ##  ##  ##       ##       
#### ####  ##   ##     ##    ##       ##     ##  ##  ##       ##       
## ### ## ##     ##    ##    ######   ########   ##  ######   ##       
##     ## #########    ##    ##       ##   ##    ##  ##       ##       
##     ## ##     ##    ##    ##       ##    ##   ##  ##       ##       
##     ## ##     ##    ##    ######## ##     ## #### ######## ######## 



SOV_grabin_design_bureau_organization = {
	include = generic_artillery_organization
	icon = GFX_idea_grabin_design_bureau
	
	allowed = {	
		OR = {
			tag = SOV 
			AND = {
				tag = GRE
				has_dlc = "Battle for the Bosporus"
			}
		}
	}
	
	available = {
		# When in a Foreign MIO, countries need to be at peace with original country
		IF = {
			limit = {
				FROM = { NOT = { original_tag = SOV } }
			}
			FROM = { NOT = { has_war_with = SOV } }
		}

		IF = {
			limit = { FROM = { original_tag = GRE } }
			FROM = {
				has_completed_focus = GRE_appeal_to_the_soviet_union 
			}
		}
	}

	add_trait = { 
		token = SOV_mio_trait_merge_plant_no_172
		name = SOV_merge_materiel_plant_1_artillery
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_department_icon_artillery_production
		special_trait_background = yes

		position = { x=@materiel_1_X y=@materiel_1_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		available = {
			FROM = {
				has_full_control_of_state = 398 #PERM
			}
			FROM = {
				has_completed_focus = SOV_merge_tank_and_materiel_plants
			}
			#Only exists in this MIO
		}

		production_bonus = {
			production_cost_factor = @artillery_production_cost_factor
		}
	}
	
	add_trait = { 
		token = SOV_mio_trait_merge_nkmz_plant
		name = SOV_merge_materiel_plant_2
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_efficiency_cap
		special_trait_background = yes

		position = { x=@materiel_2_X y=@materiel_2_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		available = {
			FROM = {
				has_full_control_of_state = 227 #STALINO
			}
			FROM = {
				has_completed_focus = SOV_merge_tank_and_materiel_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_nkmz_plant_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_nkmz_plant_flag
			}
		}

		production_bonus = {
			production_efficiency_cap_factor = @materiel_production_efficiency_cap_factor
		}
	}

	add_trait = { 
		token = SOV_mio_trait_merge_magnitogorsk_metallurgical_plant
		name = SOV_merge_materiel_plant_3
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_production_capacity
		special_trait_background = yes

		position = { x=@materiel_3_X y=@materiel_3_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		available = {
			FROM = {
				has_full_control_of_state = 582 #MAGNITOGORSK
			}
			FROM = {
				has_completed_focus = SOV_merge_tank_and_materiel_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_magnitogorsk_metallurgical_plant_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_magnitogorsk_metallurgical_plant_flag
			}
		}

		production_bonus = {
			production_capacity_factor = @materiel_production_capacity_factor
		}
	}
}

SOV_tula_arms_plant_organization = {
	include = generic_infantry_equipment_organization	
	icon = GFX_idea_tula_arms_plant
	
	allowed = {	
		original_tag = SOV
	}

	tree_header_text = {
		text = mio_header_design_and_production
		x = 2.5
	}

	tree_header_text = {
		text = mio_header_anti_tank
		x = 7
	}

	override_trait = {
		token = generic_mio_trait_armor_piercing_rounds
		
		position = { x=0 y=2 }
		relative_position_id = generic_mio_trait_quality_materials
	}

	override_trait = {
		token = generic_mio_trait_advanced_barrel_forging
		
		position = { x=1 y=2 }
		relative_position_id = generic_mio_trait_drum_pattern_sights
	}

	override_trait = {
		token = generic_mio_trait_reinforced_stocks
		
		position = { x=3 y=0 }
		relative_position_id = generic_mio_trait_drum_pattern_sights
	}

	add_trait = { 
		token = SOV_mio_trait_merge_plant_no_622
		name = SOV_merge_materiel_plant_1_infantry
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_department_icon_infantry_production
		special_trait_background = yes

		position = { x=@materiel_1_X y=@materiel_1_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		available = {
			FROM = {
				has_full_control_of_state = 399 #UDMURTIA (Izhevsk)
			}
			FROM = {
				has_completed_focus = SOV_merge_tank_and_materiel_plants
			}
			#Only exists in this MIO
		}

		production_bonus = {
			production_cost_factor = @infantry_equipment_production_cost_factor
		}
	}

	add_trait = { 
		token = SOV_mio_trait_merge_nkmz_plant
		name = SOV_merge_materiel_plant_2
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_efficiency_cap
		special_trait_background = yes

		position = { x=@materiel_2_X y=@materiel_2_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		available = {
			FROM = {
				has_full_control_of_state = 227 #STALINO
			}
			FROM = {
				has_completed_focus = SOV_merge_tank_and_materiel_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_nkmz_plant_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_nkmz_plant_flag
			}
		}

		production_bonus = {
			production_efficiency_cap_factor = @materiel_production_efficiency_cap_factor
		}
	}

	add_trait = { 
		token = SOV_mio_trait_merge_magnitogorsk_metallurgical_plant
		name = SOV_merge_materiel_plant_3
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_production_capacity
		special_trait_background = yes

		position = { x=@materiel_3_X y=@materiel_3_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		available = {
			FROM = {
				has_full_control_of_state = 582 #MAGNITOGORSK
			}
			FROM = {
				has_completed_focus = SOV_merge_tank_and_materiel_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_magnitogorsk_metallurgical_plant_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_magnitogorsk_metallurgical_plant_flag
			}
		}

		production_bonus = {
			production_capacity_factor = @materiel_production_capacity_factor
		}
	}
}

SOV_gaz_organization = {
	include = generic_motorized_mechanized_organization
	icon = GFX_idea_gaz
	
	allowed = {	
		OR = {
			tag = SOV 
			AND = {
				tag = BUL
				has_dlc = "Battle for the Bosporus"
			}
			AND = {
				tag = ETH 
				has_dlc = "By Blood Alone"
			}
			AND = {
				tag = ARG
				has_dlc = "Trial of Allegiance" #TODO_Eildih fix DLC
			}
			AND = {
				tag = BRA
				has_dlc = "Trial of Allegiance" #TODO MH fix DLC
			}
			NOR_AAT = yes
		}
	}

	visible = {
		IF = { 
			limit = { FROM = { original_tag = ETH } } 
			FROM = { has_completed_focus = ETH_soviet-ethiopian_trade_agreement }
		}
	}
	
	available = {
		# When in a Foreign MIO, countries need to be at peace with original country
		IF = {
			limit = {
				FROM = { NOT = { original_tag = SOV } }
			}
			FROM = { NOT = { has_war_with = SOV } }
		}

		IF = {
			limit = { FROM = { original_tag = BUL } }
			custom_trigger_tooltip = {
				tooltip = has_invited_mio_tt
				FROM = {
					has_country_flag = has_invited_gaz_mio_flag
				}
			}
			FROM = {
				OR = {
					is_subject = no
					is_subject_of = SOV
				}
				#is_in_faction_with = SOV
				NOT = { has_completed_focus = BUL_nationalization }
			}
		}
		ELSE_IF = {
			limit = {
				FROM = { original_tag = NOR }
			}
			FROM = { has_completed_focus = NOR_invite_soviet_designers }
		}

		IF = {
			limit = {
				FROM = { original_tag = ARG }
			}
			FROM = { has_completed_focus = ARG_russian_manufacturers }
		}

		IF = {
			limit = {
				FROM = { original_tag = BRA }
			}
			FROM = { has_completed_focus = BRA_soviet_arms_industry }
		}
	}

	add_trait = { 
		token = SOV_mio_trait_merge_automobile_tool_plant
		name = SOV_merge_materiel_plant_1_motorized
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_department_icon_motorized_mechanized_production
		special_trait_background = yes

		position = { x=@materiel_1_X y=@materiel_1_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		available = {
			FROM = {
				has_full_control_of_state = 252 #GORKY
			}
			FROM = {
				has_completed_focus = SOV_merge_tank_and_materiel_plants
			}
			#Only exists in this MIO
		}

		production_bonus = {
			production_cost_factor = @motorized_production_cost_factor
		}
	}
	
	add_trait = { 
		token = SOV_mio_trait_merge_nkmz_plant
		name = SOV_merge_materiel_plant_2
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_efficiency_cap
		special_trait_background = yes

		position = { x=@materiel_2_X y=@materiel_2_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		available = {
			FROM = {
				has_full_control_of_state = 227 #STALINO
			}
			FROM = {
				has_completed_focus = SOV_merge_tank_and_materiel_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_nkmz_plant_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_nkmz_plant_flag
			}
		}

		production_bonus = {
			production_efficiency_cap_factor = @materiel_production_efficiency_cap_factor
		}
	}

	add_trait = { 
		token = SOV_mio_trait_merge_magnitogorsk_metallurgical_plant
		name = SOV_merge_materiel_plant_3
		#icon = GFX_generic_mio_department_icon_facilities
		icon = GFX_generic_mio_trait_icon_production_capacity
		special_trait_background = yes

		position = { x=@materiel_3_X y=@materiel_3_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		available = {
			FROM = {
				has_full_control_of_state = 582 #MAGNITOGORSK
			}
			FROM = {
				has_completed_focus = SOV_merge_tank_and_materiel_plants
			}
			FROM = {
				NOT = { has_country_flag = SOV_merge_magnitogorsk_metallurgical_plant_flag }
			}
		}

		on_complete = {
			custom_effect_tooltip = generic_trait_will_not_be_available_in_other_organizations
			FROM = {
				set_country_flag = SOV_merge_magnitogorsk_metallurgical_plant_flag
			}
		}

		production_bonus = {
			production_capacity_factor = @materiel_production_capacity_factor
		}
	}
}
