• Our friends from AlphaCentauri2.info are in need of technical assistance. If you have experience with the LAMP stack and some hours to spare, please help them out and post here.

Quick Modding Questions Thread

Text in the game works like this:
0 to 255 (0xFF) are regular characters.
Sometimes wide characters are used (like CvWString), in which case each character use 16 bit. GameFonts are added in the 16 bit area. The first one is at 8483 and then you just count the offset. Don't ask why it's that number. It just is according to the exe.

In python you can access them using code like this:
PHP:
iID= 8483
string = u"<font=4u>" + (u" %c" %  (iID)) + u"</font>"
Size 2 or smaller will use the small GameFont file while size 3+ will use the big one.

Some info classes have functions like getChar(). Functions like that returns an int and can be used instead of iID. Writing the number directly will allow access to all, even those not accessible by class functions.
Do note that the exe sometimes skip empty icons, meaning you can't be 100% sure of the number by just counting. It might require a bit of trial and error to get the number right.

I wrote a python screen to get the ID of all gamefont icons. However the way I wrote it makes it tricky to move from Colonization to BTS. Still it should be fairly trivial to loop the ints and print int and icon to get them all.
 
Last edited:
Nice, thank you. I was trying to trial and error my way through but it seems the behaviour of skipping empty icons is what threw me off there.

This really helps a lot.
 
I need help in using the game fonts file. I have roughly the following font file, similar to the BUG base including some changes for my mod:

View attachment 467509

In particular, I need to know how to address some of these icons in Python code. I know how to handle everything from the happy face char onwards (use FontSymbols enum, and export new additions to Python wrapper if needed). I need to add about 16 icons, and with the current fonts file there is not enough space in the row where I know how it works. But if I go about adding icons into other rows, how do I actually reference them in Python?

For example, the row right above it contains icons for space ship projects (coming from BUG iirc), but I cannot find where they are actually used to learn how it works. Can I put new icons into this row, and if so, how can I address them?

BUG is completely integrated into my mod, so if it comes with utilities that would help doing this that's possible.

Look in /Assets/Config/init.xml for the FontUtil section. Here you can add new symbols and specify their offset (positive or negative) from existing symbols. Finding the right offset can require some experimenting, especially with new lines, but generally most positions are possible. Below is how it looks in HR; if you want to add new symbols to the spaceship line you can just add them after the Thruster, as it's read sequentially from the last defined offset. To reference them, use FontUtil.getChar("symbol id")

PHP:
    <init module="FontUtil" immediate="True"/>
    <symbol id="war" from="COMMERCE_GOLD" offset="25"/>
    <symbol id="peace"/>
    <symbol id="space"/>  <!-- blank symbol the same size as other standard symbols -->
    <symbol id="militaryinstructor" name="MILITARY_INSTRUCTOR"/>
    <symbol id="land" name="DOMAIN_LAND"/>
    <symbol id="sea" name="DOMAIN_SEA"/>
    <symbol id="air" name="DOMAIN_AIR"/>
    <symbol id="sentry" name="ORDER_SENTRY"/>
    <symbol id="fortify" name="ORDER_FORTIFY"/>
    <symbol id="wait" name="ORDER_WAIT"/>
    <symbol id="upgrade"/>
    <symbol id="cancel"/>
    <symbol id="ss casing" from="HAPPY" offset="-25"/>
    <symbol id="ss cockpit"/>
    <symbol id="ss docking bay"/>
    <symbol id="ss engine"/>
    <symbol id="ss life support"/>
    <symbol id="ss stasis chamber"/>
    <symbol id="ss thruster"/>
    <symbol id="citizen" from="POWER" offset="1"/>
    <symbol id="national" name="NATIONAL"/>
 
Look in /Assets/Config/init.xml for the FontUtil section.
This requires BUG while my reply works with vanilla. It's ok because the question states that BUG is in use. I just wanted to point out this difference in case somebody else comes across this at some point.

There is a GameFont editor which I highly recommend here
I thought about mentioning this one and forgot to write it. I say it goes beyond recommendation. Not only is it a whole lot easier to use, it's also way less likely to break your GameFont file.
 
