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. hrochland

    hrochland Prince

    Joined:
    Apr 9, 2006
    Messages:
    2,227
    Location:
    Czech Kingdom
  2. Sir Spanky

    Sir Spanky Chieftain

    Joined:
    Jun 22, 2009
    Messages:
    76
    Will do Hrochland. RedKey, I so love this mod!
     
  3. Red Key

    Red Key Modder

    Joined:
    Sep 24, 2011
    Messages:
    418
    Gender:
    Male
    Location:
    USA
    Super Forts now has over 70 downloads! I have a small request for everyone out there who has played through a game of Super Forts. Please post your observations of the AI's behavior when attacking you and your forts. This will help me to improve the AI for future versions.

    I am already aware the AI does a poor job defending forts and that should soon be fixed. This request is specifically about the AI's behavior when at war with you. I would like to know things like:
    • Does the AI attack and capture your forts?
    • Have you seen AI weaken your forts' defense with bombard before attacking?
    • If you have an undefended fort does the AI quickly move to capture it?
    • Have you seen the AI pillage any forts?
    • Have you seen the AI do anything weird due to forts?
    • Any other observations of the AI's war/attacking behavior around forts...

    Thanks everyone!
     
  4. hrochland

    hrochland Prince

    Joined:
    Apr 9, 2006
    Messages:
    2,227
    Location:
    Czech Kingdom
    Hi, Red Key. I do not want to be offensive. Your mod is good idea but play it single is a bit :mischief:
    If you know somebody who can add your forts function to my library, I will glad post you my observations :)
     
  5. Red Key

    Red Key Modder

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

    I have released version 1.01! The AI has been modded to better defend forts.

    I also added in some text to go along with improvements that use the bUpgradeRequiresFortify tag. Now they will read "Must fortify to become..." instead of "City must work to become..." which was inaccurate.

    I have also used phungus' installation script to create an installer for the mod. I have never used installation scripts before, so let me know if there are problems. The script will install the mod to "/Mods/Super Forts" in your BTS directory. If you installed the mod previously to a different directory such as "/Mods/super_forts", then you may want to go delete the old version after installing the new one.

    This may be the final version of Super Forts. I currently do not plan on making any more versions unless bugs are found.

    Happy New Year! :newyear:
     
  6. Cruel

    Cruel King

    Joined:
    Jun 22, 2005
    Messages:
    823
    Location:
    São Paulo, Brazil
    You will start another project?
     
  7. Red Key

    Red Key Modder

    Joined:
    Sep 24, 2011
    Messages:
    418
    Gender:
    Male
    Location:
    USA
    Yep. I should have mentioned that. I am finalizing Super Forts so I can start working on another mod.

    I want to make a mod based off the game Age of Wonders, and Super Forts will be merged into it.
     
  8. embryodead

    embryodead Caliph

    Joined:
    Jan 1, 2003
    Messages:
    5,179
    Location:
    basement
    I merged in parts of Super Forts (skipped the bombardment & upgrade parts as I don't need them). Here are my comments so far:

    - the way you comment the code can be a bit inconvenient when merging with other mods with modified code - it's difficult to guess what's what when there's just comment at the top, while lines & brackets below aren't commented; I'd suggest enclosing every block & commenting single lines/brackets
    - none of the new improvement features appear in the Civilopedia
    - despite the AI tweaks, the AI doesn't seem to care about defending Forts (although I'm talking about a scenario where both forts & units are pre-placed). It seems that eventually it just shifts all defenders to cities. I might add some kind of new, immobile UNITAI type (CITY_SPECIAL doesn't seem to work) just with pre-placed fort defenders in mind.
    - EDIT: it doesn't seem to care about capturing them either, even if they are undefended, unless they happen to stand in the unit's path
    - other than that, works like a charm and solves my problems, THANK YOU :)
    - it's great that the culture range works even with iCulture=0, since I'd rather not have influence accumulated from forts :)
     
  9. embryodead

    embryodead Caliph

    Joined:
    Jan 1, 2003
    Messages:
    5,179
    Location:
    basement
    Here's a screenshot showing the effects of no-defence & no-capture. Some forts are pre-built, some were built by the AI (the ones with bonus). Yellow dude captured the purple dude's city, there's also a formerly purple fort now owned by barbarians, but they left as well. One new purple fort is defended.



    I guess it needs some kind of new routine to specifically target forts, like cities, while not spending too much forces on them...
     

    Attached Files:

  10. Red Key

    Red Key Modder

    Joined:
    Sep 24, 2011
    Messages:
    418
    Gender:
    Male
    Location:
    USA
    Thanks for the feedback embryo! It was hard for me to see where things were still lacking on my own. I will definitely try to improve some of the things you brought up. The screenshot was helpful too.

    Sorry about the poor commenting. This is my first mod, and I haven't done any merging yet, so I am blissfully unaware of what coding style makes things easier for merging. I tried to enclose multi-line changes in the code with //Super Forts begin ... //Super Forts end. If a change was only a single line with perhaps some brackets then I just put a single //Super Forts comment.

    Is there a tutorial somewhere to help me improve my commenting? or perhaps a mod that is a good example of proper commenting? I have RevDCM and FFH2 downloaded and could look at their code if one of them is a good example.

    That was completely neglected now that you mention it. I will fix that in the next version.

    I probably need to add calls to the function that determines if a unit should defend a fort in more of the AI types. I believe only CITY_DEFENSE and RESERVE currently call it, and that was how it already was in the vanilla code. It would probably also be simple for me to tweak the AI so that if a unit is the only one defending a fort it will not leave its post.

    When I was play testing, the AI was poor at defending forts in the early game when they had fewer units, but after they had built up their units in cities they put plenty of defenders in forts. For example, I razed a city next to some iron, and planned on building a fort on the iron. However, one of the other AI players built a fort on the iron before I could, and then promptly put 4 units in the fort to protect it.

    That was something I was concerned about, and was something I requested feedback on in an earlier post. It was hard for me to play test the AI's behavior by myself. I will do what I can to fix that in the next version.

    I tried to make things as flexible as possible because I knew not everyone would want all the new features. I'm glad you like it. :)
     
  11. embryodead

    embryodead Caliph

    Joined:
    Jan 1, 2003
    Messages:
    5,179
    Location:
    basement
    It's mostly fine, I think there were two instances of new code with just one comment above, and one had new brackets without any comments, with the closing one being in a later part of original code, that was the confusing part.

    You can do use the big, clear blocks that RevDCM & its modcomps have, or use the concise begin... end comments, doesn't really matter. I'd just make sure that if it's not within a block of new code, then every line, including single curly brackets, are clearly marked as part of the mod.

    BTW I think stuff like ePlayer = getOwnerINLINE() is redundant since it's just replaced with m_eOwner anyway

    I think it makes sense for just these two UNITAIs to be used to defend forts. It's possible that there's just a deficit of defenders in my scenario, although many forts remain empty throughout the game. I've also seen stuff like, AI putting 4 good defensive units in one fort, while leaving other naked.

    The biggest problem is no capturing right now, although iCulture=0 eventually produces satisfactory borders since it makes flipping of undefended forts much easier.

    As a side-note, I'm also using Influence Driven War, which goes well with this modcomp, but with iCulture=0 it can take away that 1 point of static culture, making "holes" in fort borders. I fixed that by using iCulture=1 but with a maximum of 10 culture / plot. Another way would be to simply make sure that 1 point of static culture is re-added every turn, if it's not there.

    I also noticed forts are disappearing sometimes, even though they are placed in locations where nothing else can be built. I'm wondering how is that even possible... Considering that forts are now owned, it'd mean the AI is pillaging its own forts for some reason.
     
  12. hrochland

    hrochland Prince

    Joined:
    Apr 9, 2006
    Messages:
    2,227
    Location:
    Czech Kingdom
    Hi. I made a litle test. In war go enemy first try capture city. I managed to add units to the city and enemy as second act was captured my fort.
    It´s good succes I think.


    I am still interested in this mod and looking for someone to incorporate into my library sdk
    thanks, Hrochland
     
  13. embryodead

    embryodead Caliph

    Joined:
    Jan 1, 2003
    Messages:
    5,179
    Location:
    basement
    Well, what did that unit do next? Did it stay there? The AI surely captures forts if they are on his way. However, there's just nothing in the code that would make it attack actual forts. You can see the AI's current mission by holding CTRL (or ALT, don't remember) in debug mode.
     
  14. hrochland

    hrochland Prince

    Joined:
    Apr 9, 2006
    Messages:
    2,227
    Location:
    Czech Kingdom
    I don´t know what is debug mode. I just had the pleasure of the logical step of AI. I have not tested further . I have a lot of work with models to other. I will test it done today evening.

    Still no one for me to compile a library? Help me somebody, please
    Thanks, Hrochland
     
  15. Red Key

    Red Key Modder

    Joined:
    Sep 24, 2011
    Messages:
    418
    Gender:
    Male
    Location:
    USA
    See this thread for info on debug mode. You'll probably have to merge and compile the "library" on your own. There are tutorials for how to merge and how to compile the DLL, and don't worry if you're unfamiliar with programming because you won't have to write any code yourself.

    I think I'll make so CITY_SPECIAL and CITY_COUNTER also guard forts.

    BTW, I was going through the code again in the function AI_getPlotDefendersNeeded and discovered a part of the original code was sometimes rounding the defenders needed down to 0. It will do this when you only need one defender and there are no hostile units around. The spoiler below shows how I fixed it.

    Spoiler :
    Code:
    if ((iNumHostiles == 0) && (iNumPlots < 4))
    	{
    		if (iNeeded > 1)
    		{
    			iNeeded = 1;
    		}
    		// Super Forts begin - removed code so when iNeeded is 1 it won't be changed to 0
    		//else
    		//{
    		//	iNeeded = 0;
    		//}
    		// Super Forts end
    	}
    
    	return iNeeded;


    I have never witnessed that myself. Perhaps someone took out the fort with a spy. Also, if a fort's plot becomes within range of one of the AI owner's cities then the AI will sometimes replace the fort with another improvement. I haven't seen the AI take out their own fort except when it was now in range of one of their cities and a different improvement was built to replace it.
     
  16. Red Key

    Red Key Modder

    Joined:
    Sep 24, 2011
    Messages:
    418
    Gender:
    Male
    Location:
    USA
    AI Updated

    I have released a new version with some improvements to the AI. The AI should do a little better at defending forts, and a lot better at attacking them now. Feedback from people willing to playtest would be appreciated.

    I also tried to clean up some of my SDK code comments.

    I believe this update will not break saved games.

    edit: I will next update the civilopedia but will probably be short on time for the next little while, so I wanted to get the AI update out quickly.
     
  17. embryodead

    embryodead Caliph

    Joined:
    Jan 1, 2003
    Messages:
    5,179
    Location:
    basement
    Thanks :goodjob: The getDefendersNeeded tweak did nothing for me, but I'm getting the new update and will test this weekend. About disappearing forts, they're on plots on which nothing else can be built, so that excludes new improvements. I didn't think about Espionage though, that's probably it.
     
  18. Red Key

    Red Key Modder

    Joined:
    Sep 24, 2011
    Messages:
    418
    Gender:
    Male
    Location:
    USA
    Since your disappearing forts were on a plot where nothing else can be built, then espionage is probably the answer. However, as I was playing last night I saw an AI worker build a farm over a fort. The fort was outside of the range of any of the AI player's cities and was on top of an iron (why the AI built a farm on the iron is beyond me :confused:). Thus, when the farm was complete the AI lost ownership of the plot (which was being defended by 4 units).

    In the next version I will add in checks to prevent workers from building over forts that are outside city range, and I will also see what I can do to improve unit's defending forts. The Civilopedia will also be updated, so hopefully that will be the final version of Super Forts.
     
  19. Red Key

    Red Key Modder

    Joined:
    Sep 24, 2011
    Messages:
    418
    Gender:
    Male
    Location:
    USA
    Final (Hopefully) Version Released!

    I just uploaded v1.03 and I hope it will be the final version of the Super Forts modcomp! ;)

    After version 1.00, most of the changes were to the AI. v1.03 has some more adjustments to the AI's defense of forts. A new AI function has been added to hopefully help ensure each fort gets one defender while still giving cities higher priority (because of where it is called). [edit: The function will also cause the AI to put one defender on improvements that require a fortified unit to upgrade.] I will not try to adjust the AI's defense of forts again. If you find it unsatisfactory then you will have to change it yourself. It is not easy to make the AI properly defend forts while still putting the proper emphasis on cities. However, if a bug is found in my new code, then I would of course be willing to fix it.

    v1.03 also makes it impossible for workers to build over a fort with another improvement IF the fort's plot is outside the culture range of all of your cities and other forts. This was done to prevent the AI from building over its forts and losing ownership of the plot. You can still build over forts that are inside the culture range of your cities or other forts.

    Finally, the Civilopedia has been updated. When you use the new improvement XML tags included with Super Forts this will be seen in Civilopedia improvement entries. If anyone out there is playing in French, German, Italian, or Spanish, then please forgive my Google translations of the text I have added.

    As stated I hope this will be the final version of Super Forts, so people won't have to keep waiting for better versions. I do not plan on adding anything else. I will only fix any bugs that are found in the already existing code. The one exception I will make is if the AI is still not properly attacking forts then I may adjust that code because I still have not had time to properly playtest wars with the AI after some of my changes in the previous version.
     
  20. Tholal

    Tholal Emperor

    Joined:
    May 19, 2009
    Messages:
    1,676
    Where can I find the source code for this mod?
     

Share This Page