##################
#### 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 = {
			original_tag = SOV
			original_tag = TAN
			AND = {
				tag = MEX 
				has_dlc = "Man the Guns"
			}
			AND = {
				OR = {
					is_literally_china = yes
					tag = MAN
					tag = MEN
				} 
				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 = { original_tag = TAN } }
			FROM = { is_ally_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_send_koshkin_to_kharkiv
		name = SOV_mio_trait_send_koshkin_to_kharkiv
		icon = GFX_generic_mio_department_icon_facilities
		special_trait_background = yes	
		position = { x=4 y=0 }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		organization_modifier = {
			military_industrial_organization_research_bonus = 0.1
			military_industrial_organization_design_team_assign_cost = -0.35
		}
	}
	
	add_trait = {
		token = SOV_mio_trait_balanced_design
		name = SOV_mio_trait_balanced_design
		icon = GFX_generic_mio_department_icon_tank_general_production
		special_trait_background = yes	
		any_parent = { generic_mio_quality_assurance_routines }
		position = { x=3 y=2 }

		equipment_bonus = {
			defense = 0.05
			armor_value = 0.05
			maximum_speed = 0.05
		}
	}
	
	add_trait = {
		token = SOV_mio_trait_76_mm_armaments
		name = SOV_mio_trait_76_mm_armaments
		icon = GFX_generic_mio_department_icon_tank_medium_tank_weapons
		special_trait_background = yes
		any_parent = { generic_mio_quality_assurance_routines }
		position = { x=5 y=2 }

		equipment_bonus = {
			soft_attack = 0.07
			hard_attack = 0.07
		}
	}
	
	add_trait = {
		token = SOV_mio_trait_simple_and_reliable
		name = SOV_mio_trait_simple_and_reliable
		icon = GFX_generic_mio_trait_icon_reliability
		special_trait_background = yes
		any_parent = { generic_mio_lighter_materials generic_mio_armor_hardening_process }
		position = { x=6 y=2 }

		equipment_bonus = {
			build_cost_ic = -0.03
			reliability = 0.05
		}
		
		production_bonus = {
			production_efficiency_gain_factor = 0.05
		}
	}

	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 = SOV_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 = SOV_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 = SOV_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 = SOV_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 = SOV_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 = SOV_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 = SOV_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 = SOV_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 = SOV_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
			tag = EST
			tag = LAT
			tag = LIT
			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 } }
		}
		if = {
			limit = {
				FROM = {
					OR = {
						tag = EST
						tag = LAT
						tag = LIT
					}
				}
			}
			FROM = {
				is_subject_of = 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 = SOV_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 = SOV_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 = SOV_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 = SOV_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 = SOV_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 = SOV_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_ural_heavy_machine_building_plant_organization = {
	include = generic_assault_guns_organization
	icon = GFX_idea_sov_uztm
	
	allowed = {	
		original_tag = SOV
	}

}


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

SOV_nevskoye_design_bureau_organization = {
	include = generic_battle_line_ship_organization
	icon = GFX_idea_nevskoye_design_bureau
	
	allowed = {	
		OR = {
			tag = SOV 
			tag = EST
			tag = LAT
			tag = LIT
			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 }
			}
		}
		
		if = {
			limit = {
				FROM = {
					OR = {
						tag = EST
						tag = LAT
						tag = LIT
					}
				}
			}
			FROM = {
				is_subject_of = SOV
			}
		}
	}

	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 = SOV_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 = SOV_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"
			}
			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 }
		}
	}

	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 = SOV_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 = SOV_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_tskb_32_organization = {
	include = generic_escort_ship_organization
	icon = GFX_idea_sov_sudoproekt
	
	allowed = {	
		tag = SOV
	}

	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 = SOV_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 = SOV_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_big_fleet
		name = SOV_mio_trait_big_fleet
		icon = GFX_generic_mio_department_icon_ship_screen_ship_quality
		special_trait_background = yes

		position = { x=8 y=0 }
		
		mutually_exclusive = { SOV_mio_trait_mosquito_fleet }

		equipment_bonus = {
			build_cost_ic = 0.05
			armor_value = 0.1
			max_strength = 0.1
		}
	}
	
	add_trait = {
		token = SOV_mio_trait_mosquito_fleet
		name = SOV_mio_trait_mosquito_fleet
		icon = GFX_generic_mio_department_icon_ship_capital_screen_utility
		special_trait_background = yes

		position = { x=9 y=0 }
		
		mutually_exclusive = { SOV_mio_trait_big_fleet }
		
		production_bonus = {
			production_cost_factor = -0.15
		}
	}

}

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
	}
	
	initial_trait = {
		name = generic_mio_initial_trait_black_sea_fleet_designer
		limit_to_equipment_type = { mio_cat_eq_all_carrier capital_ship screen_ship ship_hull_submarine }
		equipment_bonus = {
			anti_air_attack = 0.02
			armor_value = 0.02
			max_strength = 0.02
			naval_range = -0.05
		}
	}

	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 = SOV_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 = SOV_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 = SOV_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 = SOV_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_ivs_organization = {
	include = generic_submarine_organization
	icon = GFX_idea_sov_ivs
	
	allowed = {	
		original_tag = SOV
	}
	
	available = {
		FROM = {
			NOT = { has_war_with = HOL }
			NOT = { has_war_with = GER }
		}
	}
}

