CvDiplomacyAI::GetDenounceWeight(PlayerTypes, bool)
- Defined in
- CvDiplomacyAI.cpp, line 21560
- Class
- CvDiplomacyAI
- Hook name
CivHooks::CvDiplomacyAI_GetDenounceWeight
Hooks
static bool BeforeCvDiplomacyAI_GetDenounceWeight(CvDiplomacyAI* self, PlayerTypes ePlayer, bool bBias, int& result);static void AfterCvDiplomacyAI_GetDenounceWeight(CvDiplomacyAI* self, PlayerTypes ePlayer, bool bBias, int& result);static int ReplaceCvDiplomacyAI_GetDenounceWeight(int (*original)(CvDiplomacyAI*, PlayerTypes, bool), CvDiplomacyAI* self, PlayerTypes ePlayer, bool bBias);CivRegisterBefore<CivHooks::CvDiplomacyAI_GetDenounceWeight>(host, &BeforeCvDiplomacyAI_GetDenounceWeight);CivRegisterAfter<CivHooks::CvDiplomacyAI_GetDenounceWeight>(host, &AfterCvDiplomacyAI_GetDenounceWeight);CivRegisterReplace<CivHooks::CvDiplomacyAI_GetDenounceWeight>(host, &ReplaceCvDiplomacyAI_GetDenounceWeight);
Code
21560int CvDiplomacyAI::GetDenounceWeight(PlayerTypes ePlayer, bool bBias)21561{21562 int iWeight = 0;2156321564 // Base Personality value; ranges from 0 to 10 (ish)21565 iWeight += GetDenounceWillingness();2156621567 MajorCivApproachTypes eApproach = GetMajorCivApproach(ePlayer, /*bHideTrueFeelings*/ false);2156821569 // Hostile: Bonus21570 if(eApproach == MAJOR_CIV_APPROACH_HOSTILE)21571 iWeight += 6;21572 // Afraid: Penalty21573 else if(eApproach == MAJOR_CIV_APPROACH_AFRAID)21574 iWeight += -10;2157521576 MajorCivOpinionTypes eOpinion = GetMajorCivOpinion(ePlayer);2157721578 // Unforgivable: Big Bonus21579 if(eOpinion == MAJOR_CIV_OPINION_UNFORGIVABLE)21580 iWeight += 10;21581 // Enemy: Bonus21582 else if(eOpinion == MAJOR_CIV_OPINION_ENEMY)21583 iWeight += 5;21584 // Competitor: Small Bonus21585 else if(eOpinion == MAJOR_CIV_OPINION_COMPETITOR)21586 iWeight += 2;21587 // Good Relations: Penalty21588 else if(eOpinion == MAJOR_CIV_OPINION_FAVORABLE)21589 iWeight += -10;21590 else if(eOpinion == MAJOR_CIV_OPINION_FRIEND)21591 iWeight += -25;21592 else if(eOpinion == MAJOR_CIV_OPINION_ALLY)21593 iWeight += -50;2159421595 // We are at war21596 if(IsAtWar(ePlayer))21597 iWeight += 2;2159821599 MajorCivApproachTypes eThirdPartyApproach;2160021601 // Look for other players we like or are strong, and add a bonus if they've denounced this guy, or are at war with him21602 PlayerTypes eThirdParty;21603 CvDiplomacyAI* pThirdPartyDiplo;21604 for(int iThirdParty = 0; iThirdParty < MAX_MAJOR_CIVS; iThirdParty++)21605 {21606 eThirdParty = (PlayerTypes) iThirdParty;21607 pThirdPartyDiplo = GET_PLAYER(eThirdParty).GetDiplomacyAI();2160821609 // War or Denounced ePlayer, so we know eThirdParty doesn't like him21610 if(!pThirdPartyDiplo->IsDenouncedPlayer(ePlayer)) // && !pThirdPartyDiplo->IsAtWar(ePlayer))21611 continue;2161221613 // We must not be on bad relations with eThirdParty21614 if(GetMajorCivOpinion(eThirdParty) <= MAJOR_CIV_OPINION_COMPETITOR)21615 continue;2161621617 // If we're hostile or planning war, we don't care about this guy21618 eThirdPartyApproach = GetMajorCivApproach(eThirdParty, /*bHideTrueFeelings*/ false);21619 if(eThirdPartyApproach == MAJOR_CIV_APPROACH_HOSTILE || eThirdPartyApproach == MAJOR_CIV_APPROACH_WAR)21620 continue;2162121622 // We're close to this guy who's at war - want to gain favor21623 if(GetPlayer()->GetProximityToPlayer(eThirdParty) == PLAYER_PROXIMITY_NEIGHBORS)21624 iWeight += 1;2162521626 // Are they strong?21627 if(GetPlayerMilitaryStrengthComparedToUs(eThirdParty) > STRENGTH_AVERAGE)21628 iWeight += (GetPlayerMilitaryStrengthComparedToUs(eThirdParty) - STRENGTH_AVERAGE); // Ex: if they're immense, this will add 3 to the weight2162921630 // Are we friends with them?21631 if(IsDoFAccepted(eThirdParty))21632 iWeight += 4;21633 }2163421635 // Rand: 0-521636 iWeight += GC.getGame().getJonRandNum(5, "Diplomacy AI: Rand for whether AI wants to work with player");2163721638 // Used when friends are asking us to denounce someone21639 if(bBias)21640 iWeight += 3;2164121642 return iWeight;21643}
Calls
- CvDiplomacyAI::GetDenounceWillingness() const
- CvDiplomacyAI::GetMajorCivApproach(PlayerTypes, bool) const
- CvDiplomacyAI::GetMajorCivOpinion(PlayerTypes) const
- CvDiplomacyAI::GetPlayer()
- CvDiplomacyAI::GetPlayerMilitaryStrengthComparedToUs(PlayerTypes) const
- CvDiplomacyAI::IsAtWar(PlayerTypes)
- CvDiplomacyAI::IsDenouncedPlayer(PlayerTypes) const
- CvDiplomacyAI::IsDoFAccepted(PlayerTypes) const
- CvGame::getJonRandNum(int, const char *)
- CvGlobals::getGame()
- CvPlayer::GetDiplomacyAI() const
- CvPlayer::GetProximityToPlayer(PlayerTypes) const
- CvPlayerAI::getPlayer(PlayerTypes)