CvDiplomacyAI::GetWarMessage(PlayerTypes)
- Defined in
- CvDiplomacyAI.cpp, line 20116
- Class
- CvDiplomacyAI
- Hook name
CivHooks::CvDiplomacyAI_GetWarMessage
Hooks
static bool BeforeCvDiplomacyAI_GetWarMessage(CvDiplomacyAI* self, PlayerTypes ePlayer, const char*& result);static void AfterCvDiplomacyAI_GetWarMessage(CvDiplomacyAI* self, PlayerTypes ePlayer, const char*& result);static const char* ReplaceCvDiplomacyAI_GetWarMessage(const char* (*original)(CvDiplomacyAI*, PlayerTypes), CvDiplomacyAI* self, PlayerTypes ePlayer);CivRegisterBefore<CivHooks::CvDiplomacyAI_GetWarMessage>(host, &BeforeCvDiplomacyAI_GetWarMessage);CivRegisterAfter<CivHooks::CvDiplomacyAI_GetWarMessage>(host, &AfterCvDiplomacyAI_GetWarMessage);CivRegisterReplace<CivHooks::CvDiplomacyAI_GetWarMessage>(host, &ReplaceCvDiplomacyAI_GetWarMessage);
Code
20115/// The AI is declaring war on a human, what does he say?20116const char* CvDiplomacyAI::GetWarMessage(PlayerTypes ePlayer)20117{20118 CvAssertMsg(ePlayer >= 0, "DIPLOMACY_AI: Invalid Player Index. Please send Jon this with your last 5 autosaves and what changelist # you're playing.");20119 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.");2012020121 const char* strText = "OMG I HAVE NO DATA (DECLARING WAR) - Please send Jon this with your last 5 autosaves and what changelist # you're playing.";2012220123 // Only show the message for the active human20124 if(GC.getGame().getActivePlayer() == ePlayer)20125 {20126 MajorCivApproachTypes eApproachHidingTrueFeelings = GetMajorCivApproach(ePlayer, /*bHideTrueFeelings*/ true);20127 StrengthTypes eMilitaryStrengthComparedToUs = GetPlayerMilitaryStrengthComparedToUs(ePlayer);2012820129 // Betrayal20130 // We were Friendly (either real or fake), so we can presume this AI is betraying20131 if(eApproachHidingTrueFeelings == MAJOR_CIV_APPROACH_FRIENDLY)20132 {20133 // Betrayal, and we're weak20134 if(eMilitaryStrengthComparedToUs >= STRENGTH_STRONG)20135 return GetDiploStringForMessage(DIPLO_MESSAGE_DOW_WEAK_BETRAYAL);2013620137 // Normal betrayal20138 else20139 return GetDiploStringForMessage(DIPLO_MESSAGE_DOW_BETRAYAL);20140 }2014120142 // Land Dispute20143 // If Land Dispute is Strong or higher then this is probably a strong contributer to the DoW20144 if(GetLandDisputeLevel(ePlayer) >= DISPUTE_LEVEL_STRONG)20145 return GetDiploStringForMessage(DIPLO_MESSAGE_DOW_LAND);2014620147 // Desperate20148 // The AI is desperate at this point in the game, and views a DoW as one of its only ways to slow an opponent20149 if(eMilitaryStrengthComparedToUs >= STRENGTH_STRONG)20150 return GetDiploStringForMessage(DIPLO_MESSAGE_DOW_DESPERATE);2015120152 // World Conquest20153 // A player with the Conquest Grand Strategy brags about his goals20154 if(IsGoingForWorldConquest())20155 return GetDiploStringForMessage(DIPLO_MESSAGE_DOW_WORLD_CONQUEST);2015620157 // Opportunity20158 // The AI sees an opportunity because the opponent is weak20159 if(eMilitaryStrengthComparedToUs <= STRENGTH_POOR)20160 return GetDiploStringForMessage(DIPLO_MESSAGE_DOW_OPPORTUNITY);2016120162 // Generic DoW... probably shouldn't ever really use this20163 return GetDiploStringForMessage(DIPLO_MESSAGE_DOW_GENERIC);20164 }2016520166 return strText;20167}
Calls
- CvDiplomacyAI::GetDiploStringForMessage(DiploMessageTypes, PlayerTypes)
- CvDiplomacyAI::GetLandDisputeLevel(PlayerTypes) const
- CvDiplomacyAI::GetMajorCivApproach(PlayerTypes, bool) const
- CvDiplomacyAI::GetPlayerMilitaryStrengthComparedToUs(PlayerTypes) const
- CvDiplomacyAI::IsGoingForWorldConquest()
- CvGame::getActivePlayer() const
- CvGlobals::getGame()