-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Updated <in [tileFilter] tiles> so that you can settle on water/mountain tiles #13758
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Updated <in [tileFilter] tiles> so that you can settle on water/mountain tiles #13758
Conversation
One where city couldn't spawn naval unit. The other when naval unit spawned they could get pushed to a costal tile.
|
Did you find out what was causing the crashes? |
|
Yes. The crash was cause by not checking if the settler had an unique conditional before adding |
|
I see |
How should I go about doing this ? |
|
Find the code in settler automation that determines locations we can settle |
…s puppet city The bug for puppet city is that it couldn't settle a city if it was a military unit.
I also put the PR in draft to fix the issue that city state could settle a city
|
Do I need to change anything else to get this PR merged ? |
| val uniqueModifier = unique.getModifiers(UniqueType.ConditionalInTiles).firstOrNull() | ||
| val modConstants = civ.gameInfo.ruleset.modOptions.constants | ||
| if (!tile.isLand || tile.isImpassible()) return false | ||
| if (!unique.hasModifier(UniqueType.ConditionalInTiles) && (!tile.isLand || tile.isImpassible())) return false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be checking the param of ConditionalInTiles here, there than down below with canSettleInTileWithUnique?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (unique.hasModifier(UniqueType.ConditionalInTiles)) {
// TODO: Check the condition of params[0]
}
else if (!tile.isLand || tile.isImpassible())) {
return false
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition, since the boolean getOwner() checks following are less-expensive, may be best to put that above this one.
| if (tile.getOwner() != null && tile.getOwner() != civ) return false | ||
|
|
||
| if (unique.hasModifier(UniqueType.ConditionalInTiles)) { | ||
| canSettleInTileWithUnique = !unique.getModifiers(UniqueType.ConditionalInTiles).none{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
none { - interestingly, https://kotlinlang.org/docs/coding-conventions.html#horizontal-whitespace shows the rule for lambdas, but not other blocks or fun/if/for... bodies...
|
Just came across...
( OneTimeChangeTerrain) ... might conflict.
Sounds like some @delegate:Transient
val isRulesetAllowsSettlingWater by lazy {
ruleset.units.values.asSequence()
.flatMap { unit ->
unit.uniqueObjects.asSequence()
.filter { it.type == UniqueType.FoundCity || it.type == UniqueType.FoundPuppetCity }
.flatMap { unique -> unique.modifiers }
}
.filter { it.type == UniqueType.ConditionalInTiles }
.map { it.params[0] }
.any {
it == "Water" ||
ruleset.terrains[it]?.type == TerrainType.Water
}
}might be needed in |
Should I put this into it's own PR or in this one ? |
|
So like this |
|
Done |
| val unique = foundUniques.firstOrNull()!! | ||
| var canSettleInTileWithUnique = false | ||
|
|
||
| val uniqueModifier = unique.getModifiers(UniqueType.ConditionalInTiles).firstOrNull() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I haven't been following this closely, it looks like it checks the first conditional in tiles. I guess this assumes you wouldn't be adding multiple of these on one line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested something like this: Founds a new city <in [Coast] tiles> <in [Atoll] tiles> and it did work.
You can still add more conditional in tiles, but the first one must be the one the player/ai must settle on.
| private fun canSettleTile(tile: Tile, unit: MapUnit, nearbyCities: Sequence<City>): Boolean { | ||
| val civ = unit.civ | ||
| val foundUniques = unit.getMatchingUniques(UniqueType.FoundCity) + unit.getMatchingUniques(UniqueType.FoundPuppetCity) | ||
| val unique = foundUniques.firstOrNull()!! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also just grabs the first one it finds. What if you have multiple of them, and a subsequent one applies, while the first doesn't?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I when I added puppet city unique, I made so you can't have both at the same time.
|
Hmm, I never thought about that 😅 |
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
|
Conflicts have been resolved. |
|
I will be unable to continue working on the PR |
Updated <in [tileFilter] tiles> so that the player/ai can settle on water/mountain tiles.