About iFeatureDefense and iTerrainDefense

vorshlumpf

Emperor
Joined
Dec 5, 2003
Messages
1,096
Location
Victoria, BC, Canada
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
 
As for the New Forest problems, those are easily fixed. Here are the additions that need to be made, unless you have plans for New Forest that will make them unlike Forest entirely until the mature.

- Niilo

In CIV4PromotionInfos.xml
======================

To give elves a defensive bonus in new forest, PROMOTION_ELF needs:

Code:
	<FeatureDefense>
	  <FeatureType>FEATURE_FOREST_NEW</FeatureType>
	  <iFeatureDefense>10</iFeatureDefense>
	</FeatureDefense>

To give elves double movement in new forest, PROMOTION_ELF needs:

Code:
	<FeatureDoubleMove>
	  <FeatureType>FEATURE_FOREST_NEW</FeatureType>
	  <bFeatureDoubleMove>1</bFeatureDoubleMove>
	</FeatureDoubleMove>

To give Woodsman I and II a defensive bonus in new forest, PROMOTION_WOODSMAN1 and PROMOTION_WOODSMAN2 need (respectively):

Code:
	<FeatureDefense>
	  <FeatureType>FEATURE_FOREST_NEW</FeatureType>
	  <iFeatureDefense>40</iFeatureDefense>
	</FeatureDefense>

Code:
	<FeatureDefense>
	  <FeatureType>FEATURE_FOREST_NEW</FeatureType>
	  <iFeatureDefense>60</iFeatureDefense>
	</FeatureDefense>

To give Woodsman II double movement in new forest, PROMOTION_WOODSMAN2 needs:

Code:
	<FeatureDoubleMove>
	  <FeatureType>FEATURE_FOREST_NEW</FeatureType>
	  <bFeatureDoubleMove>1</bFeatureDoubleMove>
	</FeatureDoubleMove>
 
Thanks for your efforts.

I'll look into the code how the boni are applied there.
Hills do not count as feature so that the attacking bonus it is not applied does not surprise me.

About the general boni on defense/offense. We will inlcude a generic bonus for defense/offense in 0.15 that is terrain/feature independend.
P.S. Offensive Boni for terrain are not yet in.
 
About the new forest, i spent some time thinking about them before, and came to the conclusion that they should just be considered as adding no defense and no movement cost.
I mean, they're roughly the equivalent to a plantation, and giving them all the modifiers and such of grown forests seems like a lot of work for something that doesn't make sense.
 
By no double move, you mean for those with double movement in forests? That's good so long as there's no movement penalty so that units like Elven Scouts walk through it and keep moving. It was always strange to have my scouts double move through woods or grasslands, but be unable to navigate through these mysteriously slowing "new forests"
 
28. FeatureDefenceModifier's are applied on attacking and defending.

That was all that was added in 0.14, bonus and penalty based on the feature (not terrain). The problem with modifing the terrain is that will break the defensive skill. So before we put that in we need a base iDefense and iAttack promotion. So much to do. :)
 
Kael said:
So before we put that in we need a base iDefense and iAttack promotion. So much to do. :)
Ah, okay. I was wondering if you had something like this in the works.

- Niilo
 
Back
Top Bottom