Bazaar developer reference

CvMinorCivAI::GetFriendshipFromGoldGift(PlayerTypes, int)

Defined in
CvMinorCivAI.cpp, line 9994
Class
CvMinorCivAI
Hook name
CivHooks::CvMinorCivAI_GetFriendshipFromGoldGift

Hooks

static bool BeforeCvMinorCivAI_GetFriendshipFromGoldGift(CvMinorCivAI* self, PlayerTypes eMajor, int iGold, int& result);static void AfterCvMinorCivAI_GetFriendshipFromGoldGift(CvMinorCivAI* self, PlayerTypes eMajor, int iGold, int& result);static int ReplaceCvMinorCivAI_GetFriendshipFromGoldGift(int (*original)(CvMinorCivAI*, PlayerTypes, int), CvMinorCivAI* self, PlayerTypes eMajor, int iGold);CivRegisterBefore<CivHooks::CvMinorCivAI_GetFriendshipFromGoldGift>(host, &BeforeCvMinorCivAI_GetFriendshipFromGoldGift);CivRegisterAfter<CivHooks::CvMinorCivAI_GetFriendshipFromGoldGift>(host, &AfterCvMinorCivAI_GetFriendshipFromGoldGift);CivRegisterReplace<CivHooks::CvMinorCivAI_GetFriendshipFromGoldGift>(host, &ReplaceCvMinorCivAI_GetFriendshipFromGoldGift);

Code

9993/// How many friendship points gained from a gift of Gold9994int CvMinorCivAI::GetFriendshipFromGoldGift(PlayerTypes eMajor, int iGold)9995{9996	// The more Gold you spend the more Friendship you get!9997	iGold = (int) pow((double) iGold, (double) /*1.01*/ GC.getGOLD_GIFT_FRIENDSHIP_EXPONENT());9998	// The higher this divisor the less Friendship is gained9999	int iFriendship = int(iGold / /*9.8*/ GC.getGOLD_GIFT_FRIENDSHIP_DIVISOR());1000010001	// Game progress factor based on how far into the game we are10002	double fGameProgressFactor = float(GC.getGame().getElapsedGameTurns()) / GC.getGame().getEstimateEndTurn();10003	fGameProgressFactor = min(fGameProgressFactor, 1.0); // Don't count above 1.0, otherwise it will end up negative!10004	10005	// Tweak factor slightly, otherwise Gold will do literally NOTHING once we reach the end of the game!10006	fGameProgressFactor *= /*2*/ GC.getMINOR_CIV_GOLD_GIFT_GAME_MULTIPLIER();10007	fGameProgressFactor /= /*3*/ GC.getMINOR_CIV_GOLD_GIFT_GAME_DIVISOR();10008	fGameProgressFactor = 1 - fGameProgressFactor;1000910010	iFriendship = (int)(iFriendship * fGameProgressFactor);100111001210013	// Mod (Policies, etc.)10014	int iFriendshipMod = GET_PLAYER(eMajor).getMinorGoldFriendshipMod();10015	iFriendshipMod += GET_PLAYER(eMajor).GetReligions()->GetCityStateInfluenceModifier();10016	if(iFriendshipMod != 0)10017	{10018		iFriendship *= (100 + iFriendshipMod);10019		iFriendship /= 100;10020	}1002110022	// Game Speed Mod10023	iFriendship *= GC.getGame().getGameSpeedInfo().getGoldGiftMod();10024	iFriendship /= 100;1002510026	//antonjs: todo: refine10027	if(IsActiveQuestForPlayer(eMajor, MINOR_CIV_QUEST_INVEST))10028	{10029		int iBoostPercentage = 50; //antonjs: todo: xml10030		iFriendship *= 100 + iBoostPercentage;10031		iFriendship /= 100;10032	}1003310034	// Friendship gained should always be positive10035	iFriendship = max(iFriendship, /*5*/ GC.getMINOR_CIV_GOLD_GIFT_MINIMUM_FRIENDSHIP_REWARD());1003610037	// Round the number so it's pretty10038	int iVisibleDivisor = /*5*/ GC.getMINOR_CIV_GOLD_GIFT_VISIBLE_DIVISOR();10039	iFriendship /= iVisibleDivisor;10040	iFriendship *= iVisibleDivisor;1004110042	return iFriendship;10043}

Calls

Called by