Bazaar developer reference

CvUnit::IsCanDefend(const CvPlot *) const

Defined in
CvUnit.cpp, line 23733
Class
CvUnit
Hook name
CivHooks::CvUnit_IsCanDefend

Hooks

static bool BeforeCvUnit_IsCanDefend(const CvUnit* self, const CvPlot* pPlot, bool& result);static void AfterCvUnit_IsCanDefend(const CvUnit* self, const CvPlot* pPlot, bool& result);static bool ReplaceCvUnit_IsCanDefend(bool (*original)(const CvUnit*, const CvPlot*), const CvUnit* self, const CvPlot* pPlot);CivRegisterBefore<CivHooks::CvUnit_IsCanDefend>(host, &BeforeCvUnit_IsCanDefend);CivRegisterAfter<CivHooks::CvUnit_IsCanDefend>(host, &AfterCvUnit_IsCanDefend);CivRegisterReplace<CivHooks::CvUnit_IsCanDefend>(host, &ReplaceCvUnit_IsCanDefend);

Code

23732/// Unit able to fight back when attacked?23733bool CvUnit::IsCanDefend(const CvPlot* pPlot) const23734{23735	VALIDATE_OBJECT23736	if(pPlot == NULL)23737	{23738		pPlot = plot();23739	}2374023741	// This will catch noncombatants23742	if(GetBaseCombatStrength() == 0)23743	{23744		return false;23745	}2374623747	if(isDelayedDeath())23748	{23749		return false;23750	}2375123752	if(!pPlot->isValidDomainForAction(*this))23753	{23754		return false;23755	}2375623757	return true;23758}

Calls

Called by