# New Terrain Movement Cost System [IMPLEMENTED]

#### raystuttgart

##### Civ4Col Modder
Hi fellow modders,

I took a day of vacation today and well ... I started protoyping again ...
(The last 3 days were quite stressful in my job and I need to relax my brain a bit and modding helps me to do so.)

----

Currently I consider to change "Movement Calculation" to something more immersive.

Let me describe the "problem" first:
--------------------------------------------------

Colonist with "Movement = 1"
Jungle with "Movement Cost = 3"
• Unit moves 1 Plot in Jungle --> Current Movement = 0
• Next Turn: Unit gets back "Movement = 1"
• Unit moves 1 Plot in Jungle again --> Current Movement = 0
• Next Turn: Unit gets back "Movement = 1"
--> Colonist can still move 1 Plot in Jungle every turn
--> The "Movement Cost = 3" in Jungle does not matter !

Now let me describe the "solution" I intend to implement:
--------------------------------------------------------------------------------

Colonist with "Movement = 1"
Jungle with "Movement Cost = 3"
• Unit moves 1 Plot in Jungle --> Current Movement = 1 - 3 = - 2
• Next Turn: Unit gets back "Movement = 1" --> Current Movement = -2 + 1 = -1
• Next Turn: Unit gets back "Movement = 1" --> Current Movement = -1 + 1 = 0
• Next Turn: Unit gets back "Movement = 1" --> Current Movement = 0 + 1 = 1
• Unit moves 1 Plot in Jungle again --> Current Movement = 1 - 3 = - 2
• Next Turn: Unit gets back "Movement = 1" --> Current Movement = -2 + 1 = -1
• ...
--> Colonist can still move 1 Plot in Jungle the first turn
--> Colonist however then has to wait to fill up its Movement Points beyond 0
--> The "Movement Cost = 3" in Jungle does matter again !

----

It would be pretty simple to implement actually - if Pathfinding would not need to be adjusted.
Because I could already use this here:

Code:
``CvUnit::changeImmobileTimer(int iChange)``

However if I did it like that, Pathfinding would not yet understand it.
So I need to do it in a way that Pathfinding logic also knows.

----

@Nightinggale , @devolution , @f1rpo

Does any one of you see potential issues I miss considering general feasibility?
• Performance issues or bugs in pathfinding?
• Other issues in AI logic?
• Would there be an issue with Savegames?
• Gameplay issues I currently do not see?
• ....
What are your ideas / suggestions to implement something like that?

----

Would like to get some feedback on this.

Last edited:

#### Nebula213

##### Chieftain
I think this is confuising.
Now i know next turn he move one plout a head. In your calculate i have still to look when he will arrive his point.

I understand the current movement is like this:
A scout with horse can move on open fields 2 or 3 plots but in a jungle he can not move fast on horse and had to move like a settler or infantry with his feets thru the jungle.

Thats are only my opinion.

#### raystuttgart

##### Civ4Col Modder
Now i know next turn he move one plout a head.
That is what I simply do not like.
It basically causes "Movement Cost" to not matter at all for Units with Movement = 1.

In your calculate i have still to look when he will arrive his point.
It will be displayed.

1. In Pathfinding: The path the game shows
2. At Unit: Movement Points
3. At Unit (with negative Movmenet Points): "effect" like a red circle.

Last edited:

#### Nightinggale

##### Deity
Master of magic has a mod called Master of mana. That one changes base moves for a lot of units from 1 to 2. That greatly changes the gameplay, but honestly not for the better. The solution to increase movement points isn't a solution. Luckily it's not mentioned here but it might be if this debate continues.

It would be pretty simple to implement actually - if Pathfinding would not need to be adjusted.
Because I could already use this here:

Code:
``CvUnit::changeImmobileTimer(int iChange)``
However if I did it like that, Pathfinding would not yet understand it.
So I need to do it in a way that Pathfinding logic also knows.
Ideally I would let movement points become negative and then instead of resetting movement points each turn, I would increase by whatever it resets to right now. The benefit of that system is that it handles "half movement points" as in setups where a unit can move 1, 2, 1, 2 plots a turn. This would make even more sense when it comes to roads. We could also make ferries slow down further etc.

