Resource icon

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

WOW, what a difference, look at the IJN sending 10 naval units to the Port Moresby area!! The only thing is they're still not bombarding our units on the road, just hitting the city itself. I removed the "required escort" tag from the Transports as well, not sure if that makes any difference.

What about the carriers though, is the AI also going to leave these guys by themselves also???

Navy.jpg
 
Transports require escorts? I have never had to have escorts for transports. I have given them some combat power so as to not be bother by the barbarians.
 
In the unmodded stock game, at difficulty levels where the AI productivity is not utterly crippled (I play at Emperor-DG), the AI is hardcoded to send escorts with its troop-transports at a roughly 3:1 ratio. At Emperor, this is usually first noticeable in the early Medieval, when the AI will send a single loaded Galley along with 3 'escort Galleys'. Similarly, in the late Medieval Age, a single AI Galleon (or Caravel, or even a Galley) will usually be protected by 3 Frigates.

Escort-ships typically do not pre-emptively attack incoming enemy ships, beyond firing a single defensive-salvo (if they have a B-value), nor will they bombard enemy land-units or even land-tiles once they arrive in hostile waters -- so do almost nothing but act as punching-bags.

Escorts also become completely irrelevant once Subs become buildable, because Stealth Attack allows the transport-ship to be sniped out from under the escorts.
 
Inspired partially by Predator145's thread, do you think it would be possible to implement these things for improved naval gameplay:

- an option/list to make certain units able to only bombard naval units (used by e.g. submarines, torpedo bombers, AShMs)
- an option/list to make certain units able to only bombard land (or air) units (used for example by normal surface ships, to prevent them from stack-bombarding everything on the sea while still giving them a deadly land bombardement capability)
- enabling retreating rules (if faster, always) to be set for ships only, separate from land retreating rules
 
Maybe it would be more straightforward to have the setting called "max_escorts_per_transport" with a default value of 3?
Probably. The reason it's a reduction is so that a value of 0 will give the base game behavior. That's the convention I've been sticking to so far, "false" or "0" means no changes from the base game. It does create these weird upside-down options, though. Another one is the anarchy length reduction, where again 0 is no reduction and larger values mean shorter anarchy. It's not worth sticking to this convention if it's causing confusion. I'll think about changing it.
What about the carriers though, is the AI also going to leave these guys by themselves also???
No, the escort change only applies to units with the naval transport AI strategy.
 
Do you know why it is that if you de-select the "requires escort" flag, the AI will still give carriers and transports three escorts? I mean with the normal game, not CXE. It does the same thing with air units, where it can re-base them even if you unclick the rebase command.
 
No, the escort change only applies to units with the naval transport AI strategy.
It's not worth tying down 2-3 warships for the AI to bring a carrier to the fight since it loves impaling its aircrafts on 4 battleship stacks. With overpowered stock game or even more overpowered WW2 Pacific Heavy Bombers, it's worth it. But with more balanced dive/torpedo bombers, the AI is better off having another 3 destroyers instead. It would be great if the "carrier" AI strat gets the same treatment as well.
 
So the Naval force in the first test game eventually grew to 31 ships, mostly Battleships! When my foot units reached bombard range (2 tiles away) of Okaba, there were battleships in that town that red-lined them. So that’s good, but wondering if the AI sent their entire navy to just one human controlled front line city?
I tested the same scenario with the Chinese and noticed the Japanese Air Force attacking only one city per turn and then they suddenly disappeared. The Japanese army units are attacking across the whole front.
I need to start playing smaller scenarios on debug mode to really see what the AI is doing!
 
Do you know why it is that if you de-select the "requires escort" flag, the AI will still give carriers and transports three escorts? I mean with the normal game, not CXE. It does the same thing with air units, where it can re-base them even if you unclick the rebase command.
My guess it’s just one of those things the original developers never caught. Mr. Flintlock is fixing all of the stuff they left incomplete!!! :goodjob:
 
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.




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.
Also in R16 (preview 1) there is still an issue with the feature of limiting the movement on rail.
The Pathfinding with goto commands and limited rail movement is activated seems to be broken in some cases, especially when using higher limit values for movement on rails (eventually in combination with high values for the "Movement Rate Along Roads" in the C3C-Editor). The problem for the Ingame-Pathfinder can be seen in the first attached screenshot (Movement Rate Along Roads is set to 5, railroad movement ist limited to 35, selected unit has 1 movement point, length of the path to the destinated tile via rail ~30 tiles).

RR-Movement1a.jpg


-> The pathfinder should use the railroad in both cases, but the RR is only used in the case the rail movement is unlimited (or less than 30?).

