From 50a8ff3ce022bfd82059155a378e3ef63fdda3d9 Mon Sep 17 00:00:00 2001 From: OptimizedForDensity <105244635+OptimizedForDensity@users.noreply.github.com> Date: Fri, 24 Jun 2022 08:05:49 -0400 Subject: [PATCH] Fix crash when melee unit captures civilian then tries to attack it (#7282) --- core/src/com/unciv/logic/battle/Battle.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/src/com/unciv/logic/battle/Battle.kt b/core/src/com/unciv/logic/battle/Battle.kt index c0e5da85e7..92bfdac83c 100644 --- a/core/src/com/unciv/logic/battle/Battle.kt +++ b/core/src/com/unciv/logic/battle/Battle.kt @@ -58,6 +58,10 @@ object Battle { * but the hidden tile is actually IMPASSIBLE so you stop halfway! */ if (attacker.getTile() != attackableTile.tileToAttackFrom) return false + /** Rarely, a melee unit will target a civilian then move through the civilian to get + * to attackableTile.tileToAttackFrom, meaning that they take the civilian. This check stops + * the melee unit from trying to capture their own unit if this happens */ + if (getMapCombatantOfTile(attackableTile.tileToAttack)!!.getCivInfo() == attacker.getCivInfo()) return false /** Alternatively, maybe we DID reach that tile, but it turned out to be a hill or something, * so we expended all of our movement points! */