CvPlayer::calculateMilitaryMight() const
- Defined in
- CvPlayer.cpp, line 17006
- Class
- CvPlayer
- Hook name
CivHooks::CvPlayer_calculateMilitaryMight
Hooks
static bool BeforeCvPlayer_calculateMilitaryMight(const CvPlayer* self, int& result);static void AfterCvPlayer_calculateMilitaryMight(const CvPlayer* self, int& result);static int ReplaceCvPlayer_calculateMilitaryMight(int (*original)(const CvPlayer*), const CvPlayer* self);CivRegisterBefore<CivHooks::CvPlayer_calculateMilitaryMight>(host, &BeforeCvPlayer_calculateMilitaryMight);CivRegisterAfter<CivHooks::CvPlayer_calculateMilitaryMight>(host, &AfterCvPlayer_calculateMilitaryMight);CivRegisterReplace<CivHooks::CvPlayer_calculateMilitaryMight>(host, &ReplaceCvPlayer_calculateMilitaryMight);
Code
17006int CvPlayer::calculateMilitaryMight() const17007{17008 int rtnValue = 0;17009 const CvUnit* pLoopUnit;17010 int iLoop;1701117012 for(pLoopUnit = firstUnit(&iLoop); pLoopUnit != NULL; pLoopUnit = nextUnit(&iLoop))17013 {17014 // Current combat strength or bombard strength, whichever is higher17015 int iPower = pLoopUnit->GetPower();17016 if (pLoopUnit->getDomainType() == DOMAIN_SEA)17017 {17018 iPower /= 2;17019 }17020 rtnValue += iPower;17021 }1702217023 //Simplistic increase based on player's gold17024 //500 gold will increase might by 22%, 2000 by 45%, 8000 gold by 90%17025 float fGoldMultiplier = 1.0f + (sqrt((float)GetTreasury()->GetGold()) / 100.0f);17026 if(fGoldMultiplier > 2.0f) fGoldMultiplier = 2.0f;1702717028 rtnValue = (int)(rtnValue * fGoldMultiplier);1702917030 return rtnValue;17031}