In the original comments of
int CvUnit::maxCombatStr(const CvPlot* pPlot, const CvUnit* pAttacker, CombatDetails* pCombatDetails) const we find the following:
// maxCombatStr can be called in four different configurations
// pPlot == NULL, pAttacker == NULL for combat when this is the attacker
// pPlot valid, pAttacker valid for combat when this is the defender
// pPlot valid, pAttacker == NULL (new case), when this is the defender, attacker unknown
// pPlot valid, pAttacker == this (new case), when the defender is unknown, but we want to calc approx str
I have to admit that the "unknown attacker/defender" cases are completely confusing me.
Can anybody think of any combination in which either the attacker or the defender in a battle would be unknown?
This question I asked in posting 24.
Meanwhile I think I've got an idea of Firaxis' intention.
Thinking about what had to be calculated for which combination when preparing combat, I realized that we likely have quite some different cases to handle.
First, we have to take into consideration that we will have a unit (in this context, I will use the term "unit" even for unit/profession/promotion combinations). This unit may be either the attacker or the defender.
Say, our unit would be a Spanish Veteran as Musketman with Ranger1(please keep this in mind for the later explanations).
Now, when we want to find out our strongest unit in a general case, we calculate base strength (as by unit or unit/profession), which results in
3.3.
If we want to find out the strongest unit for an attack against a plot with a forest, we have to take the Ranger1 promotion into account, too (20% for attack on forests). The strengths now is
3.9.
And finally, we have the real combat situation, where a Brave is located on that plot with the forest. Then we have to add the combat strength against natives to the Veteran, too (20% due to the Spanish trait). The strength now is
4.5.
The same principles are valid in case of a defender, too.
So, we have six cases to be checked:
A = Attacker
P = Plot
D = Defender
A-- (general strength of the attacker; no real combat situation)
AP- (strength of the attacker, considering a certain plot; no real combat situation)
APD (strength of the attacker in a defined combat situation; real combat situation, all necessary information is given)
D-- (general strength of the defender; no real combat situation)
DP- (strength of the defender on his plot; no real combat situation)
DPA (strength of the defender in a defined combat situation; real combat situation, all necessary information is given)
So, we will have six different cases for which our new
maxCombatStr(...) function has to be prepared.
For this, we will need three different parameters
pAttacker,
pDefender (new) and
pPlot.
By combining these three parameters we will be able to identify any of the aforementioned six different cases.
Now I only have to find a way to bring this into readable and streamlined code...
Edit:
One might argue that case 4 (D--) doesn't make too much sense, as a defender will always and inevitably being located on a plot...