Changing XML tag values using python?

City Spammer

Apr 16, 2023
I want to change TXT_KEY_MISC_WINS_VICTORY in CIV4GameTextInfos.xml and hide the "<Player> wins a <victoryname> Victory!!!!" text that stays in the middle after a game ends.
I could just comment out the lines, but I don't want to mess around with my game files in a permanent way and would rather throw a python script I made in a directory somewhere. Is there a python function that can change tags on runtime?
Game texts are loaded from XML when the game launches. I think, from within the (GameCore) DLL, those loaded texts could be changed dynamically (CvDLLUtilityIFaceBase::addText), but that (undocumented) function doesn't appear to be exposed to Python and, in any case, I don't see how you could get the game to invoke your Python script without modifying any of the game files. If you already use a mod, the straightforward solution should be to place the blank text data ...
... in any game text file of the mod. Otherwise, you could create a mod just for this change, i.e. with a folder Assets\XML\Text and an XML file, whose name won't matter so long as it doesn't collide with any text files in the original game. The file will just need a <Civ4GameText xmlns=""> ... </Civ4GameText> element around your blank text. The mod could then be loaded by default through CivilizationIV.ini or (under Windows) through a shortcut that passes a mod=... argument to Civ4BeyondSword.exe. Or you could place your text file in CustomAssets\XML\Text under My Games\Beyond the Sword – those assets always get loaded unless a mod is used that blocks CustomAssets through its INI file. Creating your own mod will result in savegames that are incompatible with the original game and with other mods; CustomAssets don't cause savegame-incompatibility, or at least not so long as they don't affect the game rules.
I was hoping to hide the text maybe 10 turns after game end, instead of always having it hidden. Making a CustomAsset is a good idea anyways.

However, is there a DLL mod that does expose that function?
Last edited:
I see. Seems that the EXE is responsible for displaying the game end string. It gets the string from the DLL (CvGameTextMgr::getInterfaceCenterText), so it would be easy to return an empty string from there, but there doesn't seem to be anything that a Python script could do. And re-compiling the DLL might be more trouble than this is worth.

Just saw the edit – I doubt that there is a mod that either exposes addText or adds a Python call in getInterfaceCenterText.
Last edited:
Top Bottom