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

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

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


GER_porsche_organization = {
	include = generic_heavy_tank_organization
	icon = GFX_idea_porsche
	
	allowed = {	
		OR = {
			tag = GER 
			AND = {
				tag = MEX 
				has_dlc = "Man the Guns"
			}
			NOR_AAT = yes
		}
	}

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

		IF = {
			limit = {
				FROM = { tag = MEX }
			}
			FROM = { is_in_faction_with = GER }
		}
		ELSE_IF = {
			limit = {
				FROM = { tag = NOR }
			}
			FROM = { has_completed_focus = NOR_invite_german_engineers }
		}
	}
}

GER_henschel_organization = {
	include = generic_mobile_tank_organization
	icon = GFX_idea_henschel
	
	allowed = {	
		OR = {
			tag = GER 
			AND = {
				tag = BUL
				has_dlc = "Battle for the Bosporus"
			}
			AND = {
				tag = ETH
				has_dlc = "By Blood Alone"
			}
		}
	}
	
	visible = {
		IF = {
			limit = { FROM = { original_tag = ETH } }
			FROM = { has_completed_focus = ETH_invite_foreign_industrialists }
		}
	}

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

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

GER_man_organization = {
	include = generic_medium_tank_organization
	icon = GFX_idea_GER_MAN
	
	allowed = {	
		OR = {
			tag = GER 
			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 = GER } }
			}
			FROM = { NOT = { has_war_with = GER } }
		}
	}
}

#Benz 
GER_daimler_benz_organization = {
	include = generic_tank_organization
	icon = GFX_idea_generic_tank_manufacturer_2 # TODO change
	
	allowed = {	
		OR = {
			tag = GER 
			AND = {
				tag = BRA
				has_dlc = "Trial of Allegiance"
			}
		}
	}

	available = {
		IF = {
			limit = {
				FROM = { NOT = { original_tag = GER } }
			}
			FROM = { NOT = { has_war_with = GER } }
		}
		IF = {
			limit = {
				FROM = {
					original_tag = BRA
				}
			}
			FROM = {
				has_completed_focus = BRA_german_tanks
			}
		}
	}

	tree_header_text = {
		text = mio_header_tank_construction
		x = 3
	}

	tree_header_text = {
		text = mio_header_equipment_and_specialization
		x = 7
	}

	tree_header_text = {
		text = mio_header_armor
		x = 9
	}
	initial_trait = {
		organization_modifier = {
			military_industrial_organization_research_bonus = 0.05
		}
	}

	add_trait = {  
		token = GER_mio_trait_hotrolled_armor
		name = GER_mio_trait_hotrolled_armor
		icon = GFX_generic_mio_department_icon_tank_general_technology
		special_trait_background = yes

		limit_to_equipment_type = { light_tank_chassis medium_tank_chassis }
		production_bonus = {
			production_efficiency_cap_factor = 0.05
			production_efficiency_gain_factor = 0.05
		}

		position = { x=9 y=0 }  
		ai_will_do = {
			base = 2
			modifier = {
				factor = 1.5
				date > 1937.1.1
			}
		}
	}

	add_trait = {
		token = GER_mio_trait_multilayer_armour
		name = GER_mio_trait_multilayer_armour
		icon = GFX_generic_mio_trait_icon_armor_value
		special_trait_background = yes

		any_parent = { GER_mio_trait_hotrolled_armor }
		limit_to_equipment_type = { light_tank_chassis medium_tank_chassis }
		equipment_bonus = {
			armor_value = 0.1
		} 

		position = { x=9 y=2 }  
		ai_will_do = {
			base = 2
			modifier = {
				factor = 1.5
				date > 1937.1.1
			}
		}
	}
}

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

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

GER_germaniawerft_organization = {
	include = generic_battle_line_ship_organization
	icon = GFX_idea_germaniawerft
	
	allowed = {	
		tag = GER 
	}
}

GER_blohm_und_voss_organization = {
	include = generic_raider_ship_organization
	icon = GFX_idea_blohm_und_voss
	
	allowed = {	
		tag = GER 
	}
}

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

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

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

