mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-08 14:57:58 +07:00
Improvement part2, for great general actions.
This commit is contained in:
@ -401,14 +401,14 @@ class SpecificUnitAutomation{
|
||||
|
||||
fun automateGeneral(unit: MapUnit){
|
||||
//try to follow nearby units. Do not garrison in city if possible
|
||||
val militantToCompany = unit.civInfo.getCivUnits()
|
||||
.firstOrNull { val tile = it.currentTile
|
||||
it.type.isLandUnit() && it.getMaxMovement() <= 2.0f
|
||||
&& (tile.civilianUnit == null || tile.civilianUnit == unit)
|
||||
&& unit.canMoveTo(tile) && !tile.isCityCenter() && unit.movementAlgs().canReach(tile) }
|
||||
val militantToCompany = unit.getDistanceToTiles().map { it.key }
|
||||
.firstOrNull {val militant = it.militaryUnit;
|
||||
militant != null && militant.civInfo == unit.civInfo
|
||||
&& (it.civilianUnit == null || it.civilianUnit == unit)
|
||||
&& militant.getMaxMovement() <= 2.0f && !it.isCityCenter()}
|
||||
|
||||
if(militantToCompany!=null) {
|
||||
unit.movementAlgs().headTowards(militantToCompany.currentTile)
|
||||
unit.movementAlgs().headTowards(militantToCompany)
|
||||
return
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user