###HoI4 AI Unit Production Limiter###
### https://gitlab.com/coop-mods/Shared-Resources/tree/master/Scripts%20and%20Code/AI%20Unit%20Limiter
###------------------------------
###Originally made by GunnarVonPontius
###Adapted to variables by Yard1
###------------------------------
###Limits the amount of divisions an AI country has to the number of factories (civ, mil, nav) it has
###If your mod adds new unit types, make sure to add them in as well

division_limiter = {
	enable = {
		set_temp_variable = {
			upper_limit = num_of_factories
		}
		multiply_temp_variable = {
			upper_limit = 1.15
		}
		if = {
			limit = {
				has_war = yes
			}
			multiply_temp_variable = {
				upper_limit = 1.2
			}
		}
		if = {
			limit = {
				is_major = yes
			}
			multiply_temp_variable = {
				upper_limit = 1.15
			}
		}
		if = {
			limit = {
				threat > 0.75
			}
			multiply_temp_variable = {
				upper_limit = 1.05
			}
		}
		check_variable = {
			num_divisions > upper_limit
		}
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = build_army
		id = cavalry
		value = -300
	}

	ai_strategy = {
		type = build_army
		id = camelry
		value = -300
	}

	ai_strategy = {
		type = build_army
		id = motorized
		value = -300
	}

	ai_strategy = {
		type = build_army
		id = armored_car
		value = -300
	}

	ai_strategy = {
		type = build_army
		id = mechanized
		value = -300
	}

	ai_strategy = {
		type = build_army
		id = garrison
		value = -300
	}

	ai_strategy = {
		type = build_army
		id = suppression
		value = -300
	}

	ai_strategy = {
		type = build_army
		id = paratroopers
		value = -300
	}

	ai_strategy = {
		type = build_army
		id = mountaineers
		value = -300
	}

	ai_strategy = {
		type = build_army
		id = marines
		value = -300
	}

	ai_strategy = {
		type = build_army
		id = armor
		value = -300
	}

	ai_strategy = {
		type = build_army
		id = light_armor
		value = -300
	}

	ai_strategy = {
		type = build_army
		id = heavy_armor
		value = -300
	}

	ai_strategy = {
		type = build_army
		id = medium_armor
		value = -300
	}

	ai_strategy = {
		type = build_army
		id = modern_armor
		value = -300
	}

	ai_strategy = {
		type = build_army
		id = infantry
		value = -300
	}

}