Possible bug, no movecost at sea?

Can you help improve your favourite game? Hardcore C mages, talented artists, and players with any level of experience are welcome!
Post Reply
Hafting
Posts: 21
Joined: Wed Oct 09, 2019 2:54 pm

Possible bug, no movecost at sea?

Post by Hafting »

I make new terrain types. Right now, sea and lakes with ice floating on top. After some problems, I was adviced to implement this as new terrain types so the move cost would work.

So I made a new terrain type, "icy lake". Ice is a navigation hazard, so food & trade is lower than for a normal lake. This works, the frozen lake was less productive.

The ice should also increase the move cost, so I set "movement_cost=3" instead of the normal "1". Comments in terrain.ruleset indicates that this is the way to make a tile slower.

Started a game, used edit mode to place a trireme. I expected it to spend its 3 move points on a single tile move in the ice, but it moved 3 steps as usual. The same with other ships - they move through icy lakes just as fast as they move through other lakes or sea.

Am I misunderstanding something, doesn't movement_cost do what I expect? Is there something else I must do? Or some sort of bug?
cazfi
Elite
Posts: 3384
Joined: Tue Jan 29, 2013 6:54 pm

Re: Possible bug, no movecost at sea?

Post by cazfi »

Likely sea units class does not have "TerrainSpeed" flag, and thus those units always move like the movement cost would be 1 (like air units flying over the terrain).
Hafting
Posts: 21
Joined: Wed Oct 09, 2019 2:54 pm

Re: Possible bug, no movecost at sea?

Post by Hafting »

Thanks. Adding "TerrainSpeed" to the sea unit classes fixed this, I can now make sea terrains that are slower to navigate. (Ice or reefs). Unfortunately, another problem came up. Rivers offer lower move cost for land units. But triremes go there too, and with TerrainSpeed they too get triple speed and go 9 tiles in one turn. (And other ships navigating my big rivers also became very fast.)

There seem to be no way to give different speed bonus to sea and land units, except when one of them doesn't use TerrainSpeed?

There seem to be one way I can have TerrainSpeed for sea units and maintain backward compatibility:
1. Triple the move cost on all land terrain and rivers/roads, so triremes on rivers (and ships on big rivers) does not get a crazy high speed while there.
2. Triple the move points for all the land units, so they get their normal speed on land with such tripled cost.

If there is a better way, it'd be nice to know. My approach will break, if land units gets some sort of bridge extra that lets them move across sea.
Hafting
Posts: 21
Joined: Wed Oct 09, 2019 2:54 pm

Re: Possible bug, no movecost at sea?

Post by Hafting »

Tripling the land move cost, as well as the land unit move points seems to work. (The display of a land units remaining move points are a bit awkward though.) Land units move as they always did, ships move at normal speed on sea and on the rivers supporting them.

There were one strange effect: A ship/trireme moving from sea into a river, now looses all its move points doing so. Moving on the river, or from river to sea, works as expected. Looks like river mouths are difficult for the navigators...
cazfi
Elite
Posts: 3384
Joined: Tue Jan 29, 2013 6:54 pm

Re: Possible bug, no movecost at sea?

Post by cazfi »

Hafting wrote: Wed Aug 06, 2025 2:58 pm There were one strange effect: A ship/trireme moving from sea into a river, now looses all its move points doing so. Moving on the river, or from river to sea, works as expected. Looks like river mouths are difficult for the navigators...
I think it doesn't lose "all" movement, but the move cost is that of the underlying terrain. That's because the move is not along the river (road type). Just like a land unit moving from a non-road tile to a road tile.
cazfi
Elite
Posts: 3384
Joined: Tue Jan 29, 2013 6:54 pm

Re: Possible bug, no movecost at sea?

Post by cazfi »

I don't think there's a way to get all this completely right with current ruleset formats, but I'm trying to figure out what future versions of freeciv engine (ruleset format) could do to better support such rulesets. Any ideas?
Hafting
Posts: 21
Joined: Wed Oct 09, 2019 2:54 pm

Re: Possible bug, no movecost at sea?

Post by Hafting »

