[SDK] Port District (Updated)

devolution

Prince
Joined
Oct 7, 2016
Messages
534
Location
Norway
The civ6 district mechanic has finally come to civ4!

ancient.png
West-facing ancient port
ren.png
South-facing renaissance port
modern.png
East-facing modern port

Improvement graphics provided by @hrochland :goodjob:

A port district (i.e. any improvement with bPort=1) now acts just like a civ6 Harbor District. A PD must built adjacent to a city and adjacent to at least 2 coastal tiles (some restrictions apply). This mechanic allows the city to construct water buildings and train water units even if the city itself is not coastal. Ships will appear in the PD rather than the city when completed (like in civ6)
The AI is fully capable of competently using the PD.

Notes:
Adds a new (optional) tag <bPort> and a new "improvement"(IMPROVEMENT_PORT) to CIV4ImprovementInfos.xml
Mod is based on K-Mod 1.46. I will assist in merging to other SDK derivatives if requested.

https://forums.civfanatics.com/resources/sdk-xml-port-district.27309

Revision history:

Replaced placeholder fort model with a port
Added support for 3 distinctive eras
Added support for 4 facing directions
 

Attachments

  • Port District.png
    Port District.png
    1.6 MB · Views: 920
Last edited:
FAQ

Q: How many ports can I build per city ?
A: Currently the limit is 1. I did consider the idea of allowing multiple ports, but then we'd have to find a way to set one of them to be active (where to place ships etc.). Of course we could always make a simple rule to say that the last port built is the active one. We can consider this for a future version so that we can support proper canals.

Q: What if the city is already coastal ?
A: A port can still be useful since it may allow the city access to a different body of water. I intend to teach the AI to consider this.

Q: Why can't I build a port in the second ring ?
A: Mostly for balance reasons, I don't want to make inland cities too powerful by allowing most cities the chance to access water buildings \ units \ routes. Secondly, I avoided having to implement a rule for the special case where city A could have a port adjacent to city B without city B considering the adjacent port to be its own.

Q: I cannot seems to place the port event though it is adjacent to both the city and a coastal tile ?
A: I spent a fair amount of time analyzing how the LSystem places city improvements (like the lighthouse, harbor) on water tiles. Unfortunately, in some cases the building will fail to show up. I was able to deduce two rules which are available in the pedia. TODO: cut'n paste the rules here + demonstrate with an image.

Q: What about the Super Forts mod ?
A: I did not choose to depend on SF at this time but it is an interesting option for a future release. Although SF has some issues (I was eventually going to look into them, but I digress...), it contains several useful functions like a an improved choke-point \ canal finder which could be quite useful.

Q: Can the AI use the port ?
A: The AI is quite happy to use the port and will generally build it whenever possible

Q: Balancing the port itself ?
A: To make testing easier I simply made it available with TECH_SAILING. I also gave it 2 commerce since it would be placed in the first ring and hence would likely compete with the yields from a farm or a cottage. If you implement the PD in your mod, you may consider giving it extra commerce at TECH_ASTRONOMY or something like that. Note that the utility of having a PD for a land-locked city far exceeds any tile yields from the PD itself. The harbor's +50% trade route yield is probably reason enough to built it. Coming to think of it, I think that the port

Q: Fort vs. port
A: My first implementation was actually based on "recycling" the fort's bActsAsCity tag but I found out that the tag had some hidden \ special meaning that made it unsuitable. For instance you may rebase air units to anything that has bActsAsCity set, which is rather inappropriate for a port. Note that I do allow a port to connect resources just like a fort does.

Q: What if the port is pillaged and I am building a ship \ water building
A: This works just the way it has always worked. Just as if you were building a swordsman and your iron was pillaged, the build will be cancelled (you will keep the hammers when it can be resumed). Conversely, if the city is razed, a new city will "inherit" the PD if placed adjacent.

Q: My city has a PD and just completed a lighthouse which ended up along the coast but not along the PD tile
A: This is a limitation of the LSystem (unless we find out how to control it). Note that in base BTS, water buildings can be placed in unexpected locations (sometimes on the opposite coast)
 
