CvUnit::GetUnhappinessCombatPenalty() const
- Defined in
- CvUnit.cpp, line 12090
- Class
- CvUnit
- Hook name
CivHooks::CvUnit_GetUnhappinessCombatPenalty
Hooks
static bool BeforeCvUnit_GetUnhappinessCombatPenalty(const CvUnit* self, int& result);static void AfterCvUnit_GetUnhappinessCombatPenalty(const CvUnit* self, int& result);static int ReplaceCvUnit_GetUnhappinessCombatPenalty(int (*original)(const CvUnit*), const CvUnit* self);CivRegisterBefore<CivHooks::CvUnit_GetUnhappinessCombatPenalty>(host, &BeforeCvUnit_GetUnhappinessCombatPenalty);CivRegisterAfter<CivHooks::CvUnit_GetUnhappinessCombatPenalty>(host, &AfterCvUnit_GetUnhappinessCombatPenalty);CivRegisterReplace<CivHooks::CvUnit_GetUnhappinessCombatPenalty>(host, &ReplaceCvUnit_GetUnhappinessCombatPenalty);
Code
12089/// Unhappy?12090int CvUnit::GetUnhappinessCombatPenalty() const12091{12092 CvPlayer &kPlayer = GET_PLAYER(getOwner());12093 int iPenalty = 0;1209412095#if defined(MOD_GLOBAL_CS_RAZE_RARELY)12096 if((!kPlayer.isMinorCiv() && kPlayer.IsEmpireUnhappy()) || (kPlayer.isMinorCiv() && kPlayer.IsEmpireVeryUnhappy()))12097#else12098 if(kPlayer.IsEmpireUnhappy())12099#endif12100 {12101 iPenalty = (-1 * kPlayer.GetExcessHappiness()) * GC.getVERY_UNHAPPY_COMBAT_PENALTY_PER_UNHAPPY();12102 iPenalty = max(iPenalty, GC.getVERY_UNHAPPY_MAX_COMBAT_PENALTY());12103 }1210412105 return iPenalty;12106}
Calls
- CvGlobals::getVERY_UNHAPPY_COMBAT_PENALTY_PER_UNHAPPY()
- CvGlobals::getVERY_UNHAPPY_MAX_COMBAT_PENALTY()
- CvPlayer::GetExcessHappiness() const
- CvPlayer::IsEmpireUnhappy() const
- CvPlayer::IsEmpireVeryUnhappy() const
- CvPlayer::isMinorCiv() const
- CvPlayerAI::getPlayer(PlayerTypes)
- CvUnit::getOwner() const
std::max