mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-21 13:18:56 +07:00
Added a unique for destroying improvements on attack (#7605)
* Added a unique to destroy improvements on attack * Removed last part of unique, as we have the `in [tileFilter] tiles` conditional
This commit is contained in:
@ -160,6 +160,7 @@ object Battle {
|
||||
attacker.unit.destroy()
|
||||
else if (attacker.unit.isMoving())
|
||||
attacker.unit.action = null
|
||||
doDestroyImprovementsAbility(attacker, attackedTile, defender)
|
||||
}
|
||||
|
||||
// Should be called after tryCaptureUnit(), as that might spawn a unit on the tile we go to
|
||||
@ -201,6 +202,7 @@ object Battle {
|
||||
if (defeatedUnitYieldSourceType == "Cost") unitCost else unitStr
|
||||
val yieldAmount = (yieldTypeSourceAmount * yieldPercent).toInt()
|
||||
|
||||
// This should be unnecessary as we check this for uniques when reading them in
|
||||
try {
|
||||
val stat = Stat.valueOf(unique.params[3])
|
||||
civUnit.getCivInfo().addStat(stat, yieldAmount)
|
||||
@ -1076,4 +1078,13 @@ object Battle {
|
||||
return true
|
||||
}
|
||||
|
||||
private fun doDestroyImprovementsAbility(attacker: MapUnitCombatant, attackedTile: TileInfo, defender: ICombatant) {
|
||||
val conditionalState = StateForConditionals(attacker.getCivInfo(), ourCombatant = attacker, theirCombatant = defender, combatAction = CombatAction.Attack, attackedTile = attackedTile)
|
||||
if (attackedTile.improvement != Constants.barbarianEncampment
|
||||
&& attackedTile.getTileImprovement()?.isAncientRuinsEquivalent() != true
|
||||
&& attacker.hasUnique(UniqueType.DestroysImprovementUponAttack, conditionalState)
|
||||
) {
|
||||
attackedTile.improvement = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -435,7 +435,6 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
||||
|
||||
UnitMaintenanceDiscount("[relativeAmount]% maintenance costs", UniqueTarget.Unit, UniqueTarget.Global),
|
||||
UnitUpgradeCost("[relativeAmount]% Gold cost of upgrading", UniqueTarget.Unit, UniqueTarget.Global),
|
||||
GreatPersonEarnedFaster("[greatPerson] is earned [relativeAmount]% faster", UniqueTarget.Unit, UniqueTarget.Global),
|
||||
|
||||
DamageUnitsPlunder("Earn [amount]% of the damage done to [combatantFilter] units as [civWideStat]", UniqueTarget.Unit, UniqueTarget.Global),
|
||||
CaptureCityPlunder("Upon capturing a city, receive [amount] times its [stat] production as [civWideStat] immediately", UniqueTarget.Unit, UniqueTarget.Global),
|
||||
@ -445,6 +444,7 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
||||
|
||||
FlatXPGain("[amount] XP gained from combat", UniqueTarget.Unit, UniqueTarget.Global),
|
||||
PercentageXPGain("[relativeAmount]% XP gained from combat", UniqueTarget.Unit, UniqueTarget.Global),
|
||||
GreatPersonEarnedFaster("[greatPerson] is earned [relativeAmount]% faster", UniqueTarget.Unit, UniqueTarget.Global),
|
||||
|
||||
Invisible("Invisible to others", UniqueTarget.Unit),
|
||||
InvisibleToNonAdjacent("Invisible to non-adjacent units", UniqueTarget.Unit),
|
||||
@ -452,6 +452,8 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
||||
|
||||
RuinsUpgrade("May upgrade to [baseUnitFilter] through ruins-like effects", UniqueTarget.Unit),
|
||||
|
||||
DestroysImprovementUponAttack("Destroys tile improvements when attacking", UniqueTarget.Unit),
|
||||
|
||||
// The following block gets cached in MapUnit for faster getMovementCostBetweenAdjacentTiles
|
||||
DoubleMovementOnTerrain("Double movement in [terrainFilter]", UniqueTarget.Unit),
|
||||
AllTilesCost1Move("All tiles cost 1 movement", UniqueTarget.Unit),
|
||||
@ -481,6 +483,7 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
||||
|
||||
CanActionSeveralTimes("Can [action] [amount] times", UniqueTarget.Unit),
|
||||
|
||||
// Hurried means: sped up using great engineer/scientist ability, so this is in some sense a unit unique that should be here
|
||||
CannotBeHurried("Cannot be hurried", UniqueTarget.Building, UniqueTarget.Tech),
|
||||
CanSpeedupConstruction("Can speed up construction of a building", UniqueTarget.Unit),
|
||||
CanSpeedupWonderConstruction("Can speed up the construction of a wonder", UniqueTarget.Unit),
|
||||
|
Reference in New Issue
Block a user