Quick Modding Questions Thread

Actually, let me also add a question from my end: I have seen mods (C2C I think) that support unicode characters in their game text XML, instead of the common HTML encoding for everything that isn't in the Latin charset, e.g. é and so on. Does anyone know how this works? I think it would make life a lot easier for writing game text in non-English languages.
 
I think you missed my point. I think I looked kind of like you when I realized that I got different icons despite using the same ints. It's like write something in a file and the game does something completely different and there is no clue to why it does it like that.
So what was the point than? I am basically at my whits end here and asking for a solution to a problem I can't solve and have honestly given up on at this point due to finding a sort of, almost, semi functional workaround.
 
So what was the point than? I am basically at my whits end here and asking for a solution to a problem I can't solve and have honestly given up on at this point due to finding a sort of, almost, semi functional workaround.
Are you trying to recolour the halo? For that, you need to change the colour settings in the Halo's NiMaterialProperty.
 

Attachments

  • Halo_Colour.jpg
    Halo_Colour.jpg
    197 KB · Views: 161
The halo it self is just a billboard. What I am trying to change is the underlying lighting effect. As in that pulsating white light that you get on the unit.
ATTACHABLE_HIGHLIGHT_PROPHET
 
So what was the point than? I am basically at my whits end here and asking for a solution to a problem I can't solve and have honestly given up on at this point due to finding a sort of, almost, semi functional workaround.
I was going to say that we (C2C) have noticed that some things don't work in modules. Sound is one. You need to copy the new stuff into the base files for it to work. Maybe that is true of the halo?
How do I increase the character limit of city names?
If you mean it does not fit in the City Bar, have you tried the Wide City Bar mod? It gives more room to display the city and build names.
I can join in on that statement. WTP displayed the wrong GameFont char in python, but not on city billboards. Same char ID, different characters. I thought I could fix it in 5-10 minutes (must be a glitch in the python file), but so far I have spend 2 days on it. It turns out GameFont adds padding, meaning it adds blocks in chunks of 16, meaning if you add 1, it might add 0 or 16. I knew that. What I didn't know is that the code for the city billboards doesn't do that. They apparently just count blocks, meaning even if both billboard and python reads from the very same GameFont.tga, they can get different results from reading the same int value. I got them back in sync by adding 11 blank boxes. I still need to do some cleanup before committing, but at least one int value will display the same thing in both places.

If somebody is interested in making a BTS version of this, feel free to contact me. The code can be copy pasted, though it needs a new way of opening as it's hooked into a colo only python file. The billboard debug code requires DLL modification, but displaying GameFont (big and small) for non-billboard purposes is pure python.

View attachment 505554 View attachment 505555
We always use the Game Font Editor by Asif(?) it handles all the padding and alignment stuff.

edit I can't remember how we converted to unicode for the XML. It is in the dll somewhere I think.
 
The halo it self is just a billboard. What I am trying to change is the underlying lighting effect. As in that pulsating white light that you get on the unit.
ATTACHABLE_HIGHLIGHT_PROPHET
Okay, so we are talking about the ...\art\effects\unit_greatpeople\fx_greatpeople_prophet_highlight.nif file, right?

That one used the texture files located in the ...\art\shared folder, so that might lead to conflicts with the files you modified. I think normally local files should overrule globally shared files, but I am not sure about that. But I think you already got so far as well.

Hmmm... maybe it would be an idea to create your own attachable. It only seem to take one entry in the CIV4AttachableInfos.xml file. You could then rename the nif and texture files so that there is no possible conflict anymore.
 
Okay, so we are talking about the ...\art\effects\unit_greatpeople\fx_greatpeople_prophet_highlight.nif file, right?

That one used the texture files located in the ...\art\shared folder, so that might lead to conflicts with the files you modified. I think normally local files should overrule globally shared files, but I am not sure about that. But I think you already got so far as well.

Hmmm... maybe it would be an idea to create your own attachable. It only seem to take one entry in the CIV4AttachableInfos.xml file. You could then rename the nif and texture files so that there is no possible conflict anymore.
That's what I did. I copied the relevant nif and textures to a separate folder inside my module and than made custom XML in a custom module specific XML file linking to that. I than opened my model nif and manually made sure that the attachable linked to is my new XML defined name. And nothing worked.
 
