Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int CvCity::getStrengthValue(bool bForRangeStrike) const
- {
- VALIDATE_OBJECT
- // Strike strikes are weaker
- if(bForRangeStrike)
- {
- int iValue = m_iStrengthValue;
- iValue -= m_pCityBuildings->GetBuildingDefense();
- CvAssertMsg(iValue > 0, "City strength should always be greater than zero. Please show Jon this and send your last 5 autosaves.");
- iValue *= /*40*/ GC.getCITY_RANGED_ATTACK_STRENGTH_MULTIPLIER();
- iValue /= 100;
- if(GetGarrisonedUnit())
- {
- iValue *= (100 + GET_PLAYER(m_eOwner).GetGarrisonedCityRangeStrikeModifier());
- iValue /= 100;
- }
- // Religion city strike mod
- int iReligionCityStrikeMod = 0;
- ReligionTypes eMajority = GetCityReligions()->GetReligiousMajority();
- if(eMajority != NO_RELIGION)
- {
- const CvReligion* pReligion = GC.getGame().GetGameReligions()->GetReligion(eMajority, getOwner());
- if(pReligion)
- {
- iReligionCityStrikeMod = pReligion->m_Beliefs.GetCityRangeStrikeModifier();
- BeliefTypes eSecondaryPantheon = GetCityReligions()->GetSecondaryReligionPantheonBelief();
- if (eSecondaryPantheon != NO_BELIEF)
- {
- iReligionCityStrikeMod += GC.GetGameBeliefs()->GetEntry(eSecondaryPantheon)->GetCityRangeStrikeModifier();
- }
- if(iReligionCityStrikeMod > 0)
- {
- iValue *= (100 + iReligionCityStrikeMod);
- iValue /= 100;
- }
- }
- }
- return iValue;
- }
- return m_iStrengthValue;
- }
- int CvCity::GetPower() const
- {
- VALIDATE_OBJECT
- return int(pow((double) getStrengthValue() / 100, 1.5)); // This is the same math used to calculate Unit Power in CvUnitEntry
- }
- void CvCity::updateStrengthValue()
- {
- VALIDATE_OBJECT
- AI_PERF_FORMAT("City-AI-perf.csv", ("CvCity::updateStrengthValue, Turn %03d, %s, %s", GC.getGame().getElapsedGameTurns(), GetPlayer()->getCivilizationShortDescription(), getName().c_str()) );
- // Default Strength
- int iStrengthValue = /*600*/ GC.getCITY_STRENGTH_DEFAULT();
- // Population mod
- iStrengthValue += getPopulation() * /*25*/ GC.getCITY_STRENGTH_POPULATION_CHANGE();
- // Building Defense
- int iBuildingDefense = m_pCityBuildings->GetBuildingDefense();
- iBuildingDefense *= (100 + m_pCityBuildings->GetBuildingDefenseMod());
- iBuildingDefense /= 100;
- iStrengthValue += iBuildingDefense;
- // Garrisoned Unit
- CvUnit* pGarrisonedUnit = GetGarrisonedUnit();
- int iStrengthFromUnits = 0;
- if(pGarrisonedUnit)
- {
- int iMaxHits = GC.getMAX_HIT_POINTS();
- iStrengthFromUnits = pGarrisonedUnit->GetBaseCombatStrength() * 100 * (iMaxHits - pGarrisonedUnit->getDamage()) / iMaxHits;
- }
- iStrengthValue += ((iStrengthFromUnits * 100) / /*300*/ GC.getCITY_STRENGTH_UNIT_DIVISOR());
- // Tech Progress increases City Strength
- int iTechProgress = GET_TEAM(getTeam()).GetTeamTechs()->GetNumTechsKnown() * 100 / GC.getNumTechInfos();
- // Want progress to be a value between 0 and 5
- double fTechProgress = iTechProgress / 100.0 * /*5*/ GC.getCITY_STRENGTH_TECH_BASE();
- double fTechExponent = /*2.0f*/ GC.getCITY_STRENGTH_TECH_EXPONENT();
- int iTechMultiplier = /*2*/ GC.getCITY_STRENGTH_TECH_MULTIPLIER();
- // The way all of this adds up...
- // 25% of the way through the game provides an extra 3.12
- // 50% of the way through the game provides an extra 12.50
- // 75% of the way through the game provides an extra 28.12
- // 100% of the way through the game provides an extra 50.00
- double fTechMod = pow(fTechProgress, fTechExponent);
- fTechMod *= iTechMultiplier;
- fTechMod *= 100; // Bring it back into hundreds
- iStrengthValue += (int)(fTechMod + 0.005); // Adding a small amount to prevent small fp accuracy differences from generating a different integer result on the Mac and PC. Assuming fTechMod is positive, round to nearest hundredth
- int iStrengthMod = 0;
- // Player-wide strength mod (Policies, etc.)
- iStrengthMod += GET_PLAYER(getOwner()).GetCityStrengthMod();
- // Apply Mod
- iStrengthValue *= (100 + iStrengthMod);
- iStrengthValue /= 100;
- m_iStrengthValue = iStrengthValue;
- // Terrain mod
- if(plot()->isHills())
- {
- m_iStrengthValue += /*3*/ GC.getCITY_STRENGTH_HILL_CHANGE();
- }
- DLLUI->setDirty(CityInfo_DIRTY_BIT, true);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement