Multiple improvements with NearbyEnemyDamage

PawelS

Ancient Druid
Joined
Dec 11, 2003
Messages
2,811
Location
Poland
I found something interesting in the source code: when a unit is next to two or more enemy improvements with NearbyEnemyDamage, it will get damage only from one of these improvements, and it's not guaranteed that it will be the one with the highest damage. The following function:
Code:
bool CvUnit::IsNearEnemyCitadel(int& iCitadelDamage)
checks all adjacent plots, but when it finds one with an improvement that has nonzero NearbyEnemyDamage, it just returns true, and the amount of damage as the iCitadelDamage parameter, which means that it doesn't check the remaining plots. I think it should check all adjacent plots, and find one with an improvement that belongs to the enemy and does the highest damage.

It's an example of mod-unfriendly coding - they did it in a way that works in the base game where there is only one such improvement, and didn't care about mods :(

Is this fixed in the VMC/CP DLLs?
 
VMC doesn't change this function - but it's an easy fix ... but should it cause the max damage or an average of the damage?
 
I think it should cause max damage. For example, if I make forts deal 10 damage to nearby units, a unit standing next to a citadel and a fort should get 30 damage. Otherwise building a fort near a citadel would be disadvantageous.
 
Top Bottom