CvDiplomacyAI::DoUpdateEstimateOtherPlayerVictoryDisputeLevels()
- Defined in
- CvDiplomacyAI.cpp, line 8738
- Class
- CvDiplomacyAI
- Hook name
CivHooks::CvDiplomacyAI_DoUpdateEstimateOtherPlayerVictoryDisputeLevels
Hooks
static bool BeforeCvDiplomacyAI_DoUpdateEstimateOtherPlayerVictoryDisputeLevels(CvDiplomacyAI* self);static void AfterCvDiplomacyAI_DoUpdateEstimateOtherPlayerVictoryDisputeLevels(CvDiplomacyAI* self);static void ReplaceCvDiplomacyAI_DoUpdateEstimateOtherPlayerVictoryDisputeLevels(void (*original)(CvDiplomacyAI*), CvDiplomacyAI* self);CivRegisterBefore<CivHooks::CvDiplomacyAI_DoUpdateEstimateOtherPlayerVictoryDisputeLevels>(host, &BeforeCvDiplomacyAI_DoUpdateEstimateOtherPlayerVictoryDisputeLevels);CivRegisterAfter<CivHooks::CvDiplomacyAI_DoUpdateEstimateOtherPlayerVictoryDisputeLevels>(host, &AfterCvDiplomacyAI_DoUpdateEstimateOtherPlayerVictoryDisputeLevels);CivRegisterReplace<CivHooks::CvDiplomacyAI_DoUpdateEstimateOtherPlayerVictoryDisputeLevels>(host, &ReplaceCvDiplomacyAI_DoUpdateEstimateOtherPlayerVictoryDisputeLevels);
Code
8737/// Updates what is our guess as to the levels of Dispute between other players over Victory is8738void CvDiplomacyAI::DoUpdateEstimateOtherPlayerVictoryDisputeLevels()8739{8740 PlayerTypes eLoopOtherPlayer;8741 int iOtherPlayerLoop;87428743 int iVictoryDisputeWeight;87448745 DisputeLevelTypes eDisputeLevel;87468747 // Loop through all (known) Majors8748 PlayerTypes eLoopPlayer;8749 for(int iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++)8750 {8751 eLoopPlayer = (PlayerTypes) iPlayerLoop;87528753 if(IsPlayerValid(eLoopPlayer))8754 {8755 // Now loop through every player HE knows8756 for(iOtherPlayerLoop = 0; iOtherPlayerLoop < MAX_MAJOR_CIVS; iOtherPlayerLoop++)8757 {8758 eLoopOtherPlayer = (PlayerTypes) iOtherPlayerLoop;87598760 // Don't compare a player to himself8761 if(eLoopPlayer != eLoopOtherPlayer)8762 {8763 // Do both we and the guy we're looking about know the third guy?8764 if(IsPlayerValid(eLoopOtherPlayer) && GET_PLAYER(eLoopPlayer).GetDiplomacyAI()->IsPlayerValid(eLoopOtherPlayer))8765 {8766 eDisputeLevel = DISPUTE_LEVEL_NONE;8767 iVictoryDisputeWeight = 0;87688769 // Do we think their Grand Strategies match?8770 if(GetPlayer()->GetGrandStrategyAI()->GetGuessOtherPlayerActiveGrandStrategy(eLoopPlayer) == GetPlayer()->GetGrandStrategyAI()->GetGuessOtherPlayerActiveGrandStrategy(eLoopOtherPlayer))8771 {8772 switch(GetPlayer()->GetGrandStrategyAI()->GetGuessOtherPlayerActiveGrandStrategyConfidence(eLoopPlayer))8773 {8774 case GUESS_CONFIDENCE_POSITIVE:8775 iVictoryDisputeWeight += /*7*/ GC.getVICTORY_DISPUTE_OTHER_PLAYER_GRAND_STRATEGY_MATCH_POSITIVE();8776 break;8777 case GUESS_CONFIDENCE_LIKELY:8778 iVictoryDisputeWeight += /*5*/ GC.getVICTORY_DISPUTE_OTHER_PLAYER_GRAND_STRATEGY_MATCH_LIKELY();8779 break;8780 case GUESS_CONFIDENCE_UNSURE:8781 iVictoryDisputeWeight += /*3*/ GC.getVICTORY_DISPUTE_OTHER_PLAYER_GRAND_STRATEGY_MATCH_UNSURE();8782 break;8783 }8784 switch(GetPlayer()->GetGrandStrategyAI()->GetGuessOtherPlayerActiveGrandStrategyConfidence(eLoopOtherPlayer))8785 {8786 case GUESS_CONFIDENCE_POSITIVE:8787 iVictoryDisputeWeight += /*7*/ GC.getVICTORY_DISPUTE_OTHER_PLAYER_GRAND_STRATEGY_MATCH_POSITIVE();8788 break;8789 case GUESS_CONFIDENCE_LIKELY:8790 iVictoryDisputeWeight += /*5*/ GC.getVICTORY_DISPUTE_OTHER_PLAYER_GRAND_STRATEGY_MATCH_LIKELY();8791 break;8792 case GUESS_CONFIDENCE_UNSURE:8793 iVictoryDisputeWeight += /*3*/ GC.getVICTORY_DISPUTE_OTHER_PLAYER_GRAND_STRATEGY_MATCH_UNSURE();8794 break;8795 }87968797 // Add weight for Player's competitiveness: assume default (5), since we can't actually know how competitive a player is8798 iVictoryDisputeWeight *= /*5*/ GC.getDEFAULT_FLAVOR_VALUE();87998800 // Example Victory Dispute Weights8801 // Positive on Both: 708802 // Positive, Unsure: 508803 // Unsure, Unsure: 3088048805 // Now See what our new Dispute Level should be8806 if(iVictoryDisputeWeight >= /*70*/ GC.getVICTORY_DISPUTE_OTHER_PLAYER_FIERCE_THRESHOLD())8807 eDisputeLevel = DISPUTE_LEVEL_FIERCE;8808 else if(iVictoryDisputeWeight >= /*50*/ GC.getVICTORY_DISPUTE_OTHER_PLAYER_STRONG_THRESHOLD())8809 eDisputeLevel = DISPUTE_LEVEL_STRONG;8810 else if(iVictoryDisputeWeight >= /*30*/ GC.getVICTORY_DISPUTE_OTHER_PLAYER_WEAK_THRESHOLD())8811 eDisputeLevel = DISPUTE_LEVEL_WEAK;8812 }88138814 // Actually set the Level8815 SetEstimateOtherPlayerVictoryDisputeLevel(eLoopPlayer, eLoopOtherPlayer, eDisputeLevel);8816 }8817 }8818 }8819 }8820 }8821}
Calls
- CvDiplomacyAI::GetPlayer()
- CvDiplomacyAI::IsPlayerValid(PlayerTypes, bool)
- CvDiplomacyAI::SetEstimateOtherPlayerVictoryDisputeLevel(PlayerTypes, PlayerTypes, DisputeLevelTypes)
- CvGlobals::getDEFAULT_FLAVOR_VALUE()
- CvGlobals::getVICTORY_DISPUTE_OTHER_PLAYER_FIERCE_THRESHOLD()
- CvGlobals::getVICTORY_DISPUTE_OTHER_PLAYER_GRAND_STRATEGY_MATCH_LIKELY()
- CvGlobals::getVICTORY_DISPUTE_OTHER_PLAYER_GRAND_STRATEGY_MATCH_POSITIVE()
- CvGlobals::getVICTORY_DISPUTE_OTHER_PLAYER_GRAND_STRATEGY_MATCH_UNSURE()
- CvGlobals::getVICTORY_DISPUTE_OTHER_PLAYER_STRONG_THRESHOLD()
- CvGlobals::getVICTORY_DISPUTE_OTHER_PLAYER_WEAK_THRESHOLD()
- CvGrandStrategyAI::GetGuessOtherPlayerActiveGrandStrategy(PlayerTypes) const
- CvGrandStrategyAI::GetGuessOtherPlayerActiveGrandStrategyConfidence(PlayerTypes) const
- CvPlayer::GetDiplomacyAI() const
- CvPlayer::GetGrandStrategyAI() const
- CvPlayerAI::getPlayer(PlayerTypes)