Resource icon

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

A shameless hijack here, but I just wanted to say I love reading over this thread. Thank you to everyone for sharing very useful knowledge, and especially to you Flintlock. Also as we were discussing a few days ago about the minimum distance for cities, please let me know if you ever find that. I would love the ability to set the limit higher by one or two tiles. For now I'm just gaming the terrain but I believe this just handicaps the AI.
I'm planning to look into the minimum city distance at some point, but I don't know when that will be. For the time being my hands are full with the AI artillery issue.
I had in plans to open a new tread for it but might as well write it here instead. I noticed that AI, when there is treasury built, only it needs to grab it and transport to the capitol to gain money, instead it holding it in a city without taking a profit. I was not sure if there something in editor settings or that's another bug.
I don't know if the AI can use treasure units in the base game (@Civinator probably knows) but if not it sounds like it would be easy to program in, I already know how to make a unit move to some tile. The hard part would be cases where the treasure unit requires naval transport to get to the capital.
I have noticed that the AI will attack with very weak units even when there are stronger units available. This allows the defender to "level up" due to combat victories so that later stronger attackers will face stronger opponents. So, just like the aforementioned artillery order of attack, the land unit order of attack might be improveable.
Based on what I've seen of the AI's behavior, I think it just loops through all of its units and moves them one at a time, so they move in whatever order they happen to appear in the master unit list. It would be nice to first pick out the civ's units, sort them according to some priority, then move them, but whether that's possible or not depends on how the game code is structured. It's not something I've looked into yet but I will soon b/c it's relevant to artillery and escorting behavior.
Smaller fixes:
Added to the list. I'm especially interested in bugs. I've already fixed what I consider to be the major ones but I'd like to get around to these edge case crashes too at some point. The "houseboat bug" is another of these that I'm keeping in mind.
The Big Addition:
I don't expect this sort of thing would be too difficult, based on my experience implementing limited railroad movement. Preventing a unit from entering a tile is possible by modifying a single function and the AI seems to handle that just fine. The hard part would be all the edge cases you mentioned like combat, cities building units, sea units, etc. It's good to know that unit types have an unused parameter, that could come in handy.
 
Excellent work with artillery it all looks very promising. If that could be solved I will be over the moon. It also means I will have to do some artillery units seeing as they can be used better.
 
Progress report: Work continues on the AI artillery issue. I've mostly been analyzing the EXE and have decoded how the escorter/escortee relationship is stored and identified a bunch of related functions. I did run one experiment, adding a bit of code to the AI artillery routine that checks if the unit is unescorted and sitting in a city and, if so, grabs any available unit in that city and assigns it as an escort. With this change in place, the AI immediately sends all of its artillery (with their escorts) into battle, confirming that an inability to find escorts is the fundamental problem limiting the AI's artillery usage. This still needs more work, for example the code I inserted actually tries to assign two escorts to each arty, but the second doesn't take. My idea was that eventually each arty unit would be escorted by an offensive and defensive unit so that way when the stack bombards a city it could follow up with an attack, as it stands the AI artillery often wastes its time bombarding cities with no attacking units nearby to capitalize on the damage done.

Still, I've observed the computer play a bit in debug mode and once the escort issue is solved the base game artillery AI isn't too bad. For example the Korea AI grouped all of its arty+escort pairs together to form this doomstack (on Deity BTW):
civ_3_ai_arty_doomstack.jpg

Which it has been marching around attacking Viking cities. It's not well coordinated with the knights and cavalry but it does a decent job based on what I've seen so far.

Additionally, I was getting burned out fiddling with the artillery issue day after day so I put that aside for a couple of days to look into some bugs. I solved the crash that @Sutsuj mentioned on the previous page. The cause of the bug is that, when doing a disembark-all, the game continually loops over all units in a transport trying to disembark them as long as a helper function says that there are some left that can be disembarked, but that helper function doesn't know that immobile units can't be disembarked. Hence the first function gets caught in an endless loop trying to disembark them. The solution I came up with was to replace a call to Unit::get_max_move_points inside that helper function with a call to a custom function that returns zero for immobile units, that way the helper thinks any immobile unit has no moves left and reports correctly that it can't be disembarked. As for the houseboat bug, I wasn't able to replicate it. I ran a search and found a thread from 2017 saying that the bug is related to settlers that don't require pop or ones that have the king flag set, but I tried with that stuff set and still didn't see it. It would very helpful if someone could post a save where the bug definitely appears. Until then there's nothing I can do.
 
