Quick Modding Questions Thread

Does someone know what's up with Civ4ForceControlInfos.xml? I get missing type XML errors pointing there when I delete the ancient era or the chieftain difficultuly in Civ4EraInfos and Civ4HandicapInfos respectively, but there's no mention of HANDICAP_CHIEFTAIN or ERA_ANCIENT in Civ4ForceControlInfos.
 
Last edited:
This is a long shot, but, I am trying to use RFC Sword of Islam's Shia Islam's assets for my own mod. To this end, I have unpacked the two .fpk-files. However, some files are just... Nowhere? I am really confused.

For instance, the Shia Missionary's button should be found at: <Button>,Art/Interface/Buttons/Units/Missionary_Shia.dds,Art/Interface/Buttons/mem_units_atlas.dds,2,10</Button>
However, neither mem_units_atlas.dds nor Missionary_Shia.dds appear to be included in any version of the mod I can find (installer version 1.0, .7z version 1.0, SVN version, or browsing through the SVN on SourceForge)

Similarly, the button of Shia Islam should be located at: <Button>Art/Interface/Buttons/Religions/Shia.dds</Button>
Except that it isn't there, nor anywhere else (using Ctrl F).

Also, if I copy the Shia Temple/Monastery/Cathedral/Shrine's art files to my own mod, they either have a pink shadow, are a red circle, or presumably have other issues - they don't work.

So probably I am missing something - could anyone guess what? Or, does anyone know where these art files are located exactly?

Thank you in advance!
 
Sorry if I'm misunderstanding the question but I was able to locate both the atlas and the button in my version of SOI. Perhaps you have a corrupted file? I've attached them to this post.

As to your issue with pink shadows/red circles it's hard to diagnose without more details. Usually these happen because of an error/typo in the relevant ART_DEFINES XML but they can be caused by issues with the art itself as well.
 

Attachments

I'm getting a python exception related to updateScoreStrings but I haven't messed with the interface at all so not sure what could be causing it. It appears whenever I run the following code:
Spoiler Custom Python Event :
Code:
def aiHandicap():
    if (gc.getGame().getGameTurn() == 1):
        iUnitWorker = gc.getInfoTypeForString("UNIT_WORKER")
        iUnitSettler = gc.getInfoTypeForString("UNIT_SETTLER")
        iUnitCeorl = gc.getInfoTypeForString("UNIT_CEORL")
        iUnitJavelinman = gc.getInfoTypeForString("UNIT_JAVELINMAN")
        iUnitScout = gc.getInfoTypeForString("UNIT_SCOUT")
        for iPlayerX in xrange (gc.getMAX_PLAYERS()):
            pPlayer = gc.getPlayer(iPlayerX)
            if (gc.getGame().getHandicapType()) == gc.getInfoTypeForString("HANDICAP_IMMORTAL"):
                if (pPlayer.isHuman() == False):
                    if (pPlayer.getCapitalCity() != None):
                        city = pPlayer.getCapitalCity()
                        pPlayer.initUnit(iUnitWorker, city.getX(), city.getY(), UnitAITypes.UNITAI_WORKER, DirectionTypes.DIRECTION_WEST)
                        pPlayer.initUnit(iUnitScout, city.getX(), city.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_WEST)
                        for x in range(2):
                            pPlayer.initUnit(iUnitCeorl, city.getX(), city.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_WEST)
                        for x in range(2):
                            pPlayer.initUnit(iUnitJavelinman, city.getX(), city.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_WEST)

which in turn is called in CvEventManager under onEndGameTurn as so:
Spoiler CvEventManager :

Code:
def onEndGameTurn(self, argsList):
        'Called at the end of the end of each turn'
        iGameTurn = argsList[0]
## RoodEvent Start
        RoodEvents.aiHandicap()

Error does not appear when I comment out RoodEvents.aiHandicap in CvEventManager. The python error it spits back looks like this:
Spoiler PythonErr Log :

Code:
Traceback (most recent call last):

  File "CvEventInterface", line 30, in onEvent

  File "CvCustomEventManager", line 139, in handleEvent

  File "CvCustomEventManager", line 150, in _handleDefaultEvent

  File "CvEventManager", line 379, in onEndGameTurn

  File "RoodEvents", line 37, in aiHandicap

