• We are currently performing site maintenance, parts of civfanatics are currently offline, but will come back online in the coming days (this includes any time you see the message "account suspended"). For more updates please see here.
Resource icon

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

If you guys keep distracting me like this, R16 will never be done. But now feels like a good time so I had another look at this bug, I'd looked into it before but only very briefly. As it turns out, it's due to a small, sloppy error in the original code, and is easy to fix.
Haha that wasn't even really adressed at you, I am sorry for the distraction. But damn, you just keep continuing to be our hero. :) Thanks for the fix, and the write-up was also interesting to read. I sadly don't really have any C/C++ knowledge, so the code isn't super self-explanatory to me (I'm mostly confined to Java), but your comments explained it well.
 
Unfortunately I didn't even think of scenario-specific art at all when writing the code to load the stacked buttons. It should be easy to make the mod look for those files in the scenario folder first before its own folder, so I'll try to make that happen for R16.

This applies to the diplo arrows as well.

The "retreat if faster" function works great exactly as intended, however, it does exacerbate an existing issue which I always thought of as a bug. Any time a multi-move unit attacks a a single-move unit, it will physically close the distance to fight, regardless of whether one or both units have the "ranged attack animation" flag. It always seemed that this flag should override the function of the fast vs slow unit. It just graphically looks bad after the medieval era and when vehicles are involved.


naked-gun-meme.gif


Just another thing to pile on, as if you didn't already have enough to do. Thanks.
 
That seems like a missed opportunity. I expect it would be easy to allow for barb cities in scenarios given how the scenario data is laid out. The only catch should be the need to give them proper city graphics since the "none" culture group doesn't have any. Given the choice between modifying the Quintillus or Firaxis editors, I'd rather do the first one since its source code is available. We could even ask Quintillus for help.
This sounded interesting enough (especially with @Lord_Hill having dug up the thread from 11 (!) years ago) that I decided to take another look at it tonight.

I found that if I set the owner group to Barbarians (versus Player or Civilization), the cities disappeared in-game. But if I set the owner to Civilization, and then choose Barbarians, at least in my one sample BIQ, the game does loads right up. In this screenshot, Neapolis is a barbarian-civilization-owned city:

1679972273292.png

Now you might think, "great! barbarians can own cities", and I neither got a crash nor a Hiawatha or Smoke Jaguar graphic (potentially though unlikely relevant detail: this is testing with the Steam version of C3C on my new laptop). But it's worth noting that Neapolis does not grow, either in food nor in shields, and perhaps less surprisingly diplomacy with the barbarians is not possible.

Even with such limitations, it could be a useful mechanic to have pre-placed capturable cities. I tried putting a barb camp on Neapolis as well, but it disappeared, although it did produce two bonus Warriors for the barbarians at that tile. The barbarians at Neapolis also seem to prefer to stay where they are rather than roam the countryside, both the "bonus warriors" and pre-placed barbarian units, which can be of any type.

I'll put together an editor update with that feature, as well as a couple others than have been waiting around for the next release, so the iron can be struck while it's hot on the barbarian city idea.
 
This sounded interesting enough (especially with @Lord_Hill having dug up the thread from 11 (!) years ago) that I decided to take another look at it tonight.

I found that if I set the owner group to Barbarians (versus Player or Civilization), the cities disappeared in-game. But if I set the owner to Civilization, and then choose Barbarians, at least in my one sample BIQ, the game does loads right up. In this screenshot, Neapolis is a barbarian-civilization-owned city:

View attachment 657847
Now you might think, "great! barbarians can own cities", and I neither got a crash nor a Hiawatha or Smoke Jaguar graphic (potentially though unlikely relevant detail: this is testing with the Steam version of C3C on my new laptop). But it's worth noting that Neapolis does not grow, either in food nor in shields, and perhaps less surprisingly diplomacy with the barbarians is not possible.

Even with such limitations, it could be a useful mechanic to have pre-placed capturable cities. I tried putting a barb camp on Neapolis as well, but it disappeared, although it did produce two bonus Warriors for the barbarians at that tile. The barbarians at Neapolis also seem to prefer to stay where they are rather than roam the countryside, both the "bonus warriors" and pre-placed barbarian units, which can be of any type.