Technically pathfinding should then find the path with the least cost and not care if the path matches the movement points like it does right now where it's fine with ending in a forest if it has half a movement point left despite being able to use grassland without any feature instead.

I think this is confuising.
It will be if we don't have a good GUI for it.

#### orlanth

##### Storm God. Yarr!
Those are really good points, I'd also thought about this issue of how to make movement penalties be strategically more interesting when thinking up a (probably too weird ) idea for a mod in a unique cyberpunk/cyberspace setting inspired by William Gibson as mentioned in the old thread below. In this concept, traversal and capture of Terrains/Bonuses represents strategic penetration and hacking of various computer systems and cybersecurity countermeasures, and successfully penetrating specific Terrains and Features may need units outfitted to overcome those challenges. So you'd want Terrain and Feature movement costs to have some real strategic impact (likewise for movement discounts from specific Units/Promotions/Techs), and the vanilla scenario of always moving 1 tile/turn would have the exact impact Ray said. I do think the solutions proposed would be interesting ways to overcome that, though I can also understand perhaps many people are too used to vanilla movement and wouldn't appreciate a change (either in WtP or some crazy cyberpunk world )

https://forums.civfanatics.com/thre...iv4col-mod-is-most-interesting-to-you.504114/

Just for kicks here's an even wilder idea I'd had for a really unique total conversion of Civ4Col, which I'd mentioned in a PM with Ray recently (after which ray probably thought I was insane, and was probably right )

* the players are rival Corporations, Hacker Organizations, or Artificial Intelligences seeking to extend domination over cyberspace and break away from their masters; "Natives" are smaller independent corporations and organizations that can be fought and subjugated or allied with.
* Cities represent major system nodes which can exert control over adjacent tiles & harvest various forms of raw data, financial assets and other resources, which can be processed into more valuable forms and sold for credits to fuel expansion of your cyberspace empire.
* Terrains represent a system type (Corporate, Public, Government, Military, Criminal, Top Secret, etc), which produce various types of Data when controlled. For graphics, could probably use unusual cyber-appearing abstract textures such as circuit boards, glowing binary digits or translucent crystals, some of which are in my terrain pack.
* Bonuses represent control of valuable system resources like Mass Media Network, University Mainframe, ISP, Satellite Uplink, Undersea Cable, Power Plant, Biotech Facility, Law Enforcement Database, Corporate HQ, Semiconductor Fab etc. The more valuable ones could be protected by security measures you need to hack into (ICE in cyberpunk lit); using stationary "animal" units which you need to defeat to claim the resource. (kind of inspired by how you first had to conquer the mana nodes in Master of Magic to use them.)
* Features represent local conditions such as Encryption, Malware, Firewall, etc which inconvenience players until they are cleared
* Each Unit represents a type of program, hacker, subroutine, or AI, which may "work" in a local city system to generate data, or be sent out across the network to explore, attack and subjugate rival systems. For graphics could likely use some cool fantasy units from FfH, maybe retextured with a glowing binary digits as cyberspace avatars. Instead of Food, each tile generates a certain amount of CPU or processing power, so you'd need to create improvements such as Server Farms to develop the capacity of your systems.
* a unique flavor could be added by making Terrains and Features more tactically important; eg certain program types (or programs with appropriate Promotion such as Government Protocols) could move faster through Government systems or get a combat bonus there, etc.

maybe sounds crazy, but could certainly make for a unique game experience! anyway I have no plans to develop it presently but it's a cool concept to think about.

I hope they will eventually make a movie version of Neuromancer, I just can't get enough Gibson for some reason lol

#### f1rpo

##### plastics
However if I did it like that, Pathfinding would not yet understand it.
So I need to do it in a way that Pathfinding logic also knows.
The reset of spent moves happens in CvUnit::doTurn. Apart from that, I'd look at the pathAdd function in CvGameCoreUtils.cpp. That function is responsible for updating the following pathfinding data:
Code:
``````FAStarNode::m_iData1 // Moves remaining to the unit with the fewest moves in the group
FAStarNode::m_iData2 // Path length measured in turns``````
There might also be code in other pathfinding functions (same .cpp file) that assumes remaining moves to be nonnegative.