This isn't a big problem for human players because they can alternatively use manual movement commands. But it's a very big problem for the AI players because they can only move their units with goto commands.

With the rules set as written above and limited rail movement is activated, the bug also occurs not only for pathfinding on railroad tracks, but also for pathfinding in open terrain with terrain types of different movement costs (plains, woods, hills and so on - like shown in the second attached screenshot).

RR-Movement2a.jpg


-> The pathfinder should use the plains-corridor in both cases, but it's only used when rail movement is unlimited or less than 30 (although there is no railroad at all).

@Flintlock
Do you have an idea what exactly the problem is? E.g. an overflow similar to the incorrect ETA's fixed in R16 (preview 1)?
 
Do you know why it is that if you de-select the "requires escort" flag, the AI will still give carriers and transports three escorts? I mean with the normal game, not CXE. It does the same thing with air units, where it can re-base them even if you unclick the rebase command.
The AI can carry out special tasks regardless of whether they've been given the special commands or not. What they need are the appropriate unit abilities and stats.

A unit flagged with "terraform" AI strat will always be able to execute every worker function as long as it has worker strength. If worker strength is set at 0 it will still try and get stuck at the tile because it will never finish.

A unit flagged with "air bombard" AI strat will always be able to rebase and bomb if it has some operational range.

A unit flagged with "air defense" AI strat will always be able to put on air superiority mission if it has operational range. If it has an attack of 0 it would always commit suicide.

A unit flagged with "artillery" will with C3X always be escorted by a "defense" AI strat unit and then bombard if it has bombard range.

And of course, as you've noticed, units flagged as "carriers" and "sea transport" will always require escorts in stock game.
 
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.
I don't know if it's doable, but the way I envision it is like this: As long as there are fighters present in a city, they will always scramble to protect the city. No matter which orders they've been given. The exception would be if they have already made an active move that turn, like Bombing, Precision Bombing, Reconnaissance, or Rebase. Then they are considered to be out of the city for that turn and not available for defense. Passive moves like Fortify, Sentry, and of course Air Superiority would make them eligible to defend. Even Skip Turn, I believe, because it's a passive move; they haven't really done anything that turn, even though it expends their movement. If there are no incoming airstrikes during the current turn, then they can heal etc. like normal. But the defense of the city takes precedense over everything else, including healing.

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.
Glad you are looking into this, that is another issue I've been wanting to fix. :) But on that note, it would be nice if you also looked at the way the AI escorts artillery. The fact that the AI even uses artillery offensively at all is very nice, and enriches the game a lot. But the AI tends to use too many escorts for each artillery piece. It seems the goal is to have 2 defenders per 1 artillery. It's not uncommon to encounter stacks with 30 Artillery and 50-60 Infantry, making the stack very hard to defeat. Usually it will target one of your cities and keep pounding it forever, leaving it a pile of rubble. But while the AI could easily defeat the city if it had only detached a few of those Infantry to follow up and attack the defenders (to take advantage of them being redlined), the whole operation is often counterproductive for the AI. At the standard C3X setting, the AI will build 1:6 of its land army as artillery (20 vs 100). The escorts account for another 2:6, totalling 3:6, or half the army. That leaves too little room for other attack units to exploit the devastation caused by the artillery. Even the AIs own city defenses may be a bit lackluster because of it. Furthermore, if someone picks off a few of the stack defenders, the AI will tend to move the "surplus" artillery (which the AI now thinks isn't adequately defended) undefended out of the stack, as sitting ducks.

I think a lot of the artillery issues can be fixed like this: Reduce artillery production from 1:6 to about 1:8. And only keep 1 defender per artillery piece (can probably be achieved in a similar way as reducing naval escorts). This means only a quarter of the army will be tied up (1:8 + 1:8). And finally the AI shouldn't send "surplus" artillery pieces out of the stack, no matter how few defenders there are.


More Mass orders:
The Mass orders that are already activated (like Mass Fortify) are very nice, but it would be even better if you could also activate some of the remaining ones too. Like: Mass Skip Turn, Mass Wait, and maybe Mass Sentry too. Why: In a large stack of units, for example aircraft in a city, it is often not desirable to Fortify the entire stack. Because, first of all, you need to remember to wake them up again the next turn. And then you may not want to wake up every unit in the city, for example if there is a large number of city defenders you want to remain fortified, but you want the aircraft operable. Sometimes it makes more sense to Mass Skip Turn all remaining units, or make an entire stack Mass Wait, to move other units first.

Riots instead of flipping:
I believe there should be some kind of mechanism that reflects the difficulties of keeping newly conquered cities in check. However, I think that the current scheme of "Culture Flipping" is much to harsh and unrealistic. If you're unlucky, you could lose big chunks of your army or airforce, while also losing control of the city itself. I'm thinking maybe there could be a high chance of riots instead. Like there may sometimes be a riot after several turns of civil unrest in a city. The city stops being productive, there's a smokestack above it, buildings are destroyed etc. Possibly some population could get killed too, or some units get injured. But the city remains under your control, and no units are lost. Don't know if this last idea is achievable, just throwing it out there. I know a lot of Civers dislike the flipping mechanic, it would be nice to replace it with something more reasonable.
 
Riots instead of flipping:
I believe there should be some kind of mechanism that reflects the difficulties of keeping newly conquered cities in check. However, I think that the current scheme of "Culture Flipping" is much to harsh and unrealistic. If you're unlucky, you could lose big chunks of your army or airforce, while also losing control of the city itself. I'm thinking maybe there could be a high chance of riots instead. Like there may sometimes be a riot after several turns of civil unrest in a city. The city stops being productive, there's a smokestack above it, buildings are destroyed etc. Possibly some population could get killed too, or some units get injured. But the city remains under your control, and no units are lost. Don't know if this last idea is achievable, just throwing it out there. I know a lot of Civers dislike the flipping mechanic, it would be nice to replace it with something more reasonable.
That's basically the way it works in Civ4: freshly-conquered cities are prone to riots due to low cultural influence, similar to Civ3's Resistance mechanic. I don't recall the precise maths, but these also serve to forewarn cities vulnerable to full-on revolt (I think there's something like a three-strike rule before defection). Building off what you've described, I wonder if it's possible to adapt something similar to the Propaganda espionage missions: as it is now, their effectiveness is extremely niche and almost totally black-boxed.
 