RuntimeError: unidentifiable C++ exception
ERR: Python function onEvent failed, module CvEventInterface
Traceback (most recent call last):

  File "CvScreensInterface", line 705, in forceScreenRedraw

  File "CvMainInterface", line 742, in redraw

  File "CvMainInterface", line 2785, in updateScoreStrings


The second error repeats endlessly as the game keeps trying to draw the interface screen. I don't think the first error is related to the bigger second error but I don't know what's causing it either. The game does sucessfully spawn units as I want it too. When playing on Immortal the AI recieves units at the end of turn one. But the interface error makes the game unplayable. I'm stumped as to why giving the AI units would cause this to happen and I know very little about the interface python. It is my own mod with many changes made but this issue specifically only arises when the aiHandicap code is called. Has anyone encountered something like this before?
 
Sorry if I'm misunderstanding the question but I was able to locate both the atlas and the button in my version of SOI. Perhaps you have a corrupted file? I've attached them to this post.

As to your issue with pink shadows/red circles it's hard to diagnose without more details. Usually these happen because of an error/typo in the relevant ART_DEFINES XML but they can be caused by issues with the art itself as well.
This is exactly what I needed (although I suspect I am missing some building files as well - I know that it should be caused by a wrong ArtDefines definition, but I copied it straight from Sword of Islam), I have no clue why I can't find these files in so many different versions (downloaded multiple times, too), but thank you for sending them to me! :)

EDIT: Yes, for example, I can see in the ArtDefines that I am missing shia_temple.nif, which should be located in <FPKFile>\art\structures\buildings\temple\islamic.
 
Last edited:
Okay, you knew this question was coming - surprisingly, I can only find piecemail tips and tricks in various threads, but not one cohesive tutorial, so alas, I return to here once more. With gamefonts!

It did work as I expected it to work:
Use RevolutionDCM's GameFont files, which luckily are already expanded a lot to have enough room to accomodate for more religions.
Tell ReligionInfos.xml the index (starting at 0) of the icons within the GameFont files.
And thus, rearrange the religious icons in the GameFont files to order them to your desire:
1668339877273.png

