armored_SOV = {

	available_for = {
		SOV
	}

	role = armor

	upgrade_prio = {
		factor = 2.17

		modifier = {
			factor = 7
			OR = {
				has_tech = basic_medium_tank
				has_tech = basic_medium_tank_chassis
			}
		}

		modifier = {
			factor = 2
			OR = {
				has_tech = main_battle_tank
				has_tech = main_battle_tank_chassis
			}
		}
	}

	light_armor_default_SOV = {

		upgrade_prio = {
			factor = 2

			modifier = {
				factor = 2
			}
		}

		can_upgrade_in_field = {
			has_equipment = { light_tank_chassis < 500 }
		}

		target_template = {

			support = {
				engineer = 1
				mot_recon = 1
				artillery = 1
			}

			regiments = {
				light_armor = 6
				motorized = 3
			}
		}


		replace_at_match = 0.4
		replace_with = medium_armor_default_SOV
		target_min_match = 0.5
	}


	heavy_armor_default_SOV = {

		upgrade_prio = {
			factor = 2

			modifier = {
				factor = 1.1
			}
		}


		target_template = {
			support = {
				engineer = 1
				mot_recon = 1
				logistics_company = 1
				maintenance_company = 1
			}

			regiments = {
				heavy_armor = 6
				infantry = 3
			}
		}

		replace_at_match = 0.4
		replace_with = modern_armor_default_SOV
		target_min_match = 0.5
	}

	medium_armor_default_SOV = {

		upgrade_prio = {
			factor = 2

			modifier = {
				factor = 10
				OR = {
					has_tech = basic_medium_tank
					has_tech = basic_medium_tank_chassis
				}
				NOT = {
					has_tech = main_battle_tank
				}
				NOT = { has_tech = main_battle_tank_chassis }
			}
		}

		target_template = {
			support = {
				engineer = 1
				mot_recon = 1
				maintenance_company = 1
				logistics_company = 1
			}

			regiments = {
				medium_armor = 4
				motorized = 4
				mot_artillery_brigade = 1
			}
		}

		replace_at_match = 0.7
		replace_with = medium_armor_2_SOV
		target_min_match = 0.5
	}

	medium_armor_2_SOV = {

		upgrade_prio = {
			factor = 2

			modifier = {
				factor = 10
				OR = {
					has_tech = improved_medium_tank
					has_tech = improved_medium_tank_chassis
				}
				has_tech = armored_car1
				NOT = {
					has_tech = main_battle_tank
					has_tech = main_battle_tank_chassis
				}
			}
		}

		target_template = {

			support = {
				engineer = 1
				armored_car_recon = 1
				maintenance_company = 1
				logistics_company = 1
			}

			regiments = {
				medium_armor = 4
				motorized = 4
				mot_artillery_brigade = 1
			}
		}

		replace_at_match = 0.7
		replace_with = modern_armor_default_SOV
		target_min_match = 0.5
	}


	modern_armor_default_SOV = {

		upgrade_prio = {
			factor = 2

			modifier = {
				factor = 3
				OR = {
					has_tech = main_battle_tank
					has_tech = main_battle_tank_chassis
				}
			}
		}

		target_template = {

			support = {
				engineer = 1
				mot_recon = 1
				maintenance_company = 1
				logistics_company = 1
			}

			regiments = {
				modern_armor = 4
				mechanized = 4
				medium_sp_artillery_brigade = 2
			}
		}
	}
}

infantry_SOV = {

	available_for = {
		SOV
	}

	role = infantry

	upgrade_prio = {
		factor = 2

		modifier = {
			factor = 5
		}
	}

	infantry_default_SOV = {

		upgrade_prio = {
			factor = 2

			modifier = {
				factor = 20
			}
		}

		target_template = {
			support = {
				engineer = 1
				anti_tank = 1
			}

			regiments = {
				infantry = 9
				artillery_brigade = 2
			}
		}

		replace_at_match = 0.9
		replace_with = infantry_improved_SOV
		target_min_match = 0.8
	}

	infantry_improved_SOV = {

		upgrade_prio = {
			factor = 2

			modifier = {
				factor = 0
				has_war = no
				date < 1940.1.1
			}

			modifier = {
				factor = 20
				has_war = yes
				date > 1940.1.1
			}
		}

		can_upgrade_in_field = {
			has_equipment = {artillery_equipment > 1000}
		}

		target_template = {

			support = {
				engineer = 1
				anti_tank = 1
				anti_air = 1
			}

			regiments = {
				infantry = 9
				artillery_brigade = 3
			}
		}
	}
}

