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

Super Forts

Discussion in 'Civ4 - Mod Components' started by Red Key, Oct 25, 2011.

  1. Red Key

    Red Key Modder

    Joined:
    Sep 24, 2011
    Messages:
    402
    Gender:
    Male
    Location:
    USA
    Super Forts Mod​

    Purpose: To make improvements to improvements, especially forts. Now also including AI code for choke and canal points!
    Download Here: http://forums.civfanatics.com/downloads.php?do=file&id=17822
    Current Version: 1.20
    Requires: BTS 3.19

    This is my début mod. When I first jumped into modding a couple months ago I started working on a big mod idea. Then I realized it would be better to first make and release a high quality smaller mod or two. There were several changes I wanted to make to improvements, especially forts, for the bigger mod so I decided to make and release a mod with those changes. Thus the “Super Forts” mod was born. This is a XML and SDK mod. I hope you enjoy it and let me know if you find any bugs.

    New Fort Rules (or any improvement with the XML tag <bActsAsCity> set to 1):
    The AI has been modded to take advantage of these new rules.
    Spoiler :
    1. When a fort is built in an unowned plot it gives the building player cultural control over the plot it is built in.

    2. If you move a unit into an unowned fort, then you will gain cultural control of the fort.

    3. If you move a military unit into an enemy fort, then you will gain cultural control over the fort.

    4. If another player has more culture in your fort&#8217;s plot than you, then the fort will culture flip if you have no defenders. Forts will never flip as long as you have a defender in the fort.

    5. Forts can be bombarded to reduce their defenses just like cities. Their defense will also be &#8220;repaired&#8221; over time like cities. [Edit: As of Version 1.00, whether an improvement is bombardable or not is controlled by an XML tag. Any improvement with a defense can be bombarded if this XML tag is set true, and not just forts.]

    6. When you control a fort your culture borders may extend to the plots around it if they are within the range specified by the <iCultureRange> XML tag. Your ownership of the plots around the fort is calculated in the same manner as plots around cities: if more than one player has a city/fort within range of a plot then the one that has the most culture in the plot owns it.


    New stuff for any improvement
    I have added several new XML tags that can be used for any improvement. In this mod, all of these new tags have been added to forts, and iCulture has been added to about everything.
    Spoiler :
    <iCulture> - the amount of :culture: added each turn to the plot the improvement is in for the owner. i.e. forts have <iCulture>2</iCulture> so each turn the owner of a plot with a fort will get 2 culture added to the plot from the fort.

    <iCultureRange> - Determines the range of an improvement's cultural influence. If the improvement acts as a city, then this is the range of its borders. An improvement with iCulture will add culture to all plots within its range, but only one that ActsAsCity will extend borders.

    <iVisibilityChange> - increases vision range similar to the &#8220;sentry&#8221; promotion, any unit in a plot with this improvement will be able to see this much farther while in the plot.

    <iSeeFrom> - this tag influences how far you can see from a plot. A high enough &#8220;see from&#8221; value allows units to &#8220;see through&#8221; terrain/forests/hills to the plots behind them. For example, this is the way units are able to see farther from a hill in the unmodded game.

    <bBombardable> - Now any improvement can be bombardable or not. An improvement will be bombardable if this is set to 1, and it has a defense modifier.

    <bUpgradeRequiresFortify> - Make improvements upgrade by fortify-ing their plot with units instead of being worked by a city. Note: No improvements currently have this active in the XML.

    <iUnique> - This is the range within which you cannot build another of this improvement.


    Hold the Fort!
    In this section I shall discuss how the new fort rules will change the game. For information on all the things forts could already do before these additions please see this thread: http://forums.civfanatics.com/showthread.php?t=308069

    Spoiler :
    Thanks to new fort rule #1 you will now be able to get cultural borders in the plot a fort is built in even outside your normal borders. This means if you build a fort on a resource outside your borders, then you will gain that resource! (provided it is connected by road or sea to your cities) This is the main use I see for this new rule.
    Spoiler :

    Claiming a resource outside of normal culture boundaries

    There&#8217;s not much to rule #2. If there is a fort in a plot with no culture border then move a unit into it and it is yours! Any unit that can move into the fort will work for this, so even a worker, missionary, or spy could do it.

    Please note the differences between rules #2 and #3. Rule #2 is for unowned forts and #3 is for forts in an enemy&#8217;s culture borders. If you move a unit that &#8220;can fight&#8221; into an enemy fort, then you gain control of that plot. One great use for this would be to establish a place in enemy territory for your units to heal or launch air strikes from.

    With new fort rule #4, I have ensured that you aren&#8217;t going to be pushed out of your forts the moment another player has more culture in the plot than you. Thus, you can hold forts deep in enemy territory or surrounded by another player&#8217;s culture. Basically it is a simplified city revolt. The way I imagine forts, if you are in control of a fort then there aren&#8217;t civilians from other cultures inside the fort with you that could rise up and kick your soldiers out. It would take military action to destroy or force your troops out. However, if you have no troops in a fort and the surrounding populace is mostly a different culture than your own, then they could easily take control of the fort.

    [Edit: As of Version 1.00, whether an improvement is bombardable or not is controlled by an XML tag. Any improvement with a defense can be bombarded if this XML tag is set true, and not just forts.] Finally, yes you can now bombard forts to reduce their defenses just like a city thanks to rule #5. With all the new advantages I have given forts in this mod I think they would be unfair without this way to overcome them. It seems to work great in all the tests I have done, but please let me know if you see anything weird happen while you are bombarding with this mod. Forts will slowly regain their defense bonus just like a city does after bombardment. If you are in range to bombard multiple forts, then the fort with the least damage will be bombarded. If you are in range to bombard a city and fort(s), then the city will always be chosen until it has no defense to bombard.

    Spoiler :

    Bombarding a fort


    Rule #6 was added in version 1.00. Forts extend borders to all plots within a range specified in the XML with <iCultureRange>. This border extension is done in the same manner as cities, which means big fat cross (BFC) style. If a plot is within range of more than one player's fort or city, then the owner is whichever player has more culture in the plot. There is no difference in the calculation between cities and forts. Improvements besides forts need iCulture to be greater than 0 for iCultureRange to do anything, but a fort can still extend borders if iCulture is set to 0 (the fort will just not add culture to the plots each turn). iCultureRange is set to 1 for forts in the downloadable version, but the screenshot in the spoiler below shows an example of iCultureRange set to 2.

    Spoiler :

    A fort with <iCultureRange> set to 2


    Additional Notes on the XML Tags
    Spoiler :
    The <iCulture> tag allows improvements to influence the culture of the plot they are in. Keep in mind that this in no way affects the :culture: in your cities. This is the just the culture of the plot itself which is used to determine cultural borders. Every turn, the improvement will add the amount of culture points specified in the tag for whoever owns the plot. Thus, this makes it a little harder for the plot to switch to another culture. If no one owns the plot then no one gets culture from the improvement. I think it makes sense that if your civilization went through the effort of building something in a plot, then that place would become more culturally significant to your civilization and your people would not let it go to another civilization as easily as an unimproved plot. [Should be 0 or a positive number]

    <iCultureRange> determines the range of an improvement's cultural influence, and is heavily related to iCulture. For the rest of this paragraph I shall use X to refer to the number that iCulture is set to. What iCultureRange does for forts was covered earlier, but iCultureRange can be used with any improvement. If an improvement does not have this tag or has it set to 0, then they only add X culture to their own plot. An improvement with iCultureRange=1 will add X to their own plot and all adjacent plots. When iCultureRange is greater than 1 things get more interesting. The BFC (big fat cross) style that cities use for their borders is used to determine if a plot is in range of an improvement. An improvement with iCultureRange=2 will add 2X to their own plot and adjacent plots, and X to all plots at a distance of 2. An improvement with iCultureRange=3 will add 3X to their own plot and adjacent plots, 2X to plots at a distance of 2, and X to plots at a distance of 3. And so on... [Should be 0 or a positive number]

    <iVisibilityChange> and <iSeeFrom> both influence your units&#8217; vision when in a plot with an improvement with these tags. I was thinking of creating a watchtower improvement for a mod I am planning to help see through the &#8220;fog&#8221; near your borders, but I realized it would be better to just make this a part of forts. You can use it for other improvements if you want, but forts were the only one I wanted it for. Now the towers of your fort actually act like a tower, and if you put a unit in the fort they can better see the land around them. iVisibilityChange changes your unit&#8217;s vision range and iSeeFrom changes what they will be able to &#8220;see through&#8221; or over. The attached thumbnails below contains some screen shots of what different forts can &#8220;see through.&#8221; In the examples iVisibilityChange=2 and iSeeFrom=1. [Should be 0 or a positive number]

    <iUnique> - As mentioned elsewhere you cannot build two of the same improvement within this range. The range is a normal square instead of a BFC (Big Fat Cross). Also, this currently does not check the improvement's upgrades, so if you used this tag on a village it might not have the desired effect due to the village upgrading to something else.[Should be 0 or a positive number]

    The <bBombardable> tag determines if an improvement can be (surprise! surprise!) bombarded to reduce its defenses. However, one other thing is also required for an improvement to be bombardable. The improvement must have a defense modifier or there will be no defense to bombard. [0=off 1(or other numbers)=on]

    <bUpgradeRequiresFortify> makes so upgrade progress (on an improvement that can be upgraded) is made only when the the improvement's plot has units that are fortifying. Thus, if this is set the improvement will only upgrade if its plot is fortified for enough turns. A city working the improvement's plot will not help upgrade an improvement with this set, so don't set this if you want improvements that upgrade the original way. The units fortifying the plot must belong to the owner of the plot. If the plot is unowned or owned by another player, then fortifying your units there will not help with the upgrade progress. Also, having multiple units fortify the plot will not speed up the upgrade. [0=off 1(or other numbers)=on]


    Note to Modders
    Feel free to use this mod as a part of your own mods. I only ask that you mention me and the mod&#8217;s title in your &#8220;credits.&#8221; All of my XML schema and SDK changes have been marked with a &#8220;Super Forts&#8221; comment. I have also tried to tag them with sub-categories if you only want to merge a certain part.

    See this post for info on how my choke point code works.

    The source code for the mod comes with the installation. There is not a separate download for it. There will be a "ChangedSDKFiles" folder with the .cpp and .h files I modified.
     

    Attached Files:

    MAvL likes this.
  2. Red Key

    Red Key Modder

    Joined:
    Sep 24, 2011
    Messages:
    402
    Gender:
    Male
    Location:
    USA
    Contributors

    Tholal (AI improvements)
    Sir Spanky (Found bug with sight/vision when pillaging)
    isenchine (Found bug with automated workboats)
    embryodead (Great feedback on the AI that helped me improve it)

    Change Log/Possible Plans for Future Releases
    Spoiler :
    • Mod the AI to better build forts under the new rules - Added in v0.91
    • Add in messages for when a fort is captured or flips - Added in v1.00
    • Add in XML tag that determines range of a fort's culture borders - Added in v1.00
    • Add in XML tag that makes so upgrading requires garrisoned/fortified units - Added in v1.00
    • Add XML tag to control if an improvement is bombardable or not - Added in v1.00
    • Fix a bug with sight/vision when improvements or cities are pillaged - Fixed in v1.00
    • Mod the AI to better defend and attack forts under the new rules - AI improved in v1.01
    • Mod the text that is displayed for improvements that require fortified units to upgrade - Added in v1.01
    • Make fort&#8217;s defense bonus visible like a city&#8217;s? - Dropped
    • Change bombard to allow you to select the target plot instead of selecting for you? - Dropped
    • Expose my new functions to python if there is a demand for that? - Dropped
    • Continue improving the AI's defense and offense with forts - Hopefully all done with v1.02
    • Comment the code better to make it easier to merge - Improved the commenting in v1.02
    • Update the Civilopedia - Completed in v1.03
    • Prevent AI workers from replacing forts that are outside the range of any city - v1.03
    • Make some final AI fort defense tweaks - v1.03
    • Fix a bug with automated workboats - v1.10
    • Make so two different players cannot have workers building a fort on the same plot - v1.10
    • Add in <iUnique> tag to control how closely together the same improvement can be built - v1.10
    • Make some internal details accessible through GlobalDefines.xml - v1.10
    • Slightly improve efficiency by changing the culture range forts array to short instead of int - v1.10
    • Make some adjustments so forts are not overused by the AI or humans - v1.10
    • Adjust the AI so forts won't be so over-defended in the late game - v1.11
    • Improve AI/automated worker logic to put in less effort to build forts outside borders on resources the player already has - v1.11
    • Rewrite some of the AI bombard code so that it can be more easily merged with mods that make changes to the same section of code - v1.11
    • Add keywords to my code comments to help mergers - v1.11
    • Make so the iUnique tag will work with improvements that upgrade - v1.12
     
  3. Red Key

    Red Key Modder

    Joined:
    Sep 24, 2011
    Messages:
    402
    Gender:
    Male
    Location:
    USA
    Extra Tips
    • Since forts claim territory like cities, some might want to make so building a fort uses up your worker like building a city "uses up" a settler. If you want to change this you will need to copy Civ4BuildInfos.xml from "Beyond the Sword\Assets\XML\Units" into a "Beyond the Sword\Mods\Super Forts\Assets\XML\Units" folder. The XML tag you will need to change is <bKill> for BUILD_FORT.
    • Some other tags in the same file could also be considered such as <iCost>, which makes it cost money to build, and <iTime> to make it take longer to build.

    Notes on AI Behavior

    • Building Forts
    • The AI is effective at building forts outside their borders on resources to claim them
    • The AI will recognize choke points and canal points and build forts on them
    • To prevent the AI workers going crazy in building forts the range they will go away from their cities has been limited
    • To prevent AI workers from building over forts it has been made impossible to build another improvement over a fort if it is outside the range of all the player's other cities and forts
      Defending Forts
    • Units with AI types of CITY_DEFENSE, CITY_SPECIAL, CITY_COUNTER, and RESERVE will defend forts
    • Cities of course take higher priority than forts, so the AI will not put any defenders in forts until their cities have enough defenders
      Attacking Forts
    • The AI seems to properly attack forts from what I have seen
     
  4. CaptainMidnight

    CaptainMidnight Warlord

    Joined:
    Apr 16, 2006
    Messages:
    141
    This looks great. Are you saying here that the AI can't use it at the moment? Or do you mean the AI needs improving?
     
  5. ripple01

    ripple01 Emperor

    Joined:
    Mar 7, 2006
    Messages:
    1,248
    Location:
    New York City
    Very cool first mod, and welcome to CFC.
     
  6. Red Key

    Red Key Modder

    Joined:
    Sep 24, 2011
    Messages:
    402
    Gender:
    Male
    Location:
    USA
    The AI needs improving. Currently, I have made no changes to the AI so it behaves as it always did. I want to improve it so that the AI will build a fort on top of a resource outside of its boundaries if it is close enough to defend and a resource the AI needs. Also, I need to look into how the AI decides to bombard, and might need to tweek that so they will also bombard forts.
     
  7. embryodead

    embryodead Caliph

    Joined:
    Jan 1, 2003
    Messages:
    5,179
    Location:
    basement
    Awesome. Are you aware of JCultureControl? I'd say that it produces more realistic results in terms of borders, but your implementation is much better, more complete (e.g. JCC doesn't work with pre-built improvements).

    The one idea you could borrow from it would be the ability to extend the borders outwards from the fort, i.e. +1 tile for a 9x9 area. For this, static culture as opposed to increasing culture works better I guess, but either way, having the option would be great.

    What do you think? I was planning to modify JCulture to work with pre-built forts, but you did that and much more, so there's just one piece missing ;)
     
  8. Red Key

    Red Key Modder

    Joined:
    Sep 24, 2011
    Messages:
    402
    Gender:
    Male
    Location:
    USA
    Great idea! I'll add it to my list of things for future releases. :goodjob:
    I had not see JCultureControl but I had seen Jeckel's Fort ZOC, but I didn't like the idea of a fort commander.
    If anyone else has a request for future changes I shall consider it but no guarantees on if I'll choose to do it.
     
  9. mechaerik

    mechaerik Tuturuu!

    Joined:
    Oct 28, 2008
    Messages:
    7,064
    Location:
    Los Angeles
    Blasted moderation queue! PM a mod or someone, I think that might help. You can bypass the queue if you have more than a certain number of posts (10? 30?).

    Looks great, especially since JCultureControl was never updated. I remember there was a python version that was compatible, but it slowed the game down and (since it was in python) the AI didn't understand it at all (i think, that may have been compensated for).

    Great work.
     
  10. Red Key

    Red Key Modder

    Joined:
    Sep 24, 2011
    Messages:
    402
    Gender:
    Male
    Location:
    USA
    Yes the queue is a pain.:( Apparently the magic number is 30 posts to make it disappear. I PM-ed The_J earlier today, but sadly as a mod he couldn't help cuz only admins have power over the queue so The_J said it would probably be a few days. I'll try to build up my post number in some other threads.
     
  11. dot80

    dot80 Emperor

    Joined:
    Jan 9, 2011
    Messages:
    1,616
    Gender:
    Male
    Location:
    United States
    Wow, you read my mind. I've been trying to get the jculture mod to work for 3 days now. It would be much appreciated if you could make the borders be able to extend :D
     
  12. Red Key

    Red Key Modder

    Joined:
    Sep 24, 2011
    Messages:
    402
    Gender:
    Male
    Location:
    USA
    I just discovered Super Forts is officially available for download! It is approved and out of the moderation queue. Those who try it please let me know if you find any bugs so I can fix them in future releases.:cheers:
     
  13. Red Key

    Red Key Modder

    Joined:
    Sep 24, 2011
    Messages:
    402
    Gender:
    Male
    Location:
    USA
    Update: I have made some changes to the AI and am in the process of testing them. It looks pretty good so far, but I might need to adjust it a little. When I am satisfied I will release a new version.

    For those 15 or so who have downloaded it: how is the mod going for you?

    My next priority after the AI is to add in the feature a few people have requested in this thread. I will make the forts extend their boundaries out based on an xml tag.

    Also, thanks to the off-topic forum and other threads I have now reached 30 posts! There will be no waiting for the moderation queue the next time I release.
     
  14. CaptainMidnight

    CaptainMidnight Warlord

    Joined:
    Apr 16, 2006
    Messages:
    141
    I think I read this idea somewhere else, a good feature could be to have forts upgrade, like cottage to village, when garrisoned.
     
  15. Red Key

    Red Key Modder

    Joined:
    Sep 24, 2011
    Messages:
    402
    Gender:
    Male
    Location:
    USA
    :goodjob: I'll add in the capability for that to be done in the XML, so that people merging this mod with their own or mod modding can have that option. However, at this time I'm not planning on adding any new improvements in the "vanilla" version of this mod, so forts won't have anything to upgrade to unless you add a new improvement in the XML.
     
  16. Cruel

    Cruel King

    Joined:
    Jun 22, 2005
    Messages:
    823
    Location:
    São Paulo, Brazil
    Great component! It has some connection with ROM-AND?
     
  17. Red Key

    Red Key Modder

    Joined:
    Sep 24, 2011
    Messages:
    402
    Gender:
    Male
    Location:
    USA
    Thanks! It has no connection to ROM-AND, but I guess ROM-AND does have a similar feature.
     
  18. Red Key

    Red Key Modder

    Joined:
    Sep 24, 2011
    Messages:
    402
    Gender:
    Male
    Location:
    USA
    New Version Released

    Super Forts version 0.91 is now available for download. The AI has been improved in this version to take advantage of some of the rules Super Forts introduces. The AI will now build forts on top of resources outside of its boundaries. If you automate your workers to build improvements then you will also see them building forts to claim resources. The AI is also now capable of bombarding forts.

    These changes should be saved game compatible, so those who already have the mod can install the new version and continue their saved games.

    I will continue to add new features to Super Forts. I am planning on including the features people have requested in this thread in the next release such as the ability to change how far forts borders extend. I will also continue to improve the AI, so it can better defend and capture forts under the new rules.
     
  19. glider1

    glider1 Deity

    Joined:
    May 29, 2006
    Messages:
    2,784
    Location:
    Where animals hop not run
    Wow Red_Key well done stay in touch. With your knowledge on AI and forts, we have the basis for a better range bombard code in RevolutionDCM. This is because with range bombard, it is a good idea to build forts and man them taking the battle out of the city plots and into the field.
    Cheers
     
  20. Red Key

    Red Key Modder

    Joined:
    Sep 24, 2011
    Messages:
    402
    Gender:
    Male
    Location:
    USA
    Thank you glider! Although I think my AI knowledge is still a bit lacking, but after I get the AI defending and attacking forts in Super Forts like I want then I will definitely have more knowledge. The AI code is a pain to go through... :crazyeye:

    To everyone, I hope to release version 1.00 in a few days or so. The new version will include the ability to make forts extend cultural boundaries beyond their own plot, and the range will be adjustable in the XML. Several requested that feature, so I just wanted to let you know that it is coming soon!
     

Share This Page