Bazaar developer reference

CvUnit::isPromotionValid(PromotionTypes) const

Defined in
CvUnit.cpp, line 20745
Class
CvUnit
Hook name
CivHooks::CvUnit_isPromotionValid

Hooks

static bool BeforeCvUnit_isPromotionValid(const CvUnit* self, PromotionTypes ePromotion, bool& result);static void AfterCvUnit_isPromotionValid(const CvUnit* self, PromotionTypes ePromotion, bool& result);static bool ReplaceCvUnit_isPromotionValid(bool (*original)(const CvUnit*, PromotionTypes), const CvUnit* self, PromotionTypes ePromotion);CivRegisterBefore<CivHooks::CvUnit_isPromotionValid>(host, &BeforeCvUnit_isPromotionValid);CivRegisterAfter<CivHooks::CvUnit_isPromotionValid>(host, &AfterCvUnit_isPromotionValid);CivRegisterReplace<CivHooks::CvUnit_isPromotionValid>(host, &ReplaceCvUnit_isPromotionValid);

Code

20745bool CvUnit::isPromotionValid(PromotionTypes ePromotion) const20746{20747	VALIDATE_OBJECT2074820749	CvPromotionEntry* promotionInfo = GC.getPromotionInfo(ePromotion);20750	if(promotionInfo == NULL)20751	{20752		return false;20753	}2075420755	if(!::isPromotionValid(ePromotion, getUnitType(), true))20756		return false;2075720758	// Insta-heal - must be damaged20759	if(promotionInfo->IsInstaHeal())20760	{20761		if(getDamage() == 0)20762			return false;20763	}2076420765	// Can't acquire interception promotion if unit can't intercept!20766	if(promotionInfo->GetInterceptionCombatModifier() != 0)20767	{20768		if(!canAirDefend())20769			return false;20770	}2077120772	// Can't acquire Air Sweep promotion if unit can't air sweep!20773	if(promotionInfo->GetAirSweepCombatModifier() != 0)20774	{20775		if(!IsAirSweepCapable())20776			return false;20777	}2077820779	// Max Interception20780	if(promotionInfo->GetInterceptChanceChange() > 0)20781	{20782		if(promotionInfo->GetInterceptChanceChange() + maxInterceptionProbability() > GC.getMAX_INTERCEPTION_PROBABILITY())20783			return false;20784	}2078520786	// Max evasion20787	if(promotionInfo->GetEvasionChange() > 0)20788	{20789		if(promotionInfo->GetEvasionChange() + evasionProbability() > GC.getMAX_EVASION_PROBABILITY())20790			return false;20791	}2079220793	// Hovering units (e.g. Helis) cannot embark20794	if(IsHoveringUnit() && promotionInfo->IsAllowsEmbarkation())20795		return false;20796		20797#if defined(MOD_PROMOTIONS_DEEP_WATER_EMBARKATION)20798	// Only hovering units can deep water embark20799	if(!IsHoveringUnit() && promotionInfo->IsEmbarkedDeepWater())20800		return false;20801#endif2080220803	return true;20804}

Calls

Called by