CvLeagueAI::EvaluateAlignment(PlayerTypes)
- Defined in
- CvVotingClasses.cpp, line 8044
- Class
- CvLeagueAI
- Hook name
CivHooks::CvLeagueAI_EvaluateAlignment
Hooks
static bool BeforeCvLeagueAI_EvaluateAlignment(CvLeagueAI* self, PlayerTypes ePlayer, CvLeagueAI::AlignmentLevels& result);static void AfterCvLeagueAI_EvaluateAlignment(CvLeagueAI* self, PlayerTypes ePlayer, CvLeagueAI::AlignmentLevels& result);static CvLeagueAI::AlignmentLevels ReplaceCvLeagueAI_EvaluateAlignment(CvLeagueAI::AlignmentLevels (*original)(CvLeagueAI*, PlayerTypes), CvLeagueAI* self, PlayerTypes ePlayer);CivRegisterBefore<CivHooks::CvLeagueAI_EvaluateAlignment>(host, &BeforeCvLeagueAI_EvaluateAlignment);CivRegisterAfter<CivHooks::CvLeagueAI_EvaluateAlignment>(host, &AfterCvLeagueAI_EvaluateAlignment);CivRegisterReplace<CivHooks::CvLeagueAI_EvaluateAlignment>(host, &ReplaceCvLeagueAI_EvaluateAlignment);
Code
8043// Calculate how much we think our interests are aligned with ePlayer, based on ideology, liberation, past voting patterns, etc.8044CvLeagueAI::AlignmentLevels CvLeagueAI::EvaluateAlignment(PlayerTypes ePlayer)8045{8046 if (ePlayer == NO_PLAYER)8047 {8048 return ALIGNMENT_NEUTRAL;8049 }8050 if (!GET_PLAYER(ePlayer).isAlive())8051 {8052 return ALIGNMENT_NEUTRAL;8053 }8054 if (GET_PLAYER(ePlayer).isMinorCiv())8055 {8056 return ALIGNMENT_NEUTRAL;8057 }8058 if (GetPlayer()->GetID() == ePlayer)8059 {8060 return ALIGNMENT_SELF;8061 }8062 if (GetPlayer()->GetDiplomacyAI()->WasResurrectedBy(ePlayer))8063 {8064 return ALIGNMENT_LIBERATOR;8065 }8066 if (GetPlayer()->getTeam() == GET_PLAYER(ePlayer).getTeam())8067 {8068 if (GET_TEAM(GetPlayer()->getTeam()).getLeaderID() == ePlayer)8069 {8070 return ALIGNMENT_LEADER;8071 }8072 else8073 {8074 return ALIGNMENT_ALLY;8075 }8076 }8077 if (GET_TEAM(GetPlayer()->getTeam()).isAtWar(GET_PLAYER(ePlayer).getTeam()))8078 {8079 return ALIGNMENT_WAR;8080 }80818082 int iAlignment = 0;80838084 // Ideology8085 PolicyBranchTypes eOurIdeology = GetPlayer()->GetPlayerPolicies()->GetLateGamePolicyTree();8086 PolicyBranchTypes eTheirIdeology = GET_PLAYER(ePlayer).GetPlayerPolicies()->GetLateGamePolicyTree();8087 if (eOurIdeology != NO_POLICY_BRANCH_TYPE && eTheirIdeology != NO_POLICY_BRANCH_TYPE)8088 {8089 if (eOurIdeology == eTheirIdeology)8090 {8091 iAlignment += 2;8092 }8093 else8094 {8095 iAlignment += -2;8096 }8097 }80988099 // Did they help us become host?8100 if (GetPlayer()->GetDiplomacyAI()->GetSupportedMyHostingScore(ePlayer) != 0)8101 {8102 iAlignment += 2;8103 }81048105 // Do we like their proposals or votes?8106 if (GetPlayer()->GetDiplomacyAI()->GetLikedTheirProposalScore(ePlayer) != 0 ||8107 GetPlayer()->GetDiplomacyAI()->GetSupportedMyProposalScore(ePlayer) != 0)8108 {8109 iAlignment += 2;8110 }8111 if (GetPlayer()->GetDiplomacyAI()->GetDislikedTheirProposalScore(ePlayer) != 0 ||8112 GetPlayer()->GetDiplomacyAI()->GetFoiledMyProposalScore(ePlayer) != 0)8113 {8114 iAlignment += -2;8115 }81168117 // DoF or Denounce8118 if (GetPlayer()->GetDiplomacyAI()->IsDoFAccepted(ePlayer))8119 {8120 iAlignment += 1;8121 }8122 if (GetPlayer()->GetDiplomacyAI()->IsDenouncedPlayer(ePlayer))8123 {8124 iAlignment += -1;8125 }81268127 // Opinion and approach8128 MajorCivOpinionTypes eOpinion = GetPlayer()->GetDiplomacyAI()->GetMajorCivOpinion(ePlayer);8129 MajorCivApproachTypes eApproach = GetPlayer()->GetDiplomacyAI()->GetMajorCivApproach(ePlayer, /*bHideTrueFeelings*/ false);8130 if (eOpinion > MAJOR_CIV_OPINION_NEUTRAL || eApproach == MAJOR_CIV_APPROACH_AFRAID || eApproach == MAJOR_CIV_APPROACH_FRIENDLY)8131 {8132 iAlignment += 1;8133 }8134 else if (eOpinion <= MAJOR_CIV_OPINION_ENEMY || eApproach == MAJOR_CIV_APPROACH_HOSTILE)8135 {8136 iAlignment += -1;8137 }81388139 AlignmentLevels eAlignment = ALIGNMENT_NEUTRAL;8140 if (iAlignment < -6)8141 {8142 eAlignment = ALIGNMENT_ENEMY;8143 }8144 else if (iAlignment < -4)8145 {8146 eAlignment = ALIGNMENT_HATRED;8147 }8148 else if (iAlignment < -1)8149 {8150 eAlignment = ALIGNMENT_RIVAL;8151 }8152 else if (iAlignment <= 1)8153 {8154 eAlignment = ALIGNMENT_NEUTRAL;8155 }8156 else if (iAlignment <= 4)8157 {8158 eAlignment = ALIGNMENT_FRIEND;8159 }8160 else if (iAlignment <= 6)8161 {8162 eAlignment = ALIGNMENT_CONFIDANT;8163 }8164 else8165 {8166 eAlignment = ALIGNMENT_ALLY;8167 }8168 return eAlignment;8169}
Calls
- CvDiplomacyAI::GetDislikedTheirProposalScore(PlayerTypes)
- CvDiplomacyAI::GetFoiledMyProposalScore(PlayerTypes)
- CvDiplomacyAI::GetLikedTheirProposalScore(PlayerTypes)
- CvDiplomacyAI::GetMajorCivApproach(PlayerTypes, bool) const
- CvDiplomacyAI::GetMajorCivOpinion(PlayerTypes) const
- CvDiplomacyAI::GetSupportedMyHostingScore(PlayerTypes)
- CvDiplomacyAI::GetSupportedMyProposalScore(PlayerTypes)
- CvDiplomacyAI::IsDenouncedPlayer(PlayerTypes) const
- CvDiplomacyAI::IsDoFAccepted(PlayerTypes) const
- CvDiplomacyAI::WasResurrectedBy(PlayerTypes) const
- CvLeagueAI::GetPlayer()
- CvPlayer::GetDiplomacyAI() const
- CvPlayer::GetID() const
- CvPlayer::GetPlayerPolicies() const
- CvPlayer::getTeam() const
- CvPlayer::isAlive() const
- CvPlayer::isMinorCiv() const
- CvPlayerAI::getPlayer(PlayerTypes)
- CvPlayerPolicies::GetLateGamePolicyTree() const
- CvTeam::getLeaderID() const
- CvTeam::getTeam(TeamTypes)
- CvTeam::isAtWar(TeamTypes) const