Now, I bet the next thing on your mind is how you can use this for your own civilizations. Well, why don't we have a look at a few examples?
First, however, you need to understand how diplomacy responses work. They are made up of two parts - the entries in the
Diplomacy_Responses database table, and the
game text entries that actually contain the lines your leader will say in diplomacy. Here's how you define a diplomacy response for your leader:
Code:
<Row LeaderType="LEADER_BOWSER">
<ResponseType>RESPONSE_FIRST_GREETING</ResponseType>
<Response>TXT_KEY_LEADER_BOWSER_FIRSTGREETING%</Response>
<Bias>500</Bias>
</Row>
- LeaderType is pretty self-explanatory - it's the internal type of the leader you wish to define a response for. Using "GENERIC" will mean that all leaders will use this response (more on that in a moment).
- ResponseType defines what situation this response will be used for. In this case, "RESPONSE_FIRST_GREETING" means that the response will be used for the greeting the leader gives when they first meet the player. There are a huge amount of diplomacy response types you can set responses to, so if you're interested in giving your leader a comprehensive set of responses, it's a good idea to dive into the game files to see what you can use.
- Response is the actual game text entry that will be used. As you can see above, it accepts wildcards, allowing multiple responses to be used for a single response type without requiring multiple entries in the Diplomacy_Responses table. In this case, it will use any game text entry that has a tag starting with "TXT_KEY_LEADER_BOWSER_FIRSTGREETING". If you wanted to specify a specific response, simply use the whole game text tag - e.g. "TXT_KEY_LEADER_BOWSER_FIRSTGREETING_1".
- Bias is an optional entry, but one I recommend you include. For some reason, CiV will still pick out responses assigned to "GENERIC" even if you specify custom ones for your leader. Having a large bias is a way to avoid this - there's still a chance to see them, but it will be very rare.
While the above example is in XML, SQL is perfectly valid as well.
These are the game text entries the above code references:
Code:
<Row Tag="TXT_KEY_LEADER_BOWSER_FIRSTGREETING_1">
<Text>Gwah ha ha ha! I am Bowser, mighty, awesome king of the Koopas, and soon to be the ruler of this world! You better not be thinking about getting in my way!</Text>
</Row>
<Row Tag="TXT_KEY_LEADER_BOWSER_FIRSTGREETING_2">
<Text>Another leader? Bwah hah hah! I am Bowser The King! A word of warning: you'd better not be the kind of fool who would dare oppose me. Stomping fools is my business!</Text>
</Row>
<Row Tag="TXT_KEY_LEADER_BOWSER_FIRSTGREETING_3">
<Text>Gwa ha haaaaa! My name is Bowser, King of the Koopas![NEWLINE][NEWLINE]Why are you standing there with that stupid look on your face? You never seen a burly king of evil before?</Text>
</Row>
<Row Tag="TXT_KEY_LEADER_BOWSER_FIRSTGREETING_4">
<Text>I, Bowser, the mighty Koopa King, offer my greeting!</Text>
</Row>
Now, while those are a perfectly fine set of responses for Bowser when he's greeting a generic leader, there's a civilization for Princess Peach you can play with! Let's give him a unique first greeting for her.
First, we need to create a new game text entry or two to use as a greeting for Peach.
Code:
<Row Tag="TXT_KEY_LEADER_BOWSER_PEACH_FIRSTGREETING_1">
<Text>Well hello there Princess Peach! Good to see you as well on this brand new world. But don't think that you won't be by my side eventually!</Text>
</Row>
<Row Tag="TXT_KEY_LEADER_BOWSER_PEACH_FIRSTGREETING_2">
<Text>Hi there, Princess Peach! Don't worry, I'm not here to kidnap you yet! I'm just here to give you my greeting!</Text>
</Row>
(Please be careful with the tag you choose for your alternative responses - depending on the value of Response in the original Diplomacy_Responses entry, the game might accidentally pick out your alternative response under normal circumstances. The best way to be sure is to not use a tag that would match a wildcard in the original. For example, with
"TXT_KEY_LEADER_BOWSER_FIRSTGREETING%", a bad choice would be
"TXT_KEY_LEADER_BOWSER_FIRSTGREETING_PEACH_1", since
"_PEACH_1" will still be a match for the
"%" wildcard.)
Okay, now that we have this, how do you go about making that appear if you're playing Peach against an AI Bowser? We'll need to use Lua to get this working. Firstly, you will need to add UniqueDiplomacyUtilsV3.lua to your mod, and then set
Import into VFS to true.
Since we want to change an existing response - in this case, the one for the first greeting - we'll use
ChangeDiplomacyResponse() from UniqueDiplomacyUtilsV3.lua. Looking at the original Diplomacy_Responses entry, the leader type will be
"LEADER_BOWSER", and the target response type will be
"RESPONSE_FIRST_GREETING". Since there is only one normal first greeting entry in Diplomacy_Responses, we don't need to specify a target response. However, if we wanted to, the target response would be
"TXT_KEY_LEADER_BOWSER_FIRSTGREETING%". Since we have multiple game text entries to choose from, we can use
"TXT_KEY_LEADER_BOWSER_PEACH_FIRSTGREETING%" as the new response, and it should pick one from the two responses above (wildcards will still work if you have only specified one as well, as long as it matches the pattern). On this occasion we'll not specify a bias either, as it is already 500 in the original response entry.
To make sure this triggers only for a player controlled Peach, we need to check either the player's leader or civilization type. I personally go with the leader type, but civilization type should work in most cases unless a mod changes the leader for that type. In this case, we want to check if the player's leader type is
"LEADER_PEACH".
We can use
Game.GetActivePlayer() to get the ID of the currently active player and then check against the Players table to get the corresponding player object. Then, we can get the leader type as a string which can be used to compare to "LEADER_PEACH" - this method will prevent us from having to check if the leader type actually exists, which you would have to do if you were using GameInfoTypes to avoid an error. (Thank you to Vicevirutoso who came up with this method for his Leanbox and Lowee civs.)
Code:
include("UniqueDiplomacyUtilsV3.lua")
function BowserUniqueResponses()
local pActivePlayer = Players[Game.GetActivePlayer()]
local sLeaderType = GameInfo.Leaders[pActivePlayer:GetLeaderType()].Type
end
Now that we have the player's leader type in a string, it's a simple matter of checking if it matches the one we want:
Code:
include("UniqueDiplomacyUtilsV3.lua")
function BowserUniqueResponses()
local pActivePlayer = Players[Game.GetActivePlayer()]
local sLeaderType = GameInfo.Leaders[pActivePlayer:GetLeaderType()].Type
[COLOR="Blue"]if (sLeaderType == "LEADER_PEACH") then
ChangeDiplomacyResponse("LEADER_BOWSER", "RESPONSE_FIRST_GREETING", "TXT_KEY_LEADER_BOWSER_PEACH_FIRSTGREETING%")
end[/COLOR]
end
Finally, we need to call the
BowserUniqueResponses() function. You can simply add that to the end of the file, and it should trigger when the game starts.
Code:
include("UniqueDiplomacyUtilsV3.lua")
function BowserUniqueResponses()
local pActivePlayer = Players[Game.GetActivePlayer()]
local sLeaderType = GameInfo.Leaders[pActivePlayer:GetLeaderType()].Type
if (sLeaderType == "LEADER_PEACH") then
ChangeDiplomacyResponse("LEADER_BOWSER", "RESPONSE_FIRST_GREETING", "TXT_KEY_LEADER_BOWSER_PEACH_FIRSTGREETING%")
end
end
[COLOR="Blue"]BowserUniqueResponses()[/COLOR]
That's it! Bowser should choose from one of the Peach-specific lines if you're playing as Princess Peach. It's easy to follow the pattern to change more lines for a specific leader, and add other leaders for Bowser to interact with:
Code:
include("UniqueDiplomacyUtilsV3.lua")
function BowserUniqueResponses()
local pActivePlayer = Players[Game.GetActivePlayer()]
local sLeaderType = GameInfo.Leaders[pActivePlayer:GetLeaderType()].Type
if (sLeaderType == "LEADER_PEACH") then
ChangeDiplomacyResponse("LEADER_BOWSER", "RESPONSE_FIRST_GREETING", "TXT_KEY_LEADER_BOWSER_PEACH_FIRSTGREETING%")
[COLOR="Blue"]ChangeDiplomacyResponse("LEADER_BOWSER", "RESPONSE_DOW_WORLD_CONQUEST", "TXT_KEY_LEADER_BOWSER_PEACH_DOW_WORLD_CONQUEST%")
ChangeDiplomacyResponse("LEADER_BOWSER", "RESPONSE_LUXURY_TRADE", "TXT_KEY_LEADER_BOWSER_PEACH_LUXURY_TRADE%")
elseif (sLeaderType == "LEADER_TYPH_ROSALINA") then
ChangeDiplomacyResponse("LEADER_BOWSER", "RESPONSE_FIRST_GREETING", "TXT_KEY_LEADER_BOWSER_ROSALINA_FIRSTGREETING%")
ChangeDiplomacyResponse("LEADER_BOWSER", "RESPONSE_DOW_WORLD_CONQUEST", "TXT_KEY_LEADER_BOWSER_ROSALINA_DOW_WORLD_CONQUEST%")
ChangeDiplomacyResponse("LEADER_BOWSER", "RESPONSE_DOW_OPPORTUNITY", "TXT_KEY_LEADER_BOWSER_ROSALINA_DOW_WORLD_CONQUEST%")[/COLOR]
end
end
BowserUniqueResponses()
For performance reasons, you might want to run a quick check before calling the function to ensure that there is an AI player using your mod's leader in the game. You can also define all of the strings you want to check for as local variables at the start of the script to make it cleaner.
Code:
include("UniqueDiplomacyUtilsV3.lua")
[COLOR="Blue"]local sLeaderPeach = "LEADER_PEACH"
local sLeaderRosalina = "LEADER_TYPH_ROSALINA"[/COLOR]
function BowserUniqueResponses()
local pActivePlayer = Players[Game.GetActivePlayer()]
local sLeaderType = GameInfo.Leaders[pActivePlayer:GetLeaderType()].Type
if (sLeaderType == sLeaderPeach) then
ChangeDiplomacyResponse("LEADER_BOWSER", "RESPONSE_FIRST_GREETING", "TXT_KEY_LEADER_BOWSER_PEACH_FIRSTGREETING%")
ChangeDiplomacyResponse("LEADER_BOWSER", "RESPONSE_DOW_WORLD_CONQUEST", "TXT_KEY_LEADER_BOWSER_PEACH_DOW_WORLD_CONQUEST%")
ChangeDiplomacyResponse("LEADER_BOWSER", "RESPONSE_LUXURY_TRADE", "TXT_KEY_LEADER_BOWSER_PEACH_LUXURY_TRADE%")
elseif (sLeaderType == sLeaderRosalina) then
ChangeDiplomacyResponse("LEADER_BOWSER", "RESPONSE_FIRST_GREETING", "TXT_KEY_LEADER_BOWSER_ROSALINA_FIRSTGREETING%")
ChangeDiplomacyResponse("LEADER_BOWSER", "RESPONSE_DOW_WORLD_CONQUEST", "TXT_KEY_LEADER_BOWSER_ROSALINA_DOW_WORLD_CONQUEST%")
ChangeDiplomacyResponse("LEADER_BOWSER", "RESPONSE_DOW_OPPORTUNITY", "TXT_KEY_LEADER_BOWSER_ROSALINA_DOW_WORLD_CONQUEST%")
end
end
[COLOR="Blue"]for iPlayer = 0, GameDefines.MAX_MAJOR_CIVS - 1, 1 do
local pPlayer = Players[iPlayer]
if pPlayer ~= nil and pPlayer:IsAlive() and not pPlayer:IsHuman() and (pPlayer:GetCivilizationType() == GameInfo.Civilizations.CIVILIZATION_KOOPA_TROOP.ID) then
Events.SequenceGameInitComplete.Add(BowserUniqueResponses) -- Will add it to the event that triggers when the game is initialised
break
end
end[/COLOR]
Tutorials for more advanced ways to use UniqueDiplomacyUtilsV3.lua will come when I find time to write them.