Bazaar developer reference

CvUnit::CanCultureBomb(const CvPlot *, bool) const

Defined in
CvUnit.cpp, line 9724
Class
CvUnit
Hook name
CivHooks::CvUnit_CanCultureBomb

Hooks

static bool BeforeCvUnit_CanCultureBomb(const CvUnit* self, const CvPlot* pPlot, bool bTestVisible, bool& result);static void AfterCvUnit_CanCultureBomb(const CvUnit* self, const CvPlot* pPlot, bool bTestVisible, bool& result);static bool ReplaceCvUnit_CanCultureBomb(bool (*original)(const CvUnit*, const CvPlot*, bool), const CvUnit* self, const CvPlot* pPlot, bool bTestVisible);CivRegisterBefore<CivHooks::CvUnit_CanCultureBomb>(host, &BeforeCvUnit_CanCultureBomb);CivRegisterAfter<CivHooks::CvUnit_CanCultureBomb>(host, &AfterCvUnit_CanCultureBomb);CivRegisterReplace<CivHooks::CvUnit_CanCultureBomb>(host, &ReplaceCvUnit_CanCultureBomb);

Code

9724bool CvUnit::CanCultureBomb(const CvPlot* pPlot, bool bTestVisible) const9725{9726	VALIDATE_OBJECT97279728	if(m_pUnitInfo->GetCultureBombRadius() <= 0)9729		return false;97309731	if(isDelayedDeath())9732		return false;97339734	// Things we test for if we're going to perform this action RIGHT NOW9735	if(!bTestVisible)9736	{9737		// Too soon?9738		if(GET_PLAYER(getOwner()).getCultureBombTimer() > 0)9739			return false;97409741		if(pPlot != NULL)9742		{9743			// Can't be inside someone else's territory9744			if(pPlot->getOwner() != NO_PLAYER && pPlot->getOwner() != getOwner())9745				return false;97469747			// We have to be in or next to friendly territory9748			bool bFoundAdjacent = false;97499750			CvPlot* pLoopPlot;9751			for(int iI = 0; iI < NUM_DIRECTION_TYPES; iI++)9752			{9753				pLoopPlot = plotDirection(pPlot->getX(), pPlot->getY(), ((DirectionTypes)iI));97549755				if(pLoopPlot != NULL)9756				{9757					if(pLoopPlot->getOwner() == getOwner())9758					{9759						bFoundAdjacent = true;9760						break;9761					}9762				}9763			}97649765			if(!bFoundAdjacent)9766				return false;9767		}9768	}97699770	return true;9771}

Calls

Called by