SOV_dalzavod_organization = {
	include = generic_small_ship_organization
	icon = GFX_idea_sov_dalzavod
	
	initial_trait = {
		name = SOV_mio_initial_trait_pacific_fleet_repair_center

		organization_modifier = {
			military_industrial_organization_research_bonus = 0.03
		}
		
		production_bonus = {
			production_capacity_factor = 0.05
		}
	}
	
	allowed = {	
		OR = {
			original_tag = SOV
			original_tag = TAN
		}
	}
	
	available = {
		FROM = { controls_state = 408 }
	}

	add_trait = {
		token = SOV_mio_trait_merge_plant_no_263
		name = SOV_mio_trait_merge_plant_no_263
		icon = GFX_generic_mio_department_icon_facilities
		special_trait_background = yes

		position = { x=@ship_1_X y=@ship_1_Y }
		
		visible = {
			FROM = { original_tag = SOV }
		}

		available = {
			FROM = {
				has_full_control_of_state = 408 #VLADIVOSTOK (Sovetskaya Gavan)
			}
			FROM = {
				has_completed_focus = SOV_merge_naval_plants
			}
		}
		
		production_bonus = {
			production_cost_factor = -0.1
		}
	}

}

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

SOV_mig_design_bureau_organization = {
	name = SOV_polikarpov_design_bureau_organization
	include = generic_light_aircraft_organization
	icon = GFX_idea_mig_design_bureau
	
	allowed = {	
		OR = {
			original_tag = SOV
			AND = {
				tag = ETH 
				has_dlc = "By Blood Alone"
			}
		}
	}
	
	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 } }
		}
	}
	
	add_trait = { 
		token = SOV_mio_trait_establish_the_mikoyan_design_bureau
		name = SOV_mio_trait_establish_the_mikoyan_design_bureau
		icon = GFX_generic_mio_department_icon_facilities
		special_trait_background = yes
#		any_parent = { generic_mio_trait_light_airframe }

		position = { x=0 y=0 }

		organization_modifier = {
			military_industrial_organization_design_team_assign_cost = -0.5
			military_industrial_organization_funds_gain = 0.15
		}
		
		on_complete = {
			mio:SOV_mig_design_bureau_organization = {
				set_mio_name_key = SOV_mikoyan_design_bureau_organization
			}
		}
	}
	
	add_trait = { 
		token = SOV_mio_trait_promote_mikoyan_and_gurevich
		name = SOV_mio_trait_promote_mikoyan_and_gurevich
		icon = GFX_generic_mio_trait_icon_unique
		special_trait_background = yes
		any_parent = { SOV_mio_trait_establish_the_mikoyan_design_bureau }

		position = { x=0 y=1 }

		organization_modifier = {
			military_industrial_organization_funds_gain = 0.15
			military_industrial_organization_research_bonus = 0.15
		}
	}
	
	add_trait = { 
		token = SOV_mio_trait_high_altitude_flying
		name = SOV_mio_trait_high_altitude_flying
		icon = GFX_generic_mio_department_icon_plane_fighter_line_efficiency
		special_trait_background = yes
		any_parent = { generic_mio_trait_advanced_aerodynamics }

		position = { x=8 y=1 }

		equipment_bonus = {
			air_agility = 0.05
			maximum_speed = 0.05
		}
	}
	
	add_trait = { 
		token = SOV_mio_trait_shvak_cannons
		name = SOV_mio_trait_shvak_cannons
		icon = GFX_generic_mio_department_icon_tank_general_aa
		special_trait_background = yes
#		any_parent = { generic_mio_trait_light_airframe }

		position = { x=1 y=0 }

		equipment_bonus = {
			air_attack = 0.07
		}
	}

	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 = SOV_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 = SOV_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 = SOV_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_okb_301_organization = {
	include = generic_high_agility_fighter_aircraft_organization
	icon = GFX_idea_sov_okb_301
	allowed = {	
		original_tag = SOV
	}
	
	add_trait = { 
		token = SOV_mio_trait_delta_wood
		name = SOV_mio_trait_delta_wood
		icon = GFX_generic_mio_department_icon_plane_fighter_materials
		special_trait_background = yes
		any_parent = { generic_mio_trait_fabric_skin generic_mio_trait_metal_skin }

		position = { x=1 y=1 }

		equipment_bonus = {
			reliability = -0.01
		}
		
		production_bonus = {
			production_resource_need_factor = -0.15
		}
	}
	
	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 = SOV_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 = SOV_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 = SOV_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_cas_aircraft_organization
	icon = GFX_idea_ilyushin_design_bureau
	
	allowed = {	
		OR = {
			original_tag = SOV 
			tag = EST
			tag = LAT
			tag = LIT
			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_ilyushin_mio_flag
				}
			}
			FROM = {
				OR = {
					is_subject = no
					is_subject_of = SOV
				}
				#is_in_faction_with = SOV
				NOT = { has_completed_focus = BUL_nationalization }
			}
		}
		if = {
			limit = {
				FROM = {
					OR = {
						tag = EST
						tag = LAT
						tag = LIT
					}
				}
			}
			FROM = {
				is_subject_of = SOV
			}
		}
	}
	
	add_trait = { 
		token = SOV_mio_trait_flying_tank
		name = SOV_mio_trait_flying_tank
		icon = GFX_generic_mio_department_icon_plane_cas_combat
		special_trait_background = yes
		any_parent = { generic_mio_trait_selectional_construction }

		position = { x=0 y=1 }

		equipment_bonus = {
			maximum_speed = -0.03
			air_ground_attack = 0.05
			air_defence = 0.05
		}
	}
	
	add_trait = {
		token = SOV_mio_trait_ptab_bombs
		name = SOV_mio_trait_ptab_bombs
		icon = GFX_generic_mio_trait_icon_air_ground_attack
		special_trait_background = yes
		any_parent = { generic_mio_heat_bombs }

		position = { x=8 y=1 }

		equipment_bonus = {
			air_ground_attack = 0.07
		}
	}

	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 = SOV_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 = SOV_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 = SOV_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_multi_role_aircraft_organization
	icon = GFX_idea_yakovlev_design_bureau
	
	allowed = {	
		OR = {
			original_tag = SOV
			original_tag = TAN
		}
	}
	
	available = {
		if = {
			limit = { FROM = { NOT = { original_tag = SOV } } }
			FROM = { NOT = { has_war_with = SOV } }
		}
		if = {
			limit = { FROM = { original_tag = TAN } }
			FROM = { is_ally_with = SOV }
		}
	}
	
	add_trait = { 
		token = SOV_mio_trait_experience_with_sports_aircraft
		name = SOV_mio_trait_experience_with_sports_aircraft
		icon = GFX_generic_mio_department_icon_plane_fighter_quality
		special_trait_background = yes
#		any_parent = { generic_mio_trait_selectional_construction }

		position = { x=2 y=0 }

		equipment_bonus = {
			air_agility = 0.05
			maximum_speed = 0.05
		}
	}
	
	add_trait = { 
		token = SOV_mio_trait_delta_wood
		name = SOV_mio_trait_delta_wood
		icon = GFX_generic_mio_department_icon_plane_fighter_materials
		special_trait_background = yes
		any_parent = { generic_mio_trait_armored_cockpit }

		position = { x=2 y=1 }

		equipment_bonus = {
			reliability = -0.01
		}
		
		production_bonus = {
			production_resource_need_factor = -0.15
		}
	}
	
	add_trait = { 
		token = SOV_mio_trait_shvak_cannons
		name = SOV_mio_trait_shvak_cannons
		icon = GFX_generic_mio_department_icon_tank_general_aa
		special_trait_background = yes
		any_parent = { generic_mio_trait_light_airframe }

		position = { x=0 y=2 }
		
		limit_to_equipment_type = { mio_cat_eq_all_small_plane }

		equipment_bonus = {
			air_attack = 0.07
		}
	}

	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=8 y=3 }
		
		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 = SOV_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 = SOV_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 = SOV_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_sukhoy_design_bureau_organization = {
	include = generic_medium_aircraft_organization
	icon = GFX_idea_sov_sukhoi_design_bureau
	allowed = {	
		original_tag = SOV
	}
}

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

	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 = SOV_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 = SOV_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 = SOV_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 = {
			original_tag = SOV 
			tag = EST
			tag = LAT
			tag = LIT
			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 
			}
		}
		
		if = {
			limit = {
				FROM = {
					OR = {
						tag = EST
						tag = LAT
						tag = LIT
					}
				}
			}
			FROM = {
				is_subject_of = SOV
			}
		}
	}
	
	add_trait = { 
		token = SOV_mio_trait_squeeze_bore
		name = SOV_mio_trait_squeeze_bore
		icon = GFX_generic_mio_trait_icon_breakthrough
		special_trait_background = yes
		any_parent = { generic_mio_trait_sliding_breech_block }
		
		mutually_exclusive = { SOV_mio_trait_classical_at_design }

		position = { x=3 y=3 }
		
		limit_to_equipment_type = { anti_tank_equipment }

		equipment_bonus = {
			hard_attack = 0.2
			build_cost_ic = 0.05
		}
	}
	
	add_trait = { 
		token = SOV_mio_trait_classical_at_design
		name = SOV_mio_trait_classical_at_design
		icon = GFX_generic_mio_department_icon_anti_tank_production
		special_trait_background = yes
		any_parent = { generic_mio_trait_sliding_breech_block }
		
		mutually_exclusive = { SOV_mio_trait_squeeze_bore }

		position = { x=5 y=3 }
		
		limit_to_equipment_type = { anti_tank_equipment }

		equipment_bonus = {
			build_cost_ic = -0.03
		}
		
		production_bonus = {
			production_capacity_factor = 0.07
		}
	}

	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 = SOV_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 = SOV_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 = SOV_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 = SOV_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_sestroretsk_tools_plant_organization = {
	include = generic_support_equipment_organization
	icon = GFX_idea_sov_sestroretsk_tools_plant
	allowed = {	
		original_tag = SOV
	}
}

