Bazaar developer reference

CvMinorCivAI::GetFriendshipChangePerTurnTimes100(PlayerTypes)

Defined in
CvMinorCivAI.cpp, line 6146
Class
CvMinorCivAI
Hook name
CivHooks::CvMinorCivAI_GetFriendshipChangePerTurnTimes100

Hooks

static bool BeforeCvMinorCivAI_GetFriendshipChangePerTurnTimes100(CvMinorCivAI* self, PlayerTypes ePlayer, int& result);static void AfterCvMinorCivAI_GetFriendshipChangePerTurnTimes100(CvMinorCivAI* self, PlayerTypes ePlayer, int& result);static int ReplaceCvMinorCivAI_GetFriendshipChangePerTurnTimes100(int (*original)(CvMinorCivAI*, PlayerTypes), CvMinorCivAI* self, PlayerTypes ePlayer);CivRegisterBefore<CivHooks::CvMinorCivAI_GetFriendshipChangePerTurnTimes100>(host, &BeforeCvMinorCivAI_GetFriendshipChangePerTurnTimes100);CivRegisterAfter<CivHooks::CvMinorCivAI_GetFriendshipChangePerTurnTimes100>(host, &AfterCvMinorCivAI_GetFriendshipChangePerTurnTimes100);CivRegisterReplace<CivHooks::CvMinorCivAI_GetFriendshipChangePerTurnTimes100>(host, &ReplaceCvMinorCivAI_GetFriendshipChangePerTurnTimes100);

Code

6143/// How much does friendship drop per turn with ePlayer?6144/// Note that this does not pay attention to whether ePlayer is at war6145/// with this minor, in which case there is no friendship change per turn.6146int CvMinorCivAI::GetFriendshipChangePerTurnTimes100(PlayerTypes ePlayer)6147{6148	CvPlayer& kPlayer = GET_PLAYER(ePlayer);6149	int iChangeThisTurn = 0;61506151	// Modifier to rate based on traits and religion6152	int iTraitMod = kPlayer.GetPlayerTraits()->GetCityStateFriendshipModifier();6153	int iReligionMod = 0;6154	if (IsSameReligionAsMajor(ePlayer))6155		iReligionMod += /*50*/ GC.getMINOR_FRIENDSHIP_RATE_MOD_SHARED_RELIGION();61566157	// Relation to anchor point?6158	int iBaseFriendship = GetBaseFriendshipWithMajor(ePlayer);6159	int iFriendshipAnchor = GetFriendshipAnchorWithMajor(ePlayer);6160	if (iBaseFriendship == iFriendshipAnchor)6161	{6162		// Change rate is 06163	}6164	else if (iBaseFriendship > iFriendshipAnchor)6165	{6166		// Hostile Minors have Friendship decay quicker6167		if(GetPersonality() == MINOR_CIV_PERSONALITY_HOSTILE)6168			iChangeThisTurn += /*-150*/ GC.getMINOR_FRIENDSHIP_DROP_PER_TURN_HOSTILE();6169		// Aggressor!6170		else if(GET_TEAM(kPlayer.getTeam()).IsMinorCivAggressor())6171			iChangeThisTurn += /*-200*/ GC.getMINOR_FRIENDSHIP_DROP_PER_TURN_AGGRESSOR();6172		// Normal decay6173		else6174			iChangeThisTurn += /*-100*/ GC.getMINOR_FRIENDSHIP_DROP_PER_TURN();61756176		// Decay modified (Trait, policies, shared religion, etc.)6177		int iDecayMod = 100;6178		iDecayMod += GET_PLAYER(ePlayer).GetMinorFriendshipDecayMod();6179		iDecayMod += (-1) * (iTraitMod / 2);6180		iDecayMod += (-1) * (iReligionMod / 2);6181		6182		if (iDecayMod < 0)6183			iDecayMod = 0;61846185		iChangeThisTurn *= iDecayMod;6186		iChangeThisTurn /= 100;6187	}6188	else6189	{6190		iChangeThisTurn += /*100*/ GC.getMINOR_FRIENDSHIP_NEGATIVE_INCREASE_PER_TURN();61916192		// Recovery modified (Trait, policies, shared religion, etc.)6193		int iRecoveryMod = 100;6194		iRecoveryMod += iTraitMod;6195		iRecoveryMod += iReligionMod;6196		6197		if (iRecoveryMod < 0)6198			iRecoveryMod = 0;61996200		iChangeThisTurn *= iRecoveryMod;6201		iChangeThisTurn /= 100;6202	}6203	// Shift on top of base rate6204	if (GET_TEAM(kPlayer.getTeam()).isHasMet(GetPlayer()->getTeam()))6205	{6206		int iShift = 0;62076208		if (kPlayer.GetPlayerPolicies()->GetNumericModifier(POLICYMOD_PROTECTED_MINOR_INFLUENCE) != 0)6209		{6210			if (GC.getGame().GetGameTrade()->IsPlayerConnectedToPlayer(ePlayer, GetPlayer()->GetID()))6211			{6212				iShift += kPlayer.GetPlayerPolicies()->GetNumericModifier(POLICYMOD_PROTECTED_MINOR_INFLUENCE);6213			}6214		}62156216		if (CanMajorBullyGold(ePlayer))6217		{6218			iShift += kPlayer.GetPlayerPolicies()->GetNumericModifier(POLICYMOD_AFRAID_INFLUENCE);6219			iShift += kPlayer.GetPlayerTraits()->GetAfraidMinorPerTurnInfluence();6220		}6221		6222		if (iShift != 0)6223		{6224			iChangeThisTurn += iShift;6225		}6226	}62276228	// Mod everything by game speed6229	iChangeThisTurn *= GC.getGame().getGameSpeedInfo().getGoldGiftMod();6230	iChangeThisTurn /= 100;62316232	return iChangeThisTurn;6233}

Calls

Called by