CvDiplomacyAI::DoUpdatePlanningExchanges()
- Defined in
- CvDiplomacyAI.cpp, line 7395
- Class
- CvDiplomacyAI
- Hook name
CivHooks::CvDiplomacyAI_DoUpdatePlanningExchanges
Hooks
static bool BeforeCvDiplomacyAI_DoUpdatePlanningExchanges(CvDiplomacyAI* self);static void AfterCvDiplomacyAI_DoUpdatePlanningExchanges(CvDiplomacyAI* self);static void ReplaceCvDiplomacyAI_DoUpdatePlanningExchanges(void (*original)(CvDiplomacyAI*), CvDiplomacyAI* self);CivRegisterBefore<CivHooks::CvDiplomacyAI_DoUpdatePlanningExchanges>(host, &BeforeCvDiplomacyAI_DoUpdatePlanningExchanges);CivRegisterAfter<CivHooks::CvDiplomacyAI_DoUpdatePlanningExchanges>(host, &AfterCvDiplomacyAI_DoUpdatePlanningExchanges);CivRegisterReplace<CivHooks::CvDiplomacyAI_DoUpdatePlanningExchanges>(host, &ReplaceCvDiplomacyAI_DoUpdatePlanningExchanges);
Code
7395void CvDiplomacyAI::DoUpdatePlanningExchanges()7396{7397 //int iRandRoll;7398 //int iThreshold;73997400 int iNumRAsWanted = GetNumResearchAgreementsWanted();74017402 // Loop through all (known) Players7403 PlayerTypes eLoopPlayer;7404 for(int iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++)7405 {7406 eLoopPlayer = (PlayerTypes) iPlayerLoop;74077408 if(IsPlayerValid(eLoopPlayer))7409 {7410 // RESEARCH AGREEMENT7411 // Do we already have a RA?7412 if(!GET_TEAM(GetPlayer()->getTeam()).IsHasResearchAgreement(GET_PLAYER(eLoopPlayer).getTeam()))7413 {7414 // If we're Friendly and have the appropriate Tech, there's a chance we want to make a Research Agreement7415 if(!IsWantsResearchAgreementWithPlayer(eLoopPlayer))7416 {7417 //if(GetMajorCivApproach(eLoopPlayer, /*bHideTrueFeelings*/ true) == MAJOR_CIV_APPROACH_FRIENDLY)7418 //{7419 if(GET_TEAM(GetPlayer()->getTeam()).IsResearchAgreementTradingAllowedWithTeam(GET_PLAYER(eLoopPlayer).getTeam()) || // We have Tech & embassy to make a RA7420 GET_TEAM(GET_PLAYER(eLoopPlayer).getTeam()).IsResearchAgreementTradingAllowedWithTeam(GetPlayer()->getTeam())) // They have Tech & embassy to make RA7421 {7422 //iRandRoll = GC.getGame().getJonRandNumVA(100, "DIPLOMACY_AI: Random weight for player to make Research Agreement (%d; %d)", (int)GetPlayer()->GetID(), (int)eLoopPlayer);74237424 //iThreshold = /*8*/ GC.getWANT_RESEARCH_AGREEMENT_RAND();74257426 //iThreshold -= (iNumRAsWanted * 6); // Reduce the likelihood of making another another RA if we've already got some on the books. These things are expensive you know74277428 //if(iRandRoll < iThreshold)7429 //{7430 DoAddWantsResearchAgreementWithPlayer(eLoopPlayer);7431 iNumRAsWanted++; // This was calculated above, increment it by one since we know we've added another7432 //}7433 }7434 //}7435 }7436 }74377438 // Already planning an RA?7439 if(IsWantsResearchAgreementWithPlayer(eLoopPlayer))7440 {7441 bool bCancel = false;7442 if(GetMajorCivApproach(eLoopPlayer, /*bHideTrueFeelings*/ true) == MAJOR_CIV_APPROACH_HOSTILE)7443 {7444 bCancel = true;7445 }7446 else if(!(GET_TEAM(GetPlayer()->getTeam()).IsResearchAgreementTradingAllowedWithTeam(GET_PLAYER(eLoopPlayer).getTeam()) || // We have Tech & embassy to make a RA7447 GET_TEAM(GET_PLAYER(eLoopPlayer).getTeam()).IsResearchAgreementTradingAllowedWithTeam(GetPlayer()->getTeam()))) // They have Tech & embassy to make RA7448 {7449 bCancel = true;7450 }7451 7452 if (bCancel)7453 {7454 DoCancelWantsResearchAgreementWithPlayer(eLoopPlayer);7455 }7456 }7457 }7458 }7459}
Calls
- CvDiplomacyAI::DoAddWantsResearchAgreementWithPlayer(PlayerTypes)
- CvDiplomacyAI::DoCancelWantsResearchAgreementWithPlayer(PlayerTypes)
- CvDiplomacyAI::GetMajorCivApproach(PlayerTypes, bool) const
- CvDiplomacyAI::GetNumResearchAgreementsWanted() const
- CvDiplomacyAI::GetPlayer()
- CvDiplomacyAI::IsPlayerValid(PlayerTypes, bool)
- CvDiplomacyAI::IsWantsResearchAgreementWithPlayer(PlayerTypes) const
- CvPlayer::getTeam() const
- CvPlayerAI::getPlayer(PlayerTypes)
- CvTeam::getTeam(TeamTypes)
- CvTeam::IsHasResearchAgreement(TeamTypes) const
- CvTeam::IsResearchAgreementTradingAllowedWithTeam(TeamTypes) const