Combat and Stacking Overhaul

Gedemon

Modder
Super Moderator
Joined
Oct 4, 2004
Messages
12,701
Location
France
This component add some of the features of the R.E.D. WWII mod to the base game.

The R.E.D. DLL for BNW mod is mandatory, it must be activated first in the mod list (which also means that this mod is compatible with Brave New World only)

Features:

  • Range of all land/sea units is reduced to 1 tile
  • Different "stacking classes" are defined: Melee (including gun, mounted and armor units), Support (siege and "archer"), Recon, Ranged Naval, Helicopters, Workers
  • Limited stacking for Air Units in cities (3)
  • Some buildings can raise the stacking limit in cities (Barracks = +1 land, Castle = +1 land, Military Base = +3 Air +3 Land +2 Sea, Airport = +5 Air, Harbor = +1 Sea, Seaport = +1 Sea)
  • Unlimited stacking for Great People and Missiles
  • You can have 2 units of each "stacking class" on a plot (was planning 1 unit per class per tile, but wanted feedback on 2 per class in the test version)
  • Counter-Fire : ranged siege units can strike back at another siege or archer unit when the plot they are on is attacked. Archer units can only strike back at another archer unit.
  • Preparation Fire: all ranged siege units will provide a support fire to the first melee unit attacking from the plot they're on (if in range of the attacked plot)
  • Counter-Preparation fire: all siege and archer units (that include Gatling guns, machine guns and bazooka) will launch a defensive first strike when the plot they are on is attacked by a melee unit
  • Retreat: when receiving heavy casualties, a land unit will be routed and will try retreat from the plot they are. If no free retreating position is found, the unit take extra damages.
  • More units: with limited stacking allowed, the maps can handle much more units, the construction cost of all military land units has been divided by 2 and they take less casualties from combat.
  • Naval Counter Attack: ranged naval units will counter-fire at any other ranged naval unit (except submarines).

Download link: CFC Database (no steam version for the beta release)

Recommended mods:
UI fix for Unit Stacking
Any mod allowing military tile capture like Cultural Diffusion or Hex Conquer and Release.


Credits

Whys: SaveUtils code
whoward69
Mylon : Naval counter-attack original mod
 
Great :) Thanks for making this available as a separate component.

After some limited play, everything seems to work according to the description. I haven't gotten too far in a game to see all classes and combinations yet. Having a good time with it though. The counter-fire and prep fire elements add a lot of depth and seem well thought out. Reminds me a bit of 'stack aid' for CIV, which was a great addition at the time. It's a lot more tangible here, obviously.

For testing, it would be helpful to log the text notifiers (they fade pretty quickly). What would be the relevant logging option?

Wish List:santa2:

-Combat UI damage integration
-Grouped movement
 
All combats are logged in the lua.log. I may activate a combat log in game for the last few turns.

I share your wishlist, both are complex, but the first one has better chance of integration than the second.

I've just found a bug that'll be corrected in next version: naval melee unit can force another to retreat, but the feature is intended to land unit only.
 
I figured stack movement would be a tall order.

One current question... how are retreats into mountain tiles handled? The resulting damage usually kills them. I presume that's the vanilla attrition mechanism at work (e.g. Carthage), or does the mod simply remove the unit?
 
I figured stack movement would be a tall order.

One current question... how are retreats into mountain tiles handled? The resulting damage usually kills them. I presume that's the vanilla attrition mechanism at work (e.g. Carthage), or does the mod simply remove the unit?

units should not retreat into mountains, if they do, it's a bug, please confirm if it's happening.
 
units should not retreat into mountains, if they do, it's a bug, please confirm if it's happening.

Yes, I've seen it numerous times (all barbarians, so far).

edit: If I recall, the retreat was always straight back even if other (non mountain) tiles were available.

edit: Scratch that, managed to reproduce it. Here's an example with the log from the start of the combat. #664 is the defensive prep attack and #665 is the Genoan spearman's attack with the barb retreat.

attachment.php


