Bazaar developer reference

CvUnit::canEverRangeStrikeAt(int, int, const CvPlot *) const

Defined in
CvUnit.cpp, line 21690
Class
CvUnit
Hook name
CivHooks::CvUnit_canEverRangeStrikeAt

Hooks

static bool BeforeCvUnit_canEverRangeStrikeAt(const CvUnit* self, int iX, int iY, const CvPlot* pSourcePlot, bool& result);static void AfterCvUnit_canEverRangeStrikeAt(const CvUnit* self, int iX, int iY, const CvPlot* pSourcePlot, bool& result);static bool ReplaceCvUnit_canEverRangeStrikeAt(bool (*original)(const CvUnit*, int, int, const CvPlot*), const CvUnit* self, int iX, int iY, const CvPlot* pSourcePlot);CivRegisterBefore<CivHooks::CvUnit_canEverRangeStrikeAt>(host, &BeforeCvUnit_canEverRangeStrikeAt);CivRegisterAfter<CivHooks::CvUnit_canEverRangeStrikeAt>(host, &AfterCvUnit_canEverRangeStrikeAt);CivRegisterReplace<CivHooks::CvUnit_canEverRangeStrikeAt>(host, &ReplaceCvUnit_canEverRangeStrikeAt);

Code

21689#if defined(MOD_AI_SMART_V3)21690bool CvUnit::canEverRangeStrikeAt(int iX, int iY, const CvPlot* pSourcePlot) const21691#else21692bool CvUnit::canEverRangeStrikeAt(int iX, int iY) const21693#endif21694{21695#if defined(MOD_AI_SMART_V3)21696	if (!pSourcePlot)21697		pSourcePlot = plot();21698#else21699	CvPlot* pSourcePlot = plot();21700#endif21701	CvPlot* pTargetPlot = GC.getMap().plot(iX, iY);2170221703	// Plot null?21704	if(NULL == pTargetPlot)21705	{21706		return false;21707	}2170821709	// Plot not visible?21710	if(!pTargetPlot->isVisible(getTeam()))21711	{21712		return false;21713	}2171421715	// Can only bombard in domain? (used for Subs' torpedo attack)21716	if(getUnitInfo().IsRangeAttackOnlyInDomain())21717	{21718		if(!pTargetPlot->isValidDomainForAction(*this))21719		{21720			return false;21721		}2172221723		// preventing submarines from shooting into lakes.21724		if (pSourcePlot->getArea() != pTargetPlot->getArea())21725		{21726			return false;21727		}21728	}2172921730	// In Range?21731	if(plotDistance(pSourcePlot->getX(), pSourcePlot->getY(), pTargetPlot->getX(), pTargetPlot->getY()) > GetRange())21732	{21733		return false;21734	}2173521736	// Ignores LoS or can see the plot directly?21737	if(!IsRangeAttackIgnoreLOS() && getDomainType() != DOMAIN_AIR)21738	{21739#if defined MOD_BUGFIX_NAVAL_TARGETING21740		if (!pSourcePlot->canSeePlot(pTargetPlot, getTeam(), GetRange(), getFacingDirection(true), getDomainType()))21741#else21742		if (!pSourcePlot->canSeePlot(pTargetPlot, getTeam(), GetRange(), getFacingDirection(true)))21743#endif21744		{21745			return false;21746		}21747	}2174821749	return true;21750}

Calls

Called by