What is the actual defense bonus in a city?
- Hans_Lemurson
- Member
- Posts: 182
- Joined: Thu Jan 01, 1970 12:00 am
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.
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.
- Hans_Lemurson
- Member
- Posts: 182
- Joined: Thu Jan 01, 1970 12:00 am
- Hans_Lemurson
- Member
- Posts: 182
- Joined: Thu Jan 01, 1970 12:00 am
-
- Member
- Posts: 225
- Joined: Thu Jan 01, 1970 12:00 am
Doubt, that there is such high defense factor.Corbeau wrote:I think so.
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.
- kevin551
- Member
- Posts: 208
- Joined: Thu Jan 01, 1970 12:00 am
I agree. Your formula is not correct.
The two effects for city size are -
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.
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. "
The two effects for city size are -
Code: Select all
[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 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.
Code: Select all
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;
"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 on Sat Oct 13, 2018 10:07 am, edited 1 time in total.
- kevin551
- Member
- Posts: 208
- Joined: Thu Jan 01, 1970 12:00 am
This topic was previously discussed here - The best possible defense value for a unit in a city
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.
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.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).
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 on Sat Oct 13, 2018 3:43 pm, edited 1 time in total.
-
- Member
- Posts: 990
- Joined: Thu Jan 01, 1970 12:00 am
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 on Mon Oct 15, 2018 4:10 pm, edited 1 time in total.