From e6fc6a611884e5b89b767579ccd8aa91249e84ae Mon Sep 17 00:00:00 2001 From: EmperorPinguin <99119424+EmperorPinguin@users.noreply.github.com> Date: Tue, 31 Dec 2024 13:52:21 +0100 Subject: [PATCH 1/3] Update UnitAutomation.kt --- .../com/unciv/logic/automation/unit/UnitAutomation.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/src/com/unciv/logic/automation/unit/UnitAutomation.kt b/core/src/com/unciv/logic/automation/unit/UnitAutomation.kt index 2a32ddde261ce..4b786b8795abc 100644 --- a/core/src/com/unciv/logic/automation/unit/UnitAutomation.kt +++ b/core/src/com/unciv/logic/automation/unit/UnitAutomation.kt @@ -181,7 +181,9 @@ object UnitAutomation { // Restrict Human automated units from promotions via setting (UncivGame.Current.settings.automatedUnitsChoosePromotions || unit.civ.isAI())) { val availablePromotions = unit.promotions.getAvailablePromotions() - .filterNot { it.hasUnique(UniqueType.SkipPromotion) } + if (unit.health < 60 && !(unit.baseUnit.isAirUnit() || unit.baseUnit.hasUnique(UniqueType.CanMoveAfterAttacking))) + availablePromotions.filter { it.hasUnique(UniqueType.OneTimeUnitHeal) } //choose healing promotions only when beneficial + else availablePromotions.filterNot { it.hasUnique(UniqueType.SkipPromotion) } if (availablePromotions.none()) break val freePromotions = availablePromotions.filter { it.hasUnique(UniqueType.FreePromotion) }.toList() val stateForConditionals = unit.cache.state @@ -192,6 +194,13 @@ object UnitAutomation { unit.promotions.addPromotion(chosenPromotion.name) } + //This allows for military units with certain civilian abilities to behave as civilians in peace and soldiers in war + if ((unit.hasUnique(UniqueType.BuildImprovements) || unit.hasUnique(UniqueType.FoundCity) || + unit.hasUnique(UniqueType.ReligiousUnit) || unit.hasUnique(UniqueType.CreateWaterImprovements)) + && !unit.civ.isAtWar()){ + CivilianUnitAutomation.automateCivilianUnit(unit, getDangerousTiles(unit)) + return + } //This allows for military units with certain civilian abilities to behave as civilians in peace and soldiers in war if ((unit.hasUnique(UniqueType.BuildImprovements) || unit.hasUnique(UniqueType.FoundCity) || unit.hasUnique(UniqueType.ReligiousUnit) || unit.hasUnique(UniqueType.CreateWaterImprovements)) From d813920b9828b88bd8179472937fd6dbcbade8de Mon Sep 17 00:00:00 2001 From: EmperorPinguin <99119424+EmperorPinguin@users.noreply.github.com> Date: Tue, 31 Dec 2024 13:53:51 +0100 Subject: [PATCH 2/3] Update UnitAutomation.kt --- core/src/com/unciv/logic/automation/unit/UnitAutomation.kt | 7 ------- 1 file changed, 7 deletions(-) diff --git a/core/src/com/unciv/logic/automation/unit/UnitAutomation.kt b/core/src/com/unciv/logic/automation/unit/UnitAutomation.kt index 4b786b8795abc..db08cb7015ba4 100644 --- a/core/src/com/unciv/logic/automation/unit/UnitAutomation.kt +++ b/core/src/com/unciv/logic/automation/unit/UnitAutomation.kt @@ -194,13 +194,6 @@ object UnitAutomation { unit.promotions.addPromotion(chosenPromotion.name) } - //This allows for military units with certain civilian abilities to behave as civilians in peace and soldiers in war - if ((unit.hasUnique(UniqueType.BuildImprovements) || unit.hasUnique(UniqueType.FoundCity) || - unit.hasUnique(UniqueType.ReligiousUnit) || unit.hasUnique(UniqueType.CreateWaterImprovements)) - && !unit.civ.isAtWar()){ - CivilianUnitAutomation.automateCivilianUnit(unit, getDangerousTiles(unit)) - return - } //This allows for military units with certain civilian abilities to behave as civilians in peace and soldiers in war if ((unit.hasUnique(UniqueType.BuildImprovements) || unit.hasUnique(UniqueType.FoundCity) || unit.hasUnique(UniqueType.ReligiousUnit) || unit.hasUnique(UniqueType.CreateWaterImprovements)) From 845d176d94bdd4475c3563a8b43bddc33ae94298 Mon Sep 17 00:00:00 2001 From: EmperorPinguin <99119424+EmperorPinguin@users.noreply.github.com> Date: Tue, 31 Dec 2024 15:51:12 +0100 Subject: [PATCH 3/3] Update UnitAutomation.kt --- core/src/com/unciv/logic/automation/unit/UnitAutomation.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/com/unciv/logic/automation/unit/UnitAutomation.kt b/core/src/com/unciv/logic/automation/unit/UnitAutomation.kt index db08cb7015ba4..641fdfb9bf7d9 100644 --- a/core/src/com/unciv/logic/automation/unit/UnitAutomation.kt +++ b/core/src/com/unciv/logic/automation/unit/UnitAutomation.kt @@ -181,7 +181,7 @@ object UnitAutomation { // Restrict Human automated units from promotions via setting (UncivGame.Current.settings.automatedUnitsChoosePromotions || unit.civ.isAI())) { val availablePromotions = unit.promotions.getAvailablePromotions() - if (unit.health < 60 && !(unit.baseUnit.isAirUnit() || unit.baseUnit.hasUnique(UniqueType.CanMoveAfterAttacking))) + if (unit.health < 60 && !(unit.baseUnit.isAirUnit() || unit.baseUnit.hasUnique(UniqueType.CanMoveAfterAttacking)) && availablePromotions.any { it.hasUnique(UniqueType.OneTimeUnitHeal) }) availablePromotions.filter { it.hasUnique(UniqueType.OneTimeUnitHeal) } //choose healing promotions only when beneficial else availablePromotions.filterNot { it.hasUnique(UniqueType.SkipPromotion) } if (availablePromotions.none()) break