I think that is the way to go now. The only thing left that I can think of is to attach a debugger and look at the call stack when it asserts to see where the string comes from. Actually I would recommend this approach as the first step when a mystery assert like this one appears. However I didn't mention it because it seems very few people are able to use the debugger and it doesn't work with the steam version.
@dacubz145 - Do you have your source files in a repository somewhere that we can look at?
My apologies as I'm not exactly the most tech-savy modder. By source files, do you just mean the xml files? I could definitely upload those,

I don't use steam, so I use the just basic debugger. Like I said not super into coding, so don't understand the DLL, just understand how the debug tells me where things go wrong.
 
Look in /Assets/Config/init.xml for the FontUtil section. Here you can add new symbols and specify their offset (positive or negative) from existing symbols. Finding the right offset can require some experimenting, especially with new lines, but generally most positions are possible. Below is how it looks in HR; if you want to add new symbols to the spaceship line you can just add them after the Thruster, as it's read sequentially from the last defined offset. To reference them, use FontUtil.getChar("symbol id")

PHP:
    <init module="FontUtil" immediate="True"/>
    <symbol id="war" from="COMMERCE_GOLD" offset="25"/>
    <symbol id="peace"/>
    <symbol id="space"/>  <!-- blank symbol the same size as other standard symbols -->
    <symbol id="militaryinstructor" name="MILITARY_INSTRUCTOR"/>
    <symbol id="land" name="DOMAIN_LAND"/>
    <symbol id="sea" name="DOMAIN_SEA"/>
    <symbol id="air" name="DOMAIN_AIR"/>
    <symbol id="sentry" name="ORDER_SENTRY"/>
    <symbol id="fortify" name="ORDER_FORTIFY"/>
    <symbol id="wait" name="ORDER_WAIT"/>
    <symbol id="upgrade"/>
    <symbol id="cancel"/>
    <symbol id="ss casing" from="HAPPY" offset="-25"/>
    <symbol id="ss cockpit"/>
    <symbol id="ss docking bay"/>
    <symbol id="ss engine"/>
    <symbol id="ss life support"/>
    <symbol id="ss stasis chamber"/>
    <symbol id="ss thruster"/>
    <symbol id="citizen" from="POWER" offset="1"/>
    <symbol id="national" name="NATIONAL"/>
Oh that's great, I tried to look into the FontUtils module when trying to understand how it uses symbols, but I couldn't find out where it initialises its values so I could add more. I always forget that BUG relies on XML a lot. Thanks!

There is a GameFont editor which I highly recommend here
Yeah, honestly I don't really want to think about what it would be like going back to editing font files manually. Adding new icons using the editor is really comfortable, I only got stuck using them after they've been added.

This requires BUG while my reply works with vanilla. It's ok because the question states that BUG is in use. I just wanted to point out this difference in case somebody else comes across this at some point.
I'm interested both in the convenient BUG solution as well as understanding how the font file actually works, so both answers are greatly appreciated.
 
Could someone please explain me how flavors actually work?
I already learned that these are the existing ones:
Spoiler :

<FlavorTypes>
<FlavorType>FLAVOR_MILITARY</FlavorType>
<FlavorType>FLAVOR_RELIGION</FlavorType>
<FlavorType>FLAVOR_PRODUCTION</FlavorType>
<FlavorType>FLAVOR_GOLD</FlavorType>
<FlavorType>FLAVOR_SCIENCE</FlavorType>
<FlavorType>FLAVOR_CULTURE</FlavorType>
<FlavorType>FLAVOR_GROWTH</FlavorType>
<FlavorType>FLAVOR_ESPIONAGE</FlavorType>
</FlavorTypes>

My guess is that if a FLAVOR_x is present in both LeaderHeadInfos.xml AND in an other xml (building, unit, civic, etc) that it has an increased chance to be picked. Is it? What is the exact formula?
Is it hard to add new flavors? Do I only add it in GlobalTypes.xml and the other xml I want to use or does it require dll work too?

