mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-29 06:51:30 -04:00
Retreat chance is savescum-safe - #9178
This commit is contained in:
parent
ebfda6ffc0
commit
f98f4e8c9b
@ -1097,7 +1097,9 @@ object Battle {
|
|||||||
val percentChance = baseWithdrawChance - max(0, (attackBaseUnit.movement-2)) * 20 -
|
val percentChance = baseWithdrawChance - max(0, (attackBaseUnit.movement-2)) * 20 -
|
||||||
fromTile.neighbors.filterNot { it == attTile || it in attTile.neighbors }.count { canNotWithdrawTo(it) } * 20
|
fromTile.neighbors.filterNot { it == attTile || it in attTile.neighbors }.count { canNotWithdrawTo(it) } * 20
|
||||||
// Get a random number in [0,100) : if the number <= percentChance, defender will withdraw from melee
|
// Get a random number in [0,100) : if the number <= percentChance, defender will withdraw from melee
|
||||||
if (Random().nextInt(100) > percentChance) return false
|
if (Random( // 'randomness' is consistent for turn and tile, to avoid save-scumming
|
||||||
|
(attacker.getCivInfo().gameInfo.turns * defender.getTile().hashCode()).toLong()
|
||||||
|
).nextInt(100) > percentChance) return false
|
||||||
val firstCandidateTiles = fromTile.neighbors.filterNot { it == attTile || it in attTile.neighbors }
|
val firstCandidateTiles = fromTile.neighbors.filterNot { it == attTile || it in attTile.neighbors }
|
||||||
.filterNot { canNotWithdrawTo(it) }
|
.filterNot { canNotWithdrawTo(it) }
|
||||||
val secondCandidateTiles = fromTile.neighbors.filter { it in attTile.neighbors }
|
val secondCandidateTiles = fromTile.neighbors.filter { it in attTile.neighbors }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user