[Civ5] Help Changing Great Work Yields

Zoythrus

Chieftain
Joined
Jul 11, 2012
Messages
36
Hello,

I'm a noob wanting to make a modded Civ with the following UA:
"Additional +1 Culture, +1 Tourism, and +1 Gold to all Great Works. Artist Specialists give an additional +1 Tourism, +1 GP, and +1 Culture."
(These values can change, but the idea is the same.)

Well, here's what I want to know, how can you add those yields to Great Works through the civ's UA? Can this be done without LUA? I noticed that there is a <Policy_GreatWorkYieldChanges> XML tag in the Social Policy list, and was unsure whether or not I could use this in the UA.

-Zoythrus
 
I noticed that there is a <Policy_GreatWorkYieldChanges> XML tag in the Social Policy list, and was unsure whether or not I could use this in the UA?

Yes, that's exactly the field that should be used, in combination with a brief Lua script that gives the Policy to the Civilization for free (invisible, and doesn't increase Policy costs). Related note: I don't know how to modify the yields of specific types of Specialists, only all types (a la Korea's +2 Science from them). Perhaps someone will show up that does know how, but I'm not sure if it's possible without some convoluted Lua/invisible building work (if at all). As Klisz pointed out, this can easily be done through <Trait_SpecialistYieldChanges>.

Note that Tourism is not a yield like Culture and Gold, and as such you can't assign extra Tourism yields to anything (like Great Works/Specialists) via a Policy, Trait, or anything that modifies "yields."
 
Note that Tourism is not a yield like Culture and Gold, and as such you can't assign extra Tourism yields to anything (like Great Works/Specialists) via a Policy, Trait, or anything that modifies "yields."

In the CBP, this is not true. OP, you may consider using the CPP (now renamed "Vox Populi" DLL as a base.
 
In the CBP, this is not true. OP, you may consider using the CPP (now renamed "Vox Populi" DLL as a base.

Or in DLL - Various Mod Components. However, note that DLL mods are not useable on Mac or Linux.

Related note: I don't know how to modify the yields of specific types of Specialists, only all types (a la Korea's +2 Science from them).

Trait_SpecialistYieldChanges. Korea actually just assigns +2 Science to each specialist type individually.
 
Trait_SpecialistYieldChanges. Korea actually just assigns +2 Science to each specialist type individually.

Well now I feel right silly for missing that :lol:

That means that essentially, the only difficult thing to implement for OP would be the +1 Tourism for Great Works/Specialists. It's feasible, but gets pretty mucked up due to the fact that Tourism from dummy buildings doesn't stack. I suppose that placing a dummy building in every city that gives +50% Tourism from Great Works (which is +1, as the base Tourism is +2) like the Hotel/Airport would solve the Great Work issue, but additional Tourism yields for Artists would be trickier.
 
Yes, that's exactly the field that should be used, in combination with a brief Lua script that gives the Policy to the Civilization for free (invisible, and doesn't increase Policy costs).

Are you saying that I'd have to give them the "Creative Expression" policy by default? Or are you saying that it would just give the effects without "auto-purchasing" the policy by default?

And I could always change the +1 Tourism to something else. That's not a big deal. I am disappointed that Firaxis didn't make this a standard yield, like the rest of them.
 
You'd have to create a new Policy, like so:
Code:
<GameData>
	<Policies>
		<Row>
			<Type>POLICY_CULTURE_GOLD_GREATWORK</Type>
			<Description>TXT_KEY_POLICY_CULTURE_GOLD_GREATWORK</Description>
			<PortraitIndex>24</PortraitIndex>
			<IconAtlas>POLICY_ATLAS</IconAtlas>
			<IconAtlasAchieved>POLICY_A_ATLAS</IconAtlasAchieved>
		</Row>
	</Policies>
	<Policy_GreatWorkYieldChanges>
		<Row>
			<PolicyType>POLICY_CULTURE_GOLD_GREATWORK</PolicyType>
			<YieldType>YIELD_CULTURE</YieldType>
			<Yield>1</Yield>
		</Row>
		<Row>
			<PolicyType>POLICY_CULTURE_GOLD_GREATWORK</PolicyType>
			<YieldType>YIELD_GOLD</YieldType>
			<Yield>1</Yield>
		</Row>
	</Policy_GreatWorkYieldChanges>
