Quick Modding Questions Thread

Here's the line in question -

Code:
screen.setTableText(self.ITEM_LIST_ID, 0, i, u"<font=3>" + item[0] + u"</font>", info(item[1]).getButton(), widget, data1, data2, CvUtil.FONT_LEFT_JUSTIFY)

For reference, here's the same sort of line in the normal CvPediaMain.py:

Code:
screen.setTableText(tableName, iColumn, iRow, u"<font=3>" + item[0] + u"</font>", gc.getTechInfo(item[1]).getButton(), WidgetTypes.WIDGET_PEDIA_JUMP_TO_TECH, item[1], 1, CvUtil.FONT_LEFT_JUSTIFY)

I don't see anything obviously wrong, but the info(item[1]).getButton() seems fishy for some reason. Usually when I get a C++ exception it's because I am referring to something that I think exists, but doesn't actually; for example, using gc.getInfoTypeForString("TECH_RADAR") when I haven't actually added TECH_RADAR to the xml. In this case, I'm betting that whatever that "info(item[1])" is, it's been messed up somewhere so that it no longer refers to what it should be referring to.

It could be something else in that line doing the same thing...but nothing jumps out at me.

Hi, thank you. Unfortunatly my python skils r too limited to understand what can cause this. Its weird that error dont happen always.. only maybe 30% of launched games starts with it.
 
Is it possible to make two corporations using the same resources but not competing with each other?

Corporations competing because they share resources is built into the DLL. You would have to edit at that level to make corporations noncompeting. AND has a separate tag to make corporations compete if they DON'T share resources. That is how the Guilds are divided up so you can only have one of each of the three groups (Clerks, Servants, Victuallers) in each city.
 
Corporations competing because they share resources is built into the DLL. You would have to edit at that level to make corporations noncompeting. AND has a separate tag to make corporations compete if they DON'T share resources. That is how the Guilds are divided up so you can only have one of each of the three groups (Clerks, Servants, Victuallers) in each city.
I was afraid of that :undecide:
Thanks
 
Hi,

I've got an issue in my mod where the human player automatically and immediately declares war on any other civ it meets. Even if I set peace between the civs through the worldbuilder, it immediately reverts to war.

I've been looking through the python files for declarewar and startwar and can not find what's causing it. The files I've been checking are; CvEventManager.py, CustomFunctions.py, CvGameUtils.py and CvRandomEventInterface.py.
Are there any other python functions I should look for and what are the other files I should check?
Has this happened to anyone else previously?
 

Attachments

  • wardeclaration.PNG
    wardeclaration.PNG
    25.1 KB · Views: 45
@LPlate2: Have you verified in the debugger that the call to CvTeam::declareWar comes directly from Python, i.e. through CyTeam::declareWar? If that's a given, then I'd do a full-text search on the mod's Python folder (and perhaps for good measure also on the BtS Python folder) for "declareWar".
 
I need a crash course in debugging. I’m running the mod by using Start Debug in Visual C ++ 2010 Express but I don’t see any output that helps me here. The mod does not hit a breakpoint and the call stack, command window and immediate window are all blank.

Do I need to enable anything in CivilizationIV.ini to do the necessary debugging, i.e. HAPdebugger? If HAPdebugger is set to 1, where do I access the debugging info?
Are there other parameters in CivilizationIV.ini I need to adjust, such as LoggingEnabled?

I guess my questions are; what parameters need to be adjusted in CivilizationIV.ini for debugging and where/how do I then access that debugging information?
 
