CvDiplomacyAI::DoFYIBefriendedHumanEnemy(PlayerTypes, DiploStatementTypes &, int &)
- Defined in
- CvDiplomacyAI.cpp, line 15555
- Class
- CvDiplomacyAI
- Hook name
CivHooks::CvDiplomacyAI_DoFYIBefriendedHumanEnemy
Hooks
static bool BeforeCvDiplomacyAI_DoFYIBefriendedHumanEnemy(CvDiplomacyAI* self, PlayerTypes ePlayer, DiploStatementTypes& eStatement, int& iData1);static void AfterCvDiplomacyAI_DoFYIBefriendedHumanEnemy(CvDiplomacyAI* self, PlayerTypes ePlayer, DiploStatementTypes& eStatement, int& iData1);static void ReplaceCvDiplomacyAI_DoFYIBefriendedHumanEnemy(void (*original)(CvDiplomacyAI*, PlayerTypes, DiploStatementTypes&, int&), CvDiplomacyAI* self, PlayerTypes ePlayer, DiploStatementTypes& eStatement, int& iData1);CivRegisterBefore<CivHooks::CvDiplomacyAI_DoFYIBefriendedHumanEnemy>(host, &BeforeCvDiplomacyAI_DoFYIBefriendedHumanEnemy);CivRegisterAfter<CivHooks::CvDiplomacyAI_DoFYIBefriendedHumanEnemy>(host, &AfterCvDiplomacyAI_DoFYIBefriendedHumanEnemy);CivRegisterReplace<CivHooks::CvDiplomacyAI_DoFYIBefriendedHumanEnemy>(host, &ReplaceCvDiplomacyAI_DoFYIBefriendedHumanEnemy);
Code
15554/// Possible Contact Statement15555void CvDiplomacyAI::DoFYIBefriendedHumanEnemy(PlayerTypes ePlayer, DiploStatementTypes& eStatement, int& iData1)15556{15557 CvAssertMsg(ePlayer >= 0, "DIPLOMACY_AI: Invalid Player Index. Please send Jon this with your last 5 autosaves and what changelist # you're playing.");15558 CvAssertMsg(ePlayer < MAX_MAJOR_CIVS, "DIPLOMACY_AI: Invalid Player Index. Please send Jon this with your last 5 autosaves and what changelist # you're playing.");1555915560 if(eStatement == NO_DIPLO_STATEMENT_TYPE)15561 {15562 DiploStatementTypes eTempStatement = DIPLO_STATEMENT_FYI_BEFRIEND_HUMAN_ENEMY;1556315564 if(GetNumTurnsSinceStatementSent(ePlayer, eTempStatement) >= 50 &&15565 GetNumTurnsSinceStatementSent(ePlayer, DIPLO_STATEMENT_FYI_BEFRIEND_HUMAN_ENEMY_RANDFAILED) >= 20)15566 {15567 CvDiplomacyAI* pTheirDiploAI = GET_PLAYER(ePlayer).GetDiplomacyAI();1556815569 int iWeight;15570 MajorCivApproachTypes eApproach;15571 MajorCivOpinionTypes eOpinion;1557215573 // Loop through all players until we find one that we just made friends with, that ePlayer denounced15574 PlayerTypes eLoopPlayer;15575 for(int iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++)15576 {15577 eLoopPlayer = (PlayerTypes) iPlayerLoop;1557815579 // Must be alive15580 if(!GET_PLAYER(eLoopPlayer).isAlive())15581 continue;1558215583 // Can't be either of us15584 if(eLoopPlayer == GetPlayer()->GetID() || eLoopPlayer == ePlayer)15585 continue;1558615587 // We haven't befriended this guy15588 if(!IsDoFAccepted(eLoopPlayer))15589 continue;1559015591 // They haven't denounced this guy15592 if(!pTheirDiploAI->IsDenouncedPlayer(eLoopPlayer))15593 continue;1559415595 // Too much time has passed (or maybe we already sent a message recently)15596 if(GetDoFCounter(eLoopPlayer) > 1)15597 continue;1559815599 eOpinion = GetMajorCivOpinion(ePlayer);15600 eApproach = GetMajorCivApproach(ePlayer, /*bHideTrueFeelings*/ true);1560115602 // Don't say mean things if we like ePlayer15603 if(eOpinion >= MAJOR_CIV_OPINION_FAVORABLE)15604 continue;15605 if(eApproach == MAJOR_CIV_APPROACH_FRIENDLY)15606 continue;1560715608 iWeight = 0;1560915610 if(eOpinion == MAJOR_CIV_OPINION_COMPETITOR)15611 iWeight += 2;15612 else if(eOpinion == MAJOR_CIV_OPINION_ENEMY)15613 iWeight += 5;15614 else if(eOpinion == MAJOR_CIV_OPINION_UNFORGIVABLE)15615 iWeight += 10;1561615617 iWeight += GetMeanness(); // Usually ranges from 3 to 715618 iWeight += GC.getGame().getJonRandNum(7, "Random roll for AI statement: 0");1561915620 // We're mean enough to say something15621 if(iWeight >= 7)15622 {15623 eStatement = eTempStatement;15624 iData1 = eLoopPlayer;15625 }15626 // We're going to be nice!15627 else15628 {15629 eStatement = DIPLO_STATEMENT_FYI_BEFRIEND_HUMAN_ENEMY_RANDFAILED;15630 }1563115632 // We're done in here15633 break;15634 }15635 }15636 }15637}
Calls
- CvDiplomacyAI::GetDoFCounter(PlayerTypes) const
- CvDiplomacyAI::GetMajorCivApproach(PlayerTypes, bool) const
- CvDiplomacyAI::GetMajorCivOpinion(PlayerTypes) const
- CvDiplomacyAI::GetMeanness() const
- CvDiplomacyAI::GetNumTurnsSinceStatementSent(PlayerTypes, DiploStatementTypes)
- CvDiplomacyAI::GetPlayer()
- CvDiplomacyAI::IsDenouncedPlayer(PlayerTypes) const
- CvDiplomacyAI::IsDoFAccepted(PlayerTypes) const
- CvGame::getJonRandNum(int, const char *)
- CvGlobals::getGame()
- CvPlayer::GetDiplomacyAI() const
- CvPlayer::GetID() const
- CvPlayer::isAlive() const
- CvPlayerAI::getPlayer(PlayerTypes)