Bazaar developer reference

CvDiplomacyAI::GetRandomPersonalityWeight(int) const

Defined in
CvDiplomacyAI.cpp, line 1964
Class
CvDiplomacyAI
Hook name
CivHooks::CvDiplomacyAI_GetRandomPersonalityWeight

Hooks

static bool BeforeCvDiplomacyAI_GetRandomPersonalityWeight(const CvDiplomacyAI* self, int iOriginalValue, int& result);static void AfterCvDiplomacyAI_GetRandomPersonalityWeight(const CvDiplomacyAI* self, int iOriginalValue, int& result);static int ReplaceCvDiplomacyAI_GetRandomPersonalityWeight(int (*original)(const CvDiplomacyAI*, int), const CvDiplomacyAI* self, int iOriginalValue);CivRegisterBefore<CivHooks::CvDiplomacyAI_GetRandomPersonalityWeight>(host, &BeforeCvDiplomacyAI_GetRandomPersonalityWeight);CivRegisterAfter<CivHooks::CvDiplomacyAI_GetRandomPersonalityWeight>(host, &AfterCvDiplomacyAI_GetRandomPersonalityWeight);CivRegisterReplace<CivHooks::CvDiplomacyAI_GetRandomPersonalityWeight>(host, &ReplaceCvDiplomacyAI_GetRandomPersonalityWeight);

Code

1963/// Returns a personality weight with a small random element1964int CvDiplomacyAI::GetRandomPersonalityWeight(int iOriginalValue) const1965{1966	int iMin = /*0*/ GC.getPERSONALITY_FLAVOR_MIN_VALUE();1967	int iMax = /*20*/ GC.getPERSONALITY_FLAVOR_MAX_VALUE();1968	int iPlusMinus = /*2*/ GC.getFLAVOR_RANDOMIZATION_RANGE();19691970	int iAdjust = GC.getGame().getJonRandNum((iPlusMinus * 2 + 1), "Diplomacy AI Random Weight");1971	int iRtnValue = iOriginalValue + iAdjust - iPlusMinus;19721973	if(iRtnValue < iMin)1974		iRtnValue = iMin;1975	else if(iRtnValue > iMax)1976		iRtnValue = iMax;19771978	return iRtnValue;1979}

Calls

Called by