Bazaar developer reference

CvMinorCivAI::GetFriendshipFromUnitGift(PlayerTypes, bool, bool)

Defined in
CvMinorCivAI.cpp, line 9900
Class
CvMinorCivAI
Hook name
CivHooks::CvMinorCivAI_GetFriendshipFromUnitGift

Hooks

static bool BeforeCvMinorCivAI_GetFriendshipFromUnitGift(CvMinorCivAI* self, PlayerTypes eFromPlayer, bool bGreatPerson, bool arg2, int& result);static void AfterCvMinorCivAI_GetFriendshipFromUnitGift(CvMinorCivAI* self, PlayerTypes eFromPlayer, bool bGreatPerson, bool arg2, int& result);static int ReplaceCvMinorCivAI_GetFriendshipFromUnitGift(int (*original)(CvMinorCivAI*, PlayerTypes, bool, bool), CvMinorCivAI* self, PlayerTypes eFromPlayer, bool bGreatPerson, bool arg2);CivRegisterBefore<CivHooks::CvMinorCivAI_GetFriendshipFromUnitGift>(host, &BeforeCvMinorCivAI_GetFriendshipFromUnitGift);CivRegisterAfter<CivHooks::CvMinorCivAI_GetFriendshipFromUnitGift>(host, &AfterCvMinorCivAI_GetFriendshipFromUnitGift);CivRegisterReplace<CivHooks::CvMinorCivAI_GetFriendshipFromUnitGift>(host, &ReplaceCvMinorCivAI_GetFriendshipFromUnitGift);

Code

9900int CvMinorCivAI::GetFriendshipFromUnitGift(PlayerTypes eFromPlayer, bool bGreatPerson, bool /*bDistanceGift*/)9901{9902	CvAssertMsg(eFromPlayer >= 0, "eFromPlayer is expected to be non-negative (invalid Index)");9903	CvAssertMsg(eFromPlayer < MAX_MAJOR_CIVS, "eFromPlayer is expected to be within maximum bounds (invalid Index)");9904	if (eFromPlayer < 0 || eFromPlayer >= MAX_MAJOR_CIVS) return 0;99059906	int iInfluence = 0;9907	CvPlayer& kFromPlayer = GET_PLAYER(eFromPlayer);99089909	// Influence9910	if (bGreatPerson)9911	{9912		int iGPInfluence = kFromPlayer.GetPlayerTraits()->GetGreatPersonGiftInfluence();9913		if (iGPInfluence > 0)9914		{9915			iInfluence += iGPInfluence;9916		}9917	}9918	else9919	{9920		iInfluence += GC.getFRIENDSHIP_PER_UNIT_GIFTED();99219922		// War state9923		if (IsProxyWarActiveForMajor(eFromPlayer))9924		{9925			iInfluence += GC.getFRIENDSHIP_PER_UNIT_GIFTED();9926		}9927		9928		// Policies9929		int iMilitaryInfluence = kFromPlayer.GetPlayerPolicies()->GetNumericModifier(POLICYMOD_MILITARY_UNIT_GIFT_INFLUENCE);9930		if (iMilitaryInfluence > 0)9931		{9932			iInfluence += iMilitaryInfluence;9933		}9934	}99359936	return iInfluence;9937}

Calls

Called by