How is City defense calculated?

pineappledan

Deity
Joined
Aug 9, 2017
Messages
10,853
Location
Alberta, Canada
So I am aware that city defense is made up of component parts:
  • base value from era
  • population
  • hill or flatland
  • buildings
  • garrison
What exactly is the formula, however? more specifically:
  • What are the base values for every era?
  • How much is each population worth, and is it linear?
  • how much of a bonus is hill? is it a % or is it a flat value?
  • how is garrison strength determined as a % of the CS of the unit?
I know that the lowest possible city defense in the game is 6, so does that mean that base defense in ancient is 5:c5strength:, and +1:c5strength: for every population?
 
So population adds city defense exponentially? Is there a point where additional population could start REDUCING crime?

What about hill vs flatland and base vale per era?
 
this stuff looks relevant. not terribly complicated

Code:
UPDATE Defines SET Value = '500' WHERE Name = 'CITY_STRENGTH_DEFAULT';
UPDATE Defines SET Value = '20' WHERE Name = 'CITY_STRENGTH_POPULATION_CHANGE';
UPDATE Defines SET Value = '350' WHERE Name = 'CITY_STRENGTH_UNIT_DIVISOR';
UPDATE Defines SET Value = '3.8' WHERE Name = 'CITY_STRENGTH_TECH_BASE';
UPDATE Defines SET Value = '2.2' WHERE Name = 'CITY_STRENGTH_TECH_EXPONENT';
UPDATE Defines SET Value = '0' WHERE Name = 'CITY_STRENGTH_TECH_MULTIPLIER';
UPDATE Defines SET Value = '300' WHERE Name = 'CITY_STRENGTH_HILL_CHANGE';
 
this stuff looks relevant. not terribly complicated

Code:
UPDATE Defines SET Value = '500' WHERE Name = 'CITY_STRENGTH_DEFAULT';
UPDATE Defines SET Value = '20' WHERE Name = 'CITY_STRENGTH_POPULATION_CHANGE';
UPDATE Defines SET Value = '350' WHERE Name = 'CITY_STRENGTH_UNIT_DIVISOR';
UPDATE Defines SET Value = '3.8' WHERE Name = 'CITY_STRENGTH_TECH_BASE';
UPDATE Defines SET Value = '2.2' WHERE Name = 'CITY_STRENGTH_TECH_EXPONENT';
UPDATE Defines SET Value = '0' WHERE Name = 'CITY_STRENGTH_TECH_MULTIPLIER';
UPDATE Defines SET Value = '300' WHERE Name = 'CITY_STRENGTH_HILL_CHANGE';

So it may be:
City_Strength = 5 + 0.2 * Population + Unit_Garrisoned_Strength / 3.5 + ((3.8 + Technologies_Discovered) ^ 2.2) * (1 + 0) + (Is_Hill ? 3 : 0)
That makes most sense to me, but Technology factor is most opaque here
 
Back
Top Bottom