Inspired partially by Predator145's thread, do you think it would be possible to implement these things for improved naval gameplay:
Having separate retreat rules for land & sea units would definitely be easy. Restricting bombardment to land or sea would probably be easy but I'd have to look into that to see what it would entail.
Do you know why it is that if you de-select the "requires escort" flag, the AI will still give carriers and transports three escorts? I mean with the normal game, not CXE. It does the same thing with air units, where it can re-base them even if you unclick the rebase command.
I haven't seen the "requires escort" flag anywhere in the code I've been looking at. The reason the AI ignores it must be that they forgot about that flag when programming the escort behavior for naval transports & carriers. It would be easy to add it back in, basically just make the escort requirements zero when that flag is not present. As for the rebase ability, I'll add that to the list of bugs.
@Flintlock
Do you have an idea what exactly the problem is? E.g. an overflow similar to the incorrect ETA's fixed in R16 (preview 1)?
It is the exact same issue that was causing the incorrect ETAs. I suspected that issue could also cause incorrect paths to be generated, and sure enough you found some cases where it does. Unfortunately it's difficult to do a complete fix here since the problem is baked into the memory layout, specifically the layout of the intermediate states of the path that the pathfinder is building. There's no simple way to give the remaining movement points more than one byte of space, the easiest way might actually be to rewrite the pathfinder. The fix for the incorrect ETAs doesn't resolve the fundamental problem, it simply re-walks the path the pathfinder produced to determine how long it actually is.

A full and proper fix for this problem would be difficult however I do have one trick up my sleeve. The overflows occur when a unit's total movement points are too large. Right now, the total movement points a unit can have equals its number of moves times the road movement rate times the railroad limit. The mod multiplies the railroad limit in there so that the total MP is divisible by either one road move or one railroad move. Because all we care about is that divisibility, it's possible to divide the total movement points by the GCD of the road movement rate and railroad limit. That way the movement calculations would still work out the same but with smaller numbers. The catch there is that change only helps when the GCD is greater than 1, for example it would help for your specific example of an RMR of 5 and RL of 35, but decrease the RL to 34 and it won't help.
I don't know if it's doable, but the way I envision it is like this: As long as there are fighters present in a city, they will always scramble to protect the city. No matter which orders they've been given... Even Skip Turn, I believe, because it's a passive move; they haven't really done anything that turn, even though it expends their movement. If there are no incoming airstrikes during the current turn, then they can heal etc. like normal. But the defense of the city takes precedense over everything else, including healing.
This is difficult because skipping a unit's turn simply removes its remaining moves as if it had performed a meaningful action. To make this work, I'd have to track additional things that the game doesn't already, and then there are problems like storing that additional stuff in the save game and making sure it works properly with the AI. (Does the AI even use the skip turn function? I don't know.)
I think a lot of the artillery issues can be fixed like this: Reduce artillery production from 1:6 to about 1:8. And only keep 1 defender per artillery piece (can probably be achieved in a similar way as reducing naval escorts). This means only a quarter of the army will be tied up (1:8 + 1:8). And finally the AI shouldn't send "surplus" artillery pieces out of the stack, no matter how few defenders there are.
I've been thinking of reducing the rate of AI artillery production for a while now, I agree that it produces too much artillery and then doesn't have enough attackers to take advantage of the damage the artillery does. The fundamental problem with the AI's artillery usage is that there is no unit stack AI in Civ 3. It's every unit for itself, with the small exception that some units can grab escorts. As far as I can tell, the AI only assembles stacks of artillery on accident, when all those artillery independently decide to do the same thing.

