#1 12.10.2018 18:16:20

Hans_Lemurson
Player
From: Silicon Valley
Posts: 139

What is the actual defense bonus in a city?

I have a few questions about how strongly units defend a city:
1. I have read that units get get a 1.5x defense bonus just from BEING in a city.  Is this correct?
2. Does this "In a City" bonus replace the 1.5x defense bonus they get from the normal unit-fortify command?  Or are fortified units in a city get a 2.25x bonus?
3. Do city walls give a 2x defense bonus, or do they replace the "In a City" bonus, increasing it from 1.5 to 2?
4. Size 8 cities get a 1.5x defense bonus.  Is this a separate bonus from all the others?

I have witnessed shockingly tenacious defense in a city, and I'm unsure whether this was bad luck or incorrect calculations.

Offline

#2 12.10.2018 18:29:53

Corbeau
Player
Posts: 821

Re: What is the actual defense bonus in a city?

This is what I have:

(base defence) * (terrain) * 1.5 (city or fortified) * [1.0 + (city size %) + (walls/coastal)]

Offline

#3 12.10.2018 23:05:06

Hans_Lemurson
Player
From: Silicon Valley
Posts: 139

Re: What is the actual defense bonus in a city?

So, a Phalanx in a Size 2 unwalled city on on a hill defends at what level of strength?

2(Phalanx def) * 1.5(Hill bonus) * 1.5(city or fortified bonus) * (1+0(size2 city has no bonus)+0(no walls)) = 4.5?

Offline

#4 12.10.2018 23:16:49

Corbeau
Player
Posts: 821

Re: What is the actual defense bonus in a city?

Again, defence bonus due to city size is ruleset-specific and in most (if not all so far) LT games is 50% for all cities smaller than 8.

So this example would be 6.75.

Offline

#5 13.10.2018 06:21:17

Hans_Lemurson
Player
From: Silicon Valley
Posts: 139

Re: What is the actual defense bonus in a city?

And for cities size-8 and above, it would be def strength 9?

Offline

#6 13.10.2018 08:27:21

Corbeau
Player
Posts: 821

Re: What is the actual defense bonus in a city?

I think so.

Offline

#7 13.10.2018 09:33:19

Wahazar
Player
Posts: 137

Re: What is the actual defense bonus in a city?

Corbeau wrote:

I think so.

Doubt, that there is such high defense factor.
Didn't find anything in combat.c, could you point me the line where it is?

In LT45 effetcs.ruleset I found only 50% bonus for land units in any city and additional 50% bonus for land and naval units for city of size 8 and more.

Offline

#8 13.10.2018 09:50:21

kevin551
Player
Posts: 326

Re: What is the actual defense bonus in a city?

I agree. Your formula is not correct.

The two effects for city size are -

[effect_city_defense_0]
type    = "Defend_Bonus"
value   = 50
reqs    =
    { "type", "name", "range"
      "CityTile", "Center", "Local"
}

[effect_city_defense_1]
type    = "Defend_Bonus"
value   = 50
reqs    =
    { "type", "name", "range"
      "MinSize", "8", "City"
      "CityTile", "Center", "Local"
}

A size 2 city only gets the 50% bonus once not twice.
A size 8+ city gets both bonuses. Once each. It gets a 100% bonus. (You add the bonuses then multiply, not multiply by first then multiply by second.)

A green Phalanx in a Size 2 unwalled city on on a hill defends at 4.5
A green Phalanx in a Size 8+ unwalled city on on a hill defends at 6.0

To be certain we need to look at the source code.

In combat.c lines 544 to 533 however it does look like you get the city bonus twice.
It seems strange to have effects that allow the values to be modified in the ruleset,
and then combine that with a hard coded value in the binary.

  defensepower +=
    defensepower * tile_extras_defense_bonus(ptile, def_type) / 100;

  if ((pcity || fortified)
      && uclass_has_flag(utype_class(def_type), UCF_CAN_FORTIFY)
      && !utype_has_flag(def_type, UTYF_CANT_FORTIFY)) {
    defensepower = (defensepower * 3) / 2;
  }

return defensepower;

The page http://freeciv.wikia.com/wiki/Combat is almost useless at explaining this properly.
"These factors are combined, thus a city built on a hill with a river that has city walls is very hard to conquer. "

Last edited by kevin551 (13.10.2018 10:07:22)

Offline

#9 13.10.2018 10:24:08

Corbeau
Player
Posts: 821

Re: What is the actual defense bonus in a city?

Ok, I misread. The example Hans gave had NO walls, and I calculated WITH walls. My bad.

Offline

#10 13.10.2018 12:43:25

kevin551
Player
Posts: 326

Re: What is the actual defense bonus in a city?

This topic was previously discussed here - The best possible defense value for a unit in a city

Caedo wrote:

All the different bonuses in Freeciv's supplied rulesets are multiplicative, since it's never possible to have multiple Defense_Bonus effects applying at the same time. However, as with any effect type, the values of all active effects are simply added, so if there's one Defense_Bonus effect with a value of 50 for a city of size 9 and another with a value of 100 for city walls, they're the same effect type and thus added up, giving a total value of 150, or +150% (or *2.5).

The part that puzzles me is that there appear to be two 50% bonuses for cities smaller than size 8. One hardcoded and one in the effects.ruleset.
I looked back and this was also the case in LT32. In that game I certainly tested attacking cities. I never noticed an extra 50% defence.

This was also mentioned by Caedo in the thread linked previously.

Caedo wrote:

EDIT 2: Also, there seems to be an additional +50% Defend_Bonus in a city, apart from the built-in factor of 1.5. However, this defense only works against land units.

Last edited by kevin551 (13.10.2018 15:43:19)

Offline

#11 15.10.2018 15:15:04

dion
Player
Posts: 4

Re: What is the actual defense bonus in a city?

it seems to me that the quoted source code is giving an additional 50% bonus for fortifying the unit itself inside the city. am I wrong?

Offline

#12 15.10.2018 16:10:00

Corbeau
Player
Posts: 821

Re: What is the actual defense bonus in a city?

I don't even know what language that is (C?), but "if ((pcity || fortified)" looks like "if a unit is in a city OR fortified". Meaning, even if both conditions are met, it's still just one instance of it. 1 OR 1 is still just 1.

Last edited by Corbeau (15.10.2018 16:10:12)

Offline

#13 15.10.2018 16:16:57

kevin551
Player
Posts: 326

Re: What is the actual defense bonus in a city?

Yes it is C.
And yes 1 OR 1 is 1.
There is no point fortifying in a city. You do not gain anything.

Offline

#14 15.10.2018 16:31:44

Corbeau
Player
Posts: 821

Re: What is the actual defense bonus in a city?

Well, you don't get a bonus, but you do get some peace from preventing the unit to pop up every time someone passes by smile

Offline

#15 15.10.2018 17:29:49

Wahazar
Player
Posts: 137

Re: What is the actual defense bonus in a city?

Doesn't  fortify increase speed of healing?

Offline

#16 15.10.2018 17:48:11

Corbeau
Player
Posts: 821

Re: What is the actual defense bonus in a city?

Ok, THAT is a good point. Yes, it does.

Offline

Board footer

Powered by FluxBB