mountaineers_SOV = {

	available_for = {
		SOV
	}

	role = mountaineers

	upgrade_prio = {
		factor = 2

		modifier = {
			factor = 0
			NOT = {
				has_tech = tech_mountaineers
			}
		}
	}

	mountaineers_default_SOV = {

		upgrade_prio = {
			factor = 2

			modifier = {
				factor = 1
			}
		}


		target_template = {
			support = {
				engineer = 1
				artillery = 1
				anti_tank = 1
				logistics_company = 1
			}

			regiments = {
				mountaineers = 8
				artillery_brigade = 2
			}
		}
	}
}

marines_SOV = {

	available_for = {
		SOV
	}

	role = marines

	upgrade_prio = {
		factor = 2

		modifier = {
			factor = 0
			NOT = {
				has_tech = marines
			}
		}
	}

	marine_default_SOV = {

		upgrade_prio = {
			factor = 2

			modifier = {
				factor = 1
			}
		}

		target_template = {

			support = {
				recon = 1
				logistics_company = 1
			}

			regiments = {
				marine = 9
			}
		}
	}
}

paratroopers_SOV = {

	available_for = {
		SOV
	}

	role = paratroopers

	upgrade_prio = {
		factor = 2

		modifier = {
			factor = 0
			NOT = {
				has_tech = paratroopers
			}
		}
	}

	paratrooper_default_SOV = {

		upgrade_prio = {
			factor = 2

			modifier = {
				factor = 1
			}
		}


		target_template = {
			support = {
				engineer = 1
				artillery = 1
				anti_tank = 1
			}

			regiments = {
				paratrooper= 5
			}
		}
	}
}


garrison_SOV = {

	available_for = {
		SOV
	}

	role = garrison

	upgrade_prio = {
		factor = 80

		modifier = {
			factor = 0
			ai_has_role_template = garrison
		}
	}

	garrison_SOV = {

		upgrade_prio = {
			factor = 1

			modifier = {
				factor = 15
			}
		}

		reinforce_prio = 0
		custom_icon = 7

		target_template = {
			support = {
				military_police = 1
			}

			regiments = {
				cavalry = 4
			}
		}
	}
}


anti_armor_SOV = {

	available_for = {
		SOV
	}

	role = motorized

	upgrade_prio = {
		factor = 2

		modifier = {
			factor = 30
			#has_war_with = GER
			any_enemy_country = {
				ROOT = {
					estimated_intel_max_armor = {
						tag = PREV
						value > 20
					}
				}
			}
		}
	}

	infantry_anti_armor_SOV = {

		upgrade_prio = {
			factor = 1

			modifier = {
				factor = 3
				has_tech = interwar_antitank
				#has_war_with = GER
				any_enemy_country = {
					ROOT = {
						estimated_intel_max_armor = {
							tag = PREV
							value > 20
						}
					}
				}
			}
		}

		target_template = {
			support = {
				engineer = 1
				mot_recon = 1
			}

			regiments = {
				motorized = 6
				mot_artillery_brigade = 1
				mot_anti_tank_brigade = 1
			}
		}
	}

	light_armor_anti_amor_SOV = {

		upgrade_prio = {
			factor = 1

			modifier = {
				factor = 5
				if = {
					limit = {
						NOT = { has_dlc = "No Step Back" }
					}
					has_tech = basic_light_td
				}
				#has_war_with = GER
				any_enemy_country = {
					ROOT = {
						estimated_intel_max_armor = {
							tag = PREV
							value > 27
						}
					}
				}
			}
		}

		target_template = {

			support = {
				engineer = 1
				recon = 1
				anti_tank = 1
			}

			regiments = {
				light_tank_destroyer_brigade = 1
				motorized = 6
				mot_artillery_brigade = 1
			}
		}

		replace_at_match = 0.4
		replace_with = medium_armor_anti_armor_SOV
		target_min_match = 0.5
	}

	medium_armor_anti_armor_SOV = {

		upgrade_prio = {
			factor = 2

			modifier = {
				factor = 60
				if = {
					limit = {
						NOT = { has_dlc = "No Step Back" }
					}
					has_tech = basic_medium_td
				}
				#has_war_with = GER
				any_enemy_country = {
					ROOT = {
						estimated_intel_max_armor = {
							tag = PREV
							value > 35
						}
					}
				}
			}
		}

		target_template = {

			support = {
				engineer = 1
				recon = 1
				maintenance_company = 1
				logistics_company = 1
				anti_tank = 1
			}

			regiments = {
				medium_tank_destroyer_brigade = 1
				mechanized = 6
				mot_artillery_brigade = 1
			}
		}
	}
}