Actually, let me also add a question from my end: I have seen mods (C2C I think) that support unicode characters in their game text XML, instead of the common HTML encoding for everything that isn't in the Latin charset, e.g. é and so on. Does anyone know how this works? I think it would make life a lot easier for writing game text in non-English languages.
First of all, the encoding is Windows-1252, though the rows 8_ and 9_ are not fully supported because in some places the code assumes unicode meaning only characters, which have the same value in both Windows-1252 and unicode fully works. The html escape seems to be an xml thing and not encoding specific.

As for unicode support, I would point you to this thread about Rise of Mankind translation and how it moved to UTF-16 (2 byte chars only, 4 byte chars not supported). It's the best I can think of regarding putting unicode support into civ4.
 
CvEventManager.py

PHP:
    def __eventEditCityNameBegin(self, city, bRename):
       popup = PyPopup.PyPopup(CvUtil.EventEditCityName, EventContextTypes.EVENTCONTEXT_ALL)
       popup.setUserData((city.getID(), bRename))
       popup.setHeaderString(localText.getText("TXT_KEY_NAME_CITY", ()))
       popup.setBodyString(localText.getText("TXT_KEY_SETTLE_NEW_CITY_NAME", ()))
       popup.createEditBox(city.getName())
       popup.setEditBoxMaxCharCount( 15 )
       popup.launch()
I haven't personally tried to increase the max char count, but odds are that nothing else is needed. Do test in network games and savegames just to be sure.

This does not work. I'm playing Magister Modmod for FfH2. I edited the number to be 50. When that didn't work, I went into CvEventManager for vanilla, Warlords, and BTS and did the same. No change.
 
Random question. Is there a tool out there built to help with editing the XML for units and such? Like not notepad++ but an actual editor tool of some sort.
I don't need links either, just a yes or no. I don't intend to actually use it, I am just curious.
 
First of all, the encoding is Windows-1252, though the rows 8_ and 9_ are not fully supported because in some places the code assumes unicode meaning only characters, which have the same value in both Windows-1252 and unicode fully works. The html escape seems to be an xml thing and not encoding specific.

As for unicode support, I would point you to this thread about Rise of Mankind translation and how it moved to UTF-16 (2 byte chars only, 4 byte chars not supported). It's the best I can think of regarding putting unicode support into civ4.
Hm that looks interesting, but can you clarify a bit more about what that tool does? It seems to be about managing and converting the XML files themselves. Doesn't the game's actual XML parser also need to support UTF-16? Or does this mean that the game already fully supports UTF-16 and could even read it from XML files but only the files themselves are not UTF-16 encoded?
 
This does not work. I'm playing Magister Modmod for FfH2. I edited the number to be 50. When that didn't work, I went into CvEventManager for vanilla, Warlords, and BTS and did the same. No change.
Apparently I missed something important when I took a closer look. The very next function:
PHP:
    def __eventEditCityNameApply(self, playerID, userData, popupReturn):  
       'Edit City Name Event'
       iCityID = userData[0]
       bRename = userData[1]
       player = gc.getPlayer(playerID)
       city = player.getCity(iCityID)
       cityName = popupReturn.getEditBoxString(0)
       if (len(cityName) > 30):
           cityName = cityName[:30]
       city.setName(cityName, not bRename)
Once written it will only use the first 30 characters. I just tested it (in Colonization, but same code) and I could easily make very long names.

Random question. Is there a tool out there built to help with editing the XML for units and such? Like not notepad++ but an actual editor tool of some sort.
I don't need links either, just a yes or no. I don't intend to actually use it, I am just curious.
Not completely done and not officially released yet. https://forums.civfanatics.com/threads/xml-gui-progress.561743/page-2

