• Civilization 7 has been announced. For more info please check the forum here .
Resource icon

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

An idea I had a long time ago was to create a fake worker unit that you could give to another civ. That other civ would have to research a tech that would allow him to upgrade that fake worker into a tank or a jet fighter for example.
Interesting!

How do I finish?

And if a civil worker is created, the same as the worker but with the option of promotion.

For example, it would be to create a unit of workers "civilian volunteers with minimum military characteristics according to the time they are recruited and that unit produced that could be updated to a military unit that the AI could make without problems. I think that could be done with the normal editor. I will do tests but it could work!!! :)
 
Yes, this is working. In CCM 2.5 a base unit (apprentice) can be upgraded since era 1 to different workers and with a tech coming much later in era 3, they can be upgraded to partisans and later in era 4 to different kinds of guerilla units.
 
Last edited:
Scripted events would surely be possible once Lua is integrated into the program, which would be a lot of work but I don't see any real technical limitations there. About spawning in a player in the middle of a game, that might be awkward due to engine limitations. Or maybe not, I've never tried it. Even if it's not possible you could keep a settler for that player on the edge of the map then move it into position at the appropriate date.
Is there a way to teleport units around the map or do you mean manually moving into place?
 
Is there a way to teleport units around the map or do you mean manually moving into place?
C3C has the hidden feature to teleport units. This was revealed with the Polish hacked editor (Mendax) and the Quintillus editor and I think Steph´s editor have this option, too. As the building teleport function seems to be here the wrong one (as you need an existing city with that building to teleport the settler into that city), the unit teleport function here could be more interesting. For that solution you need a telepad unit in the region where the new civ should pop up. In my eyes the telepad unit should be a HN air unit with zero defense, so that unit cannot be destroyed with normal attacks (only with nukes).

Teleporters.jpg
 
Last edited:
Ran a few tests on the recently added "optimize_improvement_loops" function. Conclusion: There was a speed gain of about 12-13% during the AI's movement phase, if set to "true".

Test setup: A Mega map on my 2021 EXPANSION mod, which is 220 x 220 tiles, 31 civs. Medium land area, pangaea map, with around 400 cities, about 300 in AI's possession. Year is 1960 AD, the same turn replayed multiple times with all show movement and animations turned off in Preferences. Time is measured from pushing the End Turn button, until my first city builds something and requests new orders. There appears to be zero effect after that.
  • Time during AI's movement phase with "optimize_improvement_loops = false": 89 seconds
  • Time during AI's movement phase with "optimize_improvement_loops = true": 77-78 seconds
  • Time saved: 11-12 seconds out of 89 seconds, which equals about 12-13%
Now, it has to be said I ran the tests on a fairly high end PC. The time saved would be greater on a more modest rig, but the percentage gained should probably remain the same.
Also, I didn't test it extensively on multiple scenarios, so there is some margin for error. But it gives an indication.
 
Last edited:
Small request from me. Would it be possible to add Clear Wetlands stack button?
/edit/ something came to me this morning. When the factions are destroyed all their troops remaining somewhere on the map dying with it them. What about turning reaming troops into barbarians or at least abandoned units, so they can make some damage to the other factions?
Sure, it should be easy to add a stack clear wetlands button. I've been thinking about adding all the various missing stack command buttons for years now, and have gotten a few requests about that too. It wouldn't be difficult, just tedious. Converting units of defeated civs into barbarians is an interesting idea. I don't know what that would involve but I can't imagine it would be too hard.
Would it be possible in the diplomacy screen to have a scrollable city list, instead of having to click once to go up or down the list for every single city?
The simplest way to solve this would be to increase the speed of the buttons. I.e., when you click the up/down arrows it would scroll by 5 items instead of one at a time. I would do that by repeating input events, so intercept the point at which mouse clicks are fed to the trade screen, detect when a click has scrolled the list, then duplicate it 4 times. It should also be possible to enable the mouse wheel to scroll the list but I don't know what that would entail exactly. I don't know if the diplo form received mouse wheel input events at all at the moment.
Is there a way to teleport units around the map or do you mean manually moving into place?
The game has an unfinished teleport function as Civinator mentioned, but with Lua scripting you'd be able to circumvent the game rules entirely and simply move any unit to whatever tile you wanted. Internally the game has a procedure to do that and I would make it available through Lua.
Ran a few tests on the recently added "optimize_improvement_loops" function. Conclusion: There was a speed gain of about 12-13% during the AI's movement phase, if set to "true".
Interesting, thanks for collecting more data. 12-13% is disappointing given some other results, but the improvement loop optimization is pretty hit or miss in general. When I tested it on an enormous map (the "Monstrosity" world map) under standard game rules, I found little to no improvement. But on a CCM save Civinator had sent me, it reduced turn times by over half. I'm not sure why, and it's probably related to the map as much as the mod. The more improvements a mod adds, the more the optimization will help since it stops the game from looping over unnecessary improvements during a couple of key computations. Those computations are (1) checking whether a city can trade via air/water while building the trade network and (2) determining the defense bonus provided by cities. Because of (2), the optimization will also help more if there are more wars going on.

