From e5b4793d5882a7c01e248ce3f7d99f1dc7dbb9c9 Mon Sep 17 00:00:00 2001 From: yairm210 Date: Sun, 13 Oct 2024 22:56:23 +0300 Subject: [PATCH] AI: Better rules to not build unit-carrying units --- core/src/com/unciv/logic/automation/Automation.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/src/com/unciv/logic/automation/Automation.kt b/core/src/com/unciv/logic/automation/Automation.kt index 88da18ccf2..9ef4c37a0e 100644 --- a/core/src/com/unciv/logic/automation/Automation.kt +++ b/core/src/com/unciv/logic/automation/Automation.kt @@ -159,7 +159,9 @@ object Automation { val totalCarriableUnits = civInfo.units.getCivUnits().count { it.matchesFilter(carryFilter) } val totalCarryingSlots = civInfo.units.getCivUnits().sumOf { getCarryAmount(it) } - return totalCarriableUnits < totalCarryingSlots + val currentUnitCarryingSlots = carryUnique.params[0].toInt() + + return totalCarriableUnits < totalCarryingSlots + currentUnitCarryingSlots } fun chooseMilitaryUnit(city: City, availableUnits: Sequence): String? { @@ -197,7 +199,7 @@ object Automation { .filter { allowSpendingResource(city.civ, it) } .filterNot { // filter out carrier-type units that can't attack if we don't need them - (it.hasUnique(UniqueType.CarryAirUnits) && it.hasUnique(UniqueType.CannotAttack)) + it.hasUnique(UniqueType.CarryAirUnits) && providesUnneededCarryingSlots(it, city.civ) } // Only now do we filter out the constructable units because that's a heavier check