Not sure what you heard about the houseboat bug, but my understanding is that if all the cities of civilization are lost and yet the civilization has some sort of settler unit in a transport vessel, the game totally freaks. I have experienced this several times, to the point where I save the game before wiping out the last city of a competing civilization.
 
Something else occurred to me (or rather, that I remembered had bothered me before) while playing @haluu's fantastical Tides of Crimson mod the other night.

I'm not sure how easy it would be to dig into the diplomatic functions, but if the Civ3 AI could be taught to better understand when it should (or should not!) sign Mutual Protection Pacts, that might make the late game more dangerous/interesting.

Signing an MPP gives a great attitude-boost towards the MPP-partner, and the AI is currently extremely eager to sign MPPs. But it does not seem to value MPPs properly: I have seen OCC AI-Civs suggest that my 50%-of-the-world hegemony should pay disproportionate lump-sum + GPT for the 'privilege' of protecting them, which seems illogical — as if the game's MPP pricing-routine is returning an opposite result to what it intuitively 'should' do (namely, that the weaker Civ should pay protection-money to the stronger Civ!). Even when the payment goes in the 'right' direction, it seems to be much lower than it should be.
Spoiler Recent example :
In the ToC-game, I had declared war on the runaway Civ on my Continent, and then tried to sign an MA against them with the runaway on the other Continent, which turned out to be really expensive (~45 GPT was still 'doubtful') but they'd happily sign an MPP in return for a nominal payment of ~6 GPT, which would suck them into my war (because this is the Civ3-AI we're talking about!), without obliging me to get involved directly in theirs :crazyeye:
And the AI-Civs also do not appear to look at who else a prospective MPP-partner has signed deals with when signing its own MPPs, or deciding to declare war — which means that it will occasionally/ sometimes/ often sign MPPs with 2 Civs which are currently at war, or will declare on a second MPP-partner of its current MPP-partner, thereby forcing one of those MPP-deals to get broken. Similarly, it also makes it laughably easy for the human player to sucker a target-AI into committing suicide-by-MPP, or to win a UN-victory.
Spoiler Human exploitation :
Say I want to fight CivB, but they have an MPP with CivC, who I don't want to fight (yet!) for whatever reason. Therefore, I also sign an MPP with CivC. Then I declare on CivB, but I don't attack them immediately: when CivB then inevitably attacks me — even if only by bombarding one of my tiles — CivC then declares on them, instead of me. And signing MPPs with all remaining minor Civs, directly before the UN-SecGen vote is due, is a near-guarantee of winning it.
Fixing any of the above problems would be great — if possible.

For example (even if the pricing routine is too complex/deeply buried), if the number of active MPPs could be restricted to 1 per Civ, i.e. no Civ would be allowed to sign an MPP with more than 1 other Civ at a time (possibly using a similar check to the one which causes Trade Embargoes to disable resource-deals?), that would go quite some way towards reducing the late-game AI-schizophrenia — and also prevent the human from exploiting the MPP-mechanic so easily.

Caveat: I have no idea if/how such a restriction might affect scenarios which use 3- or 4-way Locked Alliances (essentially, unbreakable MPPs).

But this is another pony-dream, not at all a priority.
 
Yeah diplomacy in Civ3 is unfortunately very chaotic. The AI was dramatically improved in Civ4. If there was a way for the AI to mimic those improvements in 3 without bogging down turn times, that would be great. I do wonder if the turn times might even improve with better diplomacy AI. It honestly feels like so much of the AI's trading of pacts and resources is so random that each turn the AI just does diplomacy for the heck of it. I honestly never even considered if it was possible to improve it. I usually just limit it the options in the editor.