Right now I'm experimenting with optimizing the trade net calculation itself, specifically by optimizing part of the pathfinder. I expect this will help a lot since the game does a lot of redundant calculations here and makes very poor use of the CPU cache. I'll report more once I've actually benchmarked it, though. I expect the pathfinder optimization will help in more situations than the improvement loop opt.
 
Couple of my observations while playing with your patch:
- Artillery and their escorting units disregard the damage and would keep on pushing to their target even if they health is reduced to 1 HP. Is it possible to make them retreat to safety using the same algorithm as for normal units?
- Fighter may now perform more than one interception per turn which may result in it's premature destruction. On one hand it is more realistic (an interceptor was defeated by the large group of enemies), on the other hand it does not help limited Air Force to defend itself;
 
Interesting, thanks for collecting more data. 12-13% is disappointing given some other results, but the improvement loop optimization is pretty hit or miss in general. When I tested it on an enormous map (the "Monstrosity" world map) under standard game rules, I found little to no improvement. But on a CCM save Civinator had sent me, it reduced turn times by over half. I'm not sure why, and it's probably related to the map as much as the mod. The more improvements a mod adds, the more the optimization will help since it stops the game from looping over unnecessary improvements during a couple of key computations. Those computations are (1) checking whether a city can trade via air/water while building the trade network and (2) determining the defense bonus provided by cities. Because of (2), the optimization will also help more if there are more wars going on.

Right now I'm experimenting with optimizing the trade net calculation itself, specifically by optimizing part of the pathfinder. I expect this will help a lot since the game does a lot of redundant calculations here and makes very poor use of the CPU cache. I'll report more once I've actually benchmarked it, though. I expect the pathfinder optimization will help in more situations than the improvement loop opt.
I don't think 12-13% is disappointing. Remember, it is 13% out of everything the AI needs to calculate for the entire turn. For example, if the AI spends 30% of the turn computing the city related stuff, then that would mean the time taken for those particular operations is near halved. Which is quite significant. If I were to take a guess, I suspect the majority of the time spent would go into moving units, their planning, pathfinding, combat etc., since there could easily be 10 times more of them than the number of cities, and their interactions are complex.

It is not that surprising to see a greater improvement for CCM, since the size of that mod is mindboggling. As far as I know the number of buildings in CCM is maxed out at 256, which is the largest number you can have. In comparison there are 32 in the standard game (not counting wonders), and a similar number in the mod I used to run my tests, 2021 EXPANSION. So I assume The Monstrosity with standard rules would produce similar results too.

In my opinion, the fact that you even came up with this idea and managed to pull it off, is a great bonus on top of many other useful features in Release 16.
 