The mod does not hit a breakpoint and the call stack, command window and immediate window are all blank.
I think blank windows are normal so long as no breakpoint has been hit. Since you're seeing war-declared messages, it seems safe to say that CvTeam::declareWar gets executed:
Code:
szBuffer = gDLL->getText("TXT_KEY_MISC_SOMEONE_DECLARED_WAR", getName().GetCString(), GET_TEAM(eTeam).getName().GetCString());
gDLL->getInterfaceIFace()->addMessage(((PlayerTypes)iI), false, GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_THEIRDECLAREWAR", MESSAGE_TYPE_MAJOR_EVENT, NULL, (ColorTypes)GC.getInfoTypeForString("COLOR_WARNING_TEXT"));
As a test, you could also try a breakpoint in some function that gets called all the time, e.g. CvGame::getActivePlayer.
Do I need to enable anything in CivilizationIV.ini to do the necessary debugging, i.e. HAPdebugger?
The HAP thing is for a Python debugger (to my knowledge, no one has gotten that to work). No settings in the INI should be required, though FullScreen=0 is advisable.

In the VS configuration manager, in the properties of the debug configuration, Civ4BeyondSword.exe should be in the command field along with a parameter for loading the mod. (But I don't think you'd be able to launch via the Debug button if that wasn't the case.)

And of course you need to have compiled a debug DLL and that DLL needs to be in your mod's assets folder as CvGameCoreDLL.dll. If the debug DLL is present but out of date, then breakpoints can be missed, specifically, when lines have been deleted or added in CvTeam.cpp after compiling.

Is your breakpoint shown as a red circle while debugging? Or just an empty circle with a yellow triangle and tooltip "no symbols have been loaded"?
 
The HAP thing is for a Python debugger (to my knowledge, no one has gotten that to work). No settings in the INI should be required, though FullScreen=0 is advisable.

Thanks for clarifying that to me. I've been wondering if I was missing out on something for ages as I could never understand how to use it.

I put this line,
Code:
    FAssertMsg(0!= 0, "Breakpoint trigger at start of declareWar");
in at the start of void CvTeam::declareWar(TeamTypes eTeam, bool bNewDiplo, WarPlanTypes eWarPlan). This gave me the breakpoint I needed to trace back the problem to coming from,
Code:
       if (GC.getGameINLINE().isOption(GAMEOPTION_ALWAYS_WAR))
       {
           if (isHuman() && getID() != eIndex)
           {
               declareWar(eIndex, false, NO_WARPLAN);
           }
       }
in void CvTeam::makeHasMet(TeamTypes eIndex, bool bNewDiplo).

GAMEOPTION_ALWAYS_WAR was set with bDefault 0 and bVisible 0. I changed the bVisible to 1, so I could see what value was used in game...
...and now it works as it should. There's no more automatic war declarations (still not sure why they were occurring but its fixed).

Thanks for your advice.
 
The HAP thing is for a Python debugger (to my knowledge, no one has gotten that to work).
I know I did get it to work at some point. But the python editor that needed to be used didn't seem to indicate the current line in any way while stepping, so it wasn't very useful.
 
I have a question that hopefully will be very simple to answer. I've been playing some scenarios I created for ROM: AND. I have 8 Gigantic Earth scenarios with 49 civs each, all in real locations, starting from "scratch" at 6000 BC. Well, in the first of the eight scenarios, the Harappans (in India/Pakistan) begin the game in contact with the the Moche (around Peru). This makes no sense. I've gone into the WB and tried to fix it, but nothing seems to work. What am I missing? How can I edit the scenario so that all 49 civs are present, but these two civs don't start the game in contact with each other? It really messes up the game, because once Alphabet is discovered, the Moche can trade with all of the Old World civs.
 
Have you checked revealed tiles in worldbuilder? Maybe there is some leftover visibility from units etc. that were accidentally placed and then deleted?

You could also open the scenario file with a text editor and see what it says in the Moche/Harappan entries. Some scenario formats allow encoding diplomatic contact into the scenario file (I don't know if that's the case for AND) which may be hard/impossible to change in worldbuilder.
 
Have you checked revealed tiles in worldbuilder? Maybe there is some leftover visibility from units etc. that were accidentally placed and then deleted?

You could also open the scenario file with a text editor and see what it says in the Moche/Harappan entries. Some scenario formats allow encoding diplomatic contact into the scenario file (I don't know if that's the case for AND) which may be hard/impossible to change in worldbuilder.

I had tried revealed tiles, yes. There is an odd quirk (maybe because the map is so large?) where the entire New World looks entirely "revealed," but I made sure to make the whole map "unrevealed" for every civ. I will definitely try a text editor. That sounds likely. If I don't post again, that means it worked. Thanks!

EDIT: Yeah, that was it. It's been a couple of years since I did these scenarios, and I actually forgot that the text editor even existed! You're a life saver, thanks!
 
Last edited:
You're welcome! Was a shot in the dark but that was a common pitfall I immediately had to think of.
 
Are these log files telling anything about the reason why my game is crashing to desktop at the end of turn. I mean, does it give a hint about the problem being a civic or building or something else?
If anyone looks into it, thanks for it!
 

Attachments

How do I stop the auto pillaging of a type of improvement or specific improvement? I assume that it is all handled in python somewhere but where? I tried searching for what I was looking for but it was to no avail.
 
How do I stop the auto pillaging of a type of improvement or specific improvement? I assume that it is all handled in python somewhere but where? I tried searching for what I was looking for but it was to no avail.
There is a bPermanent tag for improvements. If true, the improvement cannot be destroyed.
 
Hi,
I’d like to create a (China Mieville inspired) floating Armada city.
If I create a city in ocean, nothing in the city artstyle is visible. If I create the city in coastal waters, the city artstyle is visible clinging on the land of the adjacent land terrain.

What needs to be edited to allow for a city artstyle to appear on water plots, rather than land plots?
Are there existing mods out there which are successfully displaying water based cities?
 
I think it cannot be done but there may be a workaround:
First created a dummy city set model that represents everything that a floating city is.
Create a terrain feature with this model (you can set it indestructible with bPermanent and invisible in the pedia with bGraphicalOnly)
Place it on the desired ocean tile and place a city on it. Of course it's size won't change with the city growing.
 
I think it cannot be done but there may be a workaround:
First created a dummy city set model that represents everything that a floating city is.
Create a terrain feature with this model (you can set it indestructible with bPermanent and invisible in the pedia with bGraphicalOnly)
Place it on the desired ocean tile and place a city on it. Of course it's size won't change with the city growing.

Its a pity if that is the case. I was looking forward to having the number of ships in the armada increase with population.
In my trials, the great lighthouse graphic does appear in the water when the city is based on the coast/ocean tiles, so an appropriate "Armada" wonder building graphic could represent the city. I'll hope for a response on the graphics request thread to glue together some naval unit graphics or else graphics tutorials will have to come back on my to do list.

---

Looking through threads, it seems there was a "Genetic Era" mod for Warlords (https://forums.civfanatics.com/threads/mod-genetic-era-for-warlords.184182/) that included underwater cities. The download link for this is broken.
I don't know if their underwater tiles were based on tiles which appeared to be water but were really PLOT_LAND or if they actually got city graphics to work on water plots or if they utilised an approach similar to your suggestion.

If there's a working link to this mod somewhere, could someone advise me where it is or just tell me what approach they used for their underwater cities.
 
Last edited:
Back
Top Bottom