Bazaar developer reference

CvUnit::lead(int)

Defined in
CvUnit.cpp, line 10770
Class
CvUnit
Hook name
CivHooks::CvUnit_lead

Hooks

static bool BeforeCvUnit_lead(CvUnit* self, int iUnitId, bool& result);static void AfterCvUnit_lead(CvUnit* self, int iUnitId, bool& result);static bool ReplaceCvUnit_lead(bool (*original)(CvUnit*, int), CvUnit* self, int iUnitId);CivRegisterBefore<CivHooks::CvUnit_lead>(host, &BeforeCvUnit_lead);CivRegisterAfter<CivHooks::CvUnit_lead>(host, &AfterCvUnit_lead);CivRegisterReplace<CivHooks::CvUnit_lead>(host, &ReplaceCvUnit_lead);

Code

10770bool CvUnit::lead(int iUnitId)10771{10772	VALIDATE_OBJECT10773	if(!canLead(plot(), iUnitId))10774	{10775		return false;10776	}1077710778	PromotionTypes eLeaderPromotion = (PromotionTypes)m_pUnitInfo->GetLeaderPromotion();1077910780	if(-1 == iUnitId)10781	{10782		return false;10783	}10784	else10785	{10786		UnitHandle pUnit = GET_PLAYER(getOwner()).getUnit(iUnitId);1078710788		if(!pUnit || !pUnit->canPromote(eLeaderPromotion, GetID()))10789		{10790			return false;10791		}1079210793		pUnit->promote(eLeaderPromotion, GetID());1079410795		kill(true);1079610797		return true;10798	}10799}

Calls

Called by