1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

[SDK] Port District

Discussion in 'Civ4 - Mod Components' started by devolution, Feb 11, 2019.

  1. devolution

    devolution Chieftain

    Joined:
    Oct 7, 2016
    Messages:
    253
    Gender:
    Male
    Location:
    Stavanger, Norway
    The civ6 district mechanic has finally come to civ4!


    The fort model is just a placeholder until I find a better model of a port!

    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/
     

    Attached Files:

    Last edited: Feb 11, 2019
    vincentz, tmv, Yudishtira and 3 others like this.
  2. devolution

    devolution Chieftain

    Joined:
    Oct 7, 2016
    Messages:
    253
    Gender:
    Male
    Location:
    Stavanger, Norway
    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: Feb 22, 2019
  3. Leoreth

    Leoreth 古典部の会員 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    32,608
    Gender:
    Male
    Location:
    Kamiyama
    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.
     
  4. Sword_Of_Geddon

    Sword_Of_Geddon Mysterious Jungle Warrior

    Joined:
    Dec 21, 2003
    Messages:
    13,202
    Gender:
    Male
    Location:
    New England, USA
    Very interesting idea.
     
  5. vincentz

    vincentz Programmer

    Joined:
    Feb 4, 2009
    Messages:
    3,532
    Gender:
    Male
    Location:
    Denmark
    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?
     
  6. hrochland

    hrochland Prince

    Joined:
    Apr 9, 2006
    Messages:
    2,116
    Location:
    Czech Kingdom
    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. :(
     
  7. devolution

    devolution Chieftain

    Joined:
    Oct 7, 2016
    Messages:
    253
    Gender:
    Male
    Location:
    Stavanger, Norway
    @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: Feb 18, 2019
  8. hrochland

    hrochland Prince

    Joined:
    Apr 9, 2006
    Messages:
    2,116
    Location:
    Czech Kingdom
    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.
     
  9. Sword_Of_Geddon

    Sword_Of_Geddon Mysterious Jungle Warrior

    Joined:
    Dec 21, 2003
    Messages:
    13,202
    Gender:
    Male
    Location:
    New England, USA
    I'd be interested in trying out your personal mod if you ever decide to upload it Hrochland.
     
  10. devolution

    devolution Chieftain

    Joined:
    Oct 7, 2016
    Messages:
    253
    Gender:
    Male
    Location:
    Stavanger, Norway
    @hrochland If you're willing to share your modcomp with me or the community, I'll be happy to merge in the Port District in return for helping us out with the gfx work :thumbsup:
     
  11. hrochland

    hrochland Prince

    Joined:
    Apr 9, 2006
    Messages:
    2,116
    Location:
    Czech Kingdom
    renaissance port district I add to the database :)
     
    devolution likes this.
  12. hrochland

    hrochland Prince

    Joined:
    Apr 9, 2006
    Messages:
    2,116
    Location:
    Czech Kingdom
    I edited the Node as the file port and added mipmaps to the texture for better rendering. New ancient pot district file version in database
     
    devolution likes this.
  13. devolution

    devolution Chieftain

    Joined:
    Oct 7, 2016
    Messages:
    253
    Gender:
    Male
    Location:
    Stavanger, Norway
    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)
     
  14. hrochland

    hrochland Prince

    Joined:
    Apr 9, 2006
    Messages:
    2,116
    Location:
    Czech Kingdom
    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 :)
     
  15. hrochland

    hrochland Prince

    Joined:
    Apr 9, 2006
    Messages:
    2,116
    Location:
    Czech Kingdom
    Modern port district model in database :)
     

Share This Page