Bazaar developer reference

CvDiplomacyAI::GetAttackedByHumanMessage()

Defined in
CvDiplomacyAI.cpp, line 20057
Class
CvDiplomacyAI
Hook name
CivHooks::CvDiplomacyAI_GetAttackedByHumanMessage

Hooks

static bool BeforeCvDiplomacyAI_GetAttackedByHumanMessage(CvDiplomacyAI* self, const char*& result);static void AfterCvDiplomacyAI_GetAttackedByHumanMessage(CvDiplomacyAI* self, const char*& result);static const char* ReplaceCvDiplomacyAI_GetAttackedByHumanMessage(const char* (*original)(CvDiplomacyAI*), CvDiplomacyAI* self);CivRegisterBefore<CivHooks::CvDiplomacyAI_GetAttackedByHumanMessage>(host, &BeforeCvDiplomacyAI_GetAttackedByHumanMessage);CivRegisterAfter<CivHooks::CvDiplomacyAI_GetAttackedByHumanMessage>(host, &AfterCvDiplomacyAI_GetAttackedByHumanMessage);CivRegisterReplace<CivHooks::CvDiplomacyAI_GetAttackedByHumanMessage>(host, &ReplaceCvDiplomacyAI_GetAttackedByHumanMessage);

Code

20056/// The human declares war on the AI, how does he respond?20057const char* CvDiplomacyAI::GetAttackedByHumanMessage()20058{20059	PlayerTypes ePlayer = GC.getGame().getActivePlayer();2006020061	MajorCivOpinionTypes eOpinion = GetMajorCivOpinion(ePlayer);20062	StrengthTypes eMilitaryStrengthComparedToUs = GetPlayerMilitaryStrengthComparedToUs(ePlayer);2006320064	// Military Promise Broken20065	// This player said he wasn't going to attack us but did anyways20066	if(IsPlayerBrokenMilitaryPromise(ePlayer))20067		return GetDiploStringForMessage(DIPLO_MESSAGE_ATTACKED_MILITARY_PROMISE_BROKEN);2006820069	// Sad20070	// If we felt the other player was an Ally or Friend then we're just plain sad that they attacked us20071	if(eOpinion == MAJOR_CIV_OPINION_ALLY ||20072	        eOpinion == MAJOR_CIV_OPINION_FRIEND)20073	{20074		return GetDiploStringForMessage(DIPLO_MESSAGE_ATTACKED_SAD);20075	}2007620077	// Betrayed	-	TBD20078	// This should be related to active deals, e.g. Open Borders, luxuries, etc.20079	if(false)20080		return GetDiploStringForMessage(DIPLO_MESSAGE_ATTACKED_BETRAYED);2008120082	// Excited20083	// A player with the Conquest Grand Strategy will be excited20084	// May also look at Boldness or Offense flavor in here eventually20085	{20086		if(IsGoingForWorldConquest())20087		{20088			// They are WEAKER than us20089			if(eMilitaryStrengthComparedToUs <= STRENGTH_WEAK)20090				return GetDiploStringForMessage(DIPLO_MESSAGE_ATTACKED_STRONG_EXCITED);2009120092			// They are STRONGER than us20093			else if(eMilitaryStrengthComparedToUs >= STRENGTH_POWERFUL)20094				return GetDiploStringForMessage(DIPLO_MESSAGE_ATTACKED_WEAK_EXCITED);2009520096			// Average strength20097			return GetDiploStringForMessage(DIPLO_MESSAGE_ATTACKED_EXCITED);20098		}20099	}2010020101	// Hostile20102	// This is the default response to being attacked20103	// We are STRONGER than the person who attacked us20104	if(eMilitaryStrengthComparedToUs <= STRENGTH_WEAK)20105		return GetDiploStringForMessage(DIPLO_MESSAGE_ATTACKED_STRONG_HOSTILE);2010620107	// We are WEAKER than the person who attacked us20108	else if(eMilitaryStrengthComparedToUs >= STRENGTH_POWERFUL)20109		return GetDiploStringForMessage(DIPLO_MESSAGE_ATTACKED_WEAK_HOSTILE);2011020111	// Average strength20112	return GetDiploStringForMessage(DIPLO_MESSAGE_ATTACKED_HOSTILE);20113}

Calls

Called by