Lua.log
Spoiler :
[2102123.906] CSO_Main: ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[2102123.906] CSO_Main: ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[2102123.906] CSO_Main: TacticalAILaunchUnitAttack for Spearman of player Genoa at 84,32
[2102123.906] CSO_Main: Check for First Strike before attack of Spearman of player Genoa against 84,32
[2102123.906] CSO_Main: --------------------------
[2102123.906] CSO_Main: Defensive Support Fire
[2102123.906] CSO_Main: Support unit : Hand-Axe
[2102123.906] CSO_Main: - Support unit had 120 moves left.
[2102123.906] CSO_Main: - Set (Spearman) as best defender on plot 84,31
[2102123.906] CSO_Main: - Moves Left = 120
[2102123.906] CSO_Main: - Moves Left with bonus added = 180
[2102123.984] CSO_Main:
[2102123.984] CSO_Main: ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[2102123.984] CSO_Main: COMBAT Started #664
[2102123.984] CSO_Main: ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[2102123.984] CSO_Main: Attacking from plot at 84,32
[2102123.984] CSO_Main: Attacker is Hand-Axe, Current Damage = 24
[2102123.984] CSO_Main: Defending plot at 84,31
[2102123.984] CSO_Main: Defender is unit : Spearman, Current Damage = 0
[2102123.984] CSO_Main: Attack type : Ranged
[2102123.984] CSO_Main: ---------------------------------------------------------------------------------------------------------------
[2102123.984] CSO_Main: Combat Started: BARBARIANS attack GENOA
[2102123.984] CSO_Main: ---------------------------------------------------------------------------------------------------------------
[2102123.984] CSO_Main: Attacking Unit: Hand-Axe
[2102123.984] CSO_Main: Defending Unit: Spearman
[2102123.984] CSO_Main: Receveid Damage: 0 7
[2102123.984] CSO_Main: Final Damage: 0 7
[2102123.984] CSO_Main: HitPoints left: 76 93
[2102123.984] CSO_Main: ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[2102124.109] CSO_Main:
[2102124.109] CSO_Main: ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[2102124.109] CSO_Main: COMBAT Ended #664
[2102124.109] CSO_Main: ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[2102124.109] CSO_Main: Attacking from plot at 84,32
[2102124.109] CSO_Main: Attacker is Hand-Axe, Current Damage = 24
[2102124.109] CSO_Main: Defending plot at 84,31
[2102124.109] CSO_Main: Defender is unit : Spearman, Current Damage = 7
[2102124.109] CSO_Main: Attack type : Ranged
[2102124.109] CSO_Main: ---------------------------------------------------------------------------------------------------------------
[2102124.109] CSO_Main: Combat Ended: BARBARIANS attack GENOA
[2102124.109] CSO_Main: ---------------------------------------------------------------------------------------------------------------
[2102124.109] CSO_Main: Attacking Unit: Hand-Axe
[2102124.109] CSO_Main: Defending Unit: Spearman
[2102124.109] CSO_Main: Receveid Damage: 0 7
[2102124.109] CSO_Main: Final Damage: 0 7
[2102124.109] CSO_Main: HitPoints left: 76 93
[2102124.109] CSO_Main: ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[2102124.109] CSO_Main: - Unset (Spearman) as best defender on plot 84,31
[2102124.109] CSO_Main: - Moves Left = 180
[2102124.109] CSO_Main: - Moves Left with bonus removed = 120
[2102124.171] CSO_Main:
[2102124.171] CSO_Main: ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[2102124.171] CSO_Main: COMBAT Started #665
[2102124.171] CSO_Main: ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[2102124.171] CSO_Main: Attacking from plot at 84,31
[2102124.171] CSO_Main: Attacker is Spearman, Current Damage = 7
[2102124.171] CSO_Main: Defending plot at 84,32
[2102124.171] CSO_Main: Defender is unit : Hand-Axe, Current Damage = 24
[2102124.171] CSO_Main: ---------------------------------------------------------------------------------------------------------------
[2102124.171] CSO_Main: Combat Started: GENOA attack BARBARIANS
[2102124.171] CSO_Main: ---------------------------------------------------------------------------------------------------------------
[2102124.171] CSO_Main: Attacking Unit: Spearman
[2102124.171] CSO_Main: Defending Unit: Hand-Axe
[2102124.171] CSO_Main: Receveid Damage: 9 22
[2102124.171] CSO_Main: Final Damage: 16 46
[2102124.171] CSO_Main: HitPoints left: 84 54
[2102124.171] CSO_Main: -----------------
[2102124.171] CSO_Main: Spearman has 120 moves left.
[2102124.171] CSO_Main: diffDamage: 13
[2102124.171] CSO_Main: ratioHitPoint: 4.1538461538462
[2102124.171] CSO_Main: RETREAT !!!
[2102124.171] CSO_Main: attack direction = 5, next = 0, prev = 4
[2102124.171] CSO_Main: possible retreat direction = 5, 4, 0
[2102124.171] CSO_Main: can't retreat, another unit on plot
[2102124.171] CSO_Main: can't retreat, another unit on plot
[2102124.171] CSO_Main: retreating to new plot, attack direction is : 4
[2102124.171] CSO_Main: ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[2102124.250] CSO_Main:
[2102124.250] CSO_Main: ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[2102124.250] CSO_Main: COMBAT Ended #665
[2102124.250] CSO_Main: ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[2102124.250] CSO_Main: Attacking from plot at 84,32
[2102124.250] CSO_Main: Attacker is Spearman, Current Damage = 16
[2102124.250] CSO_Main: Defending plot at 84,32
[2102124.250] CSO_Main: Defender is unit : Hand-Axe, Current Damage = 46
[2102124.250] CSO_Main: ---------------------------------------------------------------------------------------------------------------
[2102124.250] CSO_Main: Combat Ended: GENOA attack BARBARIANS
[2102124.250] CSO_Main: ---------------------------------------------------------------------------------------------------------------
[2102124.250] CSO_Main: Attacking Unit: Spearman
[2102124.250] CSO_Main: Defending Unit: Hand-Axe
[2102124.250] CSO_Main: Receveid Damage: 9 22
[2102124.250] CSO_Main: Final Damage: 16 46
[2102124.250] CSO_Main: HitPoints left: 84 54
[2102124.250] CSO_Main: ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