- Artillery and their escorting units disregard the damage and would keep on pushing to their target even if they health is reduced to 1 HP. Is it possible to make them retreat to safety using the same algorithm as for normal units?
- Fighter may now perform more than one interception per turn which may result in it's premature destruction. On one hand it is more realistic (an interceptor was defeated by the large group of enemies), on the other hand it does not help limited Air Force to defend itself;
- Probably. I can't say for sure since I'm not familiar with how retreating works for escorters vs other units. One of the problems with the unit AI is that it can't cover retreating units well. I'd be wary about making it retreat more since the retreating units might get picked off easily. It might be a better idea to keep everything in one large stack.
- Unfortunately it's difficult to change this due to how the air combat logic is structured. It's not like ground combat where there's a process for selecting the preferred defender (which can be edited), instead the game picks the first available fighter to intercept.
I don't think 12-13% is disappointing. Remember, it is 13% out of everything the AI needs to calculate for the entire turn. For example, if the AI spends 30% of the turn computing the city related stuff, then that would mean the time taken for those particular operations is near halved. Which is quite significant. If I were to take a guess, I suspect the majority of the time spent would go into moving units, their planning, pathfinding, combat etc., since there could easily be 10 times more of them than the number of cities, and their interactions are complex.
That's true, and the improvement loop optimization is pretty simple & was quick to implement so it's 12-13% for almost free. Still I think I can do significantly better. I collected some data using a performance profiler and found, for example running that Monstrosity save, that more than half of the interturn time was spent in the pathfinder, and that the large majority of the pathfinder's time was spent computing trade networks not unit movement. Even though there are many more units than cities, I believe this is more than balanced out by two things: (1) Units mostly generate only short paths in a small area of the map whereas cities might generate sea trade connections across the entire map. (2) Each city can have its trade network recomputed multiple times per turn depending on what players do.



Meanwhile, I got distracted from working on speeding up the trade net calculations to instead look into a problem the game has when running on Linux using Wine. (This isn't really relevant for most of you but I'm going to talk about it anyway.) The problem is that any game screen that draws a line, including the map and foreign advisor, gets blacked out. It's caused by the fact that the game uses OpenGL to draw lines but Windows GDI to draw everything else. When it initializes OpenGL it assumes the system will copy over everything it has already drawn through Win GDI so it can simply draw lines on top of that. That's what happens on Windows, but on Wine the system discards the previous canvas and creates a new completely black one.

