-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
modding: Negative tile damage cannot heal more than max health
- Loading branch information
Showing
2 changed files
with
8 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package com.unciv.logic.map.mapunit | ||
|
||
import com.unciv.UncivGame | ||
import com.unciv.logic.battle.MapUnitCombatant | ||
import com.unciv.logic.civilization.LocationAction | ||
import com.unciv.logic.civilization.NotificationCategory | ||
import com.unciv.logic.civilization.NotificationIcon | ||
|
@@ -83,7 +84,7 @@ class UnitTurnManager(val unit: MapUnit) { | |
}.maxByOrNull { it.second } | ||
?: return | ||
if (damage == 0) return | ||
unit.health -= damage | ||
MapUnitCombatant(unit).takeDamage(damage) | ||
val improvementName = citadelTile.improvement!! // guarded by `getUnpillagedImprovement() != null` above | ||
val improvementIcon = "ImprovementIcons/$improvementName" | ||
val locations = LocationAction(citadelTile.position, unit.currentTile.position) | ||
|
@@ -112,18 +113,19 @@ class UnitTurnManager(val unit: MapUnit) { | |
|
||
private fun doTerrainDamage() { | ||
val tileDamage = unit.getDamageFromTerrain() | ||
unit.health -= tileDamage | ||
if (tileDamage == 0) return | ||
|
||
if (unit.health <= 0) { | ||
MapUnitCombatant(unit).takeDamage(tileDamage) | ||
This comment has been minimized.
Sorry, something went wrong.
SomeTroglodyte
Collaborator
|
||
|
||
if (unit.isDestroyed) { | ||
unit.civ.addNotification( | ||
"Our [${unit.name}] took [$tileDamage] tile damage and was destroyed", | ||
unit.currentTile.position, | ||
NotificationCategory.Units, | ||
unit.name, | ||
NotificationIcon.Death | ||
) | ||
unit.destroy() | ||
} else if (tileDamage > 0) unit.civ.addNotification( | ||
} else unit.civ.addNotification( | ||
"Our [${unit.name}] took [$tileDamage] tile damage", | ||
unit.currentTile.position, | ||
NotificationCategory.Units, | ||
|
unit.health = (unit.health - damage).coerceIn(0, 100)
Joking. But - that "cheating" is actually a good idea. Maybe do a re-worded version of the UniqueType that speaks of healing... Hot Springs that heal some extra every turn... Allow UniqueTarget.Improvement - build a Wellness center on top that heals less but yields a lotta Gold, the greedy basterds...