Resource icon

C3X: EXE Mod including Bug Fixes, Stack Bombard, and Much More Release 16

C3X GitHub page: https://github.com/maxpetul/C3X
I added current versions of my Ghidra project folders to the repo, they're inside the "Decompilation" folder. There are two archives, one for the GOG version of Civ 3 Complete and another for the Steam version. The GOG version is much more fleshed out, it's where I do all of my reverse engineering work. On the Steam version I do only as much as I need to to port the mod over. I'll try to keep these archives reasonably up to date going forward.
There's also a single player server with mod channels: https://discord.gg/H3FUwHcWeu
Thanks, I'll check it out one of these days.
 
The mod doesn't impose any maximum amount, though technically there is a limit of about 2 billion due to 32-bit integer math. But ignoring that, the mod will work with whatever perfume amount you enter, even if it's negative. I expect it would work properly even with huge or negative values, but I haven't tested that.
 
Alright, I'll post the decompilation along with the rest of the mod to GitHub tomorrow. Transferring all the decompilation work to another executable would be a big project, doubly so if the other executable isn't for an identical game. It would probably be easier to mod Conquests to emulate the original game, though it's been so long since I've played the original I've forgotten most of what was changed.

I'm not on Discord. Is there a big Civ 3 modding community there? I've heard there's a multiplayer community, but MP Civ has never interested me.

Well, there's the single-player Discord that was linked below. But mostly I just want the chance to get to talk to you myself. I head up a modding community of my own and Civ 3 has always been one of my forgotten little side projects within it... and I'd love to bring it back into the spotlight. I really think we could help each other out, especially since our interests seem closely aligned.
 
Last edited:
@Flintlock, I just remembered another (minor) bug, which hasn't yet been mentioned in this thread: the "Cultural Linkage" bug, which, when activated, places some or all of the American Culture-group Civs on the map, in preference to any Civs from the other Culture-groups.

As I understand it, the bug has actually been present in the game since Vanilla. However, since that (and PtW?) had only 3 American Civs (USA, Aztecs, Iroquois), it was really only a problem on Tiny maps -- where all 3 opponents would then be American (if the player was not randomly assigned an American civ themselves). But after Conquests added the Mayans and Inca, the bug now also manifests on Small maps, and will still be noticeable on Standard maps. On Large/Huge maps (11 or 15 opponents), or Huge+ mods with >16 Civs, it is obviously (much) less of a problem -- but many players find such large maps tedious to play out.

While I realise that this may well be something you have no time/ interest in looking at, on the off-chance that you might want to, the bug is (presumably) somewhere in the map-generation section of the .exe, since it is (IIRC) activated by selecting the following settings in the "Choose Your Civ" screen:

-- Your Civ = Random
-- AI Opponents = All Random
-- Cultural Linkage = On

If any of the above are not true, then the bug doesn't occur. So it can be worked around, but it's still slightly unsatisfying for the game not to be functioning as intended in this respect (e.g. AFAIK, same-Culture Civs are also coded to be more friendly to one another initially, so having Culture-linked neighbours, especially at higher diffs, may slightly reduce the likelihood of getting stomped in the early game...).
 
