Hooks
static bool BeforeCvMinorCivAI_GetFriendshipAnchorWithMajor(CvMinorCivAI* self, PlayerTypes eMajor, int& result);static void AfterCvMinorCivAI_GetFriendshipAnchorWithMajor(CvMinorCivAI* self, PlayerTypes eMajor, int& result);static int ReplaceCvMinorCivAI_GetFriendshipAnchorWithMajor(int (*original)(CvMinorCivAI*, PlayerTypes), CvMinorCivAI* self, PlayerTypes eMajor);CivRegisterBefore<CivHooks::CvMinorCivAI_GetFriendshipAnchorWithMajor>(host, &BeforeCvMinorCivAI_GetFriendshipAnchorWithMajor);CivRegisterAfter<CivHooks::CvMinorCivAI_GetFriendshipAnchorWithMajor>(host, &AfterCvMinorCivAI_GetFriendshipAnchorWithMajor);CivRegisterReplace<CivHooks::CvMinorCivAI_GetFriendshipAnchorWithMajor>(host, &ReplaceCvMinorCivAI_GetFriendshipAnchorWithMajor);
Code
6340/// What is the resting point of Influence this major has? Affected by religion, social policies, Wary Of, etc.6341int CvMinorCivAI::GetFriendshipAnchorWithMajor(PlayerTypes eMajor)6342{6343 int iAnchor = GC.getMINOR_FRIENDSHIP_ANCHOR_DEFAULT();63446345 CvAssertMsg(eMajor >= 0, "eMajor is expected to be non-negative (invalid Index)");6346 CvAssertMsg(eMajor < MAX_MAJOR_CIVS, "eMajor is expected to be within maximum bounds (invalid Index)");6347 if (eMajor < 0 || eMajor >= MAX_MAJOR_CIVS) return iAnchor;63486349 CvPlayer* pMajor = &GET_PLAYER(eMajor);6350 CvAssertMsg(pMajor, "MINOR CIV AI: pMajor not expected to be NULL. Please send Anton your save file and version.");6351 if (!pMajor) return iAnchor;63526353 // Pledge to Protect6354 if (IsProtectedByMajor(eMajor))6355 {6356 iAnchor += GC.getMINOR_FRIENDSHIP_ANCHOR_MOD_PROTECTED();6357 }63586359 // Wary Of?6360 if (IsWaryOfTeam(pMajor->getTeam()))6361 {6362 iAnchor += GC.getMINOR_FRIENDSHIP_ANCHOR_MOD_WARY_OF();6363 }63646365 // Social Policies6366 iAnchor += pMajor->GetMinorFriendshipAnchorMod();63676368 // Religion6369 CvPlayerReligions* pMajorReligions = pMajor->GetReligions();6370 CvAssertMsg(pMajorReligions, "MINOR CIV AI: pMajorReligions not expected to be NULL. Please send Anton your save file and version.");6371 if (!pMajorReligions) return iAnchor;6372 CvCity* pMinorCapital = GetPlayer()->getCapitalCity();6373 if (!pMinorCapital) return iAnchor; // Happens when city was just captured, after buyout, etc., so just return the anchor value we have6374 CvCityReligions* pMinorCapitalReligions = pMinorCapital->GetCityReligions();6375 CvAssertMsg(pMinorCapitalReligions, "MINOR CIV AI: pMinorCapitalReligions not expected to be NULL. Please send Anton your save file and version.");6376 if (!pMinorCapitalReligions) return iAnchor;6377 iAnchor += pMajorReligions->GetCityStateMinimumInfluence(pMinorCapitalReligions->GetReligiousMajority());63786379 return iAnchor;6380}