It looks like the barb camp on the right isn't a valid retreat direction because it's occupied (though that would be the best move). The other plot has my spearman, so it picks the mountain (which I suppose shouldn't be valid). Similar situations with ocean tiles work correctly, though, and I get the text notification "can't retreat" or whatever.

In this case, the unit survived the -50 attrition damage from the mountain, so it was a bit more obvious what had happened. He vanishes on the next turn.
 
ok thanks, I'll correct that.
 
yep, thanks, that's a consequence of the bug described in post #3, it will be corrected in next version :)
 
A couple more questions and observations after some more play time...

1) If I have 2 archer units stacked and attack into a tile with an enemy archer, when the defending unit counter-fires, my 2nd archer (who hasn't moved) counter-counter fires :)

However, when that 2nd archer gets his attack, there is no such return fire by the first archer to the defender's 2nd counter-attack. I'm guessing this is because he's already used his primary attack. Is this how it's supposed to work?

2) I see that units being attacked from defenders within a city do not get any counter-fire opportunities, but the defenders do. Is this also correct?

I have others, but I'll keep them in nice, bite sized pieces :)

Still enjoying this immensely. Thanks.
 
1/ The mechanism may change. No, correction, it will change, it's an early version you're testing, and I was testing it with 1 ranged unit per tile, I've changed it to 2 just before this first release.

So I hadn't thought of the counter-counter-fire, but I like it. I have to make some war with that mechanism to see if I want it to stay this way or not.

Now, for consistency, the counter-counter-fire should also be "free", but dynamic coding depending of the global UPT limit may not be easy.

The defender unit has unlimited counter-fire IIRC.

And what I need to add anyway is a selection of the best counter-unit on a plot, ATM the mod use the first ranged unit it found on it.

2/ Yes, but I'd like to link it to the building in the city, allowing units outside the city to counter-fire at units inside the city if there is no wall, or link it to a probability of not getting counter-fire, raising with the building type (wall, castle, etc...)

and thanks for the reports :)
 
Gedemon,

Do you need to update the R.E.D. dll for the latest patch, or have I somehow mangled my own setup?

All was well after updating until I cleared the database cache. Now the mod is only partially functional and throwing errors. I was sort of expecting a problem, but what's strange is that my laptop installation, which is offline and still at 1.0.3.18/3.0.3.0, had the same issues when I tried the mod there to confirm the Firaxis update had broken it :think:

I'll can post my log if it turns out to be relevant... thought I'd ask first.
 
Yes, I'd like the log.
 
OK, thanks. First CSO error is on 1568 (call to nil value). Most of the rest are ops on AirStackChange (which is always nil).

Cache and ModUserData were cleared, verified installation through Steam, etc.

The only mods running are yours (and Nutty's scaling mod):

Combat and Stacking Overhaul (v 1)
Cultural Diffusion (v 18)
Custom Advanced Setup Screen (v 5)
R.E.D. - Just Ethnic Diversity (v 27)
R.E.D. DLL (v 6)
R.E.D. Modpack (v 27)
Revolutions (v 9)
UI for Unit Stacking (v 1)

The result is the same with just the RED dll, CSO and the unitpanel mod. I tossed in the other mods just to see if there was a general problem. I also tried toggling various options for the RED dll in advanced setup.

And I switched from LuaJIT back to the standard library. No dice :sad:

EDIT: In game, there's no stacking (except in cities). Some combat functions are working (retreat, counter-fire etc). Damage looks like vanilla values. City bombardment distance is also vanilla (2 tiles).
 

Attachments

x-Rules.sql is not loaded.

do you have the database.log after initializing the mod ?
 
Thanks :)

Try the following:

Open x-Rules.sql with any text editor like notepad, find the code
Code:
/* Add new column for effect of buildings on number of units that can stack in a city */
ALTER TABLE Buildings ADD COLUMN AirStackChange integer DEFAULT '0';
ALTER TABLE Buildings ADD COLUMN LandStackChange integer DEFAULT '0';
ALTER TABLE Buildings ADD COLUMN SeaStackChange integer DEFAULT '0';

then cut it and past it at the top of the file, save and try to launch a game.
 
That didn't fix it, but did consolidate the error output. Just 2 in lua.log (@ 1460 & 21812). I turned on LuaDebugLibrary and ValidateGameDatabase this time.

Let me know if there's anything else I can do to trace the problem (via tuner or other debug options).
 

Attachments

did you change anything in Database.sql from the DLL mod ?
 
Back
Top Bottom