Help with tricky building?

RampantGeth

Chieftain
Joined
Aug 15, 2014
Messages
13
Heya Civ Fanatics; I'm hoping Y'all could help me out here.

Working on a civ, but need some help with an idea as part of the UA. I was hoping to get some defense bonus' out of religious Buildings; Shrines, Temples, Monasteries and the like.

Not really where to begin, or if its even possible. Can someone point me in the right direction?
 
Moderator Action: This will require lua to implement, so I'm moving it to the lua subforum.

It should be as simple as using lua to count the number of religious buildings (however you want to define that) and then change the city defense modifiers based on that value.
 
Shrines and Temples can pretty easily be done directly through Buildings with no lua required. But it will require a unique version of Shrines and Temples for your civ. I think it may also be possible to create and assign a unique version of Monasteries, Pagodas, Mosques, and Cathedrals to your civ and still make them unlockable only for your civ if and only if a player picks the correct belief that unlocks Monasteries, etc. The real problem as I see it with this approach is that the Civilopedia page will be crowded with these "shadow" unique buildings, and you will probably have problems with the Cathedrals Great Work of Art slot on the Culture Overview page. Though this last issue can be overcome using the mod that fixes the Culture Overview Panel shortcomings (name of which escapes me at the moment).

Let me know if you want me to check the Monasteries, Pagodas, Mosques, Cathedrals as unique versions.
 
