vorshlumpf
Emperor
Kael and Co.,
I hadn't received any feedback about my discovery of inconsistent terrain bonuses applied in combat, so I went ahead and did some digging. Some (most? all?) of this may be already apparent to you, but I'm just going to lay it all out. Anyone who doesn't care about such nitty-gritty details would best leave now
First, the problems discovered:
Defensive traits/promotions such as Shield of Faith and Defensive (and, I assume, even the negative ones such as Rage) are only applied when there isn't a terrain feature. So, a unit with Defensive will have overall a -40% adjustment if they are defending in forest, floodplains, fallout, etc. (-40% to STR, and the +80% defense doesn't kick in).
Woodsman I and II (and the elven +10%) do not take effect in New Forest. But they do take effect when attacking Forest, Ancient Forest, and Jungle (excepting elven 10% on jungle).
Guerilla does not take effect when attacking hills.
Doviello do not get their bonus when attacking a tundra tile or defending a tundra tile with any feature on it.
In Civ IV, there is terrain, and there are terrain features. Terrain is Grassland, Plains, Tundra, Ice (actually 'Snow' within some code), Desert, and all of those again with Hills added in. Terrain features include Jungle, Forest, Oasis, Fallout, Floodplains, New Forest, and Ancient Forest.
There seem to be three ways to add defensive bonuses to a unit (via promotions or within the unit definition itself). There are separately defined elements, two of which exist at the moment ("iCityDefense", "iHillsDefense"). There are iTerrainDefense values, which can be set for any of the terrain types. And there are iFeatureDefense values that can be set for any of the terrain features.
After discovering this, I realised the source of the above problems.
Defensive Traits (Shield of Faith, Defensive, Rage) and the Doviello tundra bonus are all dependant upon iTerrainDefense. These bonuses are nullified if the terrain has any features at all, like forest or oasis.
Woodsman and the elven 10% are based on iFeatureDefense. Forest and the like are features, so this is apparently picked up automatically by the code.
And what's up with Guerilla? Well, that is where the separately defined element iHillsDefense comes in. This seems to by-pass any conflict with terrain features, and is successfully activated for any hill-top defense.
My Suggestions
==============
I consider the following to be the goal of FfH2's design team:
- all terrain and terrain feature bonuses will be applied in attacking and on defense
- defensive bonuses will be applied only on defense
My knowledge of the code is very limited at this point, but I think the following is a possible solution to reach the stated goal:
1) Create more separately defined elements, one for each base terrain (grassland, plains, etc.). In CIV4UnitSchema.xml is the element <element type="iHillsDefense"/>. Is it a simple matter to create more? These elements would be used for defensive values only.
Unfortunately, I'm feeling this would involve an SDK change.
2) Make iTerrainDefense applicable to the attacker as well as the defender, as has been done with iFeatureDefense.
3) Switch Guerilla from the hard-coded value to a iTerrainDefense value.
4) Change defensive traits from using iTerrainDefense to the new separately defined elements.
I'm kind of taking a shot in the dark with this, but hopefully it helps you to some degree.
- Niilo
I hadn't received any feedback about my discovery of inconsistent terrain bonuses applied in combat, so I went ahead and did some digging. Some (most? all?) of this may be already apparent to you, but I'm just going to lay it all out. Anyone who doesn't care about such nitty-gritty details would best leave now

First, the problems discovered:
Defensive traits/promotions such as Shield of Faith and Defensive (and, I assume, even the negative ones such as Rage) are only applied when there isn't a terrain feature. So, a unit with Defensive will have overall a -40% adjustment if they are defending in forest, floodplains, fallout, etc. (-40% to STR, and the +80% defense doesn't kick in).
Woodsman I and II (and the elven +10%) do not take effect in New Forest. But they do take effect when attacking Forest, Ancient Forest, and Jungle (excepting elven 10% on jungle).
Guerilla does not take effect when attacking hills.
Doviello do not get their bonus when attacking a tundra tile or defending a tundra tile with any feature on it.
In Civ IV, there is terrain, and there are terrain features. Terrain is Grassland, Plains, Tundra, Ice (actually 'Snow' within some code), Desert, and all of those again with Hills added in. Terrain features include Jungle, Forest, Oasis, Fallout, Floodplains, New Forest, and Ancient Forest.
There seem to be three ways to add defensive bonuses to a unit (via promotions or within the unit definition itself). There are separately defined elements, two of which exist at the moment ("iCityDefense", "iHillsDefense"). There are iTerrainDefense values, which can be set for any of the terrain types. And there are iFeatureDefense values that can be set for any of the terrain features.
After discovering this, I realised the source of the above problems.
Defensive Traits (Shield of Faith, Defensive, Rage) and the Doviello tundra bonus are all dependant upon iTerrainDefense. These bonuses are nullified if the terrain has any features at all, like forest or oasis.
Woodsman and the elven 10% are based on iFeatureDefense. Forest and the like are features, so this is apparently picked up automatically by the code.
And what's up with Guerilla? Well, that is where the separately defined element iHillsDefense comes in. This seems to by-pass any conflict with terrain features, and is successfully activated for any hill-top defense.
My Suggestions
==============
I consider the following to be the goal of FfH2's design team:
- all terrain and terrain feature bonuses will be applied in attacking and on defense
- defensive bonuses will be applied only on defense
My knowledge of the code is very limited at this point, but I think the following is a possible solution to reach the stated goal:
1) Create more separately defined elements, one for each base terrain (grassland, plains, etc.). In CIV4UnitSchema.xml is the element <element type="iHillsDefense"/>. Is it a simple matter to create more? These elements would be used for defensive values only.
Unfortunately, I'm feeling this would involve an SDK change.
2) Make iTerrainDefense applicable to the attacker as well as the defender, as has been done with iFeatureDefense.
3) Switch Guerilla from the hard-coded value to a iTerrainDefense value.
4) Change defensive traits from using iTerrainDefense to the new separately defined elements.
I'm kind of taking a shot in the dark with this, but hopefully it helps you to some degree.
- Niilo