I just remembered another (minor) bug, which hasn't yet been mentioned in this thread: the "Cultural Linkage" bug, which, when activated, places some or all of the American Culture-group Civs on the map, in preference to any Civs from the other Culture-groups.
I had a quick look into this (I already know where the Leader objects get initialized at game start so it's just a matter of looking "behind" there) but nothing stood out to me as obviously buggy. This looks like a subtle bug, which is the worst kind. I'll add it to the list for now and maybe at some point I'll do a thorough investigation.



In other news, I put the AI's production rankings in an in-game popup and injected another call to get the point values for unit types as well as improvements. Here's what it looks like now:
ai_full_prod_ranking.png

I was hoping to apply a modifier to the AI's point values to encourage it to build more artillery, instead of the current method which overrides its build choices to enforce a ratio, but as you can see that won't work since it appears the AI assigns a value of 0 to catapults when it doesn't want any more. Similarly, a modifier won't work to encourage the AI to build more workers. It could work for buildings, though, at least in most cases. I'm thinking of changing the way perfuming works so that it's a modifier instead of a flat number of points, that could be used to encourage the AI to build more courthouses and fewer colosseums, but it wouldn't work well for granaries because the AI just doesn't get the point of them.
 
Hi Flintlock, that looks amazing!!!
would the point value be factored in as strait percentage of the total?

For example, in your screen shot above, assuming everything else is zero except spearman and swordsman, is the chance the AI will build a spearman 151 / (151 + 106) = 58% chance?
 
Last edited:
I had a quick look into this (I already know where the Leader objects get initialized at game start so it's just a matter of looking "behind" there) but nothing stood out to me as obviously buggy. This looks like a subtle bug, which is the worst kind. I'll add it to the list for now and maybe at some point I'll do a thorough investigation.
There's a scenario setting for culturally linked start locations, correct? If that's disabled, does this bug still manifest? I'm speculating that when the civs are assigned, it iterates through culture groups (AMER being first alphabetically) and assigns them start locations in clusters of some (too large) size. Maybe it doesn't take world size or player count into account at that step, or over-emphasizes clustering over representation, and all of the spots are filled by the time it finishes the first cluster.
 
would the point value be factored in as strait percentage of the total?
The AI chooses to build whatever has the highest point value. There is an element of randomness to its decision in that the values vary randomly +/- 5 points or so. For example in the case of that screenshot the AI would always choose the spearman but when I re-ran the ranking a bunch of times I occasionally saw the archer listed above the marketplace.
I'm speculating that when the civs are assigned, it iterates through culture groups (AMER being first alphabetically) and assigns them start locations in clusters of some (too large) size. Maybe it doesn't take world size or player count into account at that step, or over-emphasizes clustering over representation, and all of the spots are filled by the time it finishes the first cluster.
I've found the area of the code that randomly chooses a civ for the AI when culturally linked starts is set but I don't know yet exactly how it works. So far I don't see any loops over culture groups, only over players and civs. Also I don't see anywhere that it accounts for the distance between starting locations, only what continent they're on. Does that sound right? Does anyone know exactly how the culturally linked starts option is supposed to work?
 
The AI chooses to build whatever has the highest point value. There is an element of randomness to its decision in that the values vary randomly +/- 5 points or so. For example in the case of that screenshot the AI would always choose the spearman but when I re-ran the ranking a bunch of times I occasionally saw the archer listed above the marketplace.

Interesting thanks! I'm still a little confused by this. So in the city in your screenshot, the AI would just keep building spearmen forever?
Or do these numbers get reset after the spearman is built so that the AI might build something else?
If so, not sure if you would know what factors change these numbers (a bigger change than just the +/- 5 points that you mentioned)?
 
How hard it would be to remove unit from build queue (both for AI and player) under certain condition, for example limit unit to one per civ (for very special units) or limit to number of cities (limit early worker production) or number of certain resources controlled by civ. We can do it to some degree now by abusing leaders or armies or auto building, but it doesn't really work well, especially for AI.
 
Interesting thanks! I'm still a little confused by this. So in the city in your screenshot, the AI would just keep building spearmen forever?
I meant that if you run the production chooser function multiple times while nothing changes in the game, the spearman would always come out on top despite the randomness. On later turns, when the state of the game is different, the values would be different too. I don't know the details of how the AI comes up with those values. They're based on the basic stuff you'd expect like the unit type's attack & defense power, its abilities, etc, then there's a few hundred lines of additional logic that I haven't investigated.
How hard it would be to remove unit from build queue (both for AI and player) under certain condition, for example limit unit to one per civ (for very special units) or limit to number of cities (limit early worker production) or number of certain resources controlled by civ.
Adding restrictions to unit construction would be easy. I've already found the function that governs whether or not any given unit type is buildable in any given city and modifying it to include new conditions is straight forward. The problem with adding this kind of feature is that it would need to work based on scenario-specific config data and right now the mod can only load a single global config. The problem of creating & loading scenario-specific configs is something I've been procrastinating on for months now.
 
C3X GitHub page: https://github.com/maxpetul/C3X
I added current versions of my Ghidra project folders to the repo, they're inside the "Decompilation" folder. There are two archives, one for the GOG version of Civ 3 Complete and another for the Steam version. The GOG version is much more fleshed out, it's where I do all of my reverse engineering work. On the Steam version I do only as much as I need to to port the mod over. I'll try to keep these archives reasonably up to date going forward.

Thanks, I'll check it out one of these days.

Cool! I have cloned the repository. I don't know if I'll ever get around to doing anything with it, but it's nice to have access. Thank you!
 
Thank you Flintlock for such a nice update. Stack unit commands for workers and units are working fantastically well and the game is so much different for me.

I want to add another things to the list like the others do. I don't know if it was mentioned before, I noticed that in city governor auto production it doesn't always work as is set. When I set this: Produce Settlers or Produce Artillery to Never in All Cities it actually produces very often those units. This only happening with settlers and artillery the others city productions are fine, they work as they set.
The other this is about Treasury which has to be carried to the capitol to gain gold. I have treasuries produced by Wonders. AI is not gaining any gold from it, it's storing it in capitol. I don't know if this is something to do with my settings or just a bug.
 
The other this is about Treasury which has to be carried to the capitol to gain gold. I have treasuries produced by Wonders. AI is not gaining any gold from it, it's storing it in capitol. I don't know if this is something to do with my settings or just a bug.

register, in most cases this is an error in your settings about capturing the princess (= treasure).The only bug is, when the "treasure" (=princess) is autoproduced in your capital. In that case the AI is not able to recognize, that it first must move the "treasure" out of the capital to bring it escorted back to the capital to gain the gold of the "treasure"-flag-unit (with the victory point settings and the gold for princess setting activated).
 
register, in most cases this is an error in your settings about capturing the princess (= treasure).The only bug is, when the "treasure" (=princess) is autoproduced in your capital. In that case the AI is not able to recognize, that it first must move the "treasure" out of the capital to bring it escorted back to the capital to gain the gold of the "treasure"-flag-unit (with the victory point settings and the gold for princess setting activated).
Ok, understood. However all treasuries are autoproduced by wonders and very often AI capitols are most advanced cities and AI is building wonders there. So how to go over this?
 
I don't know if it was mentioned before, I noticed that in city governor auto production it doesn't always work as is set. When I set this: Produce Settlers or Produce Artillery to Never in All Cities it actually produces very often those units. This only happening with settlers and artillery the others city productions are fine, they work as they set.
The other this is about Treasury which has to be carried to the capitol to gain gold. I have treasuries produced by Wonders. AI is not gaining any gold from it, it's storing it in capitol.
Added to the list. I have barely touched the city governor even as a player so I don't know how difficult that would be to fix, but assuming the governor reuses the AI's production chooser logic it shouldn't be too hard. About treasure units, can you tell me exactly how they're set up? Like what AI strategy, abilities, and actions are they given? And when @Civinator says they must be moved out of the capital and brought back, does that apply to the human player too?
 
Added to the list. I have barely touched the city governor even as a player so I don't know how difficult that would be to fix, but assuming the governor reuses the AI's production chooser logic it shouldn't be too hard. About treasure units, can you tell me exactly how they're set up? Like what AI strategy, abilities, and actions are they given? And when @Civinator says they must be moved out of the capital and brought back, does that apply to the human player too?

Great thank you. About a treasure, I don't have any AI strategy set up for it, abilities are: requires escort, wheeled, flag unit. Yes, it's apply to human player too the treasury can be only converted to gold in capitol, so the human player must do the same.
Something just came to my mind. Did you try to change number of culture groups or is it doable?

settings.jpg


settings1.jpg
 
Last edited:
About treasure units, can you tell me exactly how they're set up? Like what AI strategy, abilities, and actions are they given? And when @Civinator says they must be moved out of the capital and brought back, does that apply to the human player too?

Flintlock, the "treasure units" or "supplyshipments", as I name them in CCM, are flagunits (that´s the AI strategy, too) using mechanisms of the shortgame modes "capture the princess" or "reverse capture the flag" and should provide the civs in the game with some additional gold as a kind of "caravans", when the conditions described below are fullfilled.

There are two possibilities to create those C3C-caravans:

1. The reverse-capture the flag option, when those units must be transported at least in the last move to a victory point (better suited for games with fixed maps)
2. The capture-the-princess option, when those units must be transported at least in the last move into the capital of the civ (better suited for random maps)

For both options the victory point scoring option and a value in gold when the operation is finished, must be set, too.

So these flag units could be produced normally, too, in the existing mods and scenarios it only makes sense to use autoproduced flag-units or to gain them by an event in the short game modes.

The problem with supplyshipments autoproduced in the capital, that must be moved out of the capital and than must be escorted by another unit back into the capital exists for the human player, too - but the human player is able to recognize that procedure.

Here are some screenshots from the CCM 2.50 mod (the labels text for capture the princess is changed to the more adequate text supply shipments):

Supplyshipment1.jpg


Supplyshipment2.jpg


Supplyshipments3.jpg


Supplyshipment4.jpg
 
Last edited:
Thanks for the info guys, I was able to set up a simple scenario with a treasure unit which I could use with a debugger to poke around and locate the relevant code. Now about resolving the issue, my first thought was to allow AI players to redeem any treasure units sitting in their capital, but unfortunately that's not practical since the code to redeem is tightly integrated into the unit movement code. A more practical solution would be to program the AI to do a little maneuver of removing its treasure units and bringing them back but I haven't yet found a good place to insert that behavior.

Did you try to change number of culture groups or is it doable?
I haven't looked into removing the limit on culture groups yet so I can't say for sure if it's doable. All I can say is so far I haven't come across anything that would make it impossible.
 
Top Bottom