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

Quick Modding Questions Thread

Discussion in 'Civ4 - Creation & Customization' started by kiwitt, Jan 27, 2010.

  1. f1rpo

    f1rpo plastics

    Joined:
    May 22, 2014
    Messages:
    486
    Location:
    Germany
    That would probably be best. Setting up a development environment for such a big mod could be a bit laborious though, so I'm not volunteering.

    Logging of Python events is fairly easy to enable. It should suffice to set LoggingEnabled = 1 in My Games\Beyond the Sword\CivilizationIV.ini and to set all the __LOG variables in the __init__ function of CvEventManager.py to 1 (e.g. self.__LOG_TECH = 1). RoM uses a custom event manager, but I suspect that it works as in BUG, i.e. the original event manager still gets called. CvEventManager.py isn't included in the mod, so you'd have to copy it from BtS. If it does work, then the log gets written to My Games\Beyond the Sword\Logs\PythonDbg.log.

    Hopefully, the final line in the log (before the game freezes) would somehow give you an idea what XML or artwork change is causing the problem. (My understanding is that you haven't made Python and DLL changes.)

    Then, there's the BBAI log. Not sure how to enable that in a RoM-based mod. Having taken a brief look at their BetterBTSAI.cpp, it might be enough to set XML_LOGGING_ENABLED to 1 in one of the GlobalDefines.xml files, but, more likely, all the log level variables in BetterBTSAI.cpp need to be set in addition, requiring recompilation.

    The next step would be to build a debug DLL and to step through the code with the debugger to find out which particular loop isn't terminating. However, if you're totally unfamiliar with the DLL code, then this may still not tell you what XML change is responsible.
     
  2. Nightinggale

    Nightinggale Deity Supporter

    Joined:
    Feb 2, 2009
    Messages:
    4,130
    The way I deal with infinite loops is to compile a profile dll, let the game freeze and then start profiling. Whatever loop is taking 100% of the CPU time is the one with the buggy end condition. So far this approach has worked on 100% of the freezes in the dll file.

    When asking other people for help, it's generally a very good idea to use a public git repository. Adding project files and Makefile 2 will make it easy for other people to compile whatever DLL they want (debug, profile etc) to examine the problem. Now I have to download a huge rar file just to see if you even included the dll source code. If you change one thing, then I have to download everything again if I need to test it again.
     
  3. Zeta Nexus

    Zeta Nexus Deity

    Joined:
    Jan 23, 2014
    Messages:
    3,347
    Location:
    In a constant brainstorm...
    Well, I'm not even dreaming of editing the dll. That's beyond my reach.

    Honestly... I didn't really expect anyone voluteering :blush: I know everyone is busy, so I really appriciate your effort. :hatsoff:
    The dll is the same as AND2. I make only xml and art/audio changes.

    Actually that was all the help I needed to identify the problem. Thank you :hatsoff:

    Last night I had enought time, energy and patience to find it. So the problem was adding new flavors. I added 3 new flavers for civics and leaderheads: Autocracy, oligarchy and democracy, to add a little rpg element to AI leaders.

    The problem was with Victoria. Her flavors were: gold=5, growth=2 and oligarchy=5. When outtagging oligarchy suddenly the loop was gone and I read the massage Victoria addopting 3 new civics.
    Now the question is: What's the exact math of flavors? And is it problematic to have a 3rd flavor in leaderheadinfos?

    Thank you for both your time and help :hatsoff:
     
  4. f1rpo

    f1rpo plastics

    Joined:
    May 22, 2014
    Messages:
    486
    Location:
    Germany
    Excellent. :thumbsup:
    The calculation of the civics flavor value looks harmless: CvPlayerAI.cpp#l17178 (Should be iTempValue += ... in line 17183, but that error only means that the intermediate result isn't written to the BBAI log.) Perhaps the custom flavor type is the problem. However, when FLAVOR_ESPIONAGE was added in BtS, all they did to "declare" the new flavor type was an entry in Assets\XML\GlobalTypes.xml and it looks to me like not even that should be needed.
     
  5. Zeta Nexus

    Zeta Nexus Deity

    Joined:
    Jan 23, 2014
    Messages:
    3,347
    Location:
    In a constant brainstorm...
    Well, the new flavors didn't ALWAYS crash the game. I tried a higher value, in case the flavors make 2 civics equally appelling for the AI but that wasn't a sollution.
    An other thing I want to try is this: Change civics so that in each category the civics have either just the BtS flavors or just the custom ones. Will see if that changes anything...
     
  6. Zeta Nexus

    Zeta Nexus Deity

    Joined:
    Jan 23, 2014
    Messages:
    3,347
    Location:
    In a constant brainstorm...
    Finally have managed to find the cause of the infinite loop: It wasn't the custom flavors but an other thing with civics, a rare bug coming from AND2. lt was hard to find (for me at least) but I learded a lot from it.
    Great thanx for the help :worship:
     
    f1rpo likes this.
  7. Nightinggale

    Nightinggale Deity Supporter

    Joined:
    Feb 2, 2009
    Messages:
    4,130
    If you found a way to cause AND2 to go into an infinite loop, do post about it in AND2. There might be people interested in fixing the issue from python/DLL to prevent it from happening again. You don't need further research, just tell how you managed to get it to break and what you did to fix it (which is likely a workaround rather than an actual fix).
     
  8. Zeta Nexus

    Zeta Nexus Deity

    Joined:
    Jan 23, 2014
    Messages:
    3,347
    Location:
    In a constant brainstorm...
    I will... when I have time and energy to write long senteces.
    You know... real life :hammer:
     
  9. lindsay40k

    lindsay40k Emperor

    Joined:
    Mar 13, 2009
    Messages:
    1,647
    Location:
    England
    In Civ 6, there’s two tech trees - a scientific one, and a cultural one. Beakers buy techs, notes buy policies. Doing certain things bulbs certain techs and policies, which pays 40% of the cost. It’s kind of like Civ 4 events, only without the random; killing three barbs bulbs Bronze Working, and generating a Great Scientist bulbs Education.

    Would it be doable to mod something like this into Civ 4? I guess just add a counter for accumulated culture, and have either two tech trees on two separate screens or - perhaps more useful when you know what you’re doing, but perhaps trickier for a muggle to get the hang of - one big tech tree screen with two actual tech trees? Having two separate things being researched at the same time could be tricky, I guess if you’re doing tradition Civ fill-the-bucket research you’d need a policies tab along with the tech tab?
     
  10. Yoda Power

    Yoda Power ✫✫✫✫✫✫✫

    Joined:
    Sep 24, 2002
    Messages:
    13,866
    I’ve seen some mods where the civ colour is not displayed on water in the minimap. How do I do this for my personal mod?
     
  11. Nightinggale

    Nightinggale Deity Supporter

    Joined:
    Feb 2, 2009
    Messages:
    4,130
    The quick answer is yes.

    The long answer is that Medieval Conquest (a Colonization mod) has done it. How to do it is a bit too lengthy for a quick questions thread. Headlines of what you need to do:
    • add production of the new type of research points
    • Store production in CvPlayer (including savegame)
    • Store current research and already unlocked items in CvPlayer (also save this)
    • some doTurn event where it unlocks the current research if enough points have been gathered
    • Some implementation of effect of gaining new techs
    • A new research screen in python
    • AI support (even if it's picking a completely random tech, it still needs code to pick something)
    One major shortcut is to use CvTech for techs and then somehow make techs appear on either one or the other tech tree. That way you have storage for already unlocked techs and implementation of tech effects like unlocking units.

    It goes without saying that this requires DLL modding.
     
  12. f1rpo

    f1rpo plastics

    Joined:
    May 22, 2014
    Messages:
    486
    Location:
    Germany
    You'd have to recompile the DLL. This line needs to be changed: GitHub link (Kek-Mod)

    To leave water tiles entirely uncolored, you could put this line
    if(isWater()) return;
    before the gDLL->getInterfaceIFace()->setMinimapColor call.

    @lindsay40k: Tech boosts indeed shouldn't be difficult to do. In the DLL, it's just a matter of calling CvTeam::changeResearchProgress; I've done that for goody huts (tech progress instead of a full tech). Might also be possible through the random event system – 100% chance of triggering, or maybe as quests(?).
     
    Nightinggale likes this.
  13. Leoreth

    Leoreth 心の怪盗団 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    33,121
    Gender:
    Male
    Location:
    Leblanc
    Just in case @Yoda Power is not aware that this is possible, the link in your post already changes the vanilla BtS display to make cultural colours over water more transparent.
     
    f1rpo likes this.
  14. Leoreth

    Leoreth 心の怪盗団 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    33,121
    Gender:
    Male
    Location:
    Leblanc
    Does anyone know a good way to create a single seamless image depicting an entire map? Is there a way I can zoom out while disabling the cloud cover that shows up? Or is there a tool to automatically stitch together multiple overlapping screenshots?

    In particular I need this to create the texture the game uses in the scenario selection screen so that the image on the right actually shows a globe with the map overlaid on it.
     
  15. Nightinggale

    Nightinggale Deity Supporter

    Joined:
    Feb 2, 2009
    Messages:
    4,130
    misc\CIV4DetailManager.xml. The top 4-5 or so entries controls the camera zoom level, when clouds appear, when to switch between close and distant mode etc. Basically if you figure out what the numbers does, you can control the camera zooming. If you figure out precisely what each entry does, do tell because I need to know in a not too distant future and I haven't looked closely yet.
     
    DarkLunaPhantom and Leoreth like this.
  16. Leoreth

    Leoreth 心の怪盗団 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    33,121
    Gender:
    Male
    Location:
    Leblanc
    Thanks, I'll fiddle around with it in a bit. Didn't even realise there was a distinction between close vs. distant mode and the cloud threshold.
     
  17. Leoreth

    Leoreth 心の怪盗団 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    33,121
    Gender:
    Male
    Location:
    Leblanc
    For my purposes it was sufficient to do the following:
    - set CAMERA_MAX_DISTANCE_FADER from 0.75 to 1.5, this allowed me to zoom all the way out, which wasn't possible with the default values due to the map size I suppose (there also is CAMERA_SMALLEST_MAX_DISTANCE in GlobalDefines.xml, which may factor into this as well, but I didn't touch it)
    - set all DF_SKY values from 1.0 to 0.0, this prevented the cloud texture from showing up

    Weirdly enough, my map never switched into globe view, which may also be related to its size, but that meant I didn't have to figure out how to control when that happens. But I probably should make sure the effect still appears at the highest zoom levels.

    Surprisingly, DetailManager.xml is the only XML file I have seen that has any documentation. In particular, it mentions that value changes take effect in the game immediately without restart, which made trial and erroring my way through this a lot quicker.
     
  18. rtt4a

    rtt4a Prince

    Joined:
    Mar 3, 2009
    Messages:
    444
    Can somebody please help me with editing gamefont.tga?
    Im trying to add few resources and im using asaf´s editor, all looks good but my changes disappear after i close bts:confused:
    I mean that all looks fine and icons show in game but after restarting game they r gone.. what im missing? How to save changes in gamefont and gamefont_75 files?
     
  19. Nightinggale

    Nightinggale Deity Supporter

    Joined:
    Feb 2, 2009
    Messages:
    4,130
    My best guess is that you are editing the game files rather than the files from a mod. If you use the steam version of the game, then steam has a habit of reverting the changes you make to the game files. In fact that's the only explanation I can think off where files can undo your changes.
     
  20. rtt4a

    rtt4a Prince

    Joined:
    Mar 3, 2009
    Messages:
    444
    No its not that.. I dont use steam and Im editing mods tga-files, mod im playing is ROM-AND. I did some testing and its not actually bts which is undoing my changes, its ROM-AND launcher. If I load mod via bts my changes stays there. Im really confused, I cant see how mod launcher can undo my saved changes in tga-files and I noticed other weird thing also, tga-files size wont change a bit after I add 7 new buttons there. Anyway i can see all changes in game and civilopedia so somehow they r there.

    Maybe theres something in asafs gamefont editor what im missing..
     

Share This Page