Then (a step I haven't done yet, because I first wanted to test if this would actually work), create new icons and fill in the blanks.

This works, in so far as that the logic I describe above seems to apply:
1668340027019.png


This does not work, in so far as that I now have white circles with black numbers floating around my screen for no discernible reason (see the tech bar, see the great people bar, see the Workshop's tooltip, see the Worker's movement):
1668340170511.png

The only thing I can think of, is that the default 'white circle with black number' includes a special marking, that tells the game 'look, there is an icon here', while me copying icons away replaces their former space with 'nothing', which makes the game interpret things incorrectly. If so - how would I functionally go about rearranging icons and adding new icons? Would I need to copy-paste every icon to the three rows above (with yields, commerce, and war/peace icons), because there the game seemingly handles completely white icons correctly, and so I can use that space to swap around my icons? Or can I just insert this theorised 'special marking' on the now-empty white icons? Or...?
 

Attachments

  • 1668340067744.png
    1668340067744.png
    1.9 MB · Views: 5,928
What file do I edit to make buildings not appear in the campaign and remain 'hidden'? Like the Civ5 cities that the buildings do not appear in the city graphics.
 
I'm getting a python exception related to updateScoreStrings but I haven't messed with the interface at all so not sure what could be causing it. It appears whenever I run the following code:
Spoiler Custom Python Event :
Code:
def aiHandicap():
    if (gc.getGame().getGameTurn() == 1):
        iUnitWorker = gc.getInfoTypeForString("UNIT_WORKER")
        iUnitSettler = gc.getInfoTypeForString("UNIT_SETTLER")
        iUnitCeorl = gc.getInfoTypeForString("UNIT_CEORL")
        iUnitJavelinman = gc.getInfoTypeForString("UNIT_JAVELINMAN")
        iUnitScout = gc.getInfoTypeForString("UNIT_SCOUT")
        for iPlayerX in xrange (gc.getMAX_PLAYERS()):
            pPlayer = gc.getPlayer(iPlayerX)
            if (gc.getGame().getHandicapType()) == gc.getInfoTypeForString("HANDICAP_IMMORTAL"):
                if (pPlayer.isHuman() == False):
                    if (pPlayer.getCapitalCity() != None):
                        city = pPlayer.getCapitalCity()
                        pPlayer.initUnit(iUnitWorker, city.getX(), city.getY(), UnitAITypes.UNITAI_WORKER, DirectionTypes.DIRECTION_WEST)
                        pPlayer.initUnit(iUnitScout, city.getX(), city.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_WEST)
                        for x in range(2):
                            pPlayer.initUnit(iUnitCeorl, city.getX(), city.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_WEST)
                        for x in range(2):
                            pPlayer.initUnit(iUnitJavelinman, city.getX(), city.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_WEST)

which in turn is called in CvEventManager under onEndGameTurn as so:
Spoiler CvEventManager :

Code:
def onEndGameTurn(self, argsList):
        'Called at the end of the end of each turn'
        iGameTurn = argsList[0]
## RoodEvent Start
        RoodEvents.aiHandicap()

Error does not appear when I comment out RoodEvents.aiHandicap in CvEventManager. The python error it spits back looks like this:
Spoiler PythonErr Log :

Code:
Traceback (most recent call last):

  File "CvEventInterface", line 30, in onEvent

  File "CvCustomEventManager", line 139, in handleEvent

  File "CvCustomEventManager", line 150, in _handleDefaultEvent

  File "CvEventManager", line 379, in onEndGameTurn

  File "RoodEvents", line 37, in aiHandicap

RuntimeError: unidentifiable C++ exception
ERR: Python function onEvent failed, module CvEventInterface
Traceback (most recent call last):

  File "CvScreensInterface", line 705, in forceScreenRedraw

  File "CvMainInterface", line 742, in redraw

  File "CvMainInterface", line 2785, in updateScoreStrings


The second error repeats endlessly as the game keeps trying to draw the interface screen. I don't think the first error is related to the bigger second error but I don't know what's causing it either. The game does sucessfully spawn units as I want it too. When playing on Immortal the AI recieves units at the end of turn one. But the interface error makes the game unplayable. I'm stumped as to why giving the AI units would cause this to happen and I know very little about the interface python. It is my own mod with many changes made but this issue specifically only arises when the aiHandicap code is called. Has anyone encountered something like this before?
For anyone with the same problem I've fixed this issue with updateScoreStrings. Via some debugging I figured out the problem was with gc.getMAX_PLAYERS and substituted gc.getGame().countCivPlayersEverAlive() and this got things working. Not sure on the why.
 
@Set: I don't get it either. Your code does check whether there's a capital, and players that aren't alive should have no cities. Oh, well.
 
Few of questions
1) What is the benefit of using a button atlas, rather than individual button dds? Is it worth the effort creating them?

2) In what situations is the player integer and the team integer not the same? If there are no alliances/vassalisation would the player integer also be the team integer?
 
I would imagine that in the case of permanent alliances the two wouldn't be the same since you have two players in the same team.
 
2) In what situations is the player integer and the team integer not the same? If there are no alliances/vassalisation would the player integer also be the team integer?
Vassal agreements don't affect team IDs (permanent alliances do, yes). Team IDs can be assigned arbitrarily on the Custom Game screen and in WB save files. I seem to recall that, upon launch, consecutive player and team IDs get assigned (by the EXE I guess), even if e.g. one team ID had been skipped on the Custom Game screen. But I don't know if this reliably results in player IDs being equal to team IDs. (Assuming that every team consists of just one player – if there are multiple players per team, then team IDs will obviously differ from player IDs.)
What file do I edit to make buildings not appear in the campaign and remain 'hidden'? Like the Civ5 cities that the buildings do not appear in the city graphics.
Maybe fVisibilityPriority (0? -1? no help if it really just sets a priority) in XML\Buildings\Civ4BuildingInfos.xml or (near?) 0 (negative?) scale values in XML\Art\CIV4ArtDefines_Building.xml. If an empty <NIF/> works at all, then it would also remove the 3D model from Civilopedia. Just things to try, perhaps, until someone can hopefully provide an answer. Edit: I assume that by "campaign" you mean on the main map (in the countryside, campaña), but I'm not quite sure. I also don't recall what Civ 5 does with building graphics. If you actually want to hide all building graphics – well, there's a game option (Ctrl+O menu) "Globe View Buildings Disabled", but that's of course only for Globe view.
Edit2: If you're willing to change (and recompile) the DLL, then it's easy to hide all buildings or specific individual buildings:
CvCity.cpp#L12168
And, no, negative priority is not going to help. Looks like setting GAME_CITY_SIZE_METHOD to METHOD_LINMAP and both GAME_CITY_SIZE_LINMAP_AT_0 and GAME_CITY_SIZE_LINMAP_AT_50 to 0 in GlobalDefines.xml should hide all buildings without the need for a DLL change. Hm, in a quick test, that hides all city graphics, i.e. also the generic residential buildings. Ah, but setting GAME_CITY_SIZE_MAX_PERCENT_UNIQUE to 0 seems to hide only the non-generic buildings.
 
