[SDK] function understanding -> what does it do?

keldath

LivE LonG AnD PrOsPeR
Joined
Dec 20, 2005
Messages
7,373
Location
israel
hey all,

i have a probably simple question .
i wish to verify the bold part below -> does it mean that the damage made by a unit,

if (pPlot->getPlotCity() != NULL)
{
iDamage *= 100;
iDamage /= std::max(0, (pPlot->getPlotCity()->getBuildingDefense() + 100));
}


is reduced depending on the building defense rate?
id like the % of a city defense to reduce the damage output from a ranged attack.
is this whats implemented here?

.
Code:
int CvUnit::rangeCombatDamage(const CvUnit* pDefender) const
{
    CvPlot* pPlot = pDefender->plot();

    //int iOurStrength = airCurrCombatStr(pDefender);
    //keldath change - vincentz ranged attack - i hope it right
    int iOurStrength = currCombatStr(pPlot,pDefender);
    FAssertMsg(iOurStrength > 0, "Combat strength is expected to be greater than zero");
    int iTheirStrength = pDefender->maxCombatStr(pPlot, this);

    int iStrengthFactor = ((iOurStrength + iTheirStrength + 1) / 2);

    int iDamage = std::max(1, ((GC.getDefineINT("RANGE_COMBAT_DAMAGE") * (iOurStrength + iStrengthFactor)) / (iTheirStrength + iStrengthFactor)));
    //Vincentz RANGED STRIKE Random Damage Start
    //keldath notes - i guess ths controls random damage with added city defense if any
  
    if (pPlot->getPlotCity() != NULL)
    {
        iDamage *= 100;
        iDamage /= std::max(0, (pPlot->getPlotCity()->getBuildingDefense() + 100));
    }
    iDamage *= (50 + GC.getGame().getSorenRandNum(100, "RandomHit"));
    iDamage /= 100;
    //Vincentz RANGED STRIKE Random Damage End
    return iDamage;
}

thanks in advance
 
Top Bottom