Resource icon

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

I think the work you've done with escorts has been excellent. I think the difficulty with escorts is partially the number required, and also which units are chosen by the computer. Since Naval Power covers all kinds of bases, the AI can't tell to use a destroyer for protection and a battleship to bombard. They really needed to make an escort and a combat AI strategy, essentially offense and defense strategies for sea.
I could prevent the AI from using certain types of naval power units to escort if you (and others) think that would be helpful. I don't see a practical way to make more subtle changes to the escort logic though. It would be nice if it were possible to make the AI prefer destroyers over battleships for escort duty but still be able to use both if needed but that's hard because the AI does minimal coordination between units.

This discovery is gold.
Since you did the work, its easy for you to add the following functionality:
The grayout menu entry refers to units without any other move points, but the checkbox entry could refer the unit can attack this round.
When I attack a city, I first bombard the units inside the city and then, manually select my attack units to attack.
Many times I cannot identify easily what units I used for attack and as a result a few times I select a unit that has already attacked and as a result I get the error: This unit has already attacked (something like that)
So, when you have a stack of units attacking enemy you can easily identify what units you used for attacking so you can select a unit that has not attacked.
That's a good idea. In fact I don't even have to use checkboxes since I've found out how to add images to menu items. The game uses that function to add icons to the production chooser menu you get by shift + right clicking on a city. Here's what it looks like on a unit:
food_icon_on_unit.png

I could add any image there, even one loaded from the mod folders. I'm not sure what would be a good icon to communicate that the unit can't attack again this turn. Maybe a grayed out or hollowed out sword? Maybe a hollowed out lightning bolt to indicate it's lacking the blitz ability?
 
I could prevent the AI from using certain types of naval power units to escort if you (and others) think that would be helpful. I don't see a practical way to make more subtle changes to the escort logic though. It would be nice if it were possible to make the AI prefer destroyers over battleships for escort duty but still be able to use both if needed but that's hard because the AI does minimal coordination between units.

If it is something relatively straightforward to implement it would certainly be useful. I imagine it would be a manually entered list in the config file? Civinator can weigh in with his thoughts but since CCM has many specialized naval classes I'm sure he would find a use for it also. But again I'm not trying to throw more on to version 17 since I'm sure you're ready to get it done.
 
I could prevent the AI from using certain types of naval power units to escort if you (and others) think that would be helpful. I don't see a practical way to make more subtle changes to the escort logic though. It would be nice if it were possible to make the AI prefer destroyers over battleships for escort duty but still be able to use both if needed but that's hard because the AI does minimal coordination between units.


That's a good idea. In fact I don't even have to use checkboxes since I've found out how to add images to menu items. The game uses that function to add icons to the production chooser menu you get by shift + right clicking on a city. Here's what it looks like on a unit:
View attachment 689175
I could add any image there, even one loaded from the mod folders. I'm not sure what would be a good icon to communicate that the unit can't attack again this turn. Maybe a grayed out or hollowed out sword? Maybe a hollowed out lightning bolt to indicate it's lacking the blitz ability?
Swords crossing each other could be one option.

A recommendation:

Maybe a mod have an icon like that you can use.

Any unit can attack could have that icon and any unit that already attacked has no icon.

That way we, the players, know that any remaining units that have an icon in front of their name can attack. Easy peasy.
 
@Flintlock have you seen in the code how AI handles protecting resources, airfields, etc.? Would be nice for some if ... then ... logic to have them guard valuable resources and installations. Especially with AA in later eras.
I have found the code that sends defenders to colonies, airfields, and radar towers. Does the AI ever defend resources outside of colonies? I don't recall ever seeing it do that. It wouldn't be too hard to make it do that by extending the logic for defending colonies. Specifically what I would do is add some logic after the search for colonies that redoes the search only for bare resources instead. The only complication is I'd have to assemble a list of tiles with resources on them ahead of time since searching every tile might noticeably slow the game down (there's a list of colonies so it doesn't have to search all tiles there). Getting the AI to defend with AA too would be easy in the new logic but awkward to patch into the existing logic for colonies.

If it is something relatively straightforward to implement it would certainly be useful. I imagine it would be a manually entered list in the config file? Civinator can weigh in with his thoughts but since CCM has many specialized naval classes I'm sure he would find a use for it also. But again I'm not trying to throw more on to version 17 since I'm sure you're ready to get it done.
It would be straightforward. The main naval power AI routine calls out eight times to a method that searches for a unit to escort matching some parameters. It would be easy to modify all those calls to insert a bit of logic that does nothing but return "no unit found" in case the searching unit is in some list of non-escorting units read from the config. As an aside, the reason there are eight different calls is because the unit runs searches with different and loosening parameters. For example it searches first for a transport to escort then, if it doesn't find one, a carrier. It searches first for a unit that's the same speed or slower than it is, and if it doesn't find one, it searches again for one that's faster, etc.

I am interested to hear from @Civinator or other modders if this is something they'd be interested in, otherwise I'll probably not bother. I can imagine how this feature would be a hassle to use since you'd have to ensure that the AI has some naval power unit available to build that's not in the list of non-escorting units. And then you'd have to work around the AI's insane build choices. Just because it's available doesn't mean the AI will build any.

Swords crossing each other could be one option.
A recommendation:
Maybe a mod have an icon like that you can use.
Any unit can attack could have that icon and any unit that already attacked has no icon.
That way we, the players, know that any remaining units that have an icon in front of their name can attack. Easy peasy.
That one might work but I'd have to darken the edges so it's more distinct. Keep in mind the icon can't be any larger than 15 pixels high otherwise it'll cause the entries on the menu to get spaced out. Like you mentioned, I could instead put icons on units that can still attack. Since that would mean most units would have icons, it makes me think I should just put icons on all units. Noncombat units could have a white flag or something. One nice thing about putting icons on all units is that the text on their menu items would line up. Putting an icon on an item moves the text over quite a bit. You can see that on the screenshot I posted above (except it's not a good example since the entry with the icon almost lines up with the numbers on the other items).
 
Since naval units assigned to escort duties become nothing more than punching bags the only values they can really make use of is their defense and AA stats. But if the AI can be nudged into using min-maxed defensive naval units to escort then it would free up their offensive bombarding ships.
 
It would be straightforward. The main naval power AI routine calls out eight times to a method that searches for a unit to escort matching some parameters. It would be easy to modify all those calls to insert a bit of logic that does nothing but return "no unit found" in case the searching unit is in some list of non-escorting units read from the config. As an aside, the reason there are eight different calls is because the unit runs searches with different and loosening parameters. For example it searches first for a transport to escort then, if it doesn't find one, a carrier. It searches first for a unit that's the same speed or slower than it is, and if it doesn't find one, it searches again for one that's faster, etc.

I am interested to hear from @Civinator or other modders if this is something they'd be interested in, otherwise I'll probably not bother. I can imagine how this feature would be a hassle to use since you'd have to ensure that the AI has some naval power unit available to build that's not in the list of non-escorting units. And then you'd have to work around the AI's insane build choices. Just because it's available doesn't mean the AI will build any.
Flintlock, this is very interesting information. :)

In my eyes you have done here "all the needed programming" by allowing to set the number of needed naval escorts to zero (= no escort needed). I am wondering how many playing time the game is wasting by checking the "eight times routine" and this for every transport in a game! :eek:

Even before this information, I had the opinion that the best solution would be, when a naval transport unit includes its own escort "inside" that transport unit. It is no problem to set the defense values (naval combat, AA and hitpoints) of a naval transport ship in the editor to the values of another escorting naval unit. There exists an old convoy multi-unit by Wyrmshadow (unfortunately with somewhat now outdated graphics) and I asked Wotan49 to create some new naval convoy units for the next version of CCM. He created a wonderful WW1 convoy unit, but unfortunately that unit has a graphical error, that could not be fixed until now. Therefore the next version of CCM still has to use the normal naval escorts, as these convoy units should be available for each naval era.

Nevertheless the best solution in my eyes is to get rid of that escort problem by graphical convincing naval convoy units instead of only reducing (or multiplying ?) it by additional programming - and this would be a job for unit creators, as the needed programming for the proper use of those units (zero escorts needed) was still done by you. :thumbsup:

Btw.:

1. The next version of CCM has solved the battleship/cruiser problem by making use of the new resource options in your brilliant mod. In my current test game I spotted many AI transports, escorted by cruisers, several by destroyers and some even by torpedo boats.

2. The general naval defense retreat option in my eyes is working much too well. In a one-ship-to-one-ship-battle it is very difficult to sink a ship, as after the retreat the damaged ships have a good chance to escape in the vastness of the ocean. Attacks by bombardment are not sufficient to destroy a battleship without increasing massively the rate of fire of those ships (what would have other not wanted consequences for land bombardment by those ships). Therefore I disabled that option again for my current test game, what gave me all in all more satisfying results, especially for the pirate ships.

I would like a lot, if the naval defense retreat option could be set from general to certain classes of ships in the config file. I would like to set the naval defense retreat only to submarines, where in my eyes it belongs to by using an additional dimension (diving) that most attacking ships cannot perform.
 
Last edited:
Swords crossing each other could be one option.

A recommendation:
Maybe a mod have an icon like that you can use.

Any unit can attack could have that icon and any unit that already attacked has no icon.

That way we, the players, know that any remaining units that have an icon in front of their name can attack. Easy peasy
That one might work but I'd have to darken the edges so it's more distinct. Keep in mind the icon can't be any larger than 15 pixels high otherwise it'll cause the entries on the menu to get spaced out.
15 pixels is tiny. I would keep it as simple as possible. If a sword symbol is required, why not use the black and white one that is used to designate a Barracks in cities? It is 15 pixels high, and the black frame around the sword could be edited out.

Like you mentioned, I could instead put icons on units that can still attack. Since that would mean most units would have icons, it makes me think I should just put icons on all units. Noncombat units could have a white flag or something.
If you are able to put icons on all units, perhaps it would be an idea to use a traffic light model? There are already icons for that in the game. Like, on top of the health bar for all units there is a small LED lamp that changes color depending on the movement state of the unit. Those are 6x6 pixels, but could be scaled up. For example, green could mean the unit is able to attack, yellow means it cannot attack but it can move, and red means all movement is spent so it can't be given any more orders. It would also be nice to have some indication whether fighter planes are on Air Superiority missions, since there is no good way to determine that from the right-click menu. You could always click on the fighter, but then you'll wake it up if it actually was on a Superiority mission so you'll never know, and have to give the orders over again. If this is possible to achieve, I suggest a light blue color (like the sky) for this purpose.

One nice thing about putting icons on all units is that the text on their menu items would line up. Putting an icon on an item moves the text over quite a bit.
Speaking of alignment, it would be easier to read the right-click menu when the "group_units_on_right_click_menu" option is activated, if units there are only 1 of would have the prefix "1x" added to the beginning of the line, like the others might have "2x" or "5x" or whatever. That would make the text align, and make the menu less confusing and much easier to read. :thumbsup:
.
 
Last edited:
@Flintlock have you seen in the code how AI handles protecting resources, airfields, etc.? Would be nice for some if ... then ... logic to have them guard valuable resources and installations. Especially with AA in later eras.
I have found the code that sends defenders to colonies, airfields, and radar towers. Does the AI ever defend resources outside of colonies? I don't recall ever seeing it do that. It wouldn't be too hard to make it do that by extending the logic for defending colonies. Specifically what I would do is add some logic after the search for colonies that redoes the search only for bare resources instead. The only complication is I'd have to assemble a list of tiles with resources on them ahead of time since searching every tile might noticeably slow the game down (there's a list of colonies so it doesn't have to search all tiles there). Getting the AI to defend with AA too would be easy in the new logic but awkward to patch into the existing logic for colonies.
Regarding defending resources with AA: I recently experimented with perfuming FlaK units in my 2021 EXPANSION mod, which is quite similar to the vanilla game. Normally, an AI with an army of, let's say 300 units, may only build 2-3 FlaK units or so. While experimenting, I overdid it at one point. So the AI would build about 60-70 FlaK units. In this situation, when the AI had access to an abundance of AA, I made two interesting observations:
  1. The AI would use a lot of the FlaK to protect its Radar Towers. Actually, it seemed like the AI prefers using FlaK to protect them. Which works quite well for it, since I (and probably many other human players) often use bombers to clear away the Radar Towers before I assault the city with land units.
  2. The AI started using FlaK to systematically escort its attacking army to the front. For example Cavalry, it would follow them tile by tile like a warship escorting a sea transport. I haven't seen that before. But protecting the army is one of their main tasks anyway, so that's OK.
It might just be a matter of making sure the AI has sufficient AA to make it protect Radar Towers, which is probably transferrable to protecting resources as well (it will normally only use one, though).
 