Ftr, in Alpha Centauri, moving into difficult terrain also takes several turns; however, the unit remains in the original tile until the full movement cost has been paid (screenshot attached*). I like your idea better, i.e. moving immediately and then "resting" to pay off the debt.

(* edit): Screenshot: The Scout on the right has been ordered to move north onto the Xenofungus, which costs 3 movement points. Clicking on the unit cancels the move (via the confirmation popup).

#### Attachments

• smac_popup.jpg
164.8 KB · Views: 58
Last edited:

#### raystuttgart

##### Civ4Col Modder
I like your idea better, i.e. moving immediately and then "resting" to pay off the debt.
It will feel better for gameplay and is easier to visualize.
(It is most likely also less effort to implement.)

It will be if we don't have a good GUI for it.

As I said:

It will be displayed.

1. In Pathfinding: The path the game shows
2. At Unit: Movement Points (being positive / 0 / negative)
3. At Unit (with negative Movmenet Points): "effect" like a red circle.

#### raystuttgart

##### Civ4Col Modder
Ok then, this is my next "small project".
(Should keep me busy for a bit because I am currently just modding "to relax".)

#### Boby

##### Chieftain
If you could put this new movements calculation as an option for those who want to continue using the moves of the vanilla version, it would be very interesting and real players will appreciate it.
thanks.

#### Nightinggale

##### Deity
If you could put this new movements calculation as an option for those who want to continue using the moves of the vanilla version, it would be very interesting and real players will appreciate it.
thanks.
Since it essentially comes down to the start of turn reset, changing it into being a game option seems like it could be technically possible. The question is pathfinding movement cost calculation or rather predicted number of turns to reach plot X. That would need investigation to see if it's feasible. Also we need to investigate this part in general to ensure it won't tank the performance.

#### ConjurerDragon

##### King
Supporter
Making an option out of a bug?
From the very start there was terrain that had movement costs larger than 1 and foot units with a movement of 1 - that those units could traverse over squares with e.g. movement 3 in 1 turn because they enter the square immediately and won´t have to pay more movement points than their 1 point was always wrong and meant that the movement terrain rules did not apply to all units with movement 1.

#### raystuttgart

##### Civ4Col Modder
... as an option ...
No sorry, explanation see below.

Making an option out of a bug?
Basically my opinion as well.

Otherwise I will see in my prototype testgames if I like it or not.
I will just give it a try and see if it improves gameplay.

Movement is too important for balancing to make something like this "optional". (At least that is my personal opinion.)
So no, I will myself not turn it into a game option. (Nothing I would ever implement or balance in the future would consider that game option.)

-------

However, once I am done implementing this I will like always share it and WTP or other modders may change it in any way they like.
Ignore it, use it, improve it, turn it into an option ... it is all fine for me.

#### Nightinggale

##### Deity
Otherwise I will see in my prototype testgames if I like it or not.
I will just give it a try and see if it improves gameplay.
It should be made in a new branch. This way it can easily be compared to the branch it forked from, hence reviewing the entire change in one go rather than one revision at a time. Once done and working, we can consider settings like game options or xml options. In other words regardless of what we decide later, writing the feature itself should not consider making anything of it optional. One step at a time or development becomes too complex.

Movement is too important for balancing to make something like this "optional".
That's a valid point, but at the same time we might have to consider modmods, in which case the ability to tweak this with xml settings might not be a horrible idea. However how much if anything becomes "externally controllable" depends on the workload involved. I don't feel like spending a week to implement something, which might never be used.

#### Boby

##### Chieftain
Well, well, well...
I don't know why change something that from my personal opinion, works well.
On the other hand, "if I like it or not" I think it's a bit extreme, but...
Maybe it would be better to propose in a vote for real players to give their opinion.
Thanks.

#### raystuttgart

##### Civ4Col Modder
I don't know why change something that from my personal opinion, works well.
Because in my own personal opinion it does not work well.

"if I like it or not" I think it's a bit extreme, but...
Why? Am I not allowed to implement my own private modmod anymore as I like it?

Maybe it would be better to propose in a vote for real players to give their opinion.
Why vote if this is just for my personal modmod ?

-----

Maybe you have not understood that I am not talking for WTP anymore and that I will not publish myself anymore.
I am just a private modder sharing his work with other modders.

