CvTacticalAI::IsExpectedToDamageWithRangedAttack(UnitHandle, CvPlot *)
- Defined in
- CvTacticalAI.cpp, line 9694
- Class
- CvTacticalAI
- Hook name
CivHooks::CvTacticalAI_IsExpectedToDamageWithRangedAttack
Hooks
static bool BeforeCvTacticalAI_IsExpectedToDamageWithRangedAttack(CvTacticalAI* self, UnitHandle pAttacker, CvPlot* pTargetPlot, bool& result);static void AfterCvTacticalAI_IsExpectedToDamageWithRangedAttack(CvTacticalAI* self, UnitHandle pAttacker, CvPlot* pTargetPlot, bool& result);static bool ReplaceCvTacticalAI_IsExpectedToDamageWithRangedAttack(bool (*original)(CvTacticalAI*, UnitHandle, CvPlot*), CvTacticalAI* self, UnitHandle pAttacker, CvPlot* pTargetPlot);CivRegisterBefore<CivHooks::CvTacticalAI_IsExpectedToDamageWithRangedAttack>(host, &BeforeCvTacticalAI_IsExpectedToDamageWithRangedAttack);CivRegisterAfter<CivHooks::CvTacticalAI_IsExpectedToDamageWithRangedAttack>(host, &AfterCvTacticalAI_IsExpectedToDamageWithRangedAttack);CivRegisterReplace<CivHooks::CvTacticalAI_IsExpectedToDamageWithRangedAttack>(host, &ReplaceCvTacticalAI_IsExpectedToDamageWithRangedAttack);
Code
9694bool CvTacticalAI::IsExpectedToDamageWithRangedAttack(UnitHandle pAttacker, CvPlot* pTargetPlot)9695{9696 int iExpectedDamage = 0;96979698 if(pTargetPlot->isCity())9699 {9700 CvCity* pCity = pTargetPlot->getPlotCity();9701 iExpectedDamage = pAttacker->GetRangeCombatDamage(NULL, pCity, /*bIncludeRand*/ false);9702 }9703 else9704 {9705 UnitHandle pDefender = pTargetPlot->getBestDefender(NO_PLAYER, m_pPlayer->GetID());9706 if(pDefender)9707 {9708 iExpectedDamage = pAttacker->GetRangeCombatDamage(pDefender.pointer(), NULL, false);9709 }9710 }97119712 return iExpectedDamage > 0;9713}
Calls
- CvPlayer::GetID() const
- CvPlot::getBestDefender(PlayerTypes, PlayerTypes, const CvUnit *, bool, bool, bool, bool)
- CvPlot::getPlotCity() const
- CvPlot::isCity() const
- CvUnit::GetRangeCombatDamage(const CvUnit *, CvCity *, bool, int) const
FObjectHandle::operator boolFObjectHandle::operator->FObjectHandle::pointer