The reason AI artillery leaves its stack is because its escorting unit was destroyed, causing it to attempt to flee to safety. It has no idea that it might be safer to stay in place with other friendly units on the same tile. I don't think there's a easy way to fix that. The obvious way would be to assign it to one of the other escorts on the tile, but the game logic is limited in that one unit may have multiple escorters but an escorting unit may only have one escortee. I tried setting up chains of escorts, like one artillery unit escorted by another artillery which is escorted by a defender, but that didn't work. It should be possible to edit the escort unit AI to attack weak targets on adjacent tiles but I haven't actually tried that to see how well it works in practice.
More Mass orders:
Riots instead of flipping:
I've gotten several requests now for stack sentry, it's something I'd like to get around to. Adding stack skip and stack wait at the same time should be easy. On a related note, I'd also like to try getting the stack unit commands to work in online multiplayer. About changing how culture flipping works, I'll have to add that to the list. My solution to the insane culture flip mechanics is to just turn it off in all of my games.
 
Last edited:
I don't know if it's doable, but the way I envision it is like this: As long as there are fighters present in a city, they will always scramble to protect the city. No matter which orders they've been given. The exception would be if they have already made an active move that turn, like Bombing, Precision Bombing, Reconnaissance, or Rebase. Then they are considered to be out of the city for that turn and not available for defense. Passive moves like Fortify, Sentry, and of course Air Superiority would make them eligible to defend. Even Skip Turn, I believe, because it's a passive move; they haven't really done anything that turn, even though it expends their movement. If there are no incoming airstrikes during the current turn, then they can heal etc. like normal. But the defense of the city takes precedense over everything else, including healing.
I've long wished that Aircraft had two additional, and different, abilities:
  1. To be assigned a "Combat Air Patrol" ("CAP") mission, whether they're in a City or based on a Carrier.
  2. On land, the ability to lay in a "Patrol Pattern" of Tiles, for defensive recon missions, which would continue until changed.
 
It would also be fantastic if a Civ's Name could change, by Era. Here's an example, by Era, with Era 3 "imaginary:"
  1. Varangians
  2. Kievan Rus
  3. Grand Duchy Of Moscow
  4. Russia

You'd have to be able to change traits to suit that. For example ancient western Romans were very different from medieval Romans aka "Byz" who were in turn different in traits from the early modern-modern Romans aka the Ottoman empire. These are after all, separate civs. Just in case you don't know, to the rest of the world, what you call "Byzantium" and "Ottoman Empire" is just known as "Roman Empire".

Muscovia and the resulting Russian Empire would have the same traits as the Mongols while Kievan Rus would be Agri+Sci (widespread building of medieval libraries, one of the highest medieval literacy rates in Europe). Varangians would share the same traits with the Scandi.

But after all, locations don't make a civ, the people living there do.
 
I've long wished that Aircraft had two additional, and different, abilities:
  1. To be assigned a "Combat Air Patrol" ("CAP") mission, whether they're in a City or based on a Carrier.
  2. On land, the ability to lay in a "Patrol Pattern" of Tiles, for defensive recon missions, which would continue until changed.
Adding new unit commands is difficult. I did it for stack bombard but the approach I had to take was pretty awkward. Under the hood, stack bombard is not even really a new command but a variation on regular bombard. Adding something like a recurring recon mission is extra difficult since to do it properly I'd have to record in the save file which units are in that state.
It would also be fantastic if a Civ's Name could change, by Era. Here's an example, by Era, with Era 3 "imaginary:"
This is one of those annoying cases where the hardest part would be reading in the requested changes from the INI config. Actually making the change, swapping out the civ names, would be very straight forward. The game has methods to get civ name, adjective, etc. for a given player that I could easily modify.

Changing traits by era would not be practical since traits are a property of the civilization not the player. The obvious approach would be to edit a player's civilization object when they change eras, except that won't work if there are multiple players playing the same civ. I'm not sure if it's even possible to have multiple players with the same civ, maybe with a third party editor? Anyway, the way the game is programmed leaves that possibility open and I wouldn't want to close it off.
 
Top Bottom