CvUnit::GetPower() const
- Defined in
- CvUnit.cpp, line 5587
- Class
- CvUnit
- Hook name
CivHooks::CvUnit_GetPower
Hooks
static bool BeforeCvUnit_GetPower(const CvUnit* self, int& result);static void AfterCvUnit_GetPower(const CvUnit* self, int& result);static int ReplaceCvUnit_GetPower(int (*original)(const CvUnit*), const CvUnit* self);CivRegisterBefore<CivHooks::CvUnit_GetPower>(host, &BeforeCvUnit_GetPower);CivRegisterAfter<CivHooks::CvUnit_GetPower>(host, &AfterCvUnit_GetPower);CivRegisterReplace<CivHooks::CvUnit_GetPower>(host, &ReplaceCvUnit_GetPower);
Code
5586/// Current power of unit (raw unit type power adjusted for health)5587int CvUnit::GetPower() const5588{5589 VALIDATE_OBJECT5590 int iPower = getUnitInfo().GetPower();55915592#if defined(MOD_BUGFIX_UNIT_POWER_CALC)5593 if (getUnitInfo().GetCombat() > 0) {5594 iPower = iPower * GetBaseCombatStrength() / getUnitInfo().GetCombat();5595 }5596#endif5597#if defined(MOD_API_EXTENSIONS) && defined(MOD_BUGFIX_UNIT_POWER_CALC)5598 if (getUnitInfo().GetRangedCombat() > 0) {5599 iPower = iPower * GetBaseRangedCombatStrength() / getUnitInfo().GetRangedCombat();5600 }5601#endif5602 5603 //Take promotions into account: unit with 4 promotions worth ~50% more5604 int iPowerMod = getLevel() * 125;5605 iPower = (iPower * (1000 + iPowerMod)) / 1000;5606 iPower *= GetCurrHitPoints();5607 iPower /= GetMaxHitPoints();5608 return iPower;5609}
Calls
Called by
- CvAIOperationDestroyBarbarianCamp::ShouldAbort()
- CvArmyAI::GetTotalPower()
- CvDiplomacyAI::DoUpdateWarStates()
- CvMilitaryAI::FindBestAttackTarget(AIOperationTypes, PlayerTypes, int *)
- CvMilitaryAI::FindBestUnitToScrap(bool, bool, int &)
- CvMinorCivAI::CalculateBullyMetric(PlayerTypes, bool, CvString *)
- CvPlayer::calculateMilitaryMight() const
- CvPlot::verifyUnitValidPlot()
- CvTacticalAI::ExecuteBarbarianCivilianEscortMove()
- CvTacticalAI::ScoreAssignments(bool)