To solve the problem I reimplemented the OpenGL line drawing code (there isn't much of it) using Windows GDI+ instead. The old non-plus GDI won't do since it can't draw partially transparent lines, and that must be why the original developers used OpenGL in the first place. The reason they didn't use GDI+ in the first place is that it was only introduced in Windows XP. Civ 3 was released around the same time as XP but supports Windows as old as 98.

The GDI+ lines aren't exactly the same as OpenGL. Here's a comparison:

ogl_gp_foreign_advisor_comparison.gif


Notice the lines drawn by OpenGL are fuzzier. This is especially apparent in the "Treaties" box. I'm not sure why that is, actually. Here's another comparison:

ogl_gp_city_comparison.gif


Here I think the fuzziness makes it look a bit better (look at the borders around the city boxes), unlike on the foreign advisor screen.

Anyway, this was a fun little diversion and it solves the black screen issue with Civ 3 on Wine. You'll be able to use the GDI+ version on Windows too if you want to. BTW, I tested the C3X mod itself on Linux and found that it works. Both the install & run batch files work flawlessly when run through Wine. Pretty cool.
 
That's outstanding, I'll try it on my steam deck once there's a release. Civ 3, the only game where the fan patch ports open gl back to gdi for compatibility reasons instead of the other way around! 😀
 
- Probably. I can't say for sure since I'm not familiar with how retreating works for escorters vs other units. One of the problems with the unit AI is that it can't cover retreating units well. I'd be wary about making it retreat more since the retreating units might get picked off easily. It might be a better idea to keep everything in one large stack.
Suppose that is one of the reasons the AI creates such a large stacks around a single artillery or transport unit.
- Unfortunately it's difficult to change this due to how the air combat logic is structured. It's not like ground combat where there's a process for selecting the preferred defender (which can be edited), instead the game picks the first available fighter to intercept.
Does the number of times the fighter can Intercept per turn depend on the number of it's remaining moves? Guess it should not be a problem for generic game with Aircraft having movement 1. But I have been playing "1989" where most fighters have movement 2 meaning that even if they succeed in 1st interception they are almost likely shot down in the second. Maybe the workaround would be to rebase an Aircraft every turn to spend one of the movement points?
 
Is there anyway we can make the airdrop order work without needing an airport improvement for ground units? Air units don't need them. Since the airfield terrain improvement is half baked and can't be used by the AI, I've done away with it. But that means paratroopers can only airdrop from cities. Cash rushing airports on frontline cities just for airdropping is cost prohibitive. And in communism it's impossible.
 
Is there anyway we can make the airdrop order work without needing an airport improvement for ground units? Air units don't need them. Since the airfield terrain improvement is half baked and can't be used by the AI, I've done away with it. But that means paratroopers can only airdrop from cities. Cash rushing airports on frontline cities just for airdropping is cost prohibitive. And in communism it's impossible.
Yes, I’ll second this request!
 
Does the number of times the fighter can Intercept per turn depend on the number of it's remaining moves? Guess it should not be a problem for generic game with Aircraft having movement 1. But I have been playing "1989" where most fighters have movement 2 meaning that even if they succeed in 1st interception they are almost likely shot down in the second. Maybe the workaround would be to rebase an Aircraft every turn to spend one of the movement points?
Yes. Units need to have available moves to intercept, so if they only have one move left at the end of the turn then they can only intercept once. Under the standard rules, intercepting causes a unit to lose all of its remaining moves but that mod option makes it so it only costs one move.
Just for the record, the other big Civ III Linux problem is stuttering / stuck / looping sounds. Someone has painstakingly purged all the problem sounds in this thread, but that's an awful workaround.
I'll have a look but I doubt that will be an easy fix. The big challenge there is that the guts of the game's sound code is in sound.dll which is uncharted territory for me, unlike the executable which I have pretty well mapped out at this point.

Another tiny issue I just noticed is that line drawing on Wine isn't anti-aliased. Here's what that foreign advisor screen actually looks like on Linux:
aliased_lines.png

It's not quite as nice as on Windows.
Is there anyway we can make the airdrop order work without needing an airport improvement for ground units? Air units don't need them. Since the airfield terrain improvement is half baked and can't be used by the AI, I've done away with it. But that means paratroopers can only airdrop from cities. Cash rushing airports on frontline cities just for airdropping is cost prohibitive. And in communism it's impossible.
Sure, this kind of change is generally very easy. There's probably a function call somewhere that checks if there's an airport in the city a paratrooper is standing in. I could redirect that call and make it return true if a config option is set.
 
@Flintlock yeah, far more likely to be something that needs to be addressed by the wine guys, just thought I'd flag it up anyway. Even though my main desktop is a Windows PC, I'd love all my old favourites to be 'preserved' in a sense by being runnable on an open platform like Linux. Civ 3 has long been a pain point there so I'm really pleased you looked into that. (can't say I really blame the wine devs tbh, 2001 era Open GL / GDI interop probably isn't top of their priority list!)
 
Just tried it out on my deck with the latest commit (for all of about 5 minutes) and it worked great, no black screens and diplomacy lines visible. You can install C3X on deck (or any linux distribution with Steam on it) by putting the C3X folder in the Conquests folder as usual, then adding install.bat as a 'non steam game' and forcing it to run using proton in steam settings.

Obviously the steam deck is not a sensible system to play on, as no custom config is going to be able to replace a pure mouse and keyboard game in a comfortable way, but it's a quick way to test stuff on Linux.
 
Can I just sanity check something, if I want to play the vanilla game with quality of life improvements and bug fixes but with classic AI (IE not sending in artillery, standard not very good army/great leader logic etc) I can simply set every setting in the 'AI Enhancements' section to 'false' including the numerical settings?
 
I'm out of date, so my apologies if I'm being redundant:
  1. Can Bomber Units be addressed to behave like your artillery fix?
  2. I understand that the game's Naval Escort logic is "problematic," but is it possible to apply the Escort Flag to Bombers, so that they require Fighter Escorts? I know that this might be impossible, as that wasn't the R/W case until the WW2 P-51.
 
I was recently re-reading Sulla's critique of Conquests. I believe it's a reasonably well known article in the community which you can find here.

In this article, Sulla points out two differences between bombardment in Play the World (PTW) and Conquests:

1) Bombardment rules - In PTW, bombardment would have a random 1/3 chance of striking either units, population or buildings. In Conquests, this was changed to striking at units only.
I understand the C3X patch provides an option to revert to PTW style artillery. Can someone clarify that when enabled, this is applied to AI and human players?

2) Lethal bombardment - In PTW, while artillery could damage units, artillery could never kill a unit. A non-artillery unit would be required to finish them off. This was removed in Conquests and artillery could now apply the lethal blow.
Does the C3X patch also revert this rule in it's PTW-like targeting adjustment? Or is this 'lethal bombardment' not addressed by the PTW-like targeting change?

Once again Flintlock, I thank you for your incredible work on the C3X patch!
 
Top Bottom