Regarding defending resources with AA: I recently experimented with perfuming FlaK units in my 2021 EXPANSION mod, which is quite similar to the vanilla game. Normally, an AI with an army of, let's say 300 units, may only build 2-3 FlaK units or so. While experimenting, I overdid it at one point. So the AI would build about 60-70 FlaK units. In this situation, when the AI had access to an abundance of AA, I made two interesting observations:
  1. The AI would use a lot of the FlaK to protect its Radar Towers. Actually, it seemed like the AI prefers using FlaK to protect them. Which works quite well for it, since I (and probably many other human players) often use bombers to clear away the Radar Towers before I assault the city with land units.
  2. The AI started using FlaK to systematically escort its attacking army to the front. For example Cavalry, it would follow them tile by tile like a warship escorting a sea transport. I haven't seen that before. But protecting the army is one of their main tasks anyway, so that's OK.
It might just be a matter of making sure the AI has sufficient AA to make it protect Radar Towers, which is probably transferrable to protecting resources as well (it will normally only use one, though).

Were the flaks flagged as defense units? If so did the AIs use them to defend their cities? The problem with that is that you end up with cities defended by nothing but 2 flaks. Not ideal.
 
Yes, FlaK is flagged as defensive in my mod, same as the vanilla game. The AI left some FlaK in their cities, but it used at least half of them for the tasks I mentioned. The problem is, if the AI were to protect everything to the max with AA, it requires great numbers. And if it builds too many compared to other units, it will work against it. City defenses can be somewhat taken care of by building SAM Missile Batteries (but they need to be perfumed, otherwise the AI will rarely build them). The AI is also relatively good at building fighter planes to protect its frontline cities.
 
In my eyes you have done here "all the needed programming" by allowing to set the number of needed naval escorts to zero (= no escort needed). I am wondering how many playing time the game is wasting by checking the "eight times routine" and this for every transport in a game! :eek:
I wonder that too. The search for a unit to escort involves checking every unit in the game. Most of them are quickly filtered out by owner or AI strategy but it's still necessary to read some data from each unit object to do that, and memory access isn't free, especially not multiplied by thousands of units. And that's multiplied again by 8 times and again for each AI unit searching for something to escort. This could easily be a major drag on turn times but I'd have to run the game through a profiler again to be sure. It depends on how many AI units are actually searching for something to escort. If the units already have jobs to do, they won't search.

I would like a lot, if the naval defense retreat option could be set from general to certain classes of ships in the config file. I would like to set the naval defense retreat only to submarines, where in my eyes it belongs to by using an additional dimension (diving) that most attacking ships cannot perform.
I'll keep this in mind for R18. It would be relatively easy since I've already worked out how to modify the retreat rules. By the way, I fixed that bug you reported a month ago about the rotate-before-attack flag being broken by modified naval retreat rules. That will be in the final version of R17.


So far I've got three bug fixes for R17. First, the one mentioned just above. Second, perfume not applying to all unit sub-types after they got duplicated to spread out AI strategies. Third, the max_ai_naval_escorts setting interfering with group movement of naval units. Also I investigated a fourth bug, the Philosophy tech not awarding a bonus tech when unlocked by a goody hut popped by a scout on autoexplore, but I wasn't able to replicate that one. This is the last call for bugs in R17. If no one reports any more, I'll post it soon and we can all move on to R18 (at long last...).


15 pixels is tiny. I would keep it as simple as possible. If a sword symbol is required, why not use the black and white one that is used to designate a Barracks in cities? It is 15 pixels high, and the black frame around the sword could be edited out.
That's a good idea. I could also keep the frame around it and remove the sword for units that can't attack again. I'd like the icon for combat units that can't attack again to communicate that they're somehow spent or exhausted. I was considering using an icon of a magazine full of bullets for units that can still attack and an empty magazine for combat units that have already used their attack. That might not read well though. Then I also thought, for the ancient and medieval eras, I could replace those with icons showing a quiver full of arrows vs an empty quiver. I like that idea but it's probably best to keep it simple.

If you are able to put icons on all units, perhaps it would be an idea to use a traffic light model?
How about a LED indicator which is green/yellow/red to indicate remaining moves like in the base game, and contains a sword icon to indicate ability to attack? I could also put a blue background just for fighters set to intercept.
 
Top Bottom