Announcement

Collapse
No announcement yet.

Orientation in SDK

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Orientation in SDK

    My dreams of modding civ 4 more or less died the second I saw the SDK files, since I have no clue what I'm actually looking at. I have some experience in C, some more in visual basic, and more still in jass (wc3 modding without the fancy GUI ). Are any of those sufficient to give me a prayer of working on this? My ambition's not to create a civ4-fps or anything insane like that, but to work around the edges using what's already there (more minor changes, or maybe even a mod).

    For starters, I see the 200 or so files in here. In the most general terms, what am I seeing? Obviously, tweaking *values* is done in the XML files, so I imagine I won't see anything in here that governs yield per tile or cost of barracks or whatnot. But what am I looking at here? I could possibly start to make heads or tails of this if I just had someplace to start. Is there a thread someone could direct me to? Or failing that, anyone want to give a few basic pointers?

  • #2
    I just cracked open the SDK myself. 200 files? There are 3,214 files in the zip, but don't panic. There are only 91 .cpp files. This is where the meat is. Let's say you want to change the way the AI attacks or defends. There are only about 5 files that (by their name) appear to control the AI. Chances are CyUnitAI.cpp is your target. Browse these cpp files. Many are wrappers that don't really do any game logic. Have fun!

    Comment


    • #3
      Originally posted by mdbill
      Chances are CyUnitAI.cpp is your target. Browse these cpp files. Many are wrappers that don't really do any game logic. Have fun!
      Did you mean "CvUnitAI"? There is no CyUnitAI".

      Those "Cy..." files are the Boost Python interface from the C++ files. Thus "CyUnit" is the wrapper class for "CvUnit" and is then exposed to Python in "CyUnitInterface1".

      Comment


      • #4
        Right, CvUnitAI. It's surprising how few .cpp files you really need to explore. I hope Ari is less intimidated now.

        Comment


        • #5
          If you're using CodeBlocks a good place to start is "Find in Files", with your search term, and the mask set to "Cv*.h", once you've found a promising function double click on it to go to the .h file, then right-click on the function name and use "find implementation".

          As an example of how to make changes:
          Right now I want to fix the pillage-gold bug - the amount awarded for pillaging doesn't scale with game speed. I search Cv*.h files for "pillage"; one of the search results is void CvUnit.h:illage(), clearly what I want. I double click on it, then right-click the function name and "find implementation", which takes me to the function in CvUnit.cpp, I read and understand it.


          Next I need to know how to scale something to to game speed, a promising search-all-files term turns out to be "hurry" this leads me through a few functions (using "find implementation" extensively) to locate a suitable line of code to scale something by the game speed factor. I settle on stealing some code from CvCity::flatHurryAngerLength() - it doesn't matter what I use as long as it scales linearly with the game speed. (in the perfect world I'd add a "PillageIncomePercentage" to the XML file and ye-de-da, but I'm aiming for a one-line-wonder fix here)

          The complete change involves adding 2 lines to the pillage function:
          iPillageGold *= GC.getGameSpeedInfo(GC.getGameINLINE().getGameSpee dType()).getHurryConscriptAngerPercent();
          iPillageGold /= 100;



          Note: The pillage gold game speed thing may or may not be a bug or oversight. It might be deliberately done that way. But the pillage income is sooo measly on Marathon so I'll call it a bug.

          Comment

          Working...
          X