Help with syntax to random air/ranged damage

vincentz

Programmer
Joined
Feb 4, 2009
Messages
3,614
Location
Denmark
Hey guys

I was thinking about making the damage done by airstrikes and ranged attacks (XML, not DCM) randomized, so its not the same amount done every time.

I looked at CVUnit.cpp and think I found the area that deals with damage, but how would the syntax look if the damage should be a random number between 0 and <iAirCombatLimit>
(or possible between RANGE_COMBAT_DAMAGE / AIR_COMBAT_DAMAGE)?

Spoiler :
Code:
int CvUnit::rangeCombatDamage(const CvUnit* pDefender) const
{
	CvPlot* pPlot;
	int iOurStrength;
	int iTheirStrength;
	int iStrengthFactor;
	int iDamage;

	pPlot = pDefender->plot();

	iOurStrength = airCurrCombatStr(pDefender);
	FAssertMsg(iOurStrength > 0, "Combat strength is expected to be greater than zero");
	iTheirStrength = pDefender->maxCombatStr(pPlot, this);

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

	iDamage = std::max(1, ((GC.getDefineINT("RANGE_COMBAT_DAMAGE") * (iOurStrength + iStrengthFactor)) / (iTheirStrength + iStrengthFactor)));

	return iDamage;
 
Top Bottom