Last edited:
This is really cool and solves the problem of cities being one tile away from the coast seeming like a waste. I'm looking forward to including it in my mod.
 
I'm very interested in this for a default bts sdk. .
How many ports can each city build, and if multiple how does it pick which one produces?
Also if the port tile is shared between two cities, can they shift ownership back and fourth?
 
As I wrote, it's a great idea. Here you can find my proposal for ancient district improvement. If the non-shore version does not suit, I will modify the Node as a harbor.


I downloaded your mod and found it based on Bug-mod.
Unfortunately, this probably means I will not be able to use it. :(
 
@hrochland Thanks for looking into the gfx side of things! :) As for Bug, it is true that it is included in K-Mod but you can easily turn off all the features if you want to. Not sure what you mean by not being able to use it ?

All,
I have updated the first post (reserved) with some additional info that will hopefully answer most questions.
 
Last edited:
I have many modcomps in my mod. Some people remember that the author wrote that they are incompatible with the bugmod.
I've been doing my mod for about 10 years, and if your addiction to bugmod is dependent, I'm afraid it's not my power or anyone else to reconcile my whole mod with a bugmod. :( I use Super forts, I have my code what use first and second city circle etc etc...

I have noticed that the system involves constructing port-based buildings in a non-coastal city. This probably means that you need for district improvement port harbor Node.
 
Now we only need an industrial \ modern variant with a container crane or something like that :)

Will look into what we can do with the issue of having the port face the waterfront. As a fall-back, in case we can't find a more elegant method, we could always create 4 pre-rotated versions of the port and place the appropriate version programmatically (The Strategic Rivers mod does this with its bridges which are oriented either horizontally or vertically)
 
Or, I can extend the Node so that the whole area lies on the water. But after days of thinking, I think the option at the bank is better.

I will make the industrial option. I suppose this veekend :)
 
@devolution:

Theoretically we could use the Improvement "Port District" for Cities at "Large Rivers". :think:
(In WTP, after I have implemented the prototype for the feature "Large Rivers").

Outdated:
Spoiler :

My current idea:
  • Allow it to be built only on "Large River" Plots in City Radius (also for 2-Plot-City-Radius)
  • Since "Large Rivers" can be entered by Pioneers, Pioneers could also easily build it on "Large Rivers".
  • Allow all Units to pass a "Large River" Plot with a "Port District" on it
  • Allow the Cities at a "Large River" to build Coastal Ships, just like a Pier (if in City Radius - also for 2-Plot-City-Radius)
  • Increase the "Food Yield" of Fishermen, just like "Landing Stage" does for Cities. (So we will also not have to change the rules for "Landing Stages" for Large River Cities.)
  • Maybe even give the "Port District" an 2nd Level Growing Improvement, which will futher increase the Food Yield of Fishermen (just like "Pier")
Pros:
  • Allow Crossing of Large Rivers near a City by an Improvement (and basically replacing the "Ferry Improvement" I was considering)
  • Allow to keep the code and XML for Buildings (for Landings Stages / Piers) untouched, so they continue to depend on "<isWater>" and not also on "<isLargeRiver>".
  • Still giving Cities next to a Large River the Fishing Bonusses (of Landings Stages / Piers untouched)
  • Allowing "Large River Cities" to build "Coastal Ships".
We could call it "River City Port" (and the Upgrade "Large River Port"). :think:
(For Large River Cities, this Improvements does make sense to me.)

So instead of a "Coastal Improvement" in Civ4 BTS, it would become a "Large River Improvement" in WTP.

What do you think? :dunno:
(I am currently just trying to brainstorm.)

First of all, we need to get the "Large Rivers" working though.
 
Last edited:
@keldath

I'm definitely looking to merge this modcomp with AdvCiv so it should be easy to get it into Dota after that. Having said that, I am also considering to make an "extended" version of AdvCiv that includes various modcomps and this is perhaps something we could collaborate on ? I have a shortlist of modcomps that I like (we should discuss this somewhere else)

@raystuttgart

I did indeed have WTP in mind when I started prototyping the PD modcomp, we can discuss how the PD will fit in after we "firm up" the design of the large rivers feature.
 
Top Bottom