Hm that looks interesting, but can you clarify a bit more about what that tool does? It seems to be about managing and converting the XML files themselves. Doesn't the game's actual XML parser also need to support UTF-16? Or does this mean that the game already fully supports UTF-16 and could even read it from XML files but only the files themselves are not UTF-16 encoded?
I didn't write it, meaning I'm not the right one to ask for details, but from what I get, the idea is that the exe is compiled with 8 bit character support while the Japanese exe is compiled with 16 bit character support. Using the Japanese exe (the language will not switch as that's in xml) have the memory to switch to the obsolete UTC-2, which is essentially 2 byte unicode and all characters below 0x8000 should be the same as UTF-16. XML loading then needs to convert from utf-8 to UTC-2, which is trivial since it's in C++. You can add something like iconv to get the task done easily.
 
Oh wow that sounds crazy, maybe I'll bug some of the AND people about it.
 
Apparently I missed something important when I took a closer look. The very next function:
PHP:
    def __eventEditCityNameApply(self, playerID, userData, popupReturn):
       'Edit City Name Event'
       iCityID = userData[0]
       bRename = userData[1]
       player = gc.getPlayer(playerID)
       city = player.getCity(iCityID)
       cityName = popupReturn.getEditBoxString(0)
       if (len(cityName) > 30):
           cityName = cityName[:30]
       city.setName(cityName, not bRename)
Once written it will only use the first 30 characters. I just tested it (in Colonization, but same code) and I could easily make very long names.

I don't understand what you're saying, sorry. Also, the file in the mod shows something different:

PHP:
def __eventEditCityNameApply(self, playerID, userData, popupReturn):
       city = gc.getPlayer(userData[2]).getCity(userData[0])
       cityName = popupReturn.getEditBoxString(0)
       city.setName(cityName, not userData[1])
       if CyGame().GetWorldBuilderMode() and not CyGame().isInAdvancedStart():
           WBCityEditScreen.WBCityEditScreen().placeStats()
 
That's what I did. I copied the relevant nif and textures to a separate folder inside my module and than made custom XML in a custom module specific XML file linking to that. I than opened my model nif and manually made sure that the attachable linked to is my new XML defined name. And nothing worked.
Have you tried to change the body texture of the model just to make sure that it is really that model that is loaded and not a default one?

Cannot think of anything else at the moment. I could have a look at the model though if you want to upload it somewhere.
 
I gave up and changed focus. Right now I am trying to create a simple lightning effect. As in, a lightning bolt projectile I can use as a javelin. No luck so far however. I just can't get it to look right.
 
I am working on a mod (which I took over after it was abandoned).
One issue I am having is that the game date is not displaying, it simply says 'stone age'.
Does anyone have any idea how I can fix it so it displays the game date, or at least which files determine this information?
Thanks,

upload_2018-10-16_22-43-46.png
 
I have been getting a couple of bug reports that mention a crash, when opening them with a debug DLL I end up with this stacktrace:
Spoiler :
exceptionnew.png

... which is not very helpful. It's a stack overflow error, so am I right to assume that the game is allocating too many objects until memory is exhausted, probably in a non-terminating loop? Is there anything I can do to find out where in the code that happens?
 
@EdmundIronside: Open My games/Beyond the Sword/CivilizationIV.ini
Here you make sure you have python errors enabled by setting it like this:
Code:
; Set to 1 for no python exception popups
HidePythonExceptions = 0
I'm far from certain this will help, but it's always the best place to start whenever something in the python display is missing.

I think it's also possible to overwrite this using text xml, meaning the "translation" just doesn't include the date. To quickly test this, try to move xml/text out of the mod and start it again to see if it made a difference.

@Leoreth: That's sure is annoying. Assuming you can't get a clue based on recent changes or which action you do to trigger this, the only thing I can think of offhand is using VC 2017. If you debug using that one you will get a graph of the current memory usage. This will both give you an indication of how much/fast it grows and it should also make it possible for you to break when it suddenly starts to climb steeply, in which case you can step through the code to see where in the DLL you end up. I know it's not the perfect answer, but it's all I can think of right now.
 
Well at least it's something, thanks. I'll review some recent changes to see if they're responsible, but I've been very active lately so it's not as obvious.
 
Back
Top Bottom