What I would probably do is create a dummy building that has the base defense bonus you want to add, then create a lua function that goes through the city, counts up the number of religious buildings, and spawns a number of those dummy buildings. You could then have the function get called at the start of each turn, or whenever a new building is completed. (I'm trying to remember if the recent BNW patch includes an event for when a building is sold?)

EDIT: Here's a function I used in my Mima civ, which spawned a number of "ward spells" (which added 100 defense points and 10 city hit points each) equal to half the faith output of the city:

Code:
local iWardSpell = GameInfoTypes.BUILDING_EVIL_SPIRITS_WARD_SPELL

function Mima_CastWardSpell(pPlayer)
	for pCity in pPlayer:Cities() do
		local iFaithPerTurn = pCity:GetFaithPerTurn();
		local iNumWards = math.floor(iFaithPerTurn / 2)
		if (iNumWards > 20) then 
			iNumWards = 20;
		end
		pCity:SetNumRealBuilding(iWardSpell, iNumWards)	
	end
end

Admittedly, this may not be the best solution, but I suppose it is a potential starting point for one way you could implement the UA.
 
Firstly; Wow! You guys are awesome. just jumping in here to save the day!

Secondly; Damn! I know absolutely nothing about LUA, so I guess I have some tutorial reading to do...

@LeeS; If its not too much trouble, that would be great, I suppose I don't have to do the Monasteries, Pagodas, Mosques and Cathedrals; but I was thinking it'd be a nice extra bit, since they are techincally religious buildings. Gotta be thorough when you say 'Religious buildings' :-p

@bouncymischa; ohh thanks for the code snippet! I don't really care if its the best way or not just so long as it works! I'll definitely use that as a reference once LUA looks less like gibberish to me xD.
 
I'll try to look into it tonight. It's not a big trouble -- I was thinking of something along those lines anyway in terms of something I wanted to test if it would work properly.

[edit] tested and it works OK so far as I can see. I'll post the code I used a bit later, as it's diner time here. You woould also need the Dynamic Culture Overview mod to get the unique version of the Cathedral to run properly.

Spoiler :
I used CIVILIZATION_AMERICA as the civilization to whom these unique versions of Cathedrals, etc., were assigned. Shown in blue text, you would need to alter for your civs CIVILIZATION_SOMETHING name. The buildings as I structured them add the same city defense and hit points as city walls but otherwise do exactly as the standard Cathedral, Mosque, etc. I highlighted the city defense code in red to make it easier to see. Not knowing what building name you'd really want to end up with I gave the buildings unique XML names by adding "_LRS_" to the XML names of the Cathedral, Mosque, etc. You'd probably also want to change the in-game <Text>blah blah</Text> lines (shown in green) to something a bit more appropriate for your civilzation.
Code:
<GameData>
	<Buildings>
		<Row>
			<Type>BUILDING_LRS_CATHEDRAL</Type>
			<BuildingClass>BUILDINGCLASS_CATHEDRAL</BuildingClass>
			<Cost>-1</Cost>
			<FaithCost>200</FaithCost>
			<UnlockedByBelief>true</UnlockedByBelief>
			<Description>TXT_KEY_BUILDING_LRS_CATHEDRAL</Description>
			<Civilopedia>TXT_KEY_CIV5_BUILDINGS_CATHEDRAL_TEXT</Civilopedia>
			<Strategy>TXT_KEY_BUILDING_CATHEDRAL_STRATEGY</Strategy>
			<GreatWorkSlotType>GREAT_WORK_SLOT_ART_ARTIFACT</GreatWorkSlotType>
			<GreatWorkCount>1</GreatWorkCount>
			<ConquestProb>100</ConquestProb>
			<ArtDefineTag>TEMPLE</ArtDefineTag>
			<MinAreaSize>-1</MinAreaSize>
			<Happiness>1</Happiness>
			<IconAtlas>EXPANSION_BW_ATLAS_1</IconAtlas>
			<PortraitIndex>2</PortraitIndex>
			[COLOR="Red"]<Defense>500</Defense>
			<ExtraCityHitPoints>50</ExtraCityHitPoints>[/COLOR]
		</Row>
		<Row>
			<Type>BUILDING_LRS_MOSQUE</Type>
			<BuildingClass>BUILDINGCLASS_MOSQUE</BuildingClass>
			<Cost>-1</Cost>
			<FaithCost>200</FaithCost>
			<UnlockedByBelief>true</UnlockedByBelief>
			<Description>TXT_KEY_BUILDING_LRS_MOSQUE</Description>
			<Civilopedia>TXT_KEY_CIV5_BUILDINGS_MOSQUE_TEXT</Civilopedia>
			<Strategy>TXT_KEY_BUILDING_MOSQUE_STRATEGY</Strategy>
			<ConquestProb>100</ConquestProb>
			<ArtDefineTag>TEMPLE</ArtDefineTag>
			<MinAreaSize>-1</MinAreaSize>
			<Happiness>1</Happiness>
			<IconAtlas>EXPANSION_BW_ATLAS_1</IconAtlas>
			<PortraitIndex>5</PortraitIndex>
			[COLOR="red"]<Defense>500</Defense>
			<ExtraCityHitPoints>50</ExtraCityHitPoints>[/COLOR]
		</Row>
		<Row>
			<Type>BUILDING_LRS_PAGODA</Type>
			<BuildingClass>BUILDINGCLASS_PAGODA</BuildingClass>
			<Cost>-1</Cost>
			<FaithCost>200</FaithCost>
			<UnlockedByBelief>true</UnlockedByBelief>
			<Description>TXT_KEY_BUILDING_LRS_PAGODA</Description>
			<Civilopedia>TXT_KEY_CIV5_BUILDINGS_PAGODA_TEXT</Civilopedia>
			<Strategy>TXT_KEY_BUILDING_PAGODA_STRATEGY</Strategy>
			<ConquestProb>100</ConquestProb>
			<ArtDefineTag>TEMPLE</ArtDefineTag>
			<MinAreaSize>-1</MinAreaSize>
			<Happiness>2</Happiness>
			<IconAtlas>EXPANSION_BW_ATLAS_1</IconAtlas>
			<PortraitIndex>6</PortraitIndex>
			[COLOR="red"]<Defense>500</Defense>
			<ExtraCityHitPoints>50</ExtraCityHitPoints>[/COLOR]
		</Row>
		<Row>
			<Type>BUILDING_LRS_MONASTERY</Type>
			<BuildingClass>BUILDINGCLASS_MONASTERY</BuildingClass>
			<Cost>-1</Cost>
			<FaithCost>150</FaithCost>
			<UnlockedByBelief>true</UnlockedByBelief>
			<Description>TXT_KEY_BUILDING_LRS_MONASTERY_DESC</Description>
			<Civilopedia>TXT_KEY_CIV5_BUILDINGS_MONASTERY_TEXT</Civilopedia>
			<Strategy>TXT_KEY_BUILDING_MONASTERY_STRATEGY</Strategy>
			<Help>TXT_KEY_BUILDING_MONASTERY_HELP</Help>
			<ArtDefineTag>MONASTERY</ArtDefineTag>
			<MinAreaSize>-1</MinAreaSize>
			<ConquestProb>66</ConquestProb>
			<IconAtlas>BW_ATLAS_1</IconAtlas>
			<PortraitIndex>38</PortraitIndex>
			[COLOR="red"]<Defense>500</Defense>
			<ExtraCityHitPoints>50</ExtraCityHitPoints>[/COLOR]
		</Row>
	</Buildings>

	<Civilization_BuildingClassOverrides>
		<Row>
			<CivilizationType>[COLOR="Blue"]CIVILIZATION_AMERICA[/COLOR]</CivilizationType>
			<BuildingClassType>BUILDINGCLASS_CATHEDRAL</BuildingClassType>
			<BuildingType>BUILDING_LRS_CATHEDRAL</BuildingType>
		</Row>
		<Row>
			<CivilizationType>[COLOR="blue"]CIVILIZATION_AMERICA[/COLOR]</CivilizationType>
			<BuildingClassType>BUILDINGCLASS_MOSQUE</BuildingClassType>
			<BuildingType>BUILDING_LRS_MOSQUE</BuildingType>
		</Row>
		<Row>
			<CivilizationType>[COLOR="blue"]CIVILIZATION_AMERICA[/COLOR]</CivilizationType>
			<BuildingClassType>BUILDINGCLASS_PAGODA</BuildingClassType>
			<BuildingType>BUILDING_LRS_PAGODA</BuildingType>
		</Row>
		<Row>
			<CivilizationType>[COLOR="blue"]CIVILIZATION_AMERICA[/COLOR]</CivilizationType>
			<BuildingClassType>BUILDINGCLASS_MONASTERY</BuildingClassType>
			<BuildingType>BUILDING_LRS_MONASTERY</BuildingType>
		</Row>
	</Civilization_BuildingClassOverrides>

	<Building_Flavors>
		<Row>
			<BuildingType>BUILDING_LRS_MONASTERY</BuildingType>
			<FlavorType>FLAVOR_RELIGION</FlavorType>
			<Flavor>5</Flavor>
		</Row>
		<Row>
			<BuildingType>BUILDING_LRS_MONASTERY</BuildingType>
			<FlavorType>FLAVOR_CULTURE</FlavorType>
			<Flavor>5</Flavor>
		</Row>
		<Row>
			<BuildingType>BUILDING_LRS_CATHEDRAL</BuildingType>
			<FlavorType>FLAVOR_RELIGION</FlavorType>
			<Flavor>1</Flavor>
		</Row>
		<Row>
			<BuildingType>BUILDING_LRS_CATHEDRAL</BuildingType>
			<FlavorType>FLAVOR_CULTURE</FlavorType>
			<Flavor>4</Flavor>
		</Row>
		<Row>
			<BuildingType>BUILDING_LRS_CATHEDRAL</BuildingType>
			<FlavorType>FLAVOR_GREAT_PEOPLE</FlavorType>
			<Flavor>2</Flavor>
		</Row>
		<Row>
			<BuildingType>BUILDING_LRS_CATHEDRAL</BuildingType>
			<FlavorType>FLAVOR_HAPPINESS</FlavorType>
			<Flavor>4</Flavor>
		</Row>
		<Row>
			<BuildingType>BUILDING_LRS_MOSQUE</BuildingType>
			<FlavorType>FLAVOR_RELIGION</FlavorType>
			<Flavor>4</Flavor>
		</Row>
		<Row>
			<BuildingType>BUILDING_LRS_MOSQUE</BuildingType>
			<FlavorType>FLAVOR_CULTURE</FlavorType>
			<Flavor>2</Flavor>
		</Row>
		<Row>
			<BuildingType>BUILDING_LRS_MOSQUE</BuildingType>
			<FlavorType>FLAVOR_HAPPINESS</FlavorType>
			<Flavor>4</Flavor>
		</Row>
		<Row>
			<BuildingType>BUILDING_LRS_PAGODA</BuildingType>
			<FlavorType>FLAVOR_RELIGION</FlavorType>
			<Flavor>2</Flavor>
		</Row>
		<Row>
			<BuildingType>BUILDING_LRS_PAGODA</BuildingType>
			<FlavorType>FLAVOR_CULTURE</FlavorType>
			<Flavor>2</Flavor>
		</Row>
		<Row>
			<BuildingType>BUILDING_LRS_PAGODA</BuildingType>
			<FlavorType>FLAVOR_HAPPINESS</FlavorType>
			<Flavor>6</Flavor>
		</Row>
	</Building_Flavors>

	<Building_ResourceYieldChanges>
		<Row>
			<BuildingType>BUILDING_LRS_MONASTERY</BuildingType>
			<ResourceType>RESOURCE_INCENSE</ResourceType>
			<YieldType>YIELD_FAITH</YieldType>
			<Yield>1</Yield>
		</Row>
		<Row>
			<BuildingType>BUILDING_LRS_MONASTERY</BuildingType>
			<ResourceType>RESOURCE_WINE</ResourceType>
			<YieldType>YIELD_FAITH</YieldType>
			<Yield>1</Yield>
		</Row>
		<Row>
			<BuildingType>BUILDING_LRS_MONASTERY</BuildingType>
			<ResourceType>RESOURCE_INCENSE</ResourceType>
			<YieldType>YIELD_CULTURE</YieldType>
			<Yield>1</Yield>
		</Row>
		<Row>
			<BuildingType>BUILDING_LRS_MONASTERY</BuildingType>
			<ResourceType>RESOURCE_WINE</ResourceType>
			<YieldType>YIELD_CULTURE</YieldType>
			<Yield>1</Yield>
		</Row>
	</Building_ResourceYieldChanges>

	<Building_YieldChanges>
		<Row>
			<BuildingType>BUILDING_LRS_MONASTERY</BuildingType>
			<YieldType>YIELD_CULTURE</YieldType>
			<Yield>2</Yield>
		</Row>
		<Row>
			<BuildingType>BUILDING_LRS_MONASTERY</BuildingType>
			<YieldType>YIELD_FAITH</YieldType>
			<Yield>2</Yield>
		</Row>
		<Row>
			<BuildingType>BUILDING_LRS_CATHEDRAL</BuildingType>
			<YieldType>YIELD_CULTURE</YieldType>
			<Yield>1</Yield>
		</Row>
		<Row>
			<BuildingType>BUILDING_LRS_CATHEDRAL</BuildingType>
			<YieldType>YIELD_FAITH</YieldType>
			<Yield>1</Yield>
		</Row>
		<Row>
			<BuildingType>BUILDING_LRS_MOSQUE</BuildingType>
			<YieldType>YIELD_CULTURE</YieldType>
			<Yield>2</Yield>
		</Row>
		<Row>
			<BuildingType>BUILDING_LRS_MOSQUE</BuildingType>
			<YieldType>YIELD_FAITH</YieldType>
			<Yield>3</Yield>
		</Row>
		<Row>
			<BuildingType>BUILDING_LRS_PAGODA</BuildingType>
			<YieldType>YIELD_CULTURE</YieldType>
			<Yield>2</Yield>
		</Row>
		<Row>
			<BuildingType>BUILDING_LRS_PAGODA</BuildingType>
			<YieldType>YIELD_FAITH</YieldType>
			<Yield>2</Yield>
		</Row>
	</Building_YieldChanges>

	<Language_en_US>
		<Row Tag="TXT_KEY_BUILDING_LRS_CATHEDRAL">
			[COLOR="Green"]<Text>LRS Cathedral</Text>[/COLOR]
		</Row>
		<Row Tag="TXT_KEY_BUILDING_LRS_MOSQUE">
			[COLOR="green"]<Text>LRS Mosque</Text>[/COLOR]
		</Row>
		<Row Tag="TXT_KEY_BUILDING_LRS_PAGODA">
			[COLOR="green"]<Text>LRS Pagoda</Text>[/COLOR]
		</Row>
		<Row Tag="TXT_KEY_BUILDING_LRS_MONASTERY_DESC">
			[COLOR="green"]<Text>LRS Monastery</Text>[/COLOR]
		</Row>
	</Language_en_US>
</GameData>

Also, the mod you want to look for with regard to the Cathedral great work of art issue is "Dynamic Culture Overview", I think. It's available on the Steam Workshop, and I think perhaps here on CivFanatics.
 
@ LeeS; I facepalmed so hard now that I saw that this seems as easy to do as I thought it should be...

I am concerned that if i over-wrote the building like I would for a UB it'd show up as a UB on the empire selection/Dawn of Man screen though?

Would this work for the Shrine and Temple also?

I think I might have found another way to come about the trait for now, but I'd still like to pick your brain if you don't mind? Especially in case I decide to revert to this original idea!
 
It would possibly show on the civ selection / DOM screens. Depends on what the "real" Uniques are. IIRC the game gives preference to unique units over unique buildings so far as what shows on the selection / DOM screens.

Re Temples and Shrines: Yup, will work for them too. Maya, Songhai, and Egypt all have unique versions of Shrines or Temples. So far as the game is concerned a unique replacement is just another building: it doesn't know or care what attributes a unique replacement is given.

You could give a Shrine replacement building all the gold-generating and trade-route-related commands of a Market. The game will still see it as a unique replacement for a Shrine.

The game has no "code-policeman" within it looking to see that new added unique buildings aren't doing something that the standard building doesn't do.
 
I am concerned that if i over-wrote the building like I would for a UB it'd show up as a UB on the empire selection/Dawn of Man screen though?

The DoM screen displays uniques in a certain order -- it will display all UU's first, then all UB's, and then all UI's. UUs and UBs get displayed in the order that they are listed in <Civilization_UnitClassOverrides> and <Civilization_BuildingClassOverrides>. So, for example, if your civ has a UU, a "normal" UB that replaces the Colosseum, and two "dummy" UBs the replace the Shrine and Temple, then as long as you list the Colosseum UB first in <Civilization_BuildingClassOverrides>, the subsequent two UBs won't show up on the front screen.

Unless, of course, the player is using one of the other mods that increases the display size. (I know some mods modify the DoM screen to display three uniques, for example.)
 
The DoM screen displays uniques in a certain order -- it will display all UU's first, then all UB's, and then all UI's. UUs and UBs get displayed in the order that they are listed in <Civilization_UnitClassOverrides> and <Civilization_BuildingClassOverrides>. So, for example, if your civ has a UU, a "normal" UB that replaces the Colosseum, and two "dummy" UBs the replace the Shrine and Temple, then as long as you list the Colosseum UB first in <Civilization_BuildingClassOverrides>, the subsequent two UBs won't show up on the front screen.

Unless, of course, the player is using one of the other mods that increases the display size. (I know some mods modify the DoM screen to display three uniques, for example.)
I thought that was how it worked, but I wasn't sure.

The game will display all the uniques on the Civilization's Civilopedia page, however. So you have to decide whether that extra clutter is enough to cause an aesthetic "no go" for you.
 
I see, I see... I tend to hate the clutter and want that 100% professional look; but sometimes you just have to jury-rig something else up.

Thanks all for your assistance, even if I'm trying out a bit of a new direction with the defensive ability. Keep an eye on the Workshop! Not long now.
 
Untested, but try this:

Code:
local iDummyDefNumGlobal = 0
local iDummyDefense = GameInfoTypes["BUILDING_DUMMY_RELIGION_DEFENSE"]
local iCiv = GameInfoTypes["CIVILIZATION_YOUR_CIV_HERE"]

function PopulateRelBuildingsTb()
	for pBuilding in GameInfo.Buildings() do
		local pBuildingType = GameInfo.Buildings[pBuilding].Type
		if GameInfo.Building_ResourceYieldChanges{BuildingType = pBuildingType, YieldType = "YIELD_FAITH"} then
			iDummyDefNumGlobal = iDummyDefNumGlobal + 1
			table.insert(RelBuildingsTb, pBuildingType)
		end
	end
	for i, v in pairs(RelBuildingsTb) do
		print(i, v)
	end
end

function DefeForRelBuilding(iPlayer, iCity, iBuildingClass)
	local pPlayer = Players[iPlayer]
	local pCity = pPlayer:GetCityByID(iCity)
	if pPlayer:GetCivilizationType() == iCiv then
		local pPlot = pCity:Plot()
		local eDefaultBuilding = GameInfo.BuildingClasses[iBuildingClass].DefaultBuilding
		local bIsBuildingRel = GameInfo.Buildings[eDefaultBuilding].IsReligious
		if bIsBuildingRel or GameInfo.Building_ResourceYieldChanges{BuildingType = pBuildingType, YieldType = "YIELD_FAITH"} then
			local iDummyDefNum = iDummyDefNumGlobal + 1
			pCity:SetNumRealBuildings(iDummyDefense, iDummyDefNum)
		end
	end
end

PopulateRelBuildingsTb()
LuaEvents.BuildingCreatedEvent.Add(DefeForRelBuilding)

You'll need to use Build Created Event (by Machiavelli24), which you can find here with explanations on how to use.

Hope it helps! :D
 
Untested, but try this:

Code:
local iDummyDefNumGlobal = 0
local iDummyDefense = GameInfoTypes["BUILDING_DUMMY_RELIGION_DEFENSE"]
local iCiv = GameInfoTypes["CIVILIZATION_YOUR_CIV_HERE"]

function PopulateRelBuildingsTb()
	for pBuilding in GameInfo.Buildings() do
		local pBuildingType = GameInfo.Buildings[pBuilding].Type
		if GameInfo.Building_ResourceYieldChanges{BuildingType = pBuildingType, YieldType = "YIELD_FAITH"} then
			iDummyDefNumGlobal = iDummyDefNumGlobal + 1
			table.insert(RelBuildingsTb, pBuildingType)
		end
	end
	for i, v in pairs(RelBuildingsTb) do
		print(i, v)
	end
end

function DefeForRelBuilding(iPlayer, iCity, iBuildingClass)
	local pPlayer = Players[iPlayer]
	local pCity = pPlayer:GetCityByID(iCity)
	if pPlayer:GetCivilizationType() == iCiv then
		local pPlot = pCity:Plot()
		local eDefaultBuilding = GameInfo.BuildingClasses[iBuildingClass].DefaultBuilding
		local bIsBuildingRel = GameInfo.Buildings[eDefaultBuilding].IsReligious
		if bIsBuildingRel or GameInfo.Building_ResourceYieldChanges{BuildingType = pBuildingType, YieldType = "YIELD_FAITH"} then
			local iDummyDefNum = iDummyDefNumGlobal + 1
			pCity:SetNumRealBuildings(iDummyDefense, iDummyDefNum)
		end
	end
end

PopulateRelBuildingsTb()
LuaEvents.BuildingCreatedEvent.Add(DefeForRelBuilding)

You'll need to use Build Created Event (by Machiavelli24), which you can find here with explanations on how to use.

Hope it helps! :D

Latest patch obsoletes that method, as you can now us:

Code:
GameEvents.CityConstructed(ownerId, cityId, buildingType, bGold, bFaithOrCulture);

The function that's being requested will probably want to run every turn, however - in case of buildings being sold, for instance. Basically, it's the reverse of my Hungary code (which gives Faith for every Defensive Building):

Code:
function GetNumFaithBuildings(city)
	local numFaithBuildings = 0
	for row in GameInfo.Building_YieldChanges("YieldType == 'YIELD_FAITH'") do
                local buildingID = GameInfoTypes[row.Type]
		if city:IsHasBuilding(buildingID) then
			numFaithBuildings = numFaithBuildings + 1
		end
	end
	
	return numFaithBuildings 
end

local buildingDummyDefenseID = GameInfoTypes["BUILDING_DUMMY_RELIGION_DEFENSE"]
local civilisationID = GameInfoTypes["CIVILIZATION_YOUR_CIV_HERE"]
function DefenseFromReligiousBuildings(playerID)
	local player = Players[playerID]
	if player:GetCivilizationType() == civilisationID and player:IsEverAlive() then
		for city in player:Cities() do
			city:SetNumRealBuilding(buildingDummyDefenseID , JFD_GetNumFaithBuildings(city))
		end
	end
end
GameEvents.PlayerDoTurn.Add(DefenseFromReligiousBuildings)
 
Latest patch obsoletes that method, as you can now us:

Code:
GameEvents.CityConstructed(ownerId, cityId, buildingType, bGold, bFaithOrCulture);

The function that's being requested will probably want to run every turn, however - in case of buildings being sold, for instance.

I didn't even knew there was a new patch in town. That GameEvent is very similar to whoward's.
Where can I find more information about this new patch?


EDIT: (to avoid posting just for two words) Thanks JFD! :D
 
I didn't even knew there was a new patch in town. That GameEvent is very similar to whoward's.
Where can I find more information about this new patch?

Yup. Firaxis must've divined from the Lord Whoward some wisdoms, more of which you can find here
 
Yup. Firaxis must've divined from the Lord Whoward some wisdoms, more of which you can find here

It is amusing how many of the new events seem to have come from Whoward's DLL... :P

That said...

Code:
function GetNumFaithBuildings(city)
	local numFaithBuildings = 0
	for row in GameInfo.Building_YieldChanges("YieldType == 'YIELD_FAITH'") do
                local buildingID = GameInfoTypes[row.Type]
		if city:IsHasBuilding(buildingID) then
			numFaithBuildings = numFaithBuildings + 1
		end
	end
	
	return numFaithBuildings 
end

I was wondering how you might dynamically find buildings that generated faith. A handy bit of code there!
 
Back
Top Bottom