Quick Modding Questions Thread

But isn't that the whole point? Without that, Settlers could found cities on other spots than on ruins - or am I misunderstanding you?
Perhaps you're confused about the semantics of the of the cannotFoundCity function. It's supposed to return True when the given player is not allowed to found a city on the given tile. It's not specific to any unit type or a particular way of founding a city. All other preconditions for founding a city are still checked by the DLL, and, to actually found a city, a (settler) unit will have to execute a found-city mission. cannotFoundCity doesn't need to worry about those things. Your code (and my version of it should be equivalent) says that the player can found the city so long as no settler is present at the tile, and that, if a settler is present, a ruin also needs to be present. I think (and that's what @P&nny also suggested) it should just say that a ruin is always required. Checking for a unit avoids problems with starting locations on maps that have no ruins, but those problems can be addressed differently, e.g. by checking for the name of the map. Sorry if I'm stating the obvious, I'm not sure where we misunderstand each other.
 
Last edited:
How much would it take to have a second Civic screen and put some of my civics there? Can it be done with python only or would it require dll modding too?
The action attached to the Civics Advisor button – opening the civics screen – is handled by CvGame::doControl in the DLL. The action is assigned In CvMainInterface.py:
Code:
screen.setImageButton("CivicsAdvisorButton", "", iBtnX, iBtnY, iBtnWidth, iBtnWidth,
      WidgetTypes.WIDGET_ACTION,
      gc.getControlInfo(ControlTypes.CONTROL_CIVICS_SCREEN).getActionInfoIndex(), -1)
Opening a screen should be possible through just Python. Should suffice to call the screen's interfaceScreen method; may want to do that via a showSecondCivicsScreen function added to CvScreensInterface.py – to be consistent with the other advisor screens. Attaching an action to an image button should be possible through CvMainInterface.handleInput; could take a look at the BUG options button for reference.

Ideally, the two civics screens should share the same code, e.g. through inheritance, but that'll be more difficult to accomplish than just copying CvCivicsScreen.py and making some edits in the copy. I don't know how a player could change civics on both screens in a single revolution. Perhaps a second tab on the original Civics screen would be a cleaner solution.
 
Perhaps you're confused about the semantics of the of the cannotFoundCity function. It's supposed to return True when the given player is not allowed to found a city on the given tile. It's not specific to any unit type or a particular way of founding a city. All other preconditions for founding a city are still checked by the DLL, and, to actually found a city, a (settler) unit will have to execute a found-city mission. cannotFoundCity doesn't need to worry about those things. Your code (and my version of it should be equivalent) says that the player can found the city so long as no settler is present at the tile, and that, if a settler is present, a ruin also needs to be present. I think (and that's what @P&nny also suggested) it should just say that a ruin is always required. Checking for a unit avoids problems with starting locations on maps that have no ruins, but those problems can be addressed differently, e.g. by checking for the name of the map. Sorry if I'm stating the obvious, I'm not sure where we misunderstand each other.
Ah, of course - and you are right! Changing the code to this:
Code:
def cannotFoundCity(argsList):
    if gameUtils().cannotFoundCity(argsList):
        return True
    iPlayer, iPlotX, iPlotY = argsList
    pPlayer = gc.getPlayer(iPlayer)
    pPlot = gc.getMap().plot(iPlotX, iPlotY)
    if pPlot.getImprovementType() == gc.getInfoTypeForString('IMPROVEMENT_CITY_RUINS'):
        return False
    else:
        return True
    return False
Sees various AI's founding a new city on the very next turn of my previous savegame. So excellent, this seems to work perfectly then! :)
 
Last edited:
Perhaps a second tab on the original Civics screen would be a cleaner solution.
And how would you go about that? Would it be easier to code?
Since I'm no programmer just a merger, I'm looking for simple solutions :blush:
 
Sees various AI's founding a new city on the very next turn of my previous savegame. So excellent, this seems to work perfectly then! :)
Cool. Still going to break map scripts, but if you use the mod only for your customized Earth scenario, then that's not a concern.

@Zeta Nexus: Just a blank tab isn't much effort. For a fairly minimal example, one can look at a diff between the BUG Financial Advisor (no tabs) and (an early version of) the K-Mod Financial Advisor (tab for Global Warming added and renamed to "Economics Advisor"). I'm attaching both files. To move stuff from the main tab of the civics screen to the new tab, I'd try to leave the drawContents method alone and just modify the three methods called from there, so that e.g. drawAllButtons only draws only some of the civics or some of the civic options depending on which tab (self.iPage in the K-Mod code) is selected. Getting that right will, I think, require some understanding of how the code works. If you purely go by copy and paste and trial and error, then duplicating the whole screen sounds somewhat more likely to succeed – but I don't see how that could allow a player to adopt a pair of civics that aren't on the same screen.
 

Attachments

I would like to know if it's possible to give the airship part of the bomber attack animation so it shows actually dropping bombs rather than just passing by and magically damaging stuff. If it can be done with just xml edits then that would be awesome.
 
I would like to know if it's possible to give the airship part of the bomber attack animation so it shows actually dropping bombs rather than just passing by and magically damaging stuff. If it can be done with just xml edits then that would be awesome.
I'm not an expert but I think it takes the model to be changed. Try asking for it I the Graphics Modifications thread.
 
What causes a, “maximum recursion depth exceeded” error and how do I fix it?
It seems to be getting triggered during onUnitCreated by the line
Code:
    player = PyPlayer(unit.getOwner())
 
@P&nny:My bet would be that the EXE places the text directly, presumably at coordinates computed based on the screen resolution.

Ah thanks for this, had missed the answer and was looking again (still as baffled as when looked the first time).
Yes that makes sense, that string and the string of victory are never called again anywhere else.
It's annoying but I had worked on an alternate solution (easy way to toggle off/on the texts that overlap) so I'll just stick with that for now

Thanks a ton !
 
Hello! How do you make a unit do a RangedFortify instead of a FortifyA, like the archery units? Simply adding the RangedFortify and RangedIdle entries to the kfm doesn't seem to do anything.
 
Hello! How do you make a unit do a RangedFortify instead of a FortifyA, like the archery units? Simply adding the RangedFortify and RangedIdle entries to the kfm doesn't seem to do anything.
For the art info definition in the CIV4ArtDefines_Unit.xml file, make sure that the bActAsRanged entry is set to 1:
Code:
<bActAsRanged>1</bActAsRanged>
 
Another question: what could be the cause of effects like great prophet glow showing up as a black square in the bottom left corner, but otherwise working fine?
 
Is there a mod or something (not SDK) that can allow me to give my units much longer names? Like, the current name tags are just too short.
 
The AI seems to be somewhat peaceful in my mod now. I have tried tinkering with a few things. E.g. I increased iAIDeclareWarProb in CIV4HandicapInfo by an extreme 200 but I am still not fully satisfied with the autoplays yet. (The mod has Aggressive AI option but test plays were without that).
I cannot mod the dll and I'm not in the mood of editing every leader's values individually.
Any other ideas or hints?
 
@Zeta Nexus: I don't think going above 100 for iAIDeclareWarProb makes any difference; I only see 100-sided dice rolled in the code. As a preliminary test, you could perhaps use automated search and replace to take the trailing zeros away from all the war rand values in Civ4LeaderHeadInfos. E.g. by searching for
0</iMaxWarRand>
The war rands should be a fairly organic way to make the AI more bellicose, but dividing by 10 is pretty drastic. Though it could also be that the AI isn't waging war because the power ratios don't diverge fast enough (decrease ratio thresholds? make units cheaper?) or because relations tend to be too warm (adjust relations modifiers) or the map doesn't allow for many adjacency relationships or gives civs too much space for too long. Or the AI does actually prepare for war but often times out; if you have the BBAI debug hover text available, you could hold down Alt on the scoreboard to see wars in preparation.
 
Does anyone know where the formula for calculating game points is stored? I think I can change something for myself
 
@maksyutar: That's implemented in Python for some strange reason (game rules like this are normally handled by the DLL), specifically in the calculateScore method of CvGameUtils.py, which, in turn, calls getScoreComponent in CvUtil.py. Also parameterized with a bunch of global defines loaded from XML.
 
Is units running in place (animation) a known issue with BtS? Or should I worry that I've messed something up? In the attached screenshot, only one guy jogs. I think he does it forever while the group (of 4 Axemen and 1 Spearman) remains selected. If I select a different group, he stands still; then, if I select his group again, he continues. If I break the group up, he stops for good. I imagine that there is a way to reproduce this from a savegame by selecting and moving units in some particular sequence (but I don't know which sequence).
 

Attachments

  • Civ4ScreenShot0000.jpg
    Civ4ScreenShot0000.jpg
    523.1 KB · Views: 37
Is units running in place (animation) a known issue with BtS? Or should I worry that I've messed something up? In the attached screenshot, only one guy jogs. I think he does it forever while the group (of 4 Axemen and 1 Spearman) remains selected. If I select a different group, he stands still; then, if I select his group again, he continues. If I break the group up, he stops for good. I imagine that there is a way to reproduce this from a savegame by selecting and moving units in some particular sequence (but I don't know which sequence).

Admittedly my memory is pretty bad nowadays but I don't recall ever having an issue like that even with very large platoons, but I could be forgetting. Hope my thought helps for what it's worth.
 
Back
Top Bottom