Last edited:
On my PC, where I have been playing Civilization IV for at least a decade, I always heard a religious sound the very moment I let a Missionary spread its religion. Yesterday, I installed Civilization IV on my laptop - and there, I only hear the religious sounds all at once (a cacophony, really) when I start the next turn. Does anyone have any idea what causes this? How does this work for others? Crossposting this between the General and the Creation & Customisation forums because I am not sure if this could be related to (but how?) or fixed with modding.
 
Maybe fVisibilityPriority (0? -1? no help if it really just sets a priority) in XML\Buildings\Civ4BuildingInfos.xml or (near?) 0 (negative?) scale values in XML\Art\CIV4ArtDefines_Building.xml. If an empty <NIF/> works at all, then it would also remove the 3D model from Civilopedia. Just things to try, perhaps, until someone can hopefully provide an answer. Edit: I assume that by "campaign" you mean on the main map (in the countryside, campaña), but I'm not quite sure. I also don't recall what Civ 5 does with building graphics. If you actually want to hide all building graphics – well, there's a game option (Ctrl+O menu) "Globe View Buildings Disabled", but that's of course only for Globe view.
Edit2: If you're willing to change (and recompile) the DLL, then it's easy to hide all buildings or specific individual buildings:
CvCity.cpp#L12168
And, no, negative priority is not going to help. Looks like setting GAME_CITY_SIZE_METHOD to METHOD_LINMAP and both GAME_CITY_SIZE_LINMAP_AT_0 and GAME_CITY_SIZE_LINMAP_AT_50 to 0 in GlobalDefines.xml should hide all buildings without the need for a DLL change. Hm, in a quick test, that hides all city graphics, i.e. also the generic residential buildings. Ah, but setting GAME_CITY_SIZE_MAX_PERCENT_UNIQUE to 0 seems to hide only the non-generic buildings.

Wow, thanks for the explanation on how to try it, i'm getting some buildings to not appears, I mean, only the non-wonder buildings, btw, there is a way to make all the upgrades cost 0? I dont see a option in the game to turn upgrades free on or off like the new ones.
 
There is UNIT_UPGRADE_COST_PER_PRODUCTION (amount of :gold: per 1:hammers: difference in production cost) and BASE_UNIT_UPGRADE_COST (fixed :gold: cost added in the end) in GlobalDefines.xml. Setting both to 0 should result in free upgrades. The game should be able to handle that as the Leadership promotion already grants free upgrades. (As for game balance, free upgrades will allow players to train lots of 15:hammers: Warriors while researching e.g. Iron Working and, upon finishing that tech, turn them into Swordsmen that would normally cost 40:hammers: and immediately start a war. :undecide:) The AI already gets a 50% discount on upgrades on all difficulty levels (minus iAIPerEraModifier times the current era number). That discount can be adjusted through iAIUnitUpgradePercent in XML\GameInfo\Civ4HandicapInfos.xml. The upgrade price calculation, based on those XML values, happens here in the DLL.
 
There is UNIT_UPGRADE_COST_PER_PRODUCTION (amount of :gold: per 1:hammers: difference in production cost) and BASE_UNIT_UPGRADE_COST (fixed :gold: cost added in the end) in GlobalDefines.xml. Setting both to 0 should result in free upgrades. The game should be able to handle that as the Leadership promotion already grants free upgrades. (As for game balance, free upgrades will allow players to train lots of 15:hammers: Warriors while researching e.g. Iron Working and, upon finishing that tech, turn them into Swordsmen that would normally cost 40:hammers: and immediately start a war. :undecide:) The AI already gets a 50% discount on upgrades on all difficulty levels (minus iAIPerEraModifier times the current era number). That discount can be adjusted through iAIUnitUpgradePercent in XML\GameInfo\Civ4HandicapInfos.xml. The upgrade price calculation, based on those XML values, happens here in the DLL.
Understood, I don't intend to exploit this, if the AI doesn't build obsolete units as well then that would be fine to me.
 
