Skip to content

Commit

Permalink
Add DIPLO_STATEMENT_COOP_WAR_WARNING
Browse files Browse the repository at this point in the history
AI warns human that another AI asked them to start a coop war against human
  • Loading branch information
RecursiveVision committed Dec 4, 2024
1 parent 6949fdd commit 759d9dc
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@
<Response>TXT_KEY_GENERIC_RESPONSE_SHARE_INTRIGUE_COOP_WAR%</Response>
</Row>

<!-- AI warns human that another AI asked them to start a coop war against human -->
<Row LeaderType="GENERIC">
<ResponseType>RESPONSE_COOP_WAR_WARNING</ResponseType>
<Response>TXT_KEY_GENERIC_RESPONSE_COOP_WAR_WARNING%</Response>
</Row>

<!-- AI requests help -->
<Row LeaderType="GENERIC">
<ResponseType>RESPONSE_GENEROUS_OFFER</ResponseType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2311,6 +2311,15 @@
<Text>Our spies have uncovered that {1_PlayerName} and {2_PlayerName} are preparing to go to war with you. We hope that you will share any intrigue your agents discover with us.</Text>
</Row>

<!-- AI warns human that another AI asked them to start a coop war against human -->
<!-- Technically intrigue, but not shared in the same way -->
<Row Tag="TXT_KEY_GENERIC_RESPONSE_COOP_WAR_WARNING_1">
<Text>{1_PlayerName} attempted to persuade us to start a cooperative war against you. I hope my rejection of their offer pleases you.</Text>
</Row>
<Row Tag="TXT_KEY_GENERIC_RESPONSE_COOP_WAR_WARNING_2">
<Text>While {1_PlayerName} is my friend, I just told them their plan for a joint war against you was unacceptable. Beware their intentions!</Text>
</Row>

<!--// STATEMENTS //-->

<!-- Human is influential over us (Ancient/Classical) -->
Expand Down
2 changes: 2 additions & 0 deletions CvGameCoreDLLUtil/include/CvEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,8 @@ enum CLOSED_ENUM DiploMessageTypes
DIPLO_MESSAGE_SHARE_INTRIGUE_BRIBE_WAR,
DIPLO_MESSAGE_SHARE_INTRIGUE_COOP_WAR,

DIPLO_MESSAGE_COOP_WAR_WARNING, // Technically intrigue, but not shared in the same way

DIPLO_MESSAGE_HUMAN_KILLED_MY_SPY_UNFORGIVEN,
DIPLO_MESSAGE_HUMAN_KILLED_MY_SPY_FORGIVEN,

Expand Down
34 changes: 28 additions & 6 deletions CvGameCoreDLL_Expansion2/CvDiplomacyAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37311,6 +37311,11 @@ const char* CvDiplomacyAI::GetDiploStringForMessage(DiploMessageTypes eDiploMess
strText = GetDiploTextFromTag("RESPONSE_SHARE_INTRIGUE_COOP_WAR", strOptionalKey1, strOptionalKey2);
break;

// AI warns human that another AI asked them to start a coop war against human
case DIPLO_MESSAGE_COOP_WAR_WARNING:
strText = GetDiploTextFromTag("RESPONSE_COOP_WAR_WARNING", strOptionalKey1);
break;

// Human catches enemy spy and does not forgive the thief
case DIPLO_MESSAGE_HUMAN_KILLED_MY_SPY_UNFORGIVEN:
strText = GetDiploTextFromTag("RESPONSE_HUMAN_KILLED_MY_SPY_UNFORGIVEN");
Expand Down Expand Up @@ -41871,12 +41876,6 @@ CoopWarStates CvDiplomacyAI::RespondToCoopWarRequest(PlayerTypes eAskingPlayer,
/// We rejected eAskingPlayer's request to go to war with eTargetPlayer, but should we warn the target?
bool CvDiplomacyAI::IsCoopWarRequestUnacceptable(PlayerTypes eAskingPlayer, PlayerTypes eTargetPlayer) const
{
// Don't warn humans - no dialogue for this
if (GET_PLAYER(eTargetPlayer).isHuman())
{
return false;
}

CivApproachTypes eApproachTowardsAsker = GetCivApproach(eAskingPlayer);
CivOpinionTypes eOpinionOfAsker = GetCivOpinion(eAskingPlayer);
CivApproachTypes eApproachTowardsTarget = GetCivApproach(eTargetPlayer);
Expand Down Expand Up @@ -41989,6 +41988,29 @@ void CvDiplomacyAI::DoWarnCoopWarTarget(PlayerTypes eAskingPlayer, PlayerTypes e
{
PlayerTypes eLoopPlayer = (PlayerTypes) iPlayerLoop;

// If human was target, send message
if (GET_PLAYER(eLoopPlayer).isHuman())
{
if (GET_PLAYER(eLoopPlayer).getTeam() == eTargetTeam && !CvPreGame::isNetworkMultiplayerGame() && GC.getGame().getActivePlayer() == eLoopPlayer && !GC.getGame().IsAllDiploStatementsDisabled())
{
const char* szPlayerName = NULL;
if (GC.getGame().isGameMultiPlayer() && GET_PLAYER(eAskingPlayer).isHuman())
{
szPlayerName = GET_PLAYER(eAskingPlayer).getNickName();
}
else
{
szPlayerName = GET_PLAYER(eAskingPlayer).getNameKey();
}

DLLUI->SetForceDiscussionModeQuitOnBack(true); // Set force quit so that when discuss mode pops up the Back button won't go to leader root
const char* strText = GetDiploStringForMessage(DIPLO_MESSAGE_COOP_WAR_WARNING, NO_PLAYER, szPlayerName);
gDLL->GameplayDiplomacyAILeaderMessage(GetID(), DIPLO_UI_STATE_BLANK_DISCUSSION, strText, LEADERHEAD_ANIM_POSITIVE);
}
continue;
}

// Process global reactions for AI players
if (IsPlayerValid(eLoopPlayer, true) && eLoopPlayer != eMyPlayer)
{
CvDiplomacyAI* pDiplo = GET_PLAYER(eLoopPlayer).GetDiplomacyAI();
Expand Down

0 comments on commit 759d9dc

Please sign in to comment.