So how do you know what the four magic ResponseXyz parameters need to be?
Unfortunately the answer to that involves digging into the Lua code, and, if you want to be very sure of what you're doing, you really need to also delve into the C++ code. Fortunately the delving is quite simple - it's just a case of searching various files and carefully following the breadcrumb trail.
Firstly you need to know what the RESPONSE_ type is that the diplomacy screen is displaying.
So you were playing happily, clicked "End Turn" and went to go get a coffee. On your return, instead of being ready for your next turn, the game is paused with an AI whinging about you buying land that they consider their's. The exact text is
"Your purchase of land in my vicinity has caused some alarm. I caution you so that this issue does not become more serious." The key part here is "purchase of land", so search the core Civ5*.xml files for this text ... you'll find it in Civ5_Dialog__GENERIC.xml and it's associated with the TXT_KEY_PLOT_BUYING_WARNING_1 key. Ignore the _1 bit on the end and search the Civ5Diplomacy_Responses.xml file for "TXT_KEY_PLOT_BUYING_WARNING" ... it's associated with the RESPONSE_PLOT_BUYING_WARNING key. Eureka! We know what the RESPONSE_ type is.
But that's only half the problem. We also need to find out what, if any, player replies are available. Unfortunately, the Lua UI doesn't use RESPONSE_ type keys, but a different DIPLO_UI_STATE_ type key ... and the mapping between these is in the C++ code. So you can either delve into the C++ code (not difficult, see below) or you'll have to figure out what the possible replies are by deconstructing the Lua (really not recommended). The C++ route is not hard and not open to interpretation errors.
Using a plain text editor, open the CvDiplomacyAI.cpp file in the CvGameCoreDLL_Expansion2 source code sub-directory of the SDK and search it for RESPONSE_PLOT_BUYING_WARNING, you'll find a block of code like
Code:
// AI is warning player about his plot buying
case DIPLO_MESSAGE_PLOT_BUYING_WARNING:
strText = GetDiploTextFromTag("RESPONSE_PLOT_BUYING_WARNING");
break;
We want the DIPLO_MESSAGE_PLOT_BUYING_WARNING bit. Search the same file from the top for that and you'll find a block of code like
Code:
szText = GetDiploStringForMessage(DIPLO_MESSAGE_PLOT_BUYING_WARNING);
CvDiplomacyRequests::SendRequest(GetPlayer()->GetID(), ePlayer, DIPLO_UI_STATE_DISCUSS_YOU_PLOT_BUYING_WARNING, szText, LEADERHEAD_ANIM_NEGATIVE);
we want the DIPLO_UI_STATE_DISCUSS_YOU_PLOT_BUYING_WARNING bit.
NOTE: Avoid the temptation to assume that you can deduce the DIPLO_UI_STATE_ type from the RESPONSE_ type (as they appear to share the same ending) ... trust me, it doesn't work!
Armed with DIPLO_UI_STATE_DISCUSS_YOU_PLOT_BUYING_WARNING, we are now ready to delve into the Lua to find out the possible human player replies
Open DiscussionDialog.lua (make sure you've got the BNW one!) with a plain text editor and search for DIPLO_UI_STATE_DISCUSS_YOU_PLOT_BUYING_WARNING, you'll find several blocks of code
Code:
elseif (iDiploUIState == DiploUIStateTypes.DIPLO_UI_STATE_DISCUSS_YOU_PLOT_BUYING_WARNING) then
bMyMode = true;
Code:
elseif (g_DiploUIState == DiploUIStateTypes.DIPLO_UI_STATE_DISCUSS_YOU_PLOT_BUYING_WARNING) then
strButton1Text = Locale.ConvertTextKey( "TXT_KEY_DIPLO_DISCUSS_NOT_YOUR_BUSINESS" );
strButton2Text = Locale.ConvertTextKey( "TXT_KEY_DIPLO_DISCUSS_SORRY_FOR_CLAIMING" );
bHideBackButton = true;
Code:
-- AI warning us about plot buying - we tell him to go away
elseif (g_DiploUIState == DiploUIStateTypes.DIPLO_UI_STATE_DISCUSS_YOU_PLOT_BUYING_WARNING) then
Game.DoFromUIDiploEvent( FromUIDiploEventTypes.FROM_UI_DIPLO_EVENT_PLOT_BUYING_WARNING_RESPONSE, g_iAIPlayer, iButtonID, 0 );
Code:
-- AI warning us about plot buying - we apologize
elseif (g_DiploUIState == DiploUIStateTypes.DIPLO_UI_STATE_DISCUSS_YOU_PLOT_BUYING_WARNING) then
Game.DoFromUIDiploEvent( FromUIDiploEventTypes.FROM_UI_DIPLO_EVENT_PLOT_BUYING_WARNING_RESPONSE, g_iAIPlayer, iButtonID, 0 );
The first block is just setting up the diplomacy screen, if you don't find something like it, you can't automate the reply with this process
The second block is setting up the text on the reply buttons - typically these are buttons 1 and 2, but not always, so take note of which buttons are being configured
The third and fourth blocks are what happens when the player clicks a button - block three for button 1 (go away) and block 4 for button 2 (I'm sorry). As we want to tell the AI to eff off, we're interested in block 3
Specifically the DoFromUIDiploEvent() call
Code:
Game.DoFromUIDiploEvent(FromUIDiploEventTypes.FROM_UI_DIPLO_EVENT_PLOT_BUYING_WARNING_RESPONSE, g_iAIPlayer, iButtonID, 0)
as the four parameters to this call correspond directly to the four parameters we need to set in the Diplomacy_Stfu entry
In the LiveTuner/FireTuner console, select WorldView and enter "FromUIDiploEventTypes.FROM_UI_DIPLO_EVENT_PLOT_BUYING_WARNING_RESPONSE" and press return, you'll get the number 17 back. We don't care what the value of g_iAIPlayer is, just that it's not -1, and as this is the action for button 1 iButtonID will be 1 (you can find it higher up in the Lua code). Which is how we get all the required values
Code:
<!-- Need to fake up Game.DoFromUIDiploEvent(FromUIDiploEventTypes.FROM_UI_DIPLO_EVENT_PLOT_BUYING_WARNING_RESPONSE, iAiPlayer, 1, 0) -->
<Respond>true</Respond>
<ResponseEvent>17</ResponseEvent>
<ResponseAI>true</ResponseAI>
<ResponseData1>1</ResponseData1>
<ResponseData2>0</ResponseData2>
NOTE: if the 2nd parameter (g_iAIPlayer) to DoFromUIDiploEvent had been -1, ResponseAI would have been set to false