</GameData>
(The Description/Portrait/Icon fields are needed; the Policy won't show in the Civilopedia but if they're not there it can nonetheless cause problems with how the Civilopedia gets and shows its data).

Afterward, you assign it at the start of the game to the person playing your Civilization:
Code:
-- Replace "YOUR_CIV_ID" with your actual Civilization Type
local iCivID = GameInfoTypes["YOUR_CIV_ID"]
local iDummyPolicyID = GameInfoTypes["POLICY_CULTURE_GOLD_GREATWORK"]

function AssignDummyPolicy()
	-- this will loop through all major Civs in the game
	for iPlayerID = 0, GameDefines.MAX_MAJOR_CIVS - 1, 1 do
	
		-- get the Player object, so you can find information about it, like...
		local pPlayer = Players[iPlayerID]
		
		-- ...getting the Civiliation they're playing
		if (pPlayer:GetCiviliationType() == iCivID) then
		-- if they're playing your Civiliation, we're in the clear, so we can give them the Policy
			
			-- first make sure they don't already have the policy
			local bPlayerHasPolicy = pPlayer:HasPolicy(iDummyPolicyID)
			
			if (not bPlayerHasPolicy) then
				-- the following is a trick that fools the game into thinking you have a free Policy
				pPlayer:SetNumFreePolicies(1)
				pPlayer:SetNumFreePolicies(0)
				
				-- so when you give it to them, it won't increase Policy costs
				pPlayer:SetHasPolicy(iDummyPolicyID, true)
				
				-- throw in a print statement for logging purposes, to make sure the code gets this far.
				-- this doesn't appear in game, it's for your eyes only
				print("Policy given to Civ")
				-- obviously replace "Civ" with your actual Civilization's name
			end
		end
	end
end
-- make sure to add the event to the game engine so the game actually knows to process it
-- the reason we do the Policy check is because this event will run whenever there is a load screen;
-- i.e. at the start of a new game, but also whenever you load the game again
Events.LoadScreenClose.Add(AssignDummyPolicy)

When you're making the mod (presumably in the SDK), under Actions, set the XML file with the Policy to UpdateDatabase; under Content, set the Lua file with the code to assign the Policy to InGameUIAddin (you might need to select the File first, then set it to InGameUIAddin). The code might not be perfect; I haven't tested it and wrote it up in a few minutes. If you encounter problems, or if someone else sees something, feel free to speak up.

Edit: Fixed LeeS's correction. One day...
 
Thank you, Cyphose and LeeS!

One last question concerning this topic - can I add Tech restrictions to the abilities of the Trait? I want to have things like the Culture and Gold attributes come into play at the research of Education and Archaeology, respectively.

Sadly, Civ5 doesn't have any examples of adding this to Great Works, only improvements and buildings.
 
One possible way to achieve that is to make several dummy policies: 1 default (no extra yields) and 2 'advanced/buffed' policies (the ones with the extra yields that unlock at education and archaeology).
E.g. I want the policy to provide +1 gold per great work without education, but I want it to provide +2 gold with education --> create 2 different dummy policies, one which provides a +1 gold yield and one which provides a +2 gold yield. Do this the same way as Cyphose did in his XML-code above (E.g. create POLICY_CULTURE_GOLD_GREATWORK (the default) and POLICY_CULTURE_GOLD_GREATWORK_EDUCATION (the buffed one)) (I hope I explained that clearly enough :blush:)

To swap policies out, you can use this piece of lua (this won't increase policy cost since you swap out two policies (The cost is lowered first and raised after that, meaning that pretty much nothing happens)):
Code:
pPlayer:SetHasPolicy(iDummyPolicyID_default, false)
pPlayer:SetHasPolicy(iDummyPolicyID_education, true)

Now, we only want to swap this once the education tech has been discovered, for which we could use this:
Code:
local iEducation = GameInfoTypes.TECH_EDUCATION
local iArchaeology = GameInfoTypes.TECH_ARCHAEOLOGY --(not sure if this this how the tech is actually called; I'll need to check that)

function BuffByTech(iPlayer)
     local pPlayer=Players[iPlayer]
     if (pPlayer:GetCiviliationType() == iCivID) then --iCivID was defined in Cyphose's code
          local pTeam=Teams[pPlayer:GetTeam()] --technologies are discovered by teams, not by players!

          if pTeam:IsHasTech(iEducation) and not pPlayer:HasPolicy(iDummyPolicyID_education) and not pPlayer:HasPolicy(iDummyPolicyID_archaeology) then --If we only added the IsHasTech-part then this part of the code would ALWAYS fire after education has been discovered, which we do not want!
               pPlayer:SetHasPolicy(iDummyPolicyID_default, false)
               pPlayer:SetHasPolicy(iDummyPolicyID_education, true)
               print("Target Civ has discovered education: New Dummy Policy given") --for logging purposes
          elseif pTeam:IsHasTech(iArchaeology) and pPlayer:HasPolicy(iDummyPolicyID_education) and not pPlayer:HasPolicy(iDummyPolicyID_archaeology) then
               pPlayer:SetHasPolicy(iDummyPolicyID_education, false)
               pPlayer:SetHasPolicy(iDummyPolicyID_archaeology, true)
               print("Target Civ has discovered archaeology: New Dummy Policy given")
          end
     end
end

Now we only need to add another Lua hook to make the previous code fire multiple times in the game (technologies get discovered after your game loads, so we have to use something different). The code below fires every turn (for every player), meaning that the code above will check for the technologies every turn
Code:
GameEvents.PlayerDoTurn.Add( BuffByTech )

DISCLAIMER: Using dummy policies could make the Prora (+1 Happiness per 2 policies) OP. What I usually end up doing is give every civ the same amount of policies (which won't do anything) as our target civ (so it's easier to balance). Then I usually end up removing/lowering the base Happiness that the Prora gives.
E.g. Every civ has 2 dummy policies (only our target civ's policies do something). This would mean that the prora gives +1 extra happiness due to its +1 happiness/2 policies effect. Therefore, we want to lower the Prora's base happiness by 1, so that the wonder won't differ from the base game (since the 2 dummy policies that every civ have will provide the +1 happiness we removed as a base happiness).
Note that you can't make negative happiness! So if you have for example 10 extra dummy policies, you'll need to increase the building cost or something.

This is how your final lua code will look like (the code that was added/changed by this post is added in blue; the other code was provided by Cyphose in his pot above):
Spoiler :

Code:
-- Replace "YOUR_CIV_ID" with your actual Civilization Type
local iCivID = GameInfoTypes["YOUR_CIV_ID"]
local iDummyPolicyID[COLOR="RoyalBlue"]_default[/COLOR] = GameInfoTypes["POLICY_CULTURE_GOLD_GREATWORK"]
[COLOR="royalblue"]
local iDummyPolicyID_education = GameInfoTypes.POLICY_CULTURE_GOLD_GREATWORK_EDUCATION --this is the same as GameInfoTypes["POLICY_CULTURE_GOLD_GREATWORK_EDUCATION"]; use whatever you prefer
local iDummyPolicyID_archaeology = GameInfoTypes.POLICY_CULTURE_GOLD_GREATWORK_ARCHAEOLOGY
local iEducation = GameInfoTypes.TECH_EDUCATION
local iArchaeology = GameInfoTypes.TECH_ARCHAEOLOGY --(not sure if this this how the tech is actually called; I'll need to check that)[/COLOR]

function AssignDummyPolicy()
	-- this will loop through all major Civs in the game
	for iPlayerID = 0, GameDefines.MAX_MAJOR_CIVS - 1, 1 do
	
		-- get the Player object, so you can find information about it, like...
		local pPlayer = Players[iPlayerID]
		
		-- ...getting the Civiliation they're playing
		if (pPlayer:GetCiviliationType() == iCivID) then
		-- if they're playing your Civiliation, we're in the clear, so we can give them the Policy
			
			-- first make sure they don't already have the policy
			local bPlayerHasPolicy = pPlayer:HasPolicy(iDummyPolicyID[COLOR="RoyalBlue"]_default[/COLOR])
			
			if (not bPlayerHasPolicy) then
				-- the following is a trick that fools the game into thinking you have a free Policy
				pPlayer:SetNumFreePolicies(1)
				pPlayer:SetNumFreePolicies(0)
				
				-- so when you give it to them, it won't increase Policy costs
				pPlayer:SetHasPolicy(iDummyPolicyID[COLOR="RoyalBlue"]_default[/COLOR], true)
				
				-- throw in a print statement for logging purposes, to make sure the code gets this far.
				-- this doesn't appear in game, it's for your eyes only
				print("Policy given to Civ")
				-- obviously replace "Civ" with your actual Civilization's name
			end
		end
	end
end

[COLOR="royalblue"]function BuffByTech(iPlayer)
     local pPlayer=Players[iPlayer]
     if (pPlayer:GetCiviliationType() == iCivID) then --iCivID was defined in Cyphose's code
          local pTeam=Teams[pPlayer:GetTeam()] --technologies are discovered by teams, not by players!

          if pTeam:IsHasTech(iEducation) and not pPlayer:HasPolicy(iDummyPolicyID_education) and not pPlayer:HasPolicy(iDummyPolicyID_archaeology) then
               pPlayer:SetHasPolicy(iDummyPolicyID_default, false)
               pPlayer:SetHasPolicy(iDummyPolicyID_education, true)
               print("Target Civ has discovered education: New Dummy Policy given") --for logging purposes
          elseif pTeam:IsHasTech(iArchaeology) and pPlayer:HasPolicy(iDummyPolicyID_education) and not pPlayer:HasPolicy(iDummyPolicyID_archaeology) then
               pPlayer:SetHasPolicy(iDummyPolicyID_education, false)
               pPlayer:SetHasPolicy(iDummyPolicyID_archaeology, true)
               print("Target Civ has discovered archaeology: New Dummy Policy given")
          end
     end
end[/COLOR]
-- make sure to add the event to the game engine so the game actually knows to process it
-- the reason we do the Policy check is because this event will run whenever there is a load screen;
-- i.e. at the start of a new game, but also whenever you load the game again
Events.LoadScreenClose.Add(AssignDummyPolicy)
[COLOR="royalblue"]GameEvents.PlayerDoTurn.Add( BuffByTech )[/COLOR]
 
If you are linking something to a team researching a technology, then link your lua to a team researching a technology with GameEvents.TeamTechResearched(iTeam, iTech, iChange)

Code:
-------------------------------------------------------------------------------------------------------
--Team (Player) Tech Researched
-------------------------------------------------------------------------------------------------------

local tTechsAndDummyPolicies = { [GameInfoTypes.TECH_EDUCATION] = GameInfoTypes.POLICY_CULTURE_GOLD_GREATWORK_EDUCATION,
	[GameInfoTypes.TECH_ARCHAEOLOGY] = GameInfoTypes.POLICY_CULTURE_GOLD_GREATWORK_ARCHAEOLOGY }

function OnTechResearched(iTeam, iTech, iChange)
 	if tTechsAndDummyPolicies[iTech] then
		for iPlayer = 0, GameDefines.MAX_MAJOR_CIVS - 1, 1 do
			local pPlayer = Players[iPlayer]
			if (pPlayer ~= nil) then
				if (pPlayer:GetTeam() == iTeam) and (pPlayer:GetCiviliationType() == iCivID) then
					if pPlayer:HasPolicy(iDummyPolicyID_default) then
						pPlayer:SetHasPolicy(iDummyPolicyID_default, false)
					else
						for iTech,iPolicy in pairs(tTechsAndDummyPolicies) do
							if pPlayer:HasPolicy(iPolicy)
								pPlayer:SetHasPolicy(iPolicy, false)
							end
						end
					end
					pPlayer:SetHasPolicy(tTechsAndDummyPolicies[iTech], true)
					return
				end
			end
 		end
	end
end
GameEvents.TeamTechResearched.Add(OnTechResearched)
By placing correspondance between tech-discovered and dummy-policy into an lua table, it is possible to make the code easily handle multiple such correspondances without changes to the rest of the code.

As structured, however, expansion to add more tech-policy correspondances requires that each technology listed is placed within the tech-tree such that you have to research all the techs in a specific order, and can't for example, get to tech-C without having first researched tech-A and tech-B. Education and Archaeology conform to this in the standard tech tree, but not necessarily in a heavily-modded tech-tree.
 
Looks like I over-complicated it a bit... I completely forgot about TeamTechResearched... Fortunately, LeeS was here to save the day ;) (His method is better since it allows you to change things up pretty quickly (it's more dynamic(?)). E.g. I'm using elseif-statements (which add up really quick), LeeS loops through a table (which will always take up one line))


Anyway, to further illustrate what LeeS was trying to say in his last paragraph is that you can't research Archaeology before having researched Eduction (unless you're cheating with IGE :O). This means that the player always researches Education first, meaning that we can always assign the mediocre buffing policy upon researching education.
'So where lies the problem here?' Well, it's that if we for example want the bonuses to unlock at Trapping and Archery for example, this wouldn't work. Since we don't know at which order the techs will be researched (One could research trapping before archery, or the other way around) we simply can't make any of the policies stronger than the other (like we are doing now).
E.g. If we made the trapping policy have better bonuses (like Archaeology has now), and the player would Research trapping first, then he would get more buffs than was actually designed (since he hasn't researched archery yet!).

The solution for this Trapping-Archery problem could be to assign multiple dummy policies. E.g. at Trapping and archery, gold yield is increased by one. This would mean we have to create 2 dummy policies: POLICY_CULTURE_GOLD_GREATWORK_TRAPPING and POLICY_CULTURE_GOLD_GREATWORK_ARCHERY. Both these policies would increase YIELD_GOLD by 1. Now, if the player researches trapping, POLICY_...._TRAPPING would be assigned. However, if the player researches Archery, POLICY_..._ARCHERY would be assigned on top of the effects of POLICY_..._TRAPPING (with the SetNumFreePolicies-trick), which means that the player now has a total of 2 buffing dummy policies. (DISCLAIMER: This would make balancing the Prora a bit more difficult, since the amount of dummy policies isn't static anymore like in the method above)

(DISCLAIMER: Some policy/building-things have stacking issues (E.g. Adding tourism), meaning that the effects won't stack! E.g. I have 2 dummy buildings (the exact same buildings) that both apply +2 tourism in a city. However, since tourism doesn't stack (for the same building), we only get a +2 tourism result, rather than the expected +4 tourism!)
 
I want to do something similar with a Civ I am working on right now, but I only want the bonus to apply to great works of writing. Is there a way to do this? Also, does this work with faith? I know faith is a bit of a wonky yield sometimes.
 
I want to do something similar with a Civ I am working on right now, but I only want the bonus to apply to great works of writing. Is there a way to do this? Also, does this work with faith? I know faith is a bit of a wonky yield sometimes.

I'm trying to get this to work with a Faith yield, first and foremost. Sadly, I can't seem to get the actual LUA snippet to fire properly, despite leaving Cyphose's code unchanged.

Theoretically, though, it should work if the code would fire.
 
I'm trying to get this to work with a Faith yield, first and foremost. Sadly, I can't seem to get the actual LUA snippet to fire properly, despite leaving Cyphose's code unchanged.

Theoretically, though, it should work if the code would fire.
  1. Check your settings in Modbuddy for the lua-file. It should be set as an InGameUIAddin in the ModBuddy project's 'Content' tab, and it should not be set as "Import Into VFS = true" for the lua-file's individual file-properties.
  2. It is entirely possible that "Faith" has not been implemented for table <Policy_GreatWorkYieldChanges>. There are quite a few xml-game-tables that are not implemented for all the possible yields (even setting aside the issues of Happiness and Tourism). William Howard and others did a major project to ferret out and fix all these issues for custom-dll mods such as William's VMC, and Gazebo's CP. Unfortunately, if using the stock Firaxis-made DLL, you are stuck with all these omissions, and it is really hit-or-miss as to whether an individual game-table is hooked up to work for all yields of gold, culture, food, science, production, and faith.
 
  1. Check your settings in Modbuddy for the lua-file. It should be set as an InGameUIAddin in the ModBuddy project's 'Content' tab, and it should not be set as "Import Into VFS = true" for the lua-file's individual file-properties.
  2. It is entirely possible that "Faith" has not been implemented for table <Policy_GreatWorkYieldChanges>. There are quite a few xml-game-tables that are not implemented for all the possible yields (even setting aside the issues of Happiness and Tourism). William Howard and others did a major project to ferret out and fix all these issues for custom-dll mods such as William's VMC, and Gazebo's CP. Unfortunately, if using the stock Firaxis-made DLL, you are stuck with all these omissions, and it is really hit-or-miss as to whether an individual game-table is hooked up to work for all yields of gold, culture, food, science, production, and faith.

I've gotten it to work with a Culture yield, but not a Faith yield, leading me to believe that it might just not be set up for Faith. So, then, with LUA, am I able to either add it or do a "Number of Great Works in a city multiplied by 2" deal to simulate the effect?

I'm actually making a mod for a friend, and he plays the game on a Mac, so I can't use custom DLL. Still, I *really* want this "Great Works give Faith" attribute for the particular civ I'm making, and I really don't care how I do it.
 
Code:
local iFaithPerGreatWork = 2
local iRequiredCivilization = GameInfoTypes.CIVILIZATION_SOMETHING_OR_OTHER

function FaithPerGreatWork(iPlayer)
	local pPlayer = Players[iPlayer]
	if pPlayer:GetCivilizationType() == iRequiredCivilization then
		for pCity in pPlayer:Cities() do
			pPlayer:ChangeFaith(pCity:GetNumGreatWorks() * iFaithPerGreatWork)
		end
	end
end
GameEvents.PlayerDoTurn.Add(FaithPerGreatWork)
It won't show the effect in the UI on the top panel, nor anywhere when in the city view, but the adjustment to faith will be made.
 
I want to do something similar with a Civ I am working on right now, but I only want the bonus to apply to great works of writing. Is there a way to do this? Also, does this work with faith? I know faith is a bit of a wonky yield sometimes.
It's possible but requires a bit more lua code-gymnastics than the code I posted for Zoythrus.

Spoiler has the code pre-SetUp for 2 Faith per Great Work of Literature. Attachment is the code in an lua-file.
Spoiler :
Code:
--LeeS
--28May2016
----------------------------------------------------------------------------------------------------------
--	INSTRUCTIONAL COMMENTS
----------------------------------------------------------------------------------------------------------
--[[

1)	Use only the following designations as 'keys' in table tGreatWorkTypeFaithSelections

	"GREAT_WORK_SLOT_MUSIC"
	"GREAT_WORK_SLOT_LITERATURE"
	"GREAT_WORK_SLOT_ART_ARTIFACT"

	a)	You can state more than one type of great work, as in this sort of construction:

		local tGreatWorkTypeFaithSelections = { ["GREAT_WORK_SLOT_LITERATURE"] = 2,
			["GREAT_WORK_SLOT_ART_ARTIFACT"] = 3,
			["GREAT_WORK_SLOT_MUSIC"] = 4 }

2)	The 'value' side of each data pair in table tGreatWorkTypeFaithSelections will be the amount of faith to be added for each great work of the appropriate
	type.

3)	You need to specifiy the correct civilization xml-name for "iRequiredCivilization"
	As-is, CIVILIZATION_SOMETHING_OR_OTHER is just a placeholder

4)	If you only want a specific civilization to have this effect, leave this line as is:

		local bSpecificCivRequired = true

]]--
----------------------------------------------------------------------------------------------------------
--	END OF INSTRUCTIONAL COMMENTS
----------------------------------------------------------------------------------------------------------


local bSpecificCivRequired = true
local iRequiredCivilization = GameInfoTypes.CIVILIZATION_SOMETHING_OR_OTHER

local tGreatWorkTypeFaithSelections = {["GREAT_WORK_SLOT_LITERATURE"] = 2}

------------------------------------------------------------------------------------------------------------------------------------------------
--GreatWorksInCityUtilities
------------------------------------------------------------------------------------------------------------------------------------------------

local tBuildingsWithGreatWorkSlots = {}
local tBuildingsWithGreatWorkSlotsOfType = {}

for Building in DB.Query("SELECT ID, BuildingClass, GreatWorkSlotType FROM Buildings WHERE GreatWorkCount > 0") do
	if not tBuildingsWithGreatWorkSlotsOfType[Building.GreatWorkSlotType] then
		tBuildingsWithGreatWorkSlotsOfType[Building.GreatWorkSlotType] = {}
	end
	tBuildingsWithGreatWorkSlotsOfType[Building.GreatWorkSlotType][Building.ID] = GameInfoTypes[Building.BuildingClass]
	tBuildingsWithGreatWorkSlots[Building.ID] = GameInfoTypes[Building.BuildingClass]
end
function ReturnNumberGreatWorksOfTypeInCity(pCity, sGreatWorkType)
	local iNumberGreatWorksOfType = 0
	if pCity:GetNumGreatWorks() > 0 then
		for Building,BuildingClass in pairs(tBuildingsWithGreatWorkSlotsOfType[sGreatWorkType]) do
			if pCity:IsHasBuilding(Building) then
				iNumberGreatWorksOfType = iNumberGreatWorksOfType + pCity:GetNumGreatWorksInBuilding(BuildingClass)
			end
		end
	end
	return iNumberGreatWorksOfType
end

------------------------------------------------------------------------------------------------------------------------------------------------
--Faith Changes Per Great Work
------------------------------------------------------------------------------------------------------------------------------------------------

function FaithPerGreatWorkOfSpecificTypes(iPlayer)
	local pPlayer = Players[iPlayer]
	if bSpecificCivRequired then
		if pPlayer:GetCivilizationType() ~= iRequiredCivilization then return end
	end
	for pCity in pPlayer:Cities() do
		for sGreatWorkType,iFaithChange in pairs(tGreatWorkTypeFaithSelections) do
			pPlayer:ChangeFaith(ReturnNumberGreatWorksOfTypeInCity(pCity, sGreatWorkType) * iFaithChange)
		end
	end
end
------------------------------------------------------------
---- WilliamHoward's IsCivInPlay
------------------------------------------------------------

function IsCivInPlay(iCivType)
  for iSlot = 0, GameDefines.MAX_MAJOR_CIVS-1, 1 do
    local iSlotStatus = PreGame.GetSlotStatus(iSlot)
    if (iSlotStatus == SlotStatus.SS_TAKEN or iSlotStatus == SlotStatus.SS_COMPUTER) then
      if (PreGame.GetCivilization(iSlot) == iCivType) then
        return true
      end
    end
  end
  
  return false