Speaking of that, it would be great if I could turn off trade of all recurring things in the editor. Not just mutual protection pacts and open borders, etc... But also gold per turn and resources. I feel like the AI gets into more trouble with any recurring pacts than it does benefit from it.
 
It honestly feels like so much of the AI's trading of pacts and resources is so random that each turn the AI just does diplomacy for the heck of it.
Thanks for the prompt...

Something that might be easier to implement than my pony, and would definitely reduce interturn-tedium in the late game, especially on fully populated Large/ Huge/ Huge+ maps, would be to continue to allow the AI-Civs to form MAs/ MPPs, but to eliminate at least half to two-thirds of the pop-ups that have to be clicked away when such deals are signed:

"We lost our [Resource]!" <click>
"X has signed an MA with Y against Z!" <click>
"X has declared war on Z!" <click>

The only pop-up(s) I really need to see is/are the ones which affect me directly — but even then, I don't need 3 pop-ups all telling me essentially the same thing ("You're [bork]ed!").

And if I'm not X, Y, or Z — I don't care! If I want/need to know who else is fighting each other at the moment, I can go and look at the F4-screen.
But also gold per turn and resources. I feel like the AI gets into more trouble with any recurring pacts than it does benefit from it.
I don't like this idea much, TBH. True, the AI doesn't always stick to its 20-turn deals, but the possibility is needed, e.g. to allow resource-trading during long science-games.

Restricting 20-turn trades to direct like-for-like exchanges might be an improvement (while allowing to make up any deficits only with gold/GPT), i.e. techs can only be swapped for techs, resources for resources, and diplomatic agreements can't be combined (which would eliminate the "MAPT"-exploit).

(It's like that in Civ IV, right? Haven't played that one hardly at all)
 
Last edited:
I don't know if the AI can use treasure units in the base game (@Civinator probably knows) but if not it sounds like it would be easy to program in, I already know how to make a unit move to some tile. The hard part would be cases where the treasure unit requires naval transport to get to the capital.

"Treasure units" (or supply shipments as I named them in the mods CCM and RARR) can be used in the base game, too - but the AI doesn´t handle them very well.

There are two different methods, to implant supply shipments to C3C games:

a) The "Reverse Capture the Flag" option that needs a transport of the supplyshipment to a victory point. This methode per example is used in the scenario AoI and is the better methode in scenarios/mods with fixed maps (as it is the worldmap in AoI).

and

b) The "Capture the Princess" option (that I have renamed in CCM and RARR to "Capture Shipments") so it can be better identified. This option is suited better for mods with random maps, as here the supply shipment must be transported into the capital (and not to a victory point that can be standing alone in the surroundings if the capital is not founded in the starting tile).

Both methods can be used for random maps in the 'base game', as in the base game every civ has a capital or (not so good) every civ can be started with a victory point in its starting location.

Here I explained with added images how the supply shipments must be handled: https://forums.civfanatics.com/threads/ccm1-epic-mod.352057/page-78#post-13184258

The AI especially has problems, when the supply shipment is directly produced in the capital. So I set the value of these shipments to the same value for randomly defeating a barbarian tribe in the game: 25 gold. This assures, that there is a vitalizing element in the game with no game changing grave consequences, when the AI didn´t handle this feature well.

The needed 'flag unit' in these settings must be a land unit. It would be very cool, if in scenarios naval units could become treasure units, too when arriving in some coastal port cities - even of other civs (and in the base game this combined with a flexible minimum distance that this naval flag unit must have crossed from its starting point to the destiny harbor) ... to establish a working merchant marine in C3C and not only naval troop carries as it currently is set in C3C... but these are all only dreams. Interesting could also be different flag units, that allow different rewards in the game. At present in the C3C general settings only one unit can be set as flag unit.
------------------------------------------------------

