CvUnit::updateCombat
...
iAttackerStrength = currCombatStr(NULL, NULL, &cdAttackerDetails, true, pDefender); // Smarter Orcs
iAttackerFirepower = currFirepower(NULL, NULL, true, pDefender); // Smarter Orcs
//FfH: Added by Kael 03/06/2007
int CvUnit::maxCombatStr(const CvPlot* pPlot, const CvUnit* pAttacker, CombatDetails* pCombatDetails) const
{
return maxCombatStr(pPlot, pAttacker, pCombatDetails, true, NULL);//Smarter Orcs
}
//FfH: End Add
//FfH: Modified by Kael 12/22/2006
//int CvUnit::maxCombatStr(const CvPlot* pPlot, const CvUnit* pAttacker, CombatDetails* pCombatDetails) const
// BetterAI start
// 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
// note, in this last case, it is expected pCombatDetails == NULL, it does not have to be, but some
// values may be unexpectedly reversed in this case (iModifierTotal will be the negative sum)
// BetterAI end
//Smarter Orcs start
// In: pDefender - the defending unit.
int CvUnit::maxCombatStr(const CvPlot* pPlot, const CvUnit* pAttacker, CombatDetails* pCombatDetails, bool bAttacking, const CvUnit* pDefender) const
// Smarter Orcs end
//FfH: End Modify
{
// CvCity* pCity; // BetterAI removal
int iModifier;
int iCombat;
FAssertMsg((pPlot == NULL) || (pPlot->getTerrainType() != NO_TERRAIN), "(pPlot == NULL) || (pPlot->getTerrainType() is not expected to be equal with NO_TERRAIN)");
FAssertMsg((pAttacker == NULL) || (pDefender == NULL),"Improper call!"); // Smarter Orcs
...
// Following replaces the resistance code:
// Smarter Orcs start
int iResistCold = 0;
int iResistDeath = 0;
int iResistFire = 0;
int iResistHoly = 0;
int iResistLightning = 0;
int iResistPoison = 0;
int iResistUnholy = 0;
const CvUnit *pOtherUnit;
if (pAttacker != NULL)
{
pOtherUnit = pAttacker;
}
else if (pDefender != NULL)
{
pOtherUnit = pDefender;
}
else
{
pOtherUnit = NULL;
}
if (pOtherUnit != NULL)
{
iResistCold = pOtherUnit->getResistCold();
iResistDeath = pOtherUnit->getResistDeath();
iResistFire = pOtherUnit->getResistFire();
iResistHoly = pOtherUnit->getResistHoly();
iResistLightning = pOtherUnit->getResistLightning();
iResistPoison = pOtherUnit->getResistPoison();
iResistUnholy = pOtherUnit->getResistUnholy();
}
if (getCombatCold() != 0)
{
iCombat += getCombatCold() * (100 - iResistCold);
}
if (getCombatDeath() != 0)
{
iCombat += getCombatDeath() * (100 - iResistDeath);
}
if (getCombatFire() != 0)
{
iCombat += getCombatFire() * (100 - iResistFire);
}
if (getCombatHoly() != 0)
{
iCombat += getCombatHoly() * (100 - iResistHoly);
}
if (getCombatLightning() != 0)
{
iCombat += getCombatLightning() * (100 - iResistLightning);
}
if (getCombatPoison() != 0)
{
iCombat += getCombatPoison() * (100 - iResistPoison);
}
if (getCombatUnholy() != 0)
{
iCombat += getCombatUnholy() * (100 - iResistUnholy);
}
// Smarter Orcs end
//FfH: Added by Kael 03/06/2007
int CvUnit::currCombatStr(const CvPlot* pPlot, const CvUnit* pAttacker, CombatDetails* pCombatDetails) const
{
return currCombatStr(pPlot, pAttacker, pCombatDetails, true, NULL); // Smarter Orcs
}
//FfH: End Add
//FfH: Modified by Kael 12/22/2006
//int CvUnit::currCombatStr(const CvPlot* pPlot, const CvUnit* pAttacker, CombatDetails* pCombatDetails) const
//{
// return ((maxCombatStr(pPlot, pAttacker, pCombatDetails) * currHitPoints()) / maxHitPoints());
//}
// Smarter Orcs start
int CvUnit::currCombatStr(const CvPlot* pPlot, const CvUnit* pAttacker, CombatDetails* pCombatDetails, bool bAttacking, const CvUnit* pDefender) const
{
return ((maxCombatStr(pPlot, pAttacker, pCombatDetails, bAttacking, pDefender) * currHitPoints()) / maxHitPoints());
// Smarter Orcs end
}
//FfH: End Modify
//FfH: Added by Kael 03/06/2007
int CvUnit::currFirepower(const CvPlot* pPlot, const CvUnit* pAttacker) const
{
return currFirepower(pPlot, pAttacker, true, NULL); // Smarter Orcs
}
//FfH: End Add
//FfH: Modified by Kael 12/22/2006
//int CvUnit::currFirepower(const CvPlot* pPlot, const CvUnit* pAttacker) const
//{
// return ((maxCombatStr(pPlot, pAttacker) + currCombatStr(pPlot, pAttacker) + 1) / 2);
// Smarter Orcs start
int CvUnit::currFirepower(const CvPlot* pPlot, const CvUnit* pAttacker, bool bAttacking, const CvUnit* pDefender) const
{
return ((maxCombatStr(pPlot, pAttacker, NULL, bAttacking, pDefender) + currCombatStr(pPlot, pAttacker, NULL, bAttacking, pDefender) + 1) / 2);
// Smarter Orcs end
//FfH: End Modify
}
//BetterAI start
// this nomalizes str by firepower, useful for quick odds calcs
// the effect is that a damaged unit will have an effective str lowered by firepower/maxFirepower
// doing the algebra, this means we mulitply by 1/2(1 + currHP)/maxHP = (maxHP + currHP) / (2 * maxHP)
int CvUnit::currEffectiveStr(const CvPlot* pPlot, const CvUnit* pAttacker, CombatDetails* pCombatDetails) const
{
return currEffectiveStr(pPlot, pAttacker, pCombatDetails, true);
}
//Smarter Orcs start
int CvUnit::currEffectiveStr(const CvPlot* pPlot, const CvUnit* pAttacker, CombatDetails* pCombatDetails, bool bAttacking, const CvUnit* pDefender) const // Smarter Orcs
{
int currStr = currCombatStr(pPlot, pAttacker, pCombatDetails, bAttacking, pDefender); // Smarter Orcs
currStr *= (maxHitPoints() + currHitPoints());
currStr /= (2 * maxHitPoints());
return currStr;
}
//Smarter Orcs end
//BetterAI end
//FfH: Added by Kael 03/06/2007
float CvUnit::maxCombatStrFloat(const CvPlot* pPlot, const CvUnit* pAttacker) const
{
return maxCombatStrFloat(pPlot, pAttacker, true, NULL);// Smarter Orcs
}
//FfH: End Add
//FfH: Modified by Kael 12/22/2006
//float CvUnit::maxCombatStrFloat(const CvPlot* pPlot, const CvUnit* pAttacker) const
//{
// return (((float)(maxCombatStr(pPlot, pAttacker))) / 100.0f);
//Smarter Orcs start
float CvUnit::maxCombatStrFloat(const CvPlot* pPlot, const CvUnit* pAttacker, bool bAttacking, const CvUnit* pDefender) const
{
return (((float)(maxCombatStr(pPlot, pAttacker, NULL, bAttacking, pDefender))) / 100.0f);
// Smarter Orcs end
//FfH: End Modify
}
//FfH: Added by Kael 03/06/2007
float CvUnit::currCombatStrFloat(const CvPlot* pPlot, const CvUnit* pAttacker) const
{
return currCombatStrFloat(pPlot, pAttacker, true, NULL);//Smarter Orcs
}
//FfH: End Add
//FfH: Modified by Kael 12/22/2006
//float CvUnit::currCombatStrFloat(const CvPlot* pPlot, const CvUnit* pAttacker) const
//{
// return (((float)(currCombatStr(pPlot, pAttacker))) / 100.0f);
//Smarter Orcs start
float CvUnit::currCombatStrFloat(const CvPlot* pPlot, const CvUnit* pAttacker, bool bAttacking, const CvUnit* pDefender) const
{
return (((float)(currCombatStr(pPlot, pAttacker, NULL, bAttacking, pDefender))) / 100.0f);
// Smarter Orcs end
//FfH: End Modify
}
...
bool CvGameTextMgr::setCombatPlotHelp(CvWString &szString, CvPlot* pPlot)
{
...
szOffenseOdds.Format(L"%.2f", ((pAttacker->getDomainType() == DOMAIN_AIR) ? pAttacker->airCurrCombatStrFloat() : pAttacker->currCombatStrFloat(NULL, NULL, true, pDefender))); // Smarter Orcs
...
int CvUnitAI::AI_attackOdds(const CvPlot* pPlot, bool bPotentialEnemy) const
{
...
iOurStrength = ((getDomainType() == DOMAIN_AIR) ? airCurrCombatStr() : currCombatStr(NULL, NULL, NULL, true, pDefender)); // Smarter Orcs
iOurFirepower = ((getDomainType() == DOMAIN_AIR) ? iOurStrength : currFirepower(NULL, NULL, true, pDefender)); // Smarter Orcs
...
int getCombatOdds(CvUnit* pAttacker, CvUnit* pDefender)
{
...
iAttackerStrength = pAttacker->currCombatStr(NULL, NULL, NULL, true, pDefender); // Smarter Orcs
iAttackerFirepower = pAttacker->currFirepower(NULL, NULL, true, pDefender); // Smarter Orcs
...
// CvUnit.h:
int currEffectiveStr(const CvPlot* pPlot, const CvUnit* pAttacker, CombatDetails* pCombatDetails = NULL, bool bAttacker = true, const CvUnit* pDefender = NULL) const; // BetterAI // Smarter Orcs
DllExport float maxCombatStrFloat(const CvPlot* pPlot, const CvUnit* pAttacker) const; // Exposed to Python
DllExport float currCombatStrFloat(const CvPlot* pPlot, const CvUnit* pAttacker) const; // Exposed to Python
//FfH: Added by Kael 12/22/2006
DllExport int maxCombatStr(const CvPlot* pPlot, const CvUnit* pAttacker, CombatDetails* pCombatDetails = NULL, bool bAttacking = true, const CvUnit* pDefender = NULL) const; // Smarter Orcs
DllExport int currCombatStr(const CvPlot* pPlot, const CvUnit* pAttacker, CombatDetails* pCombatDetails = NULL, bool bAttacking = true, const CvUnit* pDefender = NULL) const; // Smarter Orcs
DllExport int baseCombatStr(bool bAttacking = true) const;
DllExport int currFirepower(const CvPlot* pPlot, const CvUnit* pAttacker, bool bAttacking = true, const CvUnit* pDefender = NULL) const; // Smarter Orcs
DllExport float maxCombatStrFloat(const CvPlot* pPlot, const CvUnit* pAttacker, bool bAttacking = true, const CvUnit* pDefender = NULL) const; // Smarter Orcs
DllExport float currCombatStrFloat(const CvPlot* pPlot, const CvUnit* pAttacker, bool bAttacking = true, const CvUnit* pDefender = NULL) const; // Smarter Orcs
//FfH: End Add