SOV_gaz_organization = {
	include = generic_motorized_mechanized_organization
	icon = GFX_idea_gaz
	
	allowed = {	
		OR = {
			original_tag = SOV 
			AND = {
				tag = BUL
				has_dlc = "Battle for the Bosporus"
			}
			AND = {
				tag = ETH 
				has_dlc = "By Blood Alone"
			}
			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 }
		}
	}
	
	add_trait = {
		token = SOV_mio_trait_katyusha_rocket_launcher
		name = SOV_mio_trait_katyusha_rocket_launcher
		icon = GFX_military_industrial_organization_motorized_rocket_equipment
		special_trait_background = yes	
		position = { x=3 y=0 }
		
		limit_to_equipment_type = { motorized_rocket_equipment }

		equipment_bonus = {
			soft_attack = 0.07
			build_cost_ic = -0.05
		}
	}
	
	add_trait = {
		token = SOV_mio_trait_psychological_warfare
		name = SOV_mio_trait_psychological_warfare
		icon = GFX_generic_mio_trait_icon_soft_attack
		special_trait_background = yes	
		any_parent = { SOV_mio_trait_katyusha_rocket_launcher }
		position = { x=3 y=1 }
		
		limit_to_equipment_type = { motorized_rocket_equipment }

		equipment_bonus = {
			soft_attack = 0.1
			breakthrough = 0.05
		}
	}

	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 = SOV_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 = SOV_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_izhora_plant_organization = {
	include = generic_armored_car_organization	
	icon = GFX_idea_sov_izhora_plant
	
	allowed = {	
		original_tag = SOV
	}

}

SOV_mil_design_bureau_organization = {
	include = generic_helicopter_organization
	icon = GFX_idea_sov_mil_design_bureau
	
	allowed = {	
		original_tag = SOV
	}
}

SOV_nii_88_organization = {
	include = generic_rocketry_organization
	icon = GFX_idea_sov_nii_88
	
	allowed = {	
		original_tag = SOV
	}
	
	add_trait = { 
		token = SOV_mio_trait_form_okb_1_under_korolev
		name = SOV_mio_trait_form_okb_1_under_korolev
		icon = GFX_generic_mio_department_icon_facilities
		special_trait_background = yes
		position = { x=-1 y=0 }
		relative_position_id = generic_mio_trait_establish_a_rocket_research_center
		any_parent = { generic_mio_trait_establish_a_rocket_research_center }
		
		organization_modifier = {
			military_industrial_organization_industrial_manufacturer_assign_cost = -0.5
			military_industrial_organization_design_team_assign_cost = -0.5
			military_industrial_organization_funds_gain = 0.25
			military_industrial_organization_research_bonus = 0.1
		}
	}
}