I will post something to the houseboat bug, too, when I have the time for it. Here only a search link:
https://forums.civfanatics.com/search/162472298/?q=Houseboat+Bug&o=date&c[node]=67
 
Last edited:
Apologies if this has already been addressed, but speaking of boats, what about the endless transport exploit? There are a few ways that could be avoided, the simplest being that the Load action consumes all MP. But on second thought, I suppose that would only matter to the local human player, so you could always just not do that.
 
Flintlock... Great Results concerning the AI Artillery and the Computer either crashing or at least hanging when the AI tries to have an immobile Unit off load from a ship. The problem has been that an immobile Unit cannot move so it cannot move itself off a Ship but rather had to be Off Loaded when inside a city... the AI did not understand that.

Concerning Artillery, I realize it is difficult enough to have Normal Artillery used by the AI on the Map but was wondering if there could be a way of using Attack/Defense Settings to omit the need for escorts.
I was thinking about your approach for the AI to use Artillery on the Map and I wondered about "Bombarding Land Units with an Attack/Defense" such as a soldier with a Rifle that has Lethal Bombardment and Attack/Defense settings... Is there a way to have the AI move those Units out on the Map individually and use their Bombard=Shoot settings? IF there is some method to set the AI where Land Units that have Bombard settings WITH Attack/Defense settings, would that allow those AI Units to function without an escort or simply escort themselves? :crazyeye: What is the programing for Radar Artillery to work for the AI?

The other faulty thing the AI does from a stack (although rarely) is allow a Wheeled Unit to go to or Attack a tile where one of its normal Units goes to or attacks from the stack. Generally the Wheeled unit is stuck between the two tiles and the Human Player cannot injure or kill that Unit until the next turn when the Wheeled Unit returns to its correct tile.

This thread is certainly becoming huge and I hope you don't become overwhelmed with the plethora of requests. If nothing else, it all serves as more information and in any case, guess you know you have "Job Security" here if wanted :cool:
 
Not sure what you heard about the houseboat bug, but my understanding is that if all the cities of civilization are lost and yet the civilization has some sort of settler unit in a transport vessel, the game totally freaks. I have experienced this several times, to the point where I save the game before wiping out the last city of a competing civilization.
I was going off what I read here: https://forums.civfanatics.com/threads/houseboat-bug-solutions.616078/, which says the simple version of the bug, what you described, was solved back in vanilla Civ 3 but that it can reappear in Conquests if settlers are modded somehow.

@tjs282 and @Nanuk:

I haven't looked into the diplo code in detail yet, I've only brushed up against it when I was working on removing the unit limit. (This is a tangent but I like talking about the technical details of the mod: I was searching through the disassembly for instances of the unit limit and found one in the code that gathers all tradeable items for when the diplo trade screen is opened. For whatever reason it loops over all possible unit IDs instead of up to the largest one in use when searching for, I think, tradeable workers. I actually didn't patch this so, assuming I'm right about this code which I didn't inspect in detail, even with the no unit limit patch applied you won't see workers as tradeable if they don't appear within the first 8192 entries in the game's master list of units.) I wanted to look into the diplo code for another reason, that I mentioned in the OP, to make setting gold amounts in the trade screen easier. I'll make a note of these suggestions for when/if I get around to it.

