Code
6062/// Per-turn friendship stuff6063void CvMinorCivAI::DoFriendship()6064{6065 Localization::String strMessage;6066 Localization::String strSummary;6067 const char* strMinorsNameKey = GetPlayer()->getNameKey();60686069 PlayerTypes ePlayer;6070 for(int iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++)6071 {6072 ePlayer = (PlayerTypes) iPlayerLoop;60736074 if(GET_PLAYER(ePlayer).isAlive())6075 {6076 // Update friendship even if the player hasn't met us yet, since we may have heard things through the grapevine (Wary Of, SP, etc.)60776078 // Look at the base friendship (not counting war status etc.) and change it6079 int iOldFriendship = GetBaseFriendshipWithMajor(ePlayer);6080 int iChangeThisTurn = GetFriendshipChangePerTurnTimes100(ePlayer);6081 int iFriendshipAnchor = GetFriendshipAnchorWithMajor(ePlayer);6082 int iNewFriendship = iOldFriendship + (iChangeThisTurn / 100);6083 if(iOldFriendship >= iFriendshipAnchor && iNewFriendship < iFriendshipAnchor)6084 {6085 // If we are at or above anchor, don't let the decay dip us below it6086 SetFriendshipWithMajor(ePlayer, iFriendshipAnchor);6087 }6088 else if (iChangeThisTurn != 0)6089 {6090 ChangeFriendshipWithMajorTimes100(ePlayer, iChangeThisTurn);6091 }6092 else6093 {6094 // Friendship amount doesn't change, but ally state could have (ex. current ally decays below our level)6095 DoFriendshipChangeEffects(ePlayer, iOldFriendship, iNewFriendship);6096 }60976098 // Notification for status changes6099 if(GetPlayer()->isAlive() && IsHasMetPlayer(ePlayer))6100 {6101 const int iTurnsWarning = 2;6102 const int iAlliesThreshold = GetAlliesThreshold() * 100;6103 const int iFriendsThreshold = GetFriendsThreshold() * 100;6104 int iEffectiveFriendship = GetEffectiveFriendshipWithMajorTimes100(ePlayer);6105 if(IsAllies(ePlayer))6106 {6107 if(iEffectiveFriendship + (iTurnsWarning * iChangeThisTurn) < iAlliesThreshold &&6108 iEffectiveFriendship + ((iTurnsWarning-1) * iChangeThisTurn) >= iAlliesThreshold)6109 {6110 strMessage = Localization::Lookup("TXT_KEY_NTFN_CITY_STATE_ALMOST_NOT_ALLIES");6111 strMessage << strMinorsNameKey;6112 strSummary = Localization::Lookup("TXT_KEY_NTFN_CITY_STATE_ALMOST_SM");6113 strSummary << strMinorsNameKey;61146115 AddNotification(strMessage.toUTF8(), strSummary.toUTF8(), ePlayer);6116 }6117#if !defined(NO_ACHIEVEMENTS)6118 if(!GC.getGame().isGameMultiPlayer() && GET_PLAYER(ePlayer).isHuman())6119 {6120 gDLL->UnlockAchievement(ACHIEVEMENT_CITYSTATE_ALLY);6121 }6122#endif61236124 }6125 else if(IsFriends(ePlayer))6126 {6127 if(iEffectiveFriendship + (iTurnsWarning * iChangeThisTurn) < iFriendsThreshold &&6128 iEffectiveFriendship + ((iTurnsWarning-1) * iChangeThisTurn) >= iFriendsThreshold)6129 {6130 strMessage = Localization::Lookup("TXT_KEY_NTFN_CITY_STATE_ALMOST_NOT_FRIENDS");6131 strMessage << strMinorsNameKey;6132 strSummary = Localization::Lookup("TXT_KEY_NTFN_CITY_STATE_ALMOST_SM");6133 strSummary << strMinorsNameKey;61346135 AddNotification(strMessage.toUTF8(), strSummary.toUTF8(), ePlayer);6136 }6137 }6138 }6139 }6140 }6141}