cazfi wrote: Wed Aug 06, 2025 6:15 pm
Hafting wrote: Wed Aug 06, 2025 2:58 pm There were one strange effect: A ship/trireme moving from sea into a river, now looses all its move points doing so.
I think it doesn't lose "all" movement, but the move cost is that of the underlying terrain. That's because the move is not along the river (road type). Just like a land unit moving from a non-road tile to a road tile.
It looses "all" move points. A destroyer has 6 move points, and is on a sea tile next to a big river mouth. The big river is on grassland, which has move cost 3 in this setup. And with a river on the tile, the move cost is 1. So, I expect the destroyer to have 5 moves left when moving into that river mouth, (which it indeed gets, if it moves from another river tile instead of from a sea tile.) Now, if it mistakenly looses 3 move points from terrain, then it ought to have 2 move points left. But it has none, so it lost all its move points entering that big river. The only difference between big rivers and normal rivers, is that the big rivers are native to all sea units, not only triremes. And of course, the graphics.

The destroyer did not move along the river, but onto it. That is correct. But it moved away from a sea tile with move cost 1, not something with move cost 6. If the terrain move cost without river is used, then that cost was 3, not 6.

When there is a coastal city next to the river, then the destroyer move with the expected cost of 1 from sea to city, and a cost of 1 from city to big river. (And the same for triremes on small rivers.)
Hafting
Posts: 21
Joined: Wed Oct 09, 2019 2:54 pm

Re: Possible bug, no movecost at sea?

Post by Hafting »

cazfi wrote: Wed Aug 06, 2025 6:19 pm I don't think there's a way to get all this completely right with current ruleset formats, but I'm trying to figure out what future versions of freeciv engine (ruleset format) could do to better support such rulesets. Any ideas?
For my use, it is sufficient if an "extra", such as a river or canal, can specify different move costs for land units and sea units. I could then specify the usual 1/3 move point for land units using the river/canal, and 1 move point for a sea unit (ship) using the river/canal. With that, it won't be necessary to triple the move cost for land units. And a "bridge extra" connecting islands, could do the same. Cheap moves for land units because the bridge has a road on it, and normal move cost for ships passing under.

Currently, a river extra has 2 sections in terrain.ruleset specifying who may use it, and what the move cost is:

Code: Select all

[extra_river]
name           = _("River")
causes         = "Road"
native_to      = "Land", "Small Land", "Merchant", "Trireme"
flags          = "NativeTile"
...
[road_river]
extra          = "River"
move_cost      = 2
;move cost in sixths of a move point
A simple way would be to specify a "sea_move_cost" and a "land_move_cost". And if the old "move_cost" is used, it simply sets both. I could then specify "2" for land, and "6" for sea.

A more flexible way, would be to specify the move_cost in the "native_to" part. That would allow different cost for different classes. Something like:

Code: Select all

native_to  = "Land":2, "Small Land":2, "Merchant":2, "Trireme":6, "Big Land":4
Here, small land units get their usual speed bonus using the river. The trireme gets its normal speed too, but no bonus. In this example, big land units gets a bonus, but not as much as small land. (Your soldiers need to build bigger boats to bring cannons, so less speed advantage.)
John Campbell
Posts: 9
Joined: Wed Jan 18, 2023 6:57 pm

Re: Possible bug, no movecost at sea?

Post by John Campbell »

I've been considering just removing the River-road effect from my ruleset entirely. Or removing the speed multiplier and taking ground units (except Hovercraft) out of the native list, anyway. The justification for it existing in the first place seems to be using notional boats that don't actually exist as units to transport real units on the river, but if we've got actual riverboats that can really carry units... (And I have several besides just Triremes in my ruleset, including Longships that are both River- and Deep Ocean-capable.)

I'd actually like to make it so crossing rivers without a bridge or ferry costs MP, but it doesn't really work with the way the game mechanically handles Rivers.

I'm four turns from starship arrival in my current game; I think I'm going to try removing ground movement on rivers for the next one and see how it goes.

I'd really like to be able to set different terrain costs for different classes or even different units, though. Among other things, I don't like the Always Road for Alpine Troops, that gives them fast movement across Grassland, Plains, Swamp...

Tangentially, is there a setting for the old Civ effect (I don't even remember whether it was in Civ2 or just Civ1) where attempting a move that you didn't actually have the MP for could sometimes fail? (I think in proportion to the MP you were short, so if you were to attempt to move into Mountains with only 1 MP left, it'd only work 1/3 of the time.)
John Campbell
Posts: 9
Joined: Wed Jan 18, 2023 6:57 pm

Re: Possible bug, no movecost at sea?

Post by John Campbell »

Also, if it's supposed to represent using virtual boats as river transport, it seems weird that the speed depends on the ground unit's speed.
Post Reply