CvUnit::IsNearEnemyCitadel(int &)
- Defined in
- CvUnit.cpp, line 18555
- Class
- CvUnit
- Hook name
CivHooks::CvUnit_IsNearEnemyCitadel
Hooks
static bool BeforeCvUnit_IsNearEnemyCitadel(CvUnit* self, int& iCitadelDamage, bool& result);static void AfterCvUnit_IsNearEnemyCitadel(CvUnit* self, int& iCitadelDamage, bool& result);static bool ReplaceCvUnit_IsNearEnemyCitadel(bool (*original)(CvUnit*, int&), CvUnit* self, int& iCitadelDamage);CivRegisterBefore<CivHooks::CvUnit_IsNearEnemyCitadel>(host, &BeforeCvUnit_IsNearEnemyCitadel);CivRegisterAfter<CivHooks::CvUnit_IsNearEnemyCitadel>(host, &AfterCvUnit_IsNearEnemyCitadel);CivRegisterReplace<CivHooks::CvUnit_IsNearEnemyCitadel>(host, &ReplaceCvUnit_IsNearEnemyCitadel);
Code
18554// Citadel18555bool CvUnit::IsNearEnemyCitadel(int& iCitadelDamage)18556{18557 VALIDATE_OBJECT1855818559 int iCitadelRange = 1;1856018561 CvPlot* pLoopPlot;1856218563 ImprovementTypes eImprovement;18564 int iDamage;1856518566 // Look around this Unit to see if there's an adjacent Citadel18567 for(int iX = -iCitadelRange; iX <= iCitadelRange; iX++)18568 {18569 for(int iY = -iCitadelRange; iY <= iCitadelRange; iY++)18570 {18571 pLoopPlot = plotXYWithRangeCheck(getX(), getY(), iX, iY, iCitadelRange);1857218573 if(pLoopPlot != NULL)18574 {18575 eImprovement = pLoopPlot->getImprovementType();1857618577 // Citadel here?18578 if(eImprovement != NO_IMPROVEMENT && !pLoopPlot->IsImprovementPillaged())18579 {18580 iDamage = GC.getImprovementInfo(eImprovement)->GetNearbyEnemyDamage();18581 if(iDamage != 0)18582 {18583 if(pLoopPlot->getOwner() != NO_PLAYER)18584 {18585 if(GET_TEAM(getTeam()).isAtWar(pLoopPlot->getTeam()))18586 {18587 iCitadelDamage = iDamage;18588 return true;18589 }18590 }18591 }18592 }18593 }18594 }18595 }1859618597 return false;18598}
Calls
- CvGlobals::getImprovementInfo(ImprovementTypes)
- CvImprovementEntry::GetNearbyEnemyDamage() const
- CvPlot::getImprovementType() const
- CvPlot::getOwner() const
- CvPlot::getTeam() const
- CvPlot::IsImprovementPillaged() const
- CvTeam::getTeam(TeamTypes)
- CvTeam::isAtWar(TeamTypes) const
- CvUnit::getTeam() const
- CvUnit::getX() const
- CvUnit::getY() const
- plotXYWithRangeCheck(int, int, int, int, int)