GER_messerschmitt_organization = {
	include = generic_light_aircraft_organization
	icon = GFX_idea_messerschmitt
	
	allowed = {	
		OR = {
			tag = GER
			NOR_AAT = yes 
		}
	}

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

	add_trait = {
		token = GER_mio_trait_maintenance_first_design
		name = GER_mio_trait_maintenance_first_design

		icon = GFX_generic_mio_department_icon_plane_fighter_line_efficiency
		special_trait_background = yes
		
		position = { x=-2 y=1 }
		relative_position_id = generic_mio_trait_expanded_production_facilities

		all_parents = { generic_mio_trait_expanded_production_facilities }

		equipment_bonus = {
			reliability = 0.05
		}

		production_bonus = {
			production_efficiency_gain_factor = 0.05
		}
	}

	add_trait = {
		token = GER_mio_trait_fuselage_based_weapons
		name = GER_mio_trait_fuselage_based_weapons

		icon = GFX_generic_mio_trait_icon_anti_air_attack
		special_trait_background = yes
		
		position = { x=1 y=1 }
		relative_position_id = generic_mio_trait_gun_pods

		any_parent = { generic_mio_trait_heavier_airframe generic_mio_trait_maximum_wing_loads generic_mio_trait_gun_pods }

		equipment_bonus = {
			air_attack = 0.05
			air_agility = 0.05
		} 
	}
}

GER_junkers_organization = {
	include = generic_cas_aircraft_organization
	icon = GFX_idea_junkers
	
	allowed = {	 
		OR = {
			tag = GER 
			AND = {
				tag = ETH
				has_dlc = "By Blood Alone"
			}
		}
	}
	
	visible = {
		IF = {
			limit = { FROM = { original_tag = ETH } }
			FROM = { has_completed_focus = ETH_invite_foreign_industrialists }
		}
	}

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

		IF = {
			limit = {
				FROM = { NOT  = { original_tag = GER } }
			}
			custom_trigger_tooltip = {
				tooltip = has_invited_mio_tt
				FROM = {
					has_country_flag = has_invited_GER_junkers_organization_flag
				}
			}
		}
	}

	add_trait = {
		token = GER_mio_trait_psychological_warfare
		name = GER_mio_trait_psychological_warfare

		icon = GFX_generic_mio_trait_icon_fuel_consumption
		special_trait_background = yes
		
		position = { x=2 y=0 }
		relative_position_id = generic_mio_trait_reinforced_wings

		equipment_bonus = {
			fuel_consumption = -0.05
		} 
	}
}

GER_focke_wulf_organization = {
	include = generic_multi_role_aircraft_organization
	icon = GFX_idea_focke_wulf
	
	allowed = {	
		tag = GER 
	}
	override_trait = {
		token = generic_mio_trait_hardened_frames
		position = { x=-3 y=1 }
		relative_position_id = generic_mio_trait_light_airframe
	}

	add_trait = {
		token = GER_mio_trait_interceptor
		name = GER_mio_trait_interceptor
		icon = GFX_generic_mio_trait_icon_anti_air_attack
		
		position = { x=2 y=2 }
		
		limit_to_equipment_type = { small_plane_airframe }
		
		any_parent = { generic_mio_trait_light_airframe }
		
		equipment_bonus = {
			air_attack = 0.10
			air_agility = 0.05
			maximum_speed = 0.10
			air_defence = 0.10
			weight = -0.10
			air_range = -0.15
			
		}
	}

	add_trait = {
		token = GER_mio_trait_oversized_propeller_spinner
		name = GER_mio_trait_oversized_propeller_spinner
		icon = GFX_generic_mio_department_icon_plane_general_engine
		
		position = { x=2 y=3 }
		
		limit_to_equipment_type = { small_plane_airframe }
		
		any_parent = { GER_mio_trait_interceptor }
		
		equipment_bonus = {
			maximum_speed = 0.05
			thrust = 0.10
		}
	}

	add_trait = {
		token = GER_mio_trait_pushrod_control_system
		name = GER_mio_trait_pushrod_control_system
		icon = GFX_generic_mio_trait_icon_reliability
		
		position = { x=1 y=3 }
		
		limit_to_equipment_type = { small_plane_airframe }
		
		any_parent = { GER_mio_trait_interceptor }
		
		equipment_bonus = {
			reliability = 0.05
			air_agility = 0.10
			air_defence = 0.05
		}
	}

	add_trait = {
		token = GER_mio_trait_electrically_powered_equipment
		name = GER_mio_trait_electrically_powered_equipment
		icon = GFX_generic_mio_trait_icon_defense
		
		position = { x=0 y=3 }
		
		limit_to_equipment_type = { small_plane_airframe }
		
		any_parent = { GER_mio_trait_interceptor }
		
		equipment_bonus = {
			reliability = 0.05
			air_defence = 0.15
		}
	}
}

