UniqueDiplomacyUtils A Lua addon for mods that assists in defining unique diplomacy dialogue Version 3 download This is a set of Lua functions I wrote for the purpose of changing diplomacy lines dynamically, depending on certain conditions. Many of you will know of Ryoga's Unique Cultural Influence, which allows the diplomacy line that appears when you are culturally influential over another civilization from the default "blue jeans and pop music" line to something a bit more fitting for who you are playing as. This is an expansion of that concept and is intended to make it easy for modders to change lines depending on certain other conditions, primarily the leader the player is playing as. UniqueDiplomacyUtils provides two different ways to do this: altering the entries in the Diplomacy_Responses table, or changing game text entries directly. While it is intended to be used as a VFS-imported file that is included in your own Lua script, you are of course free to copy and adapt the code into your own scripts. Important note: Since these functions directly alter database tables, the changes you make will persist when you load a new game without returning to the main menu. It is possible to code your unique diplomacy lua so it resets to the default when a game is loaded, though there are few circumstances where this would actually be an issue so it is up to you whether you wish to put the effort in. Functions for altering the Diplomacy_Responses table: ChangeDiplomacyResponse(leaderType, targetResponseType, newResponse, targetResponse, bias) Changes an existing diplomacy response to reference other entries in your game text. bias is optional, and only one of targetResponseType and targetResponse is required (though you can specify both, if you want). Passing nil to the former will replace all entries that match targetResponse regardless of their response type, while passing nil to the latter will replace all entries that match the targetResponseType. Not specifying a bias will preserve the existing one. targetResponse is moved for version 3 because for most people's purposes, there is no need to check for a specific response, and so it can be omitted (though if you want to specifiy a bias without a targetResponse, you will still need to pass nil as the fourth parameter). AddDiplomacyResponse(leaderType, targetResponseType, newResponse, bias) Adds a new diplomacy response that references entries in your game text. Bias is again optional, and will default to 1 if you do not pass one. RemoveDiplomacyResponse(leaderType, targetResponseType, targetResponse) Removes an existing diplomacy response. All parameters are required for safety. Unless you remove the leader's RESPONSE_FIRST_GREETING or RESPONSE_DEFEATED (as by default there is no generic entry for either), your leader will use the generic diplomacy lines if you remove all of their custom ones. Functions for altering the entries in the game text database directly: ChangeDiplomacyGameText(targetText, newText) Overwrites the contents of targetText with the contents of newText in the current locale. AddDiplomacyGameText(targetText, newText) Copies the contents of newText into a new game text entry targetText in the current locale. RemoveDiplomacyGameText(targetText) Removes targetText from the database in the current locale. Be careful when using this as you can't get it back unless you copy the entry elsewhere first! ChangeDiplomacyGameTextToString(targetText, newString, locale) Overwrites the contents of targetText with the string newString. Locale is optional - it will use the current locale if you do not specify one. If you do pass a locale, it expects it in the form "Language_??_??". AddDiplomacyGameTextFromString(targetText, newString, locale) Creates a game text entry targetText with the contents newString. Locale is optional - it will use the current locale if you do not specify one. If you do pass a locale, it expects it in the form "Language_??_??". Note that since game text entries are not specific to diplomacy, you can use these functions to replace any game text you might need. While it is safer to alter entries in Diplomacy_Responses (it's difficult to restore game text after you change it, after all), I've still included them for those people who know what they're doing. New in version 3: targetResponse is now optional in ChangeDiplomacyResponse, and is moved in the list of parameters. You'll need to change your calls to the function if you wish to use the new version - removing or moving the targetResponse parameter, depending on what you need. --------------------------------------- Examples: JFD's Empire of Byzantium (Alexios I Komnenos) - first greeting when playing as Theodora. Spoiler : Vicevirtuoso's Planeptune Mk2 - first greeting when playing as Mogarane's Neptune. Spoiler : Typhlomence's Koopa Troop - example of a response that both is dynamic in content and changes between turns. Bowser will talk about kidnapping female leaders if they are present, and the actual line will change depending on whether the player's leader is male or female and whether Princess Peach is in the game. It will only appear if Bowser has actually met any female leaders, and if so, it will pick a random one out of those he has met to appear in the actual line. Spoiler : While I can't show it here due to foul language, Vicevirtuoso's Lowee is also a great example for lines changing under certain circumstances - in this case, depending on Blanc's mood towards the player.