CvUnit::canNukeAt(const CvPlot *, int, int) const
- Defined in
- CvUnit.cpp, line 6463
- Class
- CvUnit
- Hook name
CivHooks::CvUnit_canNukeAt
Hooks
static bool BeforeCvUnit_canNukeAt(const CvUnit* self, const CvPlot* pPlot, int iX, int iY, bool& result);static void AfterCvUnit_canNukeAt(const CvUnit* self, const CvPlot* pPlot, int iX, int iY, bool& result);static bool ReplaceCvUnit_canNukeAt(bool (*original)(const CvUnit*, const CvPlot*, int, int), const CvUnit* self, const CvPlot* pPlot, int iX, int iY);CivRegisterBefore<CivHooks::CvUnit_canNukeAt>(host, &BeforeCvUnit_canNukeAt);CivRegisterAfter<CivHooks::CvUnit_canNukeAt>(host, &AfterCvUnit_canNukeAt);CivRegisterReplace<CivHooks::CvUnit_canNukeAt>(host, &ReplaceCvUnit_canNukeAt);
Code
6463bool CvUnit::canNukeAt(const CvPlot* pPlot, int iX, int iY) const6464{6465 VALIDATE_OBJECT64666467 if(!canNuke(pPlot))6468 {6469 return false;6470 }64716472 int iDistance = plotDistance(pPlot->getX(), pPlot->getY(), iX, iY);64736474 if(iDistance <= 0)6475 return false; // Don't let the user nuke the same plot they are on.64766477 int iRange = GetRange();6478 if(iRange > 0 && iDistance > iRange) // Range 0 can hit anywhere6479 {6480 return false;6481 }64826483 for(int iI = 0; iI < MAX_TEAMS; iI++)6484 {6485 if(GET_TEAM((TeamTypes)iI).isAlive())6486 {6487 CvPlot* pTargetPlot = GC.getMap().plot(iX, iY);6488 if(pTargetPlot)6489 {6490 TeamTypes eTheirTeam = (TeamTypes)iI;6491 if(isNukeVictim(pTargetPlot, eTheirTeam))6492 {6493 CvTeam& myTeam = GET_TEAM(getTeam());6494#if defined(MOD_EVENTS_WAR_AND_PEACE)6495 if(!myTeam.isAtWar(eTheirTeam) && !myTeam.canDeclareWar(eTheirTeam, getOwner()))6496#else6497 if(!myTeam.isAtWar(eTheirTeam) && !myTeam.canDeclareWar(eTheirTeam))6498#endif6499 {6500 return false;6501 }6502 }6503 }6504 }6505 }65066507 return true;6508}
Calls
- CvGlobals::getMap()
- CvMap::plot(int, int) const
- CvPlot::getX() const
- CvPlot::getY() const
- CvTeam::canDeclareWar(TeamTypes, PlayerTypes) const
- CvTeam::getTeam(TeamTypes)
- CvTeam::isAlive() const
- CvTeam::isAtWar(TeamTypes) const
- CvUnit::canNuke(const CvPlot *) const
- CvUnit::getOwner() const
- CvUnit::GetRange() const
- CvUnit::getTeam() const
- CvUnit::isNukeVictim(const CvPlot *, TeamTypes) const
- plotDistance(int, int, int, int)