GER_heinkel_organization = {
	include = generic_medium_aircraft_organization
	icon = GFX_idea_heinkel
	
	allowed = {	
		OR = {
			tag = GER 
			AND = {
				tag = BUL
				has_dlc = "Battle for the Bosporus"
			}
			NOR_AAT = yes
		}
	}

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

		IF = {
			limit = {
				FROM = { original_tag = BUL }
			}
			custom_trigger_tooltip = {
				tooltip = has_invited_mio_tt
				FROM = {
					has_country_flag = has_invited_heinkel_mio_flag
				}
			}
			FROM = { 
				OR = {
					is_subject = no
					is_subject_of = GER
				}
				#is_in_faction_with = GER
				NOT = { has_completed_focus = BUL_nationalization }
			}
		}
		ELSE_IF = {
			limit = {
				FROM = { original_tag = NOR }
			}
			FROM = { has_completed_focus = NOR_invite_german_engineers }
		}
	}
}

GER_dornier_organization = {
	include = generic_naval_aircraft_organization
	icon = GFX_idea_dornier
	
	allowed = {	
		tag = GER 
	}
}


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

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


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

GER_rheinmetall_organization = {
	include = generic_artillery_organization
	icon = GFX_idea_rheinmetall
	
	allowed = {	
		OR = {
			tag = GER 
			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 = GER } }
			}
			FROM = { NOT = { has_war_with = GER } }
		}
	}
}

GER_mauser_organization = {
	include = generic_infantry_equipment_organization
	icon = GFX_idea_mauser
	
	allowed = {	 
		OR = {
			tag = GER 
			AND = {
				tag = ETH
				has_dlc = "By Blood Alone"
			}
		}
	}
	
	visible = {
		IF = {
			limit = { FROM = { original_tag = ETH } }
			FROM = { has_completed_focus = ETH_invite_foreign_industrialists }
		}
	}
	
	available = {
		# When in a Foreign MIO, countries need to be at peace with original country
		IF = {
			limit = {
				FROM = { NOT = { original_tag = GER } }
			}
			FROM = { NOT = { has_war_with = GER } }
		}

		IF = {
			limit = {
				FROM = { NOT  = { original_tag = GER } }
			}
			custom_trigger_tooltip = {
				tooltip = has_invited_mio_tt
				FROM = {
					has_country_flag = has_invited_GER_mauser_organization_flag
				}
			}
		}
	}
}

GER_opel_organization = {
	include = generic_motorized_mechanized_organization
	icon = GFX_idea_opel
	
	allowed = {	
		OR = {
			tag = GER
			AND = {
				tag = ROM
				has_dlc = "Death or Dishonor"
			}
			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 = GER } }
			}
			FROM = { NOT = { has_war_with = GER } }
		}

		IF = {
			limit = { FROM = { original_tag = BUL } }
			custom_trigger_tooltip = {
				tooltip = has_invited_mio_tt
				FROM = {
					has_country_flag = has_invited_opel_mio_flag
				}
			}
			FROM = { 
				OR = {
					is_subject = no
					is_subject_of = GER
				}
				#is_in_faction_with = GER
				NOT = { has_completed_focus = BUL_nationalization }
			}
		}
		IF = {
			limit = { FROM = { original_tag = ROM } }
			FROM = { has_country_flag = GER_mot_chosen }
		}	
	}
}