THX in advance!



EDIT:
After some search I have found sufficient answer for my question: https://forums.civfanatics.com/threads/quick-modding-questions-thread.351519/page-243#post-14384592 :)
 
Last edited:
Could someone please explain me how flavors actually work?
I too was interested in an answer to this and I just stumbled on a post that explains what happens in the code. The important bit is
...

Basically in evaluating something, part of the process involves a flavor calculation (this applies to civics and buildings). Essentailly what is does is:

For each flavor type (FLAVOR_GOLD, FLAVOR_MILITARY, etc.) it takes the flavor value defined in its leaderhead info, and multiplies it by the same flavor's value defined in the object being evaluated (civic for the purposes of this discussion).

...
 
As far as I know, AI weight is completely separate from flavours. Basically, whenever the AI makes a decision (let's say which civic to adopt), it will make an internal calculation about the values of different civics, which is coded in the DLL and depends on the effects of the civic and its current game situation (with varying degrees of accuracy). The AI weight is simply added on top of that value score. It's useful for example when you code additional effects for a civic (e.g. in Python) that the DLL AI code does not know about, because you then can increase the value of the civic in that way to make the AI value it at least somehow, so this is obviously a very blunt tool.

So basically, AI weights are about AI decisions in general while flavours exist to create different AI personalities.

By the way, I wonder what happens when you set negative flavour values ...

Edit: quick correction, AI weight is multiplied by your number of cities.
 
Last edited:
I been experimenting with new civics and I noticed that civic effect that gives +% growth to cottages doesn't seem to do anything. New cottages still take exact same time to grow as before implementing this civic.
I assume you mean iImprovementUpgradeRateModifier. I just checked the code and I think I spotted your problem. The growth rate is (modifier + 100) / 100. That looks fine at first glance. 100+5 => 105/100 = 1.05, which math tells us is +5%. However since the number is stored as an int, it is rounded down. This means (0+100)/100 = 1, but also that (99+100)/100 = 1 (because it's 1.99). This means all you can do is to use +100%, +200% etc. It would be nice to get +50% or +20% or something like that, but that would require changes to the DLL.
 
I assume you mean iImprovementUpgradeRateModifier. I just checked the code and I think I spotted your problem. The growth rate is (modifier + 100) / 100. That looks fine at first glance. 100+5 => 105/100 = 1.05, which math tells us is +5%. However since the number is stored as an int, it is rounded down. This means (0+100)/100 = 1, but also that (99+100)/100 = 1 (because it's 1.99). This means all you can do is to use +100%, +200% etc. It would be nice to get +50% or +20% or something like that, but that would require changes to the DLL.

Thank You Nightinggale!
I understand now, I guess I will have to deal with dll changes sometime later. ;)
I wonder if 2 different Civics at 50% would combine into 100 total, or will they also nullify before that?
 
How do I combine BUFFY, Cultural Citystyles, and K-Mod?

(If that's really complicated I'll settle for adding BUG to K-mod.)

EDIT: No one seems interested so I made a thread.
 
Last edited:
Question. I want to make a new building that will add specific Resource to the specific city only.
The normal resource adding option in Buildings file adds Resource to entire empire (all cities) where I only want it for where the building is built.

I know Corporations like Synthetic Oils does something like that, but I don't want to use Corps, I just want to emulate the effect.
Any ideas?

Thanks!
 
I think resources are added to plotgroups and then cities read the plotgroup they are in. This means making a building provide resources to one city only will require DLL changes and it seems like it would be fairly strait forward to implement... once you figure out where to add it.

Next question: does this exist as a mod or modcomp already? I think I will be able to figure this one out, but I won't spend the time if it's already done ;)
 
Unfortunately I don't know of any modcomp that individual does that.

However I was experimenting with Corps and figured out a way. If I simply have executive built an instance of Ethanol Corp - I get the Oil in that city, without incorporating anything.

I assigned incorporate function to a Great Engineer directly so now he can built a single instance of Ethanol without ever forming a Corp.

I think this should work out ;)
 
Last edited:
Back
Top Bottom