Advertisement
Guest User

Untitled

a guest
Nov 19th, 2015
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.10 KB | None | 0 0
  1. int CvCity::getStrengthValue(bool bForRangeStrike) const
  2. {
  3. VALIDATE_OBJECT
  4. // Strike strikes are weaker
  5. if(bForRangeStrike)
  6. {
  7. int iValue = m_iStrengthValue;
  8.  
  9. iValue -= m_pCityBuildings->GetBuildingDefense();
  10.  
  11. CvAssertMsg(iValue > 0, "City strength should always be greater than zero. Please show Jon this and send your last 5 autosaves.");
  12.  
  13. iValue *= /*40*/ GC.getCITY_RANGED_ATTACK_STRENGTH_MULTIPLIER();
  14. iValue /= 100;
  15.  
  16. if(GetGarrisonedUnit())
  17. {
  18. iValue *= (100 + GET_PLAYER(m_eOwner).GetGarrisonedCityRangeStrikeModifier());
  19. iValue /= 100;
  20. }
  21.  
  22. // Religion city strike mod
  23. int iReligionCityStrikeMod = 0;
  24. ReligionTypes eMajority = GetCityReligions()->GetReligiousMajority();
  25. if(eMajority != NO_RELIGION)
  26. {
  27. const CvReligion* pReligion = GC.getGame().GetGameReligions()->GetReligion(eMajority, getOwner());
  28. if(pReligion)
  29. {
  30. iReligionCityStrikeMod = pReligion->m_Beliefs.GetCityRangeStrikeModifier();
  31. BeliefTypes eSecondaryPantheon = GetCityReligions()->GetSecondaryReligionPantheonBelief();
  32. if (eSecondaryPantheon != NO_BELIEF)
  33. {
  34. iReligionCityStrikeMod += GC.GetGameBeliefs()->GetEntry(eSecondaryPantheon)->GetCityRangeStrikeModifier();
  35. }
  36. if(iReligionCityStrikeMod > 0)
  37. {
  38. iValue *= (100 + iReligionCityStrikeMod);
  39. iValue /= 100;
  40. }
  41. }
  42. }
  43.  
  44. return iValue;
  45. }
  46.  
  47. return m_iStrengthValue;
  48. }
  49.  
  50.  
  51. int CvCity::GetPower() const
  52. {
  53. VALIDATE_OBJECT
  54. return int(pow((double) getStrengthValue() / 100, 1.5)); // This is the same math used to calculate Unit Power in CvUnitEntry
  55. }
  56.  
  57.  
  58. void CvCity::updateStrengthValue()
  59. {
  60. VALIDATE_OBJECT
  61. AI_PERF_FORMAT("City-AI-perf.csv", ("CvCity::updateStrengthValue, Turn %03d, %s, %s", GC.getGame().getElapsedGameTurns(), GetPlayer()->getCivilizationShortDescription(), getName().c_str()) );
  62. // Default Strength
  63. int iStrengthValue = /*600*/ GC.getCITY_STRENGTH_DEFAULT();
  64.  
  65. // Population mod
  66. iStrengthValue += getPopulation() * /*25*/ GC.getCITY_STRENGTH_POPULATION_CHANGE();
  67.  
  68. // Building Defense
  69. int iBuildingDefense = m_pCityBuildings->GetBuildingDefense();
  70.  
  71. iBuildingDefense *= (100 + m_pCityBuildings->GetBuildingDefenseMod());
  72. iBuildingDefense /= 100;
  73.  
  74. iStrengthValue += iBuildingDefense;
  75.  
  76. // Garrisoned Unit
  77. CvUnit* pGarrisonedUnit = GetGarrisonedUnit();
  78. int iStrengthFromUnits = 0;
  79. if(pGarrisonedUnit)
  80. {
  81. int iMaxHits = GC.getMAX_HIT_POINTS();
  82. iStrengthFromUnits = pGarrisonedUnit->GetBaseCombatStrength() * 100 * (iMaxHits - pGarrisonedUnit->getDamage()) / iMaxHits;
  83. }
  84.  
  85. iStrengthValue += ((iStrengthFromUnits * 100) / /*300*/ GC.getCITY_STRENGTH_UNIT_DIVISOR());
  86.  
  87. // Tech Progress increases City Strength
  88. int iTechProgress = GET_TEAM(getTeam()).GetTeamTechs()->GetNumTechsKnown() * 100 / GC.getNumTechInfos();
  89.  
  90. // Want progress to be a value between 0 and 5
  91. double fTechProgress = iTechProgress / 100.0 * /*5*/ GC.getCITY_STRENGTH_TECH_BASE();
  92. double fTechExponent = /*2.0f*/ GC.getCITY_STRENGTH_TECH_EXPONENT();
  93. int iTechMultiplier = /*2*/ GC.getCITY_STRENGTH_TECH_MULTIPLIER();
  94.  
  95. // The way all of this adds up...
  96. // 25% of the way through the game provides an extra 3.12
  97. // 50% of the way through the game provides an extra 12.50
  98. // 75% of the way through the game provides an extra 28.12
  99. // 100% of the way through the game provides an extra 50.00
  100.  
  101. double fTechMod = pow(fTechProgress, fTechExponent);
  102. fTechMod *= iTechMultiplier;
  103.  
  104. fTechMod *= 100; // Bring it back into hundreds
  105. 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
  106.  
  107. int iStrengthMod = 0;
  108.  
  109. // Player-wide strength mod (Policies, etc.)
  110. iStrengthMod += GET_PLAYER(getOwner()).GetCityStrengthMod();
  111.  
  112. // Apply Mod
  113. iStrengthValue *= (100 + iStrengthMod);
  114. iStrengthValue /= 100;
  115.  
  116. m_iStrengthValue = iStrengthValue;
  117.  
  118. // Terrain mod
  119. if(plot()->isHills())
  120. {
  121. m_iStrengthValue += /*3*/ GC.getCITY_STRENGTH_HILL_CHANGE();
  122. }
  123.  
  124. DLLUI->setDirty(CityInfo_DIRTY_BIT, true);
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement