Sukritact's Events and Decisions

it's an amazing idea, i really like it!
however, it seems this mod doesn't work on my game. As shown in the upperleft in my attached screenshot, there is no option for decision enact. I am sure I installed the mod correctly, and I already saw palace provided Magistrates in my game. Am I doing anything wrong? Thanks.

I believe you should check the scroll icon on the upper right instead.
 
Hey Sukritact, how are the civilization specific decisions coming along?

No rush obviously, I just ask because between E&D and cultural diversity, I think civ-specific events would be the last step in making the core civs interesting again :D
 
Is it possible to have a decision grant a "bonus" religious belief (from the in-game list) that doesn't take up the normal religious belief slots?
 
Is it possible to have a decision grant a "bonus" religious belief (from the in-game list) that doesn't take up the normal religious belief slots?

Not really. With Whoward's DLL, you can sort of do it, though, by "enhancing" your Pantheon. That's nothing to do with decisions - what you can do with decisions is only limited to your skill and to what we have available in Lua.
 
Hm. The idea I have is to give all cities in the empire a free mosque as part of a decision. I'm presuming that means the civ in question will need to have the Mosques belief, right?
 
Oh, well, that's certainly doable. You don't need the belief - the belief just allows Mosques to be purchased (the Mosque of Djenne Wonder gives a free Mosque, IIRC). Just give every city a Mosque like you would any other building.
 
That fixes that. Thanks a ton, JFD!
 
When a decision comes up and I click on an option, the game crashes. It'll then give me another decision when I reboot to the same turn and won't crash until the next decision pops up but its kind of annoying. Any ideas why?
 
When a decision comes up and I click on an option, the game crashes. It'll then give me another decision when I reboot to the same turn and won't crash until the next decision pops up but its kind of annoying. Any ideas why?

Is it a science related decision? Might be the same bug I reported earlier.
G
 
How do you define a random AI Civ for an event?

I'm doing one for Vlad based on the story where he nailed hats to emissaries' heads. I'm also looking at JFD's All-German Crown event for structure. I know {1_CivName} is supposed to display the name of the chosen Civ, which for his event is picked from a defined list of German Civs that may/may not be in the game. Since I'm not sure which Civs would be in a game with Vlad, how would I have the lua define which Civ's emissaries they are?

On a related note, and mainly because I couldn't find it elsewhere, what is the difference between {1_CivName} and {2_CivName}? I'm kinda presuming the first is the adjective and the second is the formal, but I'm not sure.
 
How do you define a random AI Civ for an event?

I'm doing one for Vlad based on the story where he nailed hats to emissaries' heads. I'm also looking at JFD's All-German Crown event for structure. I know {1_CivName} is supposed to display the name of the chosen Civ, which for his event is picked from a defined list of German Civs that may/may not be in the game. Since I'm not sure which Civs would be in a game with Vlad, how would I have the lua define which Civ's emissaries they are?

On a related note, and mainly because I couldn't find it elsewhere, what is the difference between {1_CivName} and {2_CivName}? I'm kinda presuming the first is the adjective and the second is the formal, but I'm not sure.

I wouldn't look at the All-German Crown event, on account of the fact that it doesn't exist anymore :p

Here's an example of finding a random civ:

Code:
local activeCivs = {} [COLOR="Red"]-- define a local table where all active players are going to be stored[/COLOR]
local count = 1 [COLOR="Red"]-- counter for the spot that the active player is going to take in the table[/COLOR]
for playerID = 0, GameDefines.MAX_MAJOR_CIVS - 1 do [COLOR="Red"]-- loop over all major civs[/COLOR]
	local otherPlayer = Players[playerID] [COLOR="Red"]-- define the player object for the major civ in the loop[/COLOR]
	if not (otherPlayer:IsHuman()) and Teams[otherPlayer :GetTeam()]:IsHasMet(player:GetTeam()) then [COLOR="Red"]-- make sure the other player isn't the human player (AI's don't need this flavour, and if you're getting the event, we don't want to be talking about ourselves.) And make sure the player receiving the event knows the civ. Though you can use as conditions you see fit.[/COLOR]
		activeCivs[count] = otherPlayer [COLOR="Red"]-- add them to the table[/COLOR]
		count = count + 1 [COLOR="Red"]-- tell the counter to make room for the next player in the loop[/COLOR]
	end
end
			
randomCiv = randomCivs[GetRandom(1, #randomCivs)]	[COLOR="Red"]-- choose a random civ from the table we just filled out, between 1 and the number of civs in that table[/COLOR]
if randomCiv == nil then return false end [COLOR="Red"]-- if for some reason you return nil, stop here, but otherwise, we've chosen a random civ[/COLOR]

I recommend you define randomCiv as a local variable outside the event (you can see examples of these under the "Globals" heading in most of my events; just use
Code:
local randomCiv
No need to define what's in it. This way, you can retrieve info about the civ rolled anywhere in the event.

Then we can convert some unreadable TXT_KEYs with the civ's name, like so:

Code:
Locale.ConvertTextKey("TXT_KEY_JFD_SOMETHING", player:GetName(), randomCiv:GetName())

Then our text tiself would have two placeholders, {1_CivName} and {2_CivName} for example, where the first would be filled with the return value of "player:GetName()" and the second with the return value of "randomCiv:GetName()." It doesn't matter what these placeholders are called, so long as the number at the beginning corresponds to the order in which they are sent by the ConvertTextKey method. In this case, player:GetName() returns the leader's name, but you can use anything that returns a string or integer.

Hopefully this helped.
 
I just had an event, "a Great Star" or something alike, that gives a choice between a free great scientist or 2 free great artists. I chose the artists and the popup didn't disappear... I clicked on the scientist option and I got one, then I could click it again and get another. Then it disappeared. Is this a known bug?
 
I just had an event, "a Great Star" or something alike, that gives a choice between a free great scientist or 2 free great artists. I chose the artists and the popup didn't disappear... I clicked on the scientist option and I got one, then I could click it again and get another. Then it disappeared. Is this a known bug?

Just tested it in-game and both work fine.

Whenever you get a problem like this - and that goes for everyone - it is essential that you post your Lua and Database.logs (Lua, at least) and preferable that you post the mods you're using and what civ you're playing as. Nearly impossible to diagnose any bugs without that info, as everyone's game setups, and the times at which bugs occur, are unique. In this case, there definitely should be something in the Lua log.
 
Yes, you're right, sorry about that. Here are the logs. I seem to have some runtime issue with the Kalmar Union mod... I randomly (seemingly) get huge hang-ups when opening the city view, might be related.

Mods used:
Spoiler :
- Additional Ancient Ruins Rewards (v 1)
- CSD for BNW (v 26)
- Events and Decisions (v 1)
- Exploration Continued (v 3)
- Fewer Active Religions (v 1)
- Gibraltar, Reef and Krakatoa Fixes (v 101)
- Great Prophet Historical Names (v 26)
- Historical Religions Complete (v 6)
- India Civilization Pack (v 1)
- JFD's Alternate Leaders Pack (v 1)
- JFD's Civilization Pack 1 (v 1)
- JFD's Cultural Diversity (Core) (v 1)
- JFD's Cultural Diversity (Soundtrack) (v 1)
- JFD's Grand Duchy of Lithuania (v 1)
- JFD's HRE (v 2)
- JFD's Kingdom of France (v 1)
- JFD's Papal States (v 8)
- JFD's WW2 Pack (v 1)
- Krajzen's Great Musicians Pack (v 1)
- Less Ice on Maps (v 101)
- Map Labels (v 6)
- More Luxuries (v 155)
- More Pantheons - Addon (v 122)
- Natural Wonders Fix (v 1)
- Polynesian Civilization Pack (v 1)
- Randomize City Name (v 2)
- Really Advanced Setup - Civ Groups (v 1)
- Really Advanced Setup (v 13)
- Reform & Rule (BNW) (v 25)
- Resource - Granary Includes Bison (v 3)
- Resource Display Hotkey Mod (v 100)
- Ressource - Mint Includes Copper (v 2)
- Sukritact's MCIS (v 1)
- TarcisioCM's Iberians (v 1)
- Greater Europe's Kalmar Union (v 1)
- Greater Europe's Slavs (v 1)
- Unique Cultural Influence (v 4)
 

Attachments

I wouldn't look at the All-German Crown event, on account of the fact that it doesn't exist anymore :p

Here's an example of finding a random civ:

Code:
local activeCivs = {} [COLOR="Red"]-- define a local table where all active players are going to be stored[/COLOR]
local count = 1 [COLOR="Red"]-- counter for the spot that the active player is going to take in the table[/COLOR]
for playerID = 0, GameDefines.MAX_MAJOR_CIVS - 1 do [COLOR="Red"]-- loop over all major civs[/COLOR]
	local otherPlayer = Players[playerID] [COLOR="Red"]-- define the player object for the major civ in the loop[/COLOR]
	if not (otherPlayer:IsHuman()) and Teams[otherPlayer :GetTeam()]:IsHasMet(player:GetTeam()) then [COLOR="Red"]-- make sure the other player isn't the human player (AI's don't need this flavour, and if you're getting the event, we don't want to be talking about ourselves.) And make sure the player receiving the event knows the civ. Though you can use as conditions you see fit.[/COLOR]
		activeCivs[count] = otherPlayer [COLOR="Red"]-- add them to the table[/COLOR]
		count = count + 1 [COLOR="Red"]-- tell the counter to make room for the next player in the loop[/COLOR]
	end
end
			
randomCiv = randomCivs[GetRandom(1, #randomCivs)]	[COLOR="Red"]-- choose a random civ from the table we just filled out, between 1 and the number of civs in that table[/COLOR]
if randomCiv == nil then return false end [COLOR="Red"]-- if for some reason you return nil, stop here, but otherwise, we've chosen a random civ[/COLOR]

I recommend you define randomCiv as a local variable outside the event (you can see examples of these under the "Globals" heading in most of my events; just use
Code:
local randomCiv
No need to define what's in it. This way, you can retrieve info about the civ rolled anywhere in the event.

Then we can convert some unreadable TXT_KEYs with the civ's name, like so:

Code:
Locale.ConvertTextKey("TXT_KEY_JFD_SOMETHING", player:GetName(), randomCiv:GetName())

Then our text tiself would have two placeholders, {1_CivName} and {2_CivName} for example, where the first would be filled with the return value of "player:GetName()" and the second with the return value of "randomCiv:GetName()." It doesn't matter what these placeholders are called, so long as the number at the beginning corresponds to the order in which they are sent by the ConvertTextKey method. In this case, player:GetName() returns the leader's name, but you can use anything that returns a string or integer.

Hopefully this helped.

It helped a TON! My only question is about the text key you used in the example to retrieve the civ name: does it matter what text key is put in that spot in the code?

I don't have updated versions of all your civs yet, so Prussia still has the All-German Crown decision I've been trying to reverse engineer lol
 
Yes, you're right, sorry about that. Here are the logs. I seem to have some runtime issue with the Kalmar Union mod... I randomly (seemingly) get huge hang-ups when opening the city view, might be related.

Mods used:
Spoiler :
- Additional Ancient Ruins Rewards (v 1)
- CSD for BNW (v 26)
- Events and Decisions (v 1)
- Exploration Continued (v 3)
- Fewer Active Religions (v 1)
- Gibraltar, Reef and Krakatoa Fixes (v 101)
- Great Prophet Historical Names (v 26)
- Historical Religions Complete (v 6)
- India Civilization Pack (v 1)
- JFD's Alternate Leaders Pack (v 1)
- JFD's Civilization Pack 1 (v 1)
- JFD's Cultural Diversity (Core) (v 1)
- JFD's Cultural Diversity (Soundtrack) (v 1)
- JFD's Grand Duchy of Lithuania (v 1)
- JFD's HRE (v 2)
- JFD's Kingdom of France (v 1)
- JFD's Papal States (v 8)
- JFD's WW2 Pack (v 1)
- Krajzen's Great Musicians Pack (v 1)
- Less Ice on Maps (v 101)
- Map Labels (v 6)
- More Luxuries (v 155)
- More Pantheons - Addon (v 122)
- Natural Wonders Fix (v 1)
- Polynesian Civilization Pack (v 1)
- Randomize City Name (v 2)
- Really Advanced Setup - Civ Groups (v 1)
- Really Advanced Setup (v 13)
- Reform & Rule (BNW) (v 25)
- Resource - Granary Includes Bison (v 3)
- Resource Display Hotkey Mod (v 100)
- Ressource - Mint Includes Copper (v 2)
- Sukritact's MCIS (v 1)
- TarcisioCM's Iberians (v 1)
- Greater Europe's Kalmar Union (v 1)
- Greater Europe's Slavs (v 1)
- Unique Cultural Influence (v 4)

You don't need Sukritact's MCIS. Its a tool for modders to incorporate into their own mods, and not really needed for users. And yes, Viregel might want to take a look at those errors about the Kalmar Union.

However, I can't find anything that relates to the issue you were having; which is odd. Hopefully it's a one-time occurrence.

It helped a TON! My only question is about the text key you used in the example to retrieve the civ name: does it matter what text key is put in that spot in the code?

I don't have updated versions of all your civs yet, so Prussia still has the All-German Crown decision I've been trying to reverse engineer lol

No, it doesn't matter what text key is put there.
 
Just wanted to see if I coded this right (and what the last bit of code down at the bottom does). I'm mostly concerned that I'm referencing the random civ correctly in the outcome code and that the faith/gold rewards happen even if the war/denounce/DOF don't. My apologies for butchered formatting, btw, I'm still figuring out how to post it all pretty like you do:

Spoiler :
--=======================================================================================================================
-- Foreign Emissaries
--------------------------------------------------------------------------------------------------------------------------
local activeCivs = {} -- define a local table where all active players are going to be stored
local count = 1 -- counter for the spot that the active player is going to take in the table
for playerID = 0, GameDefines.MAX_MAJOR_CIVS - 1 do -- loop over all major civs
local otherPlayer = Players[playerID] -- define the player object for the major civ in the loop
if not (otherPlayer:IsHuman()) and Teams[otherPlayer :GetTeam()]:IsHasMet(player:GetTeam()) then -- make sure the other player isn't the human player (AI's don't need this flavour, and if you're getting the event, we don't want to be talking about ourselves.) And make sure the player receiving the event knows the civ. Though you can use as conditions you see fit.
activeCivs[count] = otherPlayer -- add them to the table
count = count + 1 -- tell the counter to make room for the next player in the loop
end
end

randomCiv = randomCivs[GetRandom(1, #randomCivs)] -- choose a random civ from the table we just filled out, between 1 and the number of civs in that table
if randomCiv == nil then return false end

local Event_WallachiaEmissaries = {}
Event_WallachiaEmissaries.Name = "TXT_KEY_EVENT_WALLACHIA_EMISSARIES"
Event_WallahicaEmissaries.Desc = "TXT_KEY_EVENT_WALLACHIA_EMISSARIES_DESC"
Event_WallachiaEmissaries.Weight = 5
Event_WallachiaEmissaries.CanFunc = (
function(pPlayer)
if load(pPlayer, "Event_WallachiaEmissaries") == true then return false end
Event_WallachiaEmissaries.Desc = Locale.ConvertTextKey("TXT_KEY_EVENT_WALLACHIA_EMISSARIES_DESC", pPlayer:GetName(), pPlayer:GetCivilizationShortDescription())
if not pPlayer:GetCivilizationType() == GameInfoTypes["CIVILIZATION_WALLACHIA"] then return false end

return true
end
)
Event_WallachiaEmissaries.Outcomes = {}
--=========================================================
-- Outcome 1
--=========================================================
Event_WallachiaEmissaries.Outcomes[1] = {}
Event_WallachiaEmissaries.Outcomes[1].Name = "TXT_KEY_EVENT_WALLACHIA_EMISSARIES_OUTCOME_1"
Event_WallachiaEmissaries.Outcomes[1].Desc = "TXT_KEY_EVENT_WALLACHIA_EMISSARIES_OUTCOME_RESULT_1"
Event_WallachiaEmissaries.Outcomes[1].Weight = 5
Event_WallachiaEmissaries.Outcomes[1].CanFunc = (
function(pPlayer)
local iFaithReward = math.ceil(200 * iMod)

Event_JFDRussiaPeterPatriarchDeath.Outcomes[1].Desc = Locale.ConvertTextKey("TXT_KEY_EVENT_WALLACHIA_EMISSARIES_OUTCOME_RESULT_1", iFaithReward)
return true
end
)
Event_WallachiaEmissaries.Outcomes[1].DoFunc = (
function(pPlayer)
local randomCiv
local iFaithReward = math.ceil(200 * iMod)
local random = JFD_GetRandom(1, 100)
if random <= 5 then
if Players[playerID]:GetCivilizationType() == GameInfoTypes[randomCiv] and not Players[playerID]:IsHuman() then
Teams[Players[playerID]:GetTeam()]:DeclareWar(pPlayer:GetTeam())
JFD_SendNotification(pPlayer:GetID(), "NOTIFICATION_GENERIC", Locale.ConvertTextKey("TXT_KEY_EVENT_WALLACHIA_EMISSARIES_OUTCOME_RESULT_1_ALT_NOTIFICATION", Players[playerID]:GetCivilizationDescription()), Locale.ConvertTextKey("TXT_KEY_EVENT_WALLACHIA_EMISSARIES"))
if not pPlayer:IsHuman() then Events.GameplayAlertMessage(Locale.ConvertTextKey("[COLOR_POSITIVE_TEXT]{1_LeaderName}[ENDCOLOR] has returned emissaries sent to their empire with their hats nailed to their heads, sparking war with {2_CivName}.", pPlayer:GetName(), randomCiv:GetName())) end
else
pPlayer:ChangeFaith(iFaithReward)
end
elseif random <= 10 then
if Players[playerID]:GetCivilizationType() == GameInfoTypes[randomCiv] and not Players[playerID]:IsHuman() then
Players[playerID]:DoForceDenounce(pPlayer:GetID())
JFD_SendNotification(pPlayer:GetID(), "NOTIFICATION_GENERIC", Locale.ConvertTextKey("TXT_KEY_EVENT_WALLACHIA_EMISSARIES_OUTCOME_RESULT_1_ALT_2_NOTIFICATION", Players[playerID]:GetCivilizationDescription()), Locale.ConvertTextKey("TXT_KEY_EVENT_WALLACHIA_EMISSARIES"))
if not pPlayer:IsHuman() then Events.GameplayAlertMessage(Locale.ConvertTextKey("[COLOR_POSITIVE_TEXT]{1_LeaderName}[ENDCOLOR] has mistreated emissaries from {2_CivName}, sparking contention between their empires.", pPlayer:GetName(), randomCiv:GetName())) end
else
pPlayer:ChangeFaith(iFaithReward)
end
else
pPlayer:ChangeFaith(iFaithReward)
JFD_SendNotification(pPlayer:GetID(), "NOTIFICATION_GENERIC", Locale.ConvertTextKey("TXT_KEY_EVENT_WALLACHIA_EMISSARIES_OUTCOME_RESULT_1_NOTIFICATION"), Locale.ConvertTextKey("TXT_KEY_EVENT_WALLACHIA_EMISSARIES"))
if not pPlayer:IsHuman() then Events.GameplayAlertMessage(Locale.ConvertTextKey("[COLOR_POSITIVE_TEXT]{1_LeaderName}[ENDCOLOR] has nailed the hats of emissaries from another empire to their heads as a warning to obey their customs.", pPlayer:GetName())) end
end
end
end
end
save(pPlayer, "Event_WallachiaEmissaries", true)
end)
--=========================================================
-- Outcome 2
--=========================================================
Event_WallachiaEmissaries.Outcomes[2] = {}
Event_WallachiaEmissaries.Outcomes[2].Name = "TXT_KEY_EVENT_WALLACHIA_EMISSARIES_OUTCOME_2"
Event_WallachiaEmissaries.Outcomes[2].Desc = "TXT_KEY_EVENT_WALLACHIA_EMISSARIES_OUTCOME_RESULT_2"
Event_WallachiaEmissaries.Outcomes[2].Weight = 1
Event_WallachiaEmissaries.Outcomes[2].CanFunc = (
function(pPlayer)
local iGoldReward = math.ceil(100 * iMod)

Event_WallachiaEmissaries.Outcomes[2].Desc = Locale.ConvertTextKey("TXT_KEY_EVENT_WALLACHIA_EMISSARIES_OUTCOME_RESULT_2")
return true
end
)
Event_WallachiaEmissaries.Outcomes[2].DoFunc = (
function(pPlayer)
local iGoldReward = math.ceil(100 * iMod)

if Players[playerID]:GetCivilizationType() == GameInfoTypes[randomCiv] and Players[playerID]:IsEverAlive() and Players[playerID] ~= pPlayer then
local random = JFD_GetRandom(1, 100)
if random <= 5 then
if Players[playerID]:GetCivilizationType() == GameInfoTypes[randomCiv] and not Players[playerID]:IsHuman() then
Teams[Players[playerID]:GetTeam()]:DoForceDOF(pPlayer:GetTeam())
JFD_SendNotification(pPlayer:GetID(), "NOTIFICATION_GENERIC", Locale.ConvertTextKey("TXT_KEY_EVENT_WALLACHIA_EMISSARIES_OUTCOME_RESULT_1_ALT_NOTIFICATION", Players[playerID]:GetCivilizationDescription()), Locale.ConvertTextKey("TXT_KEY_EVENT_WALLACHIA_EMISSARIES"))
if not pPlayer:IsHuman() then Events.GameplayAlertMessage(Locale.ConvertTextKey("[COLOR_POSITIVE_TEXT]{1_LeaderName}[ENDCOLOR]'s good treatment of emissaries of {2_CivName} has resulted in a Declaration of Friendship between the empires.", pPlayer:GetName(), randomCiv:GetName())) end
else
pPlayer:ChangeGold(iGoldReward)
end

JFD_SendNotification(pPlayer:GetID(), "NOTIFICATION_GENERIC", Locale.ConvertTextKey("TXT_KEY_WALLACHIA_EMISSARIES_OUTCOME_RESULT_2_NOTIFICATION"), Locale.ConvertTextKey("TXT_KEY_EVENT_WALLACHIA_EMISSARIES"))
save(pPlayer, "Event_WallachiaEmissaries", true)
end)

for iSlot = 0, GameDefines.MAX_MAJOR_CIVS-1, 1 do
local slotStatus = PreGame.GetSlotStatus(iSlot)
if (slotStatus == SlotStatus["SS_TAKEN"] or slotStatus == SlotStatus["SS_COMPUTER"]) then
local iCiv = PreGame.GetCivilization(iSlot)
local sCiv = GameInfo.Civilizations[iCiv].Type
if Event_JFDPrussiaAllGermanCrown.tValidCivs[sCiv] then
tEvents.Event_JFDPrussiaAllGermanCrown = Event_JFDPrussiaAllGermanCrown
break
end
end
end
 
You can always post large bits of code to pastebin, for easier reading.

You'll probably want to move the randomCiv stuff into the event function, and you'll also need to define randomCiv itself as a local variable outside of the function.


Code:
if not pPlayer:GetCivilizationType() == GameInfoTypes["CIVILIZATION_WALLACHIA"]

This was the cause of problems I had with events firing for civs that they shouldn't. Use this instead; it achieves the same thing, but appears to work more accurately:

Code:
if pPlayer:GetCivilizationType() ~= GameInfoTypes["CIVILIZATION_WALLACHIA"] then

if not pPlayer:IsHuman() then Events.GameplayAlertMessage(Locale.ConvertTextKey( "[COLOR_POSITIVE_TEXT]{1_LeaderName}[ENDCOLOR] has returned emissaries sent to their empire with their hats nailed to their heads, sparking war with {2_CivName}.", pPlayer:GetName(), randomCiv:GetName())) end

This is something I don't use anymore; instead I use World Events. Chuck this add the top of your file:

Spoiler :

Code:
------------------------------------------------------------------------------------------------------------------------
-- JFD_SendWorldEvent
------------------------------------------------------------------------------------------------------------------------
function JFD_SendWorldEvent(playerID, description)
	local player = Players[playerID]
	local playerTeam = Teams[player:GetTeam()]
	local activePlayer = Players[Game.GetActivePlayer()]
	if not (player:IsHuman()) and playerTeam:IsHasMet(activePlayer:GetTeam()) then
		Players[Game.GetActivePlayer()]:AddNotification(NotificationTypes["NOTIFICATION_DIPLOMACY_DECLARATION"], description, "[COLOR_POSITIVE_TEXT]World Events[ENDCOLOR]", -1, -1)
	end
end


And call it like so:

Code:
JFD_SendWorldEvent(pPlayer:GetID(), Locale.ConvertTextKey("[COLOR_POSITIVE_TEXT]{1_LeaderName}[ENDCOLOR] has returned emissaries sent to their empire with their hats nailed to their heads, sparking war with {2_CivName}.", pPlayer:GetName(), randomCiv:GetName())

I've also gotten out of the terrible, blasphemous habit of putting direct text in my Lua (mostly), so that should probably be converted into something like:

Code:
JFD_SendWorldEvent(playerID, Locale.ConvertTextKey("TXT_KEY_WALLACHIA_EVENT_MESSAGE", pPlayer:GetName(), randomCiv:GetName()")

With "TXT_KEY_WALLACHIA_EVENT_MESSAGE" filled out in your gametext xml file with the original text.

Event_JFDRussiaPeterPatriarchDeath.Outcomes[1].Desc = Locale.ConvertTextKey("TXT_KEY_EVENT_WALLACHIA_EMISSARIES_OUTCOME_RESULT_1", iFaithReward)
return truE
end

Peter, I see :p Be weary of mistakes like this. They'll kill the entire file.

if Players[playerID]:GetCivilizationType() == GameInfoTypes[randomCiv] and not Players[playerID]:IsHuman() then

Random Civ is a player object, so you'll want to replace GameInfoTypes[randomCiv] with randomCiv:GetCivilizationType() - randomCiv is basically a variable filled with a player object, like pPlayer (which is the variable filled with the player object receiving the event). GameInfoTypes is a shortcut to asking the game to look up a particular item in the database and to retrieve its ID. RandomCiv is returning a player object created in this Lua state, not an item (like a unit or building) that already existed in the game database.

So in the end, it should all look like this:

Spoiler :

Code:
------------------------------------------------------------------------------------------------------------------------
-- JFD_SendWorldEvent
------------------------------------------------------------------------------------------------------------------------
function JFD_SendWorldEvent(playerID, description)
	local player = Players[playerID]
	local playerTeam = Teams[player:GetTeam()]
	local activePlayer = Players[Game.GetActivePlayer()]
	if not (player:IsHuman()) and playerTeam:IsHasMet(activePlayer:GetTeam()) then
		Players[Game.GetActivePlayer()]:AddNotification(NotificationTypes["NOTIFICATION_DIPLOMACY_DECLARATION"], description, "[COLOR_POSITIVE_TEXT]World Events[ENDCOLOR]", -1, -1)
	end
end 

--================================================== ================================================== ===================
-- Foreign Emissaries
--------------------------------------------------------------------------------------------------------------------------
local randomCiv

local Event_WallachiaEmissaries = {}
Event_WallachiaEmissaries.Name = "TXT_KEY_EVENT_WALLACHIA_EMISSARIES"
Event_WallahicaEmissaries.Desc = "TXT_KEY_EVENT_WALLACHIA_EMISSARIES_DESC"
Event_WallachiaEmissaries.Weight = 5
Event_WallachiaEmissaries.CanFunc = (
function(pPlayer)
	if load(pPlayer, "Event_WallachiaEmissaries") == true then return false end 
	if pPlayer:GetCivilizationType() ~= GameInfoTypes["CIVILIZATION_WALLACHIA"] then return false end
	
	local activeCivs = {} -- define a local table where all active players are going to be stored
	local count = 1 
	for playerID = 0, GameDefines.MAX_MAJOR_CIVS - 1 do -- loop over all major civs
		local otherPlayer = Players[playerID] -- define the player object for the major civ in the loop
		if not (otherPlayer:IsHuman()) and Teams[otherPlayer :GetTeam()]:IsHasMet(player:GetTeam()) then 
			activeCivs[count] = otherPlayer 
			count = count + 1 
		end
	end

	randomCiv = randomCivs[GetRandom(1, #randomCivs)] 
	if randomCiv == nil then return false end

	Event_WallachiaEmissaries.Desc = Locale.ConvertTextKey("TXT_KEY_EVENT_WALLACHIA_EMISSARIES_DESC", pPlayer:GetName(), pPlayer:GetCivilizationShortDescription()) 
	
	
		return true
	end
	)
Event_WallachiaEmissaries.Outcomes = {}
--================================================== =======
-- Outcome 1
--================================================== =======
Event_WallachiaEmissaries.Outcomes[1] = {}
Event_WallachiaEmissaries.Outcomes[1].Name = "TXT_KEY_EVENT_WALLACHIA_EMISSARIES_OUTCOME_1"
Event_WallachiaEmissaries.Outcomes[1].Desc = "TXT_KEY_EVENT_WALLACHIA_EMISSARIES_OUTCOME_RESULT _1"
Event_WallachiaEmissaries.Outcomes[1].Weight = 5
Event_WallachiaEmissaries.Outcomes[1].CanFunc = (
function(pPlayer)
	local iFaithReward = math.ceil(200 * iMod)

	Event_WallachiaEmissaries.Outcomes[1].Desc = Locale.ConvertTextKey("TXT_KEY_EVENT_WALLACHIA_EMISSARIES_OUTCOME_RESULT_1", iFaithReward)
	return true
end
)
Event_WallachiaEmissaries.Outcomes[1].DoFunc = (
function(pPlayer)
	local randomCiv
	local iFaithReward = math.ceil(200 * iMod)
	local randomNumber = GetRandom(1, 100) [COLOR="Red"]-- JFD_GetRandom is an unnecessary function that I define in all my files; Sukritact's already got a function that does the same thing in the form of "GetRandom", so use that[/COLOR]
	if randomNumber <= 5 then	
		if Players[playerID]:GetCivilizationType() == randomCiv:GetCivilizationType() and not Players[playerID]:IsHuman() then [COLOR="Red"]-- This part doesn't make much sense. Mainly because playerID doesn't exist, so I'm not sure what player you're checking for, or why it's necessary. [/COLOR]
			Teams[Players[playerID]:GetTeam()]DeclareWar(pPlayer:GetTeam())
			JFD_SendNotification(pPlayer:GetID(), "NOTIFICATION_GENERIC", Locale.ConvertTextKey("TXT_KEY_EVENT_WALLACHIA_EMISSARIES_OUTCOME_RESULT_1_ALT_NOTIFICATION", Players[playerID]:GetCivilizationDescription()), Locale.ConvertTextKey("TXT_KEY_EVENT_WALLACHIA_EMISSARIES"))
			JFD_SendWorldEvent(pPlayer:GetID(), Locale.ConvertTextKey("[COLOR_POSITIVE_TEXT]{1_LeaderName}[ENDCOLOR] has returned emissaries sent to their empire with their hats nailed to their heads, sparking war with {2_CivName}.", pPlayer:GetName(), randomCiv:GetName())
		else
			pPlayer:ChangeFaith(iFaithReward)
		end
	elseif randomNumber <= 10 then
		if Players[playerID]:GetCivilizationType() == GameInfoTypes[randomCiv] and not Players[playerID]:IsHuman() then [COLOR="Red"]-- same as above[/COLOR]
			Players[playerID]DoForceDenounce(pPlayer:GetID())
			JFD_SendNotification(pPlayer:GetID(), "NOTIFICATION_GENERIC", Locale.ConvertTextKey("TXT_KEY_EVENT_WALLACHIA_EMI SSARIES_OUTCOME_RESULT_1_ALT_2_NOTIFICATION", Players[playerID]:GetCivilizationDescription()), Locale.ConvertTextKey("TXT_KEY_EVENT_WALLACHIA_EMI SSARIES"))
			JFD_SendWorldEvent(pPlayer:GetID(), Locale.ConvertTextKey("[COLOR_POSITIVE_TEXT]{1_LeaderName}[ENDCOLOR] has mistreated emissaries from {2_CivName}, sparking contention between their empires.", pPlayer:GetName(), randomCiv:GetName()))
		else
			pPlayer:ChangeFaith(iFaithReward)
		end
	else
		pPlayer:ChangeFaith(iFaithReward)
		JFD_SendNotification(pPlayer:GetID(), "NOTIFICATION_GENERIC", Locale.ConvertTextKey("TXT_KEY_EVENT_WALLACHIA_EMI SSARIES_OUTCOME_RESULT_1_NOTIFICATION"), Locale.ConvertTextKey("TXT_KEY_EVENT_WALLACHIA_EMISSARIES"))
		JFD_SendWorldEvent(pPlayer:GetID(), Locale.ConvertTextKey("[COLOR_POSITIVE_TEXT]{1_LeaderName}[ENDCOLOR] has nailed the hats of emissaries from another empire to their heads as a warning to obey their customs.", pPlayer:GetName())) end
	end
end
save(pPlayer, "Event_WallachiaEmissaries", true)
end)
--================================================== =======
-- Outcome 2
--================================================== =======
Event_WallachiaEmissaries.Outcomes[2] = {}
Event_WallachiaEmissaries.Outcomes[2].Name = "TXT_KEY_EVENT_WALLACHIA_EMISSARIES_OUTCOME_2"
Event_WallachiaEmissaries.Outcomes[2].Desc = "TXT_KEY_EVENT_WALLACHIA_EMISSARIES_OUTCOME_RESULT _2"
Event_WallachiaEmissaries.Outcomes[2].Weight = 1
Event_WallachiaEmissaries.Outcomes[2].CanFunc = (
function(pPlayer)
	local iGoldReward = math.ceil(100 * iMod)
	Event_WallachiaEmissaries.Outcomes[2].Desc = Locale.ConvertTextKey("TXT_KEY_EVENT_WALLACHIA_EMISSARIES_OUTCOME_RESULT_2", iGoldReward) -- this was missing iGoldReward; I'm pressing its supposed to tell you how much gold you get
	return true
end
)
Event_WallachiaEmissaries.Outcomes[2].DoFunc = (
function(pPlayer)
	local iGoldReward = math.ceil(100 * iMod)
	if Players[playerID]:GetCivilizationType() == GameInfoTypes[randomCiv] and Players[playerID]:IsEverAlive() and Players[playerID] ~= pPlayer then
		local random = JFD_GetRandom(1, 100)
		if random <= 5 then
			if Players[playerID]:GetCivilizationType() == GameInfoTypes[randomCiv] and not Players[playerID]:IsHuman() then
				Teams[Players[playerID]:GetTeam()]DoForceDOF(pPlayer:GetTeam())
				JFD_SendNotification(pPlayer:GetID(), "NOTIFICATION_GENERIC", Locale.ConvertTextKey("TXT_KEY_EVENT_WALLACHIA_EMISSARIES_OUTCOME_RESULT_1_ALT_NOTIFICATION", Players[playerID]:GetCivilizationDescription()), Locale.ConvertTextKey("TXT_KEY_EVENT_WALLACHIA_EMISSARIES"))
				JFD_SendWorldEvent(pPlayer:GetID(), Locale.ConvertTextKey("[COLOR_POSITIVE_TEXT]{1_LeaderName}[ENDCOLOR]'s good treatment of emissaries of {2_CivName} has resulted in a Declaration of Friendship between the empires.", pPlayer:GetName(), randomCiv:GetName())) end
			else
		pPlayer:ChangeGold(iGoldReward)
	end

	JFD_SendNotification(pPlayer:GetID(), "NOTIFICATION_GENERIC", Locale.ConvertTextKey("TXT_KEY_WALLACHIA_EMISSARIES_OUTCOME_RESULT_2_NOTIFICATION"), Locale.ConvertTextKey("TXT_KEY_EVENT_WALLACHIA_EMISSARIES"))
	save(pPlayer, "Event_WallachiaEmissaries", true)
end)
[/SPOILER]

This:

[CODE]
for iSlot = 0, GameDefines.MAX_MAJOR_CIVS-1, 1 do
local slotStatus = PreGame.GetSlotStatus(iSlot)
if (slotStatus == SlotStatus["SS_TAKEN"] or slotStatus == SlotStatus["SS_COMPUTER"]) then
local iCiv = PreGame.GetCivilization(iSlot)
local sCiv = GameInfo.Civilizations[iCiv].Type
if Event_JFDPrussiaAllGermanCrown.tValidCivs[sCiv] then
tEvents.Event_JFDPrussiaAllGermanCrown = Event_JFDPrussiaAllGermanCrown
break
end
end
end

You don't need, and probably shouldn't worry about.

No guarantee it'll work still, though :p

Also, wasn't it Ivan the Terrible that nailed hats on the heads of emissaries that wouldn't take them off at dinner?
 
Back
Top Bottom