I don't know how difficult it would be to remove trade options, but I expect it would be easy. I do know that silencing pop-ups is easy, the only tricky part might be detecting when to do so.
Apologies if this has already been addressed, but speaking of boats, what about the endless transport exploit? There are a few ways that could be avoided, the simplest being that the Load action consumes all MP. But on second thought, I suppose that would only matter to the local human player, so you could always just not do that.
I haven't fixed any exploits yet mostly because I don't think it's worth the effort. This is a single player mod, so like you said, if someone doesn't like an exploit then easiest solution is for them to avoid using it.
I realize it is difficult enough to have Normal Artillery used by the AI on the Map but was wondering if there could be a way of using Attack/Defense Settings to omit the need for escorts.
I thought I knew how to change a unit's escort requirement but my attempt at increasing the requirement for all artillery to 2 units didn't work so I'm not sure. Creating an offensive unit with attack, defense, and bombard, and having it bombard instead of attacking is an interesting idea, I think I could make that work but I'd have to experiment with it to be sure. In any case, I'd like to make AI artilery work without changing the game rules because I think changing the rules is outside the scope of this mod.
The other faulty thing the AI does from a stack (although rarely) is allow a Wheeled Unit to go to or Attack a tile where one of its normal Units goes to or attacks from the stack. Generally the Wheeled unit is stuck between the two tiles and the Human Player cannot injure or kill that Unit until the next turn when the Wheeled Unit returns to its correct tile.
Interesting. I don't think I've ever seen that happen myself.
This thread is certainly becoming huge and I hope you don't become overwhelmed with the plethora of requests. If nothing else, it all serves as more information and in any case, guess you know you have "Job Security" here if wanted :cool:
Great security, the flexible hours are nice, the only problem with this job is the pay...
 
I am playing Civinator's RARR. The houseboat bug is alive and well in that mod.

Another thing I noticed, fairly minor and very specific, so probably not worth the effort unless you are either at the end of your queue or looking to distract yourself from a larger problem. I cannot clear jungle (or marsh) on a tile with pollution. Normally this is OK, you probably want to clear the pollution first, but if I already have a worker in the process of clearing the jungle, it would be more efficient to clear the jungle and then clear the pollution. But any worker has to clear the pollution first.
 
I thought I knew how to change a unit's escort requirement but my attempt at increasing the requirement for all artillery to 2 units didn't work so I'm not sure. Creating an offensive unit with attack, defense, and bombard, and having it bombard instead of attacking is an interesting idea, I think I could make that work but I'd have to experiment with it to be sure. In any case, I'd like to make AI artilery work without changing the game rules because I think changing the rules is outside the scope of this mod.
If it works, perhaps Artillery could be set up the same way... no escorts. Some may not want it for normal Artillery as it would appear strange for Artillery to move on its own with no escort.
Thinking of an "off the wall" way to have the AI use Artillery on the Map is probably the way to go.
If it could be found and is specific, being able to alter the AI build choice of having more than one setting type for AI units by providing Offense, Defense and Bombard settings collectively could solve the AI Artillery problem as well.

Civinator is also aware of Wheeled Units moving where they are not suppose to go when they are with Normal Units that can move to a tile. This can be a simple stack of two units, one wheeled and one normal. This has happened many times but is rare and really Not a priority.

Pay...the Best pay here is Great Appreciation and Fame :yup::salute:...:)
 
I am playing Civinator's RARR. The houseboat bug is alive and well in that mod.

Another thing I noticed, fairly minor and very specific, so probably not worth the effort unless you are either at the end of your queue or looking to distract yourself from a larger problem. I cannot clear jungle (or marsh) on a tile with pollution. Normally this is OK, you probably want to clear the pollution first, but if I already have a worker in the process of clearing the jungle, it would be more efficient to clear the jungle and then clear the pollution. But any worker has to clear the pollution first.

Speaking of that. It's a wonder that pollution can land on impassible terrain. Pollution doesn't affect coast/sea/ocean tiles. So it must be hardcoded that way. Setting terrain to impassible does not prevent pollution from appearing on it. So if you're playing an epic game and say you set mountains to impassible in the editor, by the late game you can find pollution permanently stuck on mountains since no unit can move onto them to clear it.

Pay...the Best pay here is Great Appreciation and Fame :yup::salute:...:)

I have commissioned some work for my mod. So it is possible.
 
Speaking of that. It's a wonder that pollution can land on impassible terrain. Pollution doesn't affect coast/sea/ocean tiles. So it must be hardcoded that way. Setting terrain to impassible does not prevent pollution from appearing on it.
This would be an easy change to make. It is hardcoded that pollution can't spawn on water and it would be a simple matter of patching the call to Tile::is_water with a custom function that instead instead checks "is_water_or_impassable". I'll add this to the list for when I have a spare moment.
 
Back
Top Bottom