Thus, I will mod just for my personal taste but I will also try to implement stuff WTP or other mods may find interesting or useful.
And of course I will still try to cooperate with WTP and also still try to support (e.g. with bugfixes or other small improvements).

If this ever gets integrated in WTP or if it gets published is not my decision.
Of course I would like WTP to publish some of my stuff, but the WTP team needs to decide for itself.

I am just creating it and sharing it, that is all already.

Otherwise see here:
Ignore it, use it, improve it, turn it into an option ... it is all fine for me.

Last edited:

#### raystuttgart

##### Civ4Col Modder
By the way:

The basic logic is now already done.
(It was actually a bit more tricky than I thought at first.)
• Still need to adjust pathfinding
• Still need to adjust UI (to visualize it better)
• Still need to do proper testing

TURN 1:
------------

TURN 2:
------------

TURN 3:
------------

TURN 4:
------------

#### Attachments

• Civ4ScreenShot0000.JPG
188.5 KB · Views: 476
• Civ4ScreenShot0001.JPG
190.1 KB · Views: 472
• Civ4ScreenShot0004.JPG
219.4 KB · Views: 477
• Civ4ScreenShot0005.JPG
219.8 KB · Views: 476
• Civ4ScreenShot0006.JPG
214.5 KB · Views: 475
• Civ4ScreenShot0007.JPG
214.5 KB · Views: 482

#### Boby

##### Chieftain
ok sorry, I didn't know the WTP mod had an owner, maybe that's why fewer and fewer players participate in the forum.
have fun
and enjoy it.

"Ignore it, use it, improve it, turn it into an option ... it is all fine for me."

#### raystuttgart

##### Civ4Col Modder
ok sorry, I didn't know the WTP mod had an owner ...
No, it does not. There is no "owner of WTP".
And if at all it would be @Nightinggale and @devolution the modders that founded it.

But again I am personally not a WTP member anymore.
I left the WTP team on my own decision and in friendship (at least that is what I hope).

I am just a private modder sharing his work with other modders.
-----------
Am I not allowed to become a private modder again, sharing his work with WTP and community?
Am I not allowed to mod just for my personal taste anymore like all other private modders?

If I am not allowed to further create content and share it ... well ok.
I thought community would like me to continue creating content and also to share it with WTP ...
I thought WTP team would like me to cooperate and support e.g. with bugfixes and small improvements ...

WTP team has all permissions to integrate, change ... and publish my stuff.
Nothing I do in my private modmod however needs to be integrated if community or team do not like it.

Last edited:

#### orlanth

##### Storm God. Yarr!
Peace everyone - it's understandably hard to get large groups to agree about everything, sometimes all you can do is try to spread some peace and love when possible lol

As one potential thought for a workaround if there's a big divide about this, I remember there is a bool tag in Unitinfos.xml called <bFlatMovementCost>0</bFlatMovementCost> which I believe makes that unit treat every tile as having a movement cost of 1 (this is used in Civ4 for aircraft and 2071 for Flying Saucers ). If someone is passionate about not wanting to change vanilla movement 1 units, but others really want an advanced movement system and balancing and pathfinding AI concerns make it too hard to additionally code a DLL GameOption, could one solution be for the person preferring vanilla movement to use a simple XML modmod with <bFlatMovementCost>1</bFlatMovementCost> for Movement 1 units?

#### raystuttgart

##### Civ4Col Modder
@f1rpo , @Nightinggale , @devolution

I would need some help again please.
I am not really getting a hold of the "pathfinding".

Could you give me some hints how to adapt it?
Never really worked on pathfinding in the past.

--------

I also accidently commited it already to "Plains".
(Because I normally develop up to 3 features at once in my prototypes ...)

All changes for this new feature are commented like this:
// ray, new Movement Calculation - START

--------

The feature logic itself is working without issues.
(No crashes or anything like that. The game continues to run smoothly.)
• However paths are displayed incorrectly. (And most likely also not calculated correctly by AI.)
• Also I have not yet created a "red circle" UI help for Units having negative Movement Points.
--------

ray

Replies
53
Views
6K
Replies
0
Views
322
Replies
12
Views
2K
Replies
5
Views
696
Replies
11
Views
246