end
------------------------------------------------------------
---- Game Event Hooks
------------------------------------------------------------
if bSpecificCivRequired then
	if IsCivInPlay(iRequiredCivilization) then
		GameEvents.PlayerDoTurn.Add(FaithPerGreatWorkOfSpecificTypes)
	end
else
	GameEvents.PlayerDoTurn.Add(FaithPerGreatWorkOfSpecificTypes)
end

------------------------------------------------------------
---- Loading Confirmation Print Statements
------------------------------------------------------------

print("The GreatWorksYieldsManipulations.lua loaded to the end")
 

Attachments

Code:
local iFaithPerGreatWork = 2
local iRequiredCivilization = GameInfoTypes.CIVILIZATION_SOMETHING_OR_OTHER

function FaithPerGreatWork(iPlayer)
	local pPlayer = Players[iPlayer]
	if pPlayer:GetCivilizationType() == iRequiredCivilization then
		for pCity in pPlayer:Cities() do
			pPlayer:ChangeFaith(pCity:GetNumGreatWorks() * iFaithPerGreatWork)
		end
	end
end
GameEvents.PlayerDoTurn.Add(FaithPerGreatWork)
It won't show the effect in the UI on the top panel, nor anywhere when in the city view, but the adjustment to faith will be made.

Thank you for your code.

Seeing as adding GUI elements is possible, would you happen to know of any good examples so that I might add the effects to the UI top panel and City view myself?
 
Back
Top Bottom