Last edited:
On my PC, where I have been playing Civilization IV for at least a decade, I always heard a religious sound the very moment I let a Missionary spread its religion. Yesterday, I installed Civilization IV on my laptop - and there, I only hear the religious sounds all at once (a cacophony, really) when I start the next turn. Does anyone have any idea what causes this? How does this work for others? Crossposting this between the General and the Creation & Customisation forums because I am not sure if this could be related to (but how?) or fixed with modding.
I've figured out that this can be traced back to e.g. EFFECT_MISSIONARY_ACTIVE_BUDDHISM in Civ4EffectInfos.xml, but I am at a loss how the game knows which effect to use, and thus, how I can restore proper behaviour. Somehow, 'EFFECT_MISSIONARY_ACTIVE_BUDDHISM' is only ever referred to inside Civ4EffectInfos.xml? How can that be?

EDIT: The answer lies here: https://forums.civfanatics.com/threads/quick-modding-questions-thread.351519/page-320#post-16324956
 
Last edited:
On my PC, where I have been playing Civilization IV for at least a decade, I always heard a religious sound the very moment I let a Missionary spread its religion. Yesterday, I installed Civilization IV on my laptop - and there, I only hear the religious sounds all at once (a cacophony, really) when I start the next turn. Does anyone have any idea what causes this? How does this work for others? Crossposting this between the General and the Creation & Customisation forums because I am not sure if this could be related to (but how?) or fixed with modding.
I've figured out that this can be traced back to e.g. EFFECT_MISSIONARY_ACTIVE_BUDDHISM in Civ4EffectInfos.xml [...]. EDIT: The answer lies here: [link]
I don't think the animation affects what sound is played.

The DLL picks the sound in CvCity::setReligion. The addMessage call has a parameter named "bForce". I think the effect of bForce=true is that the EXE will immediately display the message – and play its sound. setReligion uses bForce=false, which, I think, means that the message is still immediately displayed if the recipient's turn is active. Otherwise, it gets displayed at the start of the next turn.

In my experience, non-forced messages are always displayed one at a time, with a delay (of EVENT_MESSAGE_STAGGER_TIME=3 seconds?) in between, so the sounds can't stack up. Messages about declarations of war, infamously, use bForce=true.

So I don't think religion spread sounds should ever stack in unmodified BtS. And the sound of a human missionary should not get delayed until the next turn.
 
I don't think the animation affects what sound is played.

The DLL picks the sound in CvCity::setReligion. The addMessage call has a parameter named "bForce". I think the effect of bForce=true is that the EXE will immediately display the message – and play its sound. setReligion uses bForce=false, which, I think, means that the message is still immediately displayed if the recipient's turn is active. Otherwise, it gets displayed at the start of the next turn.

In my experience, non-forced messages are always displayed one at a time, with a delay (of EVENT_MESSAGE_STAGGER_TIME=3 seconds?) in between, so the sounds can't stack up. Messages about declarations of war, infamously, use bForce=true.

So I don't think religion spread sounds should ever stack in unmodified BtS. And the sound of a human missionary should not get delayed until the next turn.
Well, I would like to continue this conversation, because this is very interesting information that may be key to what I am experiencing... Despite having a fresh install and simply copying my mod from my PC to my laptop. Because the current cacophony of all 'religion-has-spread-to-a-city'-sounds playing immediately at once upon ending a turn is very annoying. And indeed, on my PC they play staggered, like what you describe.

I found a reference to AS3D-tags within the missionaries' _activate.kf-files, per the link from my post, but I don't think that does anything (or at least, nothing that I can discern).

I am incapable of compiling DLL files, but, how would you proceed, what would you do here? Can I upload any files that might be worth inspecting, like what you note about CvCity::setReligion?
 
Back
Top Bottom