I'll put together an editor update with that feature, as well as a couple others than have been waiting around for the next release, so the iron can be struck while it's hot on the barbarian city idea.
The new version of the Quintillus editor can be found here:

https://forums.civfanatics.com/thre...ts-now-available.377188/page-74#post-16435386
https://forums.civfanatics.com/resources/cross-platform-civ3-editor.15288/

Quintillus, thank you very much for creating that new version of your editor. :)

In that context here is a link to my tests with Barbarian cities that I made some years ago with the multiplayer tool:

Among some other results in that test with the multiplayer tool it was possible to place Barbarian huts and even colonies next to Barbarian cities, as those Barbarian cities had zero culture.
 
This applies to the diplo arrows as well.
Those will be replaceable too in the next version. It was trivial to make them replaceable once the basic work was done for the button images. The tile highlights would require more work so those will not be replaceable for now. I doubt anyone's bothered by that.

As for the ranged attack animations, I'll try to keep that in mind without getting distracted by it. I don't mind the distractions, it's fun to find new easy little things to work on but I'd really like to get R16 done finally. I feel like I've been talking about it for months.


Now you might think, "great! barbarians can own cities", and I neither got a crash nor a Hiawatha or Smoke Jaguar graphic (potentially though unlikely relevant detail: this is testing with the Steam version of C3C on my new laptop). But it's worth noting that Neapolis does not grow, either in food nor in shields, and perhaps less surprisingly diplomacy with the barbarians is not possible.
Very nice! The fact that barbarians have no city economy is another thing I'll change in the next version of C3X. It's actually an easy change to make. Basically the game calls a method to do the production phase for each leader in the game during the interturn, including the barbarian "leader" with ID zero. That method has a separate branch for the barb leader that does barb production like spawning units at camps. I can redirect the control flow so the production phase for the barbs includes both branches, that way the game will evaluate city production for barb cities. In other words the base code looks like this:
C:
void __thiscall
Leader::do_production_phase(Leader *this)
{
    if (this->ID != 0)
        goto civ_production;
    // do production phase for barbs
    goto done;
civ_production:
    // do production phase for civs (city production, growth, research, maintenance, etc.)
done:
    return;
}
I can redirect goto done after barb production to point instead to civ_production.

Do you know how the barbs ended up with those city graphics? What's their culture group? In my own experiments using the Firaxis editor and no preplaced barb cities (they captured them after the game started), they used incorrect city graphics consistent with what Civinator showed in that thread since they were in the "none" culture group with index -1.


Questions:
  1. How/Where does the Barbarian City Graphic(s) fit;
  2. Can there be Improvements in the City to, say, spawn particular Barbarian Units;
  3. Can they be Era specific; and,
  4. Can they be upgradeable?
The issue with city graphics for barbs is that the graphics are tied to culture groups and barbs don't normally have a real culture group. The Firaxis editor says they're in the "none" group but that group has no graphics associated with it. What I'm going to do for the next version of C3X is add a rule where, if barb city capturing is enabled and the barbs don't have a proper culture group, they're placed in the first real group (American, index 0). That's just to fix graphical corruption and crashing issues, eventually I'd like to add special city graphics just for the barbs. That shouldn't be difficult, but again I don't want to keep piling things into the next version.

As for improvements in barb cities, those should work just as well as improvements in any civ's cities. The barbs will be running the normal production logic which includes unit spawning from buildings. Hopefully it all just works. I haven't tested unit spawning specifically, this is all experimental at the moment.
 
