Optional city garrison requirement

Cruiser76

Warlord
Joined
Feb 4, 2018
Messages
116
Does the option in the AdvCiv xml file to require upgraded troops for city defense work? I tried enabling it with a “1’, but didn’t notice any effect.
 
I would've hoped so, but no. There's a times-100 error that causes garrisons to be always treated as sufficient.

Actually, now that we have this thread already, - maybe someone wants to weigh in on how this option could be improved. I'm attaching the 0.97c DLL (for 18 civs) with just the bugfix and a "tweak" that doubles the required defensive strength; see below about that. To try the option out, one needs to set DEMAND_BETTER_PROTECTION=1 in Assets\XML\GlobalDefines_advc.xml. Should immediately apply when a savegame is loaded.

The obvious (in a good way) modification of the BtS rule would be to let a single non-obsolete garrison unit quell a city's fear for its safety. However, that would strongly encourage players to avoid Hunting and Feudalism (Spearman obsoleting Warrior, Longbow obsoleting Archer) for the paradoxical reason that those techs will make citizens "fear for their safety." (Just to explain upfront why I haven't taken this approach.)

The current (optional) rule is that a city requires a total defensive strength equal to or greater than its population. A unit's defensive strength is computed as its combat strength (including generic Combat promotions) increased by defensive modifiers (if the unit can receive such modifiers) from
a) promotions (Garrison)
b) buildings (Wall, Castle; not: culture defense)
c) terrain (Hills), and defensive modifiers that are
d) built into the unit (Warrior, Archer, Longbowman).
Same thing as culture garrison strength against revolts except that unit health matters for culture garrison strength and that b) and c), i.e. modifiers from the city tile, don't count for culture garrison strength. Oh, and units that either the city or the capital can no longer train, have their defensive strength halved. Would be nice to get rid of at least this last provision for the sake of simplicity and to avoid the aforementioned anti-Feudalism incentives.

If the total defensive strength is insufficient, then NO_MILITARY_PERCENT_ANGER (33.4% as in BtS) is taken times the ratio of the missing defensive strength and the required defensive strength.

So a Warrior has defensive strength 2*1.25=2.5. I wanted this to be (fully) sufficient up to a city size of 5, so, originally, I had required defensive strength to be equal to at least half the city size. However, because of rounding, a Warrior could then still be sufficient at size 7 and, starting at size 8, anger would only gradually set in. The game adds all fractional anger values up before rounding them down; so rounding is difficult to predict.

In the DLL I've uploaded, defensive strength needs to match the full city size. So long as there is no other source of anger – and there should be none in the early game – a single Warrior will still suffice at size 5: The missing-to-required ratio is then 0.5. That times 33.4% times 5 population is 0.835. An Archer on a Hill, for another example, should suffice up to size 8. Some cities don't ever grow larger than that, but such cities won't care about anger anyway, so perhaps this isn't much of a problem. The tooltip for the unhappiness icon still needs to be changed to something like "We demand better protection (3:strength: missing)."

While "strength with def. modifiers needs to match population" is quite simple, the actual math is a lot more complicated because of rounding. If the rounding behavior were changed, it'd be inconsistent with all other anger effects, and the target defensive strength would have to be half the population again, which is also slightly complicated.

I don't think the current population-based approach is terrible, but maybe there's some other way to go about this. There's @Imp. Knoedel's Scaling Garrison Unhappiness component, but that's pretty similar to what I have.

In any case, it might be good to disable fear-for-safety anger at some point of the game in order to reduce late-game micromanagement a little (always a worthy goal). @Zeta Nexus had the idea (posted in Knoedel's thread linked above) to exempt cities when there is no non-friendly tile within a certain range. I'm instead leaning toward letting the Nationalism tech disable fear for safety everywhere. Regardless of how the anger is computed, this would ensure that anachronistic garrison units are gone by the Industrial era.
 

Attachments

  • CvGameCoreDLL.zip
    2 MB · Views: 59
Yes, I think tying it to population is both easy and somewhat logical. I also like the idea of letting a certain tech remove the need. In the industrial era+ with railroads and air transport, there is no need for garrisons in every city.
 
Hey, I updated to the new game core and started getting consistent game crashes in the classical age. I disabled the optional garrison feature and the game crashes stopped.
 
Can't reproduce that. Conceivable that the crash is caused by something else and that disabling the demand-better-protection change bypasses that crash through some butterfly effect. Or just something I'm missing. I'm attaching a DLL with assertions and the BBAI log enabled, two lines disabled that could possibly cause a crash (but should've been fine as far as I can tell) and the obsoletion check (defensive strength halved if obsolete) disabled just in case that something went wrong there – and because I hope it won't be needed gameplay-wise now that defensive strength needs to match the full population.

If it still crashes, then setting MessageLog, RandLog and LoggingEnabled to 1 in the .ini will hopefully provide some insight via BBAI.log and MPLog.txt.
 

Attachments

  • CvGameCoreDLL.zip
    2.2 MB · Views: 70
Top Bottom