Results 1 to 3 of 3

Thread: Modifying the AI to build more units

  1. #1
    MantisFanatic
    Settler
    Join Date
    24 Aug 2002
    Posts
    11
    Country
    This is MantisFanatic's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    June 18, 2013
    Local Time
    06:57

    Modifying the AI to build more units

    I am trying to modify the code for Civ4 Beyond the Swords so that the AI will want to build more units instead of trying to build things such as Research. I tried following many articles out there, such as the ones listed at "http://modiki.civfanatics.com/index.php/Civ4_Modding_Tutorials" on how to mod in general but it is not working. Can somebody explain the following things:

    1. If I modify a .cpp file, will it automatically take affect on a game that had been previously saved, or will I need to start a brand new game? Also, what do I exactly need to do in order to ensure that any changes I make to a .cpp file will be active the next time I launch Civ4 Beyond the Swords?

    2. To achieve my goal, it looks like I will need to modify the "CvCityAI.cpp" file. Does this sound right?

    If anybody can answer these questions, please provide as many details as possible since I am new to this and have absolutely no idea what I am doing. Any help would be appreciated!

  2. #2
    MantisFanatic
    Settler
    Join Date
    24 Aug 2002
    Posts
    11
    Country
    This is MantisFanatic's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    June 18, 2013
    Local Time
    06:57
    Update: The instructions I used to install the SDK were Refar's instructions at http://forums.civfanatics.com/downlo...file&id=10018|. Using Visual Studio, I am able to perform the build command without any errors, but when I modify CvCityAI.cpp to something like the following and "build":

    In void CvCityAI::AI_chooseProduction()

    Old code:

    int iCulturePressure;

    bDanger = AI_isDanger();

    New code:

    int iCulturePressure;

    int zero = 0;
    int test = 987654321/zero;


    bDanger = AI_isDanger();

    It is not crashing after completing a turn from a saved game like I would expect it to due to division by zero, which leads me back to question 1 from my previous post. I doubt it is the case that this code is not being hit, so do I need to do something else after running "build" in Visual Studio to make this code active?

  3. #3
    MantisFanatic
    Settler
    Join Date
    24 Aug 2002
    Posts
    11
    Country
    This is MantisFanatic's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    June 18, 2013
    Local Time
    06:57
    Okay, I think I answered my own questions. First of all, I was not copying and pasting the "CvGameCoreDLL.dll" file from the "Final_Release" folder to the folder that Civ4 was using. Second, I was able to encourage the AI to build more units by changing the int CvCityAI::AI_buildUnitProb() function in CvCityAI.cpp to return a larger value.

    In any event, this has been a learning experience for me, and hopefully if others want to increase the number of units the AI builds, I have provided a starting place. Now I am going to play my modded game!

Similar Threads

  1. Modifying start and city build locations
    By PennyFromHeaven in forum Civilization IV Creation
    Replies: 2
    Last Post: October 15, 2007, 10:44
  2. Modifying Governor Build Queues
    By Laszlo in forum Civ2-General/Help-Archive
    Replies: 3
    Last Post: August 1, 2003, 09:47
  3. Modifying Units
    By Caesar the Glutton in forum Civ2-General/Help-Archive
    Replies: 7
    Last Post: January 26, 2001, 22:39
  4. modifying Units in the fantasy game
    By tobyr in forum Civilization I and Civilization II
    Replies: 1
    Last Post: September 28, 2000, 21:08
  5. Modifying Dominiques build mod
    By JimMac in forum Call to Power 1
    Replies: 9
    Last Post: July 18, 1999, 04:49

Visitors found this page by searching for:

howto modify ai civ4

civ4 modify ai

biuld more units games

civ4 what units and buildings will an AI biuld

civilization IV ai making many units

Bookmarks

Posting Permissions