Speaking of the R16 (I assume there's still some time before it comes out), I'd like to get my hands on the maintenance bug fix, was just wondering if the version you currently have in Git master branch is stable enough, I might just grab that to give it a go?
 
Those will be replaceable too in the next version. It was trivial to make them replaceable once the basic work was done for the button images. The tile highlights would require more work so those will not be replaceable for now. I doubt anyone's bothered by that.

As for the ranged attack animations, I'll try to keep that in mind without getting distracted by it. I don't mind the distractions, it's fun to find new easy little things to work on but I'd really like to get R16 done finally. I feel like I've been talking about it for months.

I understand. I just figured I'd post this kind of thing in the thread to preserve before it slips my mind.
 
Speaking of the R16 (I assume there's still some time before it comes out), I'd like to get my hands on the maintenance bug fix, was just wondering if the version you currently have in Git master branch is stable enough, I might just grab that to give it a go?
At the moment I still need to find some addresses in the Steam and PCGames.de executables, so it won't work on those versions, however if you're using the GOG version of the game it should work well enough. It's been through basic but not extensive testing.
 
At the moment I still need to find some addresses in the Steam and PCGames.de executables, so it won't work on those versions, however if you're using the GOG version of the game it should work well enough. It's been through basic but not extensive testing.
Great, thanks for confirming! I have the GOG version, so shouldn't be a problem. :thumbsup:
 
Do you know how the barbs ended up with those city graphics? What's their culture group? In my own experiments using the Firaxis editor and no preplaced barb cities (they captured them after the game started), they used incorrect city graphics consistent with what Civinator showed in that thread since they were in the "none" culture group with index -1.
I figured the code probably skipped over the barbs for city production based on the observed behavior.

As for the graphics, I don't know how they wound up with those city graphics; they still have the "None" culture group in my test BIQ. I expected incorrect graphics of some sort as well. Perhaps it's just using a pointer the file name from an invalid offset in memory, and what happens to be there can vary by the scenario data? :dunno:

I've attached my test files (one in Debug Mode, one not) so it can be tested on other machines and perhaps releases of Civ.
 

Attachments

Maybe this has already been addressed somewhere else, but is there a way to make "detect invisible" work with an aircraft recon mission? Or maybe adjust the detect invisible radius for some units? I was just wondering if there were a way to add some flavor to the sub vs anti-sub gameplay by making airborne sub hunters (S-3 Viking, P-3 Orion, etc.) more viable. I only recently came across this mod (build 14) a couple of months ago but can't go back to playing without it. Thank you for your hard work.
 
Maybe this has already been addressed somewhere else, but is there a way to make "detect invisible" work with an aircraft recon mission? Or maybe adjust the detect invisible radius for some units? I was just wondering if there were a way to add some flavor to the sub vs anti-sub gameplay by making airborne sub hunters (S-3 Viking, P-3 Orion, etc.) more viable. I only recently came across this mod (build 14) a couple of months ago but can't go back to playing without it. Thank you for your hard work.

I didn't know that detect invisibility didn't work on recon missions; I've been hoping to use option that for a mod I'd like to make, so this change would be very useful for me as well.
 
As for the graphics, I don't know how they wound up with those city graphics; they still have the "None" culture group in my test BIQ. I expected incorrect graphics of some sort as well. Perhaps it's just using a pointer the file name from an invalid offset in memory, and what happens to be there can vary by the scenario data? :dunno:
It is weird. It might be related to era ID since that's a factor in what city graphic is used and that scenario has non-standard eras. As far as I know, when the game reads outside the bounds of the city graphics array, you either get a leader portrait if it reads before the start of the array, or a crash if it reads beyond the end. I tried that scenario in the GOG, Steam, and PCGames.de versions of the game and got the same city graphic in each.
Maybe this has already been addressed somewhere else, but is there a way to make "detect invisible" work with an aircraft recon mission? Or maybe adjust the detect invisible radius for some units?
It's been requested before but I haven't looked into it yet. I did read some unit detection logic at one point, and as I recall the way it's done is by searching surrounding tiles for a detector unit, in other words there's no detection effect on tiles themselves. That makes it difficult to do detector recon missions since the detection effect would need to persist somehow without any unit to create it. At least that should make increasing the detection radius easier, although there I'm not sure what would happen if that radius were larger than the unit's base visibility radius, and I don't know what difficulties might arise when trying to extend base visibility beyond two tiles.
 
It is weird. It might be related to era ID since that's a factor in what city graphic is used and that scenario has non-standard eras. As far as I know, when the game reads outside the bounds of the city graphics array, you either get a leader portrait if it reads before the start of the array, or a crash if it reads beyond the end. I tried that scenario in the GOG, Steam, and PCGames.de versions of the game and got the same city graphic in each.
In the Debug biq Quintillus had posted, I changed two additional cities of the Goths to be Barbarian cities with the newest version of his editor. Interestingly in the view of the Quintillus editor all Barbarian cities (including Neapolis) had graphics of the American culture group. This is a culture group, that is not used in the Rise of Rome scenario/Conquest (that was the base for Quintillus in his biq).

In the game only the Barbarian capital of Neapolis had a city view graphic. Both ex-gothic cities of the Barbarians changed their graphics to transparency (what for my purposes wouldn´t be bad) and the cultural borders did disappear. When I conquered the ex-gothic Barbarian cities, the city graphics of the conquering civ and the cultural borders of the conquering civ appeared on the map.

BarbCities3.jpg


BarbCities1.jpg


BarbCities2.jpg
 

Attachments

Last edited:
Hi Flintlock. Thanks for all the hard work you put into making Civ 3 a better game.

I am the author of the mod 2021 EXPANSION. I have been using C3X actively in my mod since Release 7 in August 2021. I haven't read through this entire discussion, so please bear with me if I repeat stuff.
Here is my wishlist of remaining things I would like to change if I could. If you find room to address any of them in a future release it would be appreciated.


Show capital as actual size:
Option to not show the city graphics of capitals as 1 size larger than they actually are. Why: Can't see if they have City Walls. Cities and metropolises look the same. Knowing the actual city size is important to determine the defensive combat bonuses of the city.


Aircraft with no attacks left:
In a large stack of aircraft, if some of them have already moved, it is hard to know which ones have movement left, because there is no indication. It would be nice if aircraft (or any type of unit actually) could be represented in a different color (grey for example) in the right-click menu if their movement is spent.


Fighters always on air superiority mission:
If there are fighter aircraft present in a city, and they have not expended their movement, they should always be on a superiority mission, without having to give the order manually. Optionally, if this can't be done, there needs to be at least some kind of feedback whether the fighters are on a superiority mission or not. See previous paragraph about color change (blue maybe?).


Aircraft don't lose turn if engaged by SAM Missile Battery:
I think that being engaged by a SAM Missile Battery should work the same way as a unit with anti-air defense: It is either shot down or it isn't. If not, the aircraft should proceed with its mission unaffected. It should not lose its turn.


Warning when cities are built too close:
Currently, if you try to build a new city closer to an existing city than the "adjust_minimum_city_separation" allows, nothing happens and there is no feedback. I think there should be a message saying "Cannot build here, too close to existing cities" or something similar.


Golden Age turns left shown on banner:
The C3X mod allows remaining Golden Age turns left to be shown, which is very helpful. However, I suggest moving that information to the white banner that appears when there are 20 turns left of the game (in the bottom left corner, above the minimap). Why: The way it is currently displayed (in the bottom right info box) there isn't enough room to also display the turns left to the current tech discovery, unless the tech has a very short name. A Golden Age is such an important event that it deserves the same attention as game turns left, it also makes sense that they share the same banner.



Pollution:
While I feel there needs to be a mechanism that represents environmental damage from industrialization, and some incentive to make eco-friendly choices late game, I think there are two problems with the way it's modelled in the vanilla game: Local pollution is much to severe, requiring massive micromanagement. And global warming, which is by far the greater problem in the real world, is way to mild (barely noticeable during a game). My basic idea is to address both these issues simultaneously: Not by altering the values of population- or building pollution (from now on referred to combined as city pollution). Rather, I would intervene in the calculations that determine the likelihood of pollution manifesting itself physically on the map.


Local pollution:
At present, each city pollution (yellow biohazard sign) represents 1% chance of manifesting itself as local pollution (orange blob) outside the city. For example, a city with 17 city pollution will have 17% chance of generating local pollution, which equals about 1:6 chance each turn. This requires a lot of micromanagement, and is not very realistic. Sure, there would be the occasional oil spill or chemical accident, but it should be a rare event. My solution is to have a parameter called "Percentage Chance For City Pollution To Manifest Itself As Local Pollution", with a value between 0% and 1000%. This would give complete control over local pollution: It could be anything from zero, to ten times the number of city pollution. In my mod, I would probably reduce local pollution to 10%, meaning a city with 17 pollution would have a 1,7% chance of generating local pollution on the map. Each biohazard sign (city pollution) would then represent 0,1% chance, not 1,0%.


Global warming:
The city pollution from every city in the world is added together to determine the rate of global warming. At present, this effect is too insignificant (barely noticeable) and can safely be ignored. Which it should not! In my opinion, it needs to be dialled up a lot. I propose the same solution as for local pollution, a parameter called "Percentage Chance For City Pollution To Manifest Itself As Global Warming". In my mod, I would probably set this to somewhere between 500% and 1000%, making the effect 5 to 10 times stronger.

.
 
Last edited:
I posted a preview version of R16 to my GitHub (https://github.com/maxpetul/C3X/releases/tag/Release_16_Preview_1). It's still missing a couple of things I want to add for the final release. It also hasn't been extensively tested for bugs, but it should work well enough. Going forward, I'm going to try to put out more of these preview releases to compensate for the fact that the full versions take so long. They'll let me go faster back and forth with suggestions from this thread.

What's new in Release 16 Preview 1:
  • Barbarian city capture & production (experimental) -- If activated, when a barb unit enters a city, it will capture it instead of ransacking it. Barb cities can grow and produce units. Because of how barb city production works under the hood, it's necessary to have barbs turned on for their city production to work. The mod handles this automatically, if there's at least one barb city on the map and barb activity is at level 0 (no barbs), it will be increased to level 1 (sedentary) just for city production. I've labeled this feature as experimental since I don't know if it will work in all circumstances, for example I don't know what would happen if the barbs were to win the game.
  • Can use charm flag to control PTW-like artillery targeting -- If activated, the mod will add all units with the charm bombard flag to the list of artillery that uses PTW-style targeting. This cancels out the charm effect since you can't have both.
  • Option to ignore king flag on defense -- Can make it so king units aren't always the last to defend in a stack. Useful for mods that use the king flag.
  • Harbor/airport city icons indicate unit effects not trade abilities -- Those little harbor and airport icons that appear on the map will appear for cities that have the harbor and airport unit effects (one turn healing, veterancy for new units) instead of sea or air trade routes. This has no effect under the standard game rules since the unit and trade effects are tied to the same buildings, but it's useful for mods that separate the two.
  • Fix incorrect ETAs in go-to mode when railroad movement is limited -- This bug has been in the mod since limited railroad movement was first added, back in R6 or so. I finally fixed it. It was caused by the fact that the game's pathfinder stores the number of remaining movement points at each point along the path in a single byte. The number of movement "points" a unit has equals its max moves times the road movement rate (typically 3) times the railroad movement limit. For units with many moves, like destroyers, and high railroad limits, like 15, it's easily possible to overflow that single byte of MP remaining causing incorrect path lengths to be computed. The fix is to recompute the path length after the pathfinder has finished without the one byte limitation.
  • Can limit the number of escorts the AI assigns to its naval transports -- Normally the AI will assign between 1 and 3 escorts for each of its naval transports depending on the shield cost of the transport and the number of units it's carrying. Now you can reduce the upper limit from 3 to 2, 1, or even 0. This has the effect of freeing up the AI's naval power units to battle for control of the seas and bombard enemy shores. The catch is AI naval transports will not be as well defended. If you reduce the limit to zero, the AI will send out undefended transports which will be easy targets.
  • Fix barbarian diagonal bug -- Barb units will search for targets on all tiles within six steps of their location, as intended, instead of 12 tiles only along the NW/SE diagonal. In case anyone missed it, I wrote about this bug here: https://forums.civfanatics.com/thre...rd-and-much-more.666881/page-70#post-16434678.
  • Optimize improvement loops -- This rewrites a few short bits of game code to improve efficiency. Those bits are inefficient because they loop over all possible improvements to check if a city has some effect when it's only necessary to check a few buildings. In particular, the game checks if each city is capable of establishing trade routes over water or air by considering every possible improvement. The mod replaces that code so it instead considers only the small number of improvements that enable water or air trade. In some circumstances, this can significantly reduce turn times, however it is very hit or miss. In one game I tested, a huge industrial era CCM save Civinator had sent me a couple of years ago, this optimization reduced turn times by over half. In another game I tested, an industrial era game on the "Monstrosity" map, the optimization was not effective. I still intend to post a thread all about game performance and optimization at some point, for now this is a small start.
  • Option to show untradable techs on trade screen -- They will appear grayed out
  • Option to remove Elvis Easter egg -- Stops all king-flagged units from appearing as Elvis on his birthday. Useful for mods with many king-flagged units.
  • Fix cached building maintenance amounts not being updated when buildings are obsoleted -- Firaxis intended for obsolete buildings to be maintenance-free, except the game doesn't update building maintenance when techs are unlocked so maintenance persists for obsoleted buildings. It will be removed when the player triggers a recomputation of maintenance, for example by changing governments, but then you can exploit the game by selling the obsolete buildings to have their maintenance removed twice. Both of these issues are fixed, and so is the display of maintenance costs on the city screen.
  • Load mod button images from scenario folder if present -- You can now override the mod's images for stacked unit buttons and trade screen scroll arrows with scenario-specific versions by placing the replacement PCX files in the scenario's Art directory.
  • Match only complete names from config -- I noticed my string matching code for names in the config file can pass by only matching the first letters. For example, if you specify the name "Horse", it can match "Horseman". The problem with this is if you have a unit named "Horse" it might incorrectly match "Horseman" instead. This is changed now so it only matches the entire name.
  • Improve config read error messages -- See: https://forums.civfanatics.com/thre...rd-and-much-more.666881/page-65#post-16404684
You can use the preview version to experiment with the barb city capturing. And, of course, if you find any bugs in the preview version, please report them to me so I can fix them.



Here is my wishlist of remaining things I would like to change if I could. If you find room to address any of them in a future release it would be appreciated.
Sure, I'll try to slip these into future releases. The pollution stuff should be easy enough. Unfortunately the game's interface code is a pain to work with, there's a lot of it and it's very stateful. Moving the golden age timer to that banner is probably more trouble than it's worth. A much easier solution there to replace the "Golden Age" label with an abbreviation. Fighters always being on air superiority is an interesting idea, although it would make the air sup. mission and fortify states redundant. That is unless fortify doesn't count as air sup., which would make sense since it could be used for healing instead, but then you'd never have air units end their turns with unspent moves unless the turn was force-ended without all units moved. Skipping a unit's turn removes all its remaining moves. It shouldn't be too difficult to modify the right-click menu to show which fighters are set to air superiority, since I've already decoded how it works to allow for the grouping of duplicate units.
 
Flintlock, I think this R16 beta version is a very good idea, so there are more civers that can help with testing of that version. :thumbsup: One more time a big thank you very much for all your great work with this mod.

:thanx:

  • Can limit the number of escorts the AI assigns to its naval transports -- Normally the AI will assign between 1 and 3 escorts for each of its naval transports depending on the shield cost of the transport and the number of units it's carrying. Now you can reduce the upper limit from 3 to 2, 1, or even 0. This has the effect of freeing up the AI's naval power units to battle for control of the seas and bombard enemy shores. The catch is AI naval transports will not be as well defended. If you reduce the limit to zero, the AI will send out undefended transports which will be easy targets.
Besides many other marvelous new options in R16a, the information, that the escort limit now can be set to zero, is very interesting. In my eyes escorts in a game are not necessary at all, as the naval transport ships can be set as "multiple units unit" to be their own escorts without any problem by giving them a defense value (and may be additional hitpoints) in proportion to the naval units that performed that task until now.

One such unit that exists since the days of SOE is the convoy unit. Now its graphics seem to be somewhat outdated, but may be Wotan49 (or other creators) can create some convoy units with units up to date (the more, the better).

Convoy.gif


Convoy2.gif


A "convoy unit" with 2 galleons and a war galleon for the Age of Sail, some new convoy units for the industrial era (HMS Warrior Ironclad -please not the US monitor - plus 2 tramp steamers), for WW1 (cruiser plus 2 tramp steamers) and WW2 (cruiser plus 2 troop ships) and the Cold War would be nice and in my eyes with the new option of the Flintlock mod would make a lot of sense.

Edit: Meanwhile Wotan49 created this wonderful early industrial convoy unit 😍:

Early Industrial Convoy.gif


The unit can be downloaded here: https://forums.civfanatics.com/threads/mtrampconvoysea.683209/#post-16441928
Wotan49 thank you very much for your fantastic work!
:thanx:
 
Last edited:
Back
Top Bottom