mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 14:24:43 -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> {
|
): ArrayList<AttackableTile> {
|
||||||
val tilesWithEnemies = (tilesToCheck ?: unit.civInfo.viewableTiles)
|
val tilesWithEnemies = (tilesToCheck ?: unit.civInfo.viewableTiles)
|
||||||
.filter { containsAttackableEnemy(it, MapUnitCombatant(unit)) }
|
.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.
|
// 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()
|
unit.baseUnit.isMelee() && mapCombatant is MapUnitCombatant && mapCombatant.unit.isCivilian()
|
||||||
// If we can't pass though that tile, we can't capture the civilian "remotely"
|
// 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()
|
val rangeOfAttack = unit.getRange()
|
||||||
|
@ -723,36 +723,27 @@ object UnitActions {
|
|||||||
|
|
||||||
if (isDamaged && !showingAdditionalActions && unit.rankTileForHealing(unit.currentTile) != 0)
|
if (isDamaged && !showingAdditionalActions && unit.rankTileForHealing(unit.currentTile) != 0)
|
||||||
actionList += UnitAction(UnitActionType.FortifyUntilHealed,
|
actionList += UnitAction(UnitActionType.FortifyUntilHealed,
|
||||||
action = {
|
action = { unit.fortifyUntilHealed() }.takeIf { !unit.isFortifyingUntilHealed() })
|
||||||
unit.fortifyUntilHealed()
|
|
||||||
}.takeIf { !unit.isFortifyingUntilHealed() }
|
|
||||||
)
|
|
||||||
else if (isDamaged || !showingAdditionalActions)
|
else if (isDamaged || !showingAdditionalActions)
|
||||||
actionList += UnitAction(UnitActionType.Fortify,
|
actionList += UnitAction(UnitActionType.Fortify,
|
||||||
action = {
|
action = { unit.fortify() }.takeIf { !isFortified })
|
||||||
unit.fortify()
|
|
||||||
}.takeIf { !isFortified }
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addSleepActions(actionList: ArrayList<UnitAction>, unit: MapUnit, showingAdditionalActions: Boolean) {
|
private fun addSleepActions(actionList: ArrayList<UnitAction>, unit: MapUnit, showingAdditionalActions: Boolean) {
|
||||||
if (unit.isFortified() || unit.canFortify() || unit.currentMovement == 0f) return
|
if (unit.isFortified() || unit.canFortify() || unit.currentMovement == 0f) return
|
||||||
// If this unit is working on an improvement, it cannot sleep
|
// 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 isSleeping = unit.isSleeping()
|
||||||
val isDamaged = unit.health < 100
|
val isDamaged = unit.health < 100
|
||||||
|
|
||||||
if (isDamaged && !showingAdditionalActions) {
|
if (isDamaged && !showingAdditionalActions) {
|
||||||
actionList += UnitAction(UnitActionType.SleepUntilHealed,
|
actionList += UnitAction(UnitActionType.SleepUntilHealed,
|
||||||
action = {
|
action = { unit.action = UnitActionType.SleepUntilHealed.value }
|
||||||
unit.action = UnitActionType.SleepUntilHealed.value
|
.takeIf { !unit.isSleepingUntilHealed() }
|
||||||
}.takeIf { !unit.isSleepingUntilHealed() }
|
|
||||||
)
|
)
|
||||||
} else if (isDamaged || !showingAdditionalActions) {
|
} else if (isDamaged || !showingAdditionalActions) {
|
||||||
actionList += UnitAction(UnitActionType.Sleep,
|
actionList += UnitAction(UnitActionType.Sleep,
|
||||||
action = {
|
action = { unit.action = UnitActionType.Sleep.value }.takeIf { !isSleeping }
|
||||||
unit.action = UnitActionType.Sleep.value
|
|
||||||
}.takeIf { !isSleeping }
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -792,16 +783,16 @@ object UnitActions {
|
|||||||
val giftAction = {
|
val giftAction = {
|
||||||
if (recipient.isCityState()) {
|
if (recipient.isCityState()) {
|
||||||
for (unique in unit.civInfo.getMatchingUniques("Gain [] Influence with a [] gift to a City-State")) {
|
for (unique in unit.civInfo.getMatchingUniques("Gain [] Influence with a [] gift to a City-State")) {
|
||||||
if (unit.matchesFilter(unique.params[1])
|
if (unit.matchesFilter(unique.params[1])) {
|
||||||
) {
|
recipient.getDiplomacyManager(unit.civInfo)
|
||||||
recipient.getDiplomacyManager(unit.civInfo).addInfluence(unique.params[0].toFloat() - 5f)
|
.addInfluence(unique.params[0].toFloat() - 5f)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
recipient.getDiplomacyManager(unit.civInfo).addInfluence(5f)
|
recipient.getDiplomacyManager(unit.civInfo).addInfluence(5f)
|
||||||
}
|
} else recipient.getDiplomacyManager(unit.civInfo)
|
||||||
else recipient.getDiplomacyManager(unit.civInfo).addModifier(DiplomaticModifiers.GaveUsUnits, 5f)
|
.addModifier(DiplomaticModifiers.GaveUsUnits, 5f)
|
||||||
|
|
||||||
if (recipient.isCityState() && unit.isGreatPerson())
|
if (recipient.isCityState() && unit.isGreatPerson())
|
||||||
unit.destroy() // City states dont get GPs
|
unit.destroy() // City states dont get GPs
|
||||||
@ -815,7 +806,8 @@ object UnitActions {
|
|||||||
|
|
||||||
private fun addToggleActionsAction(unit: MapUnit, actionList: ArrayList<UnitAction>, unitTable: UnitTable) {
|
private fun addToggleActionsAction(unit: MapUnit, actionList: ArrayList<UnitAction>, unitTable: UnitTable) {
|
||||||
actionList += UnitAction(
|
actionList += UnitAction(
|
||||||
type = if (unit.showAdditionalActions) UnitActionType.HideAdditionalActions else UnitActionType.ShowAdditionalActions,
|
type = if (unit.showAdditionalActions) UnitActionType.HideAdditionalActions
|
||||||
|
else UnitActionType.ShowAdditionalActions,
|
||||||
action = {
|
action = {
|
||||||
unit.showAdditionalActions = !unit.showAdditionalActions
|
unit.showAdditionalActions = !unit.showAdditionalActions
|
||||||
unitTable.update()
|
unitTable.update()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user