mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 13:55:54 -04:00
Solved bug that made civilian units uncapturable
This commit is contained in:
parent
31639aac9f
commit
0088ddd18b
@ -39,11 +39,14 @@ object BattleHelper {
|
||||
): ArrayList<AttackableTile> {
|
||||
val tilesWithEnemies = (tilesToCheck ?: unit.civInfo.viewableTiles)
|
||||
.filter { containsAttackableEnemy(it, MapUnitCombatant(unit)) }
|
||||
.filterNot { val mapCombatant = Battle.getMapCombatantOfTile(it)
|
||||
.filterNot {
|
||||
val mapCombatant = Battle.getMapCombatantOfTile(it)
|
||||
// IF all of these are true, THEN the action we'll be taking is in fact CAPTURING the civilian.
|
||||
unit.baseUnit.isMelee() && mapCombatant is MapUnitCombatant && mapCombatant.unit.isCivilian()
|
||||
// If we can't pass though that tile, we can't capture the civilian "remotely"
|
||||
&& !unit.movement.canPassThrough(it)
|
||||
// DO NOT use "!unit.movement.canPassThrough(it)" since then we won't be able to
|
||||
// capture enemy units since we can't move through them!
|
||||
&& !it.canCivPassThrough(unit.civInfo)
|
||||
}
|
||||
|
||||
val rangeOfAttack = unit.getRange()
|
||||
|
@ -723,36 +723,27 @@ object UnitActions {
|
||||
|
||||
if (isDamaged && !showingAdditionalActions && unit.rankTileForHealing(unit.currentTile) != 0)
|
||||
actionList += UnitAction(UnitActionType.FortifyUntilHealed,
|
||||
action = {
|
||||
unit.fortifyUntilHealed()
|
||||
}.takeIf { !unit.isFortifyingUntilHealed() }
|
||||
)
|
||||
action = { unit.fortifyUntilHealed() }.takeIf { !unit.isFortifyingUntilHealed() })
|
||||
else if (isDamaged || !showingAdditionalActions)
|
||||
actionList += UnitAction(UnitActionType.Fortify,
|
||||
action = {
|
||||
unit.fortify()
|
||||
}.takeIf { !isFortified }
|
||||
)
|
||||
action = { unit.fortify() }.takeIf { !isFortified })
|
||||
}
|
||||
|
||||
private fun addSleepActions(actionList: ArrayList<UnitAction>, unit: MapUnit, showingAdditionalActions: Boolean) {
|
||||
if (unit.isFortified() || unit.canFortify() || unit.currentMovement == 0f) return
|
||||
// If this unit is working on an improvement, it cannot sleep
|
||||
if ((unit.currentTile.hasImprovementInProgress() && unit.canBuildImprovement(unit.currentTile.getTileImprovementInProgress()!!))) return
|
||||
if (unit.currentTile.hasImprovementInProgress() && unit.canBuildImprovement(unit.currentTile.getTileImprovementInProgress()!!)) return
|
||||
val isSleeping = unit.isSleeping()
|
||||
val isDamaged = unit.health < 100
|
||||
|
||||
if (isDamaged && !showingAdditionalActions) {
|
||||
actionList += UnitAction(UnitActionType.SleepUntilHealed,
|
||||
action = {
|
||||
unit.action = UnitActionType.SleepUntilHealed.value
|
||||
}.takeIf { !unit.isSleepingUntilHealed() }
|
||||
action = { unit.action = UnitActionType.SleepUntilHealed.value }
|
||||
.takeIf { !unit.isSleepingUntilHealed() }
|
||||
)
|
||||
} else if (isDamaged || !showingAdditionalActions) {
|
||||
actionList += UnitAction(UnitActionType.Sleep,
|
||||
action = {
|
||||
unit.action = UnitActionType.Sleep.value
|
||||
}.takeIf { !isSleeping }
|
||||
action = { unit.action = UnitActionType.Sleep.value }.takeIf { !isSleeping }
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -792,16 +783,16 @@ object UnitActions {
|
||||
val giftAction = {
|
||||
if (recipient.isCityState()) {
|
||||
for (unique in unit.civInfo.getMatchingUniques("Gain [] Influence with a [] gift to a City-State")) {
|
||||
if (unit.matchesFilter(unique.params[1])
|
||||
) {
|
||||
recipient.getDiplomacyManager(unit.civInfo).addInfluence(unique.params[0].toFloat() - 5f)
|
||||
if (unit.matchesFilter(unique.params[1])) {
|
||||
recipient.getDiplomacyManager(unit.civInfo)
|
||||
.addInfluence(unique.params[0].toFloat() - 5f)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
recipient.getDiplomacyManager(unit.civInfo).addInfluence(5f)
|
||||
}
|
||||
else recipient.getDiplomacyManager(unit.civInfo).addModifier(DiplomaticModifiers.GaveUsUnits, 5f)
|
||||
} else recipient.getDiplomacyManager(unit.civInfo)
|
||||
.addModifier(DiplomaticModifiers.GaveUsUnits, 5f)
|
||||
|
||||
if (recipient.isCityState() && unit.isGreatPerson())
|
||||
unit.destroy() // City states dont get GPs
|
||||
@ -815,7 +806,8 @@ object UnitActions {
|
||||
|
||||
private fun addToggleActionsAction(unit: MapUnit, actionList: ArrayList<UnitAction>, unitTable: UnitTable) {
|
||||
actionList += UnitAction(
|
||||
type = if (unit.showAdditionalActions) UnitActionType.HideAdditionalActions else UnitActionType.ShowAdditionalActions,
|
||||
type = if (unit.showAdditionalActions) UnitActionType.HideAdditionalActions
|
||||
else UnitActionType.ShowAdditionalActions,
|
||||
action = {
|
||||
unit.showAdditionalActions = !unit.showAdditionalActions
|
||||
unitTable.update()
|
||||
|
Loading…
x
Reference in New Issue
Block a user