Bazaar developer reference

CvUnit::getDiscoverAmount()

Defined in
CvUnit.cpp, line 9024
Class
CvUnit
Hook name
CivHooks::CvUnit_getDiscoverAmount

Hooks

static bool BeforeCvUnit_getDiscoverAmount(CvUnit* self, int& result);static void AfterCvUnit_getDiscoverAmount(CvUnit* self, int& result);static int ReplaceCvUnit_getDiscoverAmount(int (*original)(CvUnit*), CvUnit* self);CivRegisterBefore<CivHooks::CvUnit_getDiscoverAmount>(host, &BeforeCvUnit_getDiscoverAmount);CivRegisterAfter<CivHooks::CvUnit_getDiscoverAmount>(host, &AfterCvUnit_getDiscoverAmount);CivRegisterReplace<CivHooks::CvUnit_getDiscoverAmount>(host, &ReplaceCvUnit_getDiscoverAmount);

Code

9024int CvUnit::getDiscoverAmount()9025{9026	int iValue = 0;9027	CvPlot* pPlot = plot();9028	if(canDiscover(pPlot))9029	{9030		CvPlayer* pPlayer = &GET_PLAYER(getOwner());9031		CvAssertMsg(pPlayer, "Owner of unit not expected to be NULL. Please send Anton your save file and version.");9032		if (pPlayer)9033		{9034			// Beakers boost based on previous turns9035			int iPreviousTurnsToCount = m_pUnitInfo->GetBaseBeakersTurnsToCount();9036			iValue = pPlayer->GetScienceYieldFromPreviousTurns(GC.getGame().getGameTurn(), iPreviousTurnsToCount);9037			if (pPlayer->GetGreatScientistBeakerMod() != 0)9038			{9039				iValue += (iValue * pPlayer->GetGreatScientistBeakerMod()) / 100;9040				iValue = MAX(iValue, 0); // Cannot be negative9041			}90429043			// Modify based on game speed9044			iValue *= GC.getGame().getGameSpeedInfo().getResearchPercent();9045			iValue /= 100;9046		}9047	}9048	return iValue;9049}

Calls

Called by