We-the-People-civ4col-mod / Mod

This is the repository where the mod resides.
89 stars 37 forks source link

Pathfinding going thru Rock Reef #1007

Closed dirlewagen closed 5 months ago

dirlewagen commented 5 months ago

Pathfinding going thru Rock Reef, based on Mobility I and not avoid the damage in the process. None of the tiles around the Rock Reef have movement penalty.

Develop version as of 04/15/2024 and the save file has the ship ready for movement.

https://forums.civfanatics.com/threads/we-the-people-bug-reporting.636760/post-16593129

20240415133309_1 20240415133314_1 20240415133436_1 20240415140913_1

raystuttgart commented 5 months ago

As I said, there was an additional problem in the report: The movement cost of 3 of the Stone Reef was also ignored. (So it was taking a path with more movement cost instead of just using diagonals to sail around.)

--> If this was fixed then the damage problem would not be an issue anymore. (As all ocean terrain features causing damage also always have higher movement cost.)

devolution79 commented 5 months ago

@dirlewagen what is your setting for USE_CLASSIC_MOVEMENT_SYSTEM ?

devolution79 commented 5 months ago

I suppose that player paths should never cross damaging terrains, even when taking a shortcut across such terrains might seem beneficial. For instance, despite a reef having a movement cost of 2, which could theoretically offer a shorter path in certain situations, it's generally advisable to avoid it.

dirlewagen commented 5 months ago

@dirlewagen what is your setting for USE_CLASSIC_MOVEMENT_SYSTEM ?

@devolution79

USE_CLASSIC_MOVEMENT_SYSTEM 1
raystuttgart commented 5 months ago

@devolution79 Careful with the "never". :)

If a "reef" or storm allows a shortcut through a bottleneck saving e.g. 2 or more turns, then a little damage may be the much less problematic choice.

In general I would say the damage should however be weighted as heavily as 1 or 2 additional turns. (e.g. something like +10 movement point cost.)

raystuttgart commented 5 months ago

But as I stated already: Most likely the problem will automatically be fixed - or at least strongly mitigated - by having the Pathfinding properly consider the movement costs of the Terrain Features. (As this is also currently ignored by the Pathfinding as it seems.)

Question: Maybe this is just the case on Water though? As I never noticed Pathfinding ignoring movement costs on land. (But I also hardly ever use any automatisation ... so not sure of this.)

MrZorG33 commented 5 months ago

USE_CLASSIC_MOVEMENT_SYSTEM 1

I use the NMS, not the classic one, and have not noticed any problems with reefs (possibly due to the fact that I rarely use ships like the Sloop). but sometimes ships cross tiles with Storm. however, this is due to the fact that this way they shorten the path by 1 or 2 turns. This fits into the logic that Ray described.

devolution79 commented 5 months ago

I propose the following solution to this little dilemma:

devolution79 commented 5 months ago

But as I stated already: Most likely the problem will automatically be fixed - or at least strongly mitigated - by having the Pathfinding properly consider the movement costs of the Terrain Features. (As this is also currently ignored by the Pathfinding as it seems.)

Question: Maybe this is just the case on Water though? As I never noticed Pathfinding ignoring movement costs on land. (But I also hardly ever use any automatisation ... so not sure of this.)

I checked yesterday and terrain movement costs seemed correct to me. The sloop did insist correctly on the shortcut through the reef due to the mobiility promotion (-1 movement for the reef in this case). If we implement my proposal above then the path will never be through the reef unless it is the last plot of the path (i.e the player intentionally wanted to enter it for some reason)

MrZorG33 commented 5 months ago

@devolution79 , does this also fix the problem I described at the end of this ticket(https://github.com/We-the-People-civ4col-mod/Mod/issues/779#issuecomment-1620011972)? I don’t understand why the ticket was closed, since the problem is still relevant.

devolution79 commented 5 months ago

I did experiment with various ways to deal with this issue inside the pf logic but none of them really worked out since we can't control the UI pathfinder. So as an alternative, I've figured that we could repurpose the ignore danger flag that can be set for transports (most commonly used for wagons). Assuming that the flag is off by default, we'd have the pathfinder refuse paths that would result in turn damage. This is a sensible default since a player will very rarely want to incur turn damage anyhow. This also solves the problem that many have experienced in which an accidental move is executed that results in unintentional damage his/her ship. With this change you'd have to explicitly "opt-in" to dangerous paths,

MrZorG33 commented 5 months ago

I'm a little confused. If you propose to use a flag, like ground transport, then why does it say at the end "With this change you'd have to explicitly "opt-in" to dangerous paths"? Or did the translator mistranslate again?

devolution79 commented 5 months ago

I've implemented the following: There are now 2 new command buttons: "Allow dangerous path" and "disallow dangerous path". Default is the latter and will not allow a path that would cause turn damage: image

After clicking the "allow dangerous path" button:

image

devolution79 commented 5 months ago

image

image

devolution79 commented 5 months ago

This should make it far more difficult to accidentally suffer damage!

devolution79 commented 5 months ago

Note that the command buttons use placeholder graphics. I really need someone to help out with proper button gfx!

devolution79 commented 5 months ago

Merged into develop!