New Trait: +1 Amenities if city has same religion as capital

Craig_Sutter

Deity
Joined
Aug 13, 2002
Messages
2,753
Location
Calgary, Canada
I am trying to make a leader trait for one of my civilizations. I would like the player's cities to gain +1 Amenities if they have the same religion as the capital.

First, can this be done using modifiers. I think not, but would like confirmation.

Second, assuming I need lua, I wonder what game hook I could use. I think GameCoreEvent CityReligionChanged... but in the information I have obtained from this forum, I cannot find any variables provided... Similar Civ 5 events provided iPlayer, iCity, eReligion, etc or similar such information. Are there more details provided that I have missed.

My idea is to have the event whenever a city of the player changes Religion. At which point, I would run a function to determine the religion in the capital and that city and if they were the same, install/remove a dummy building. As well, I need to account if the religion in the capital city changes, in which case, I would loop through all the players cities and check if they were the same or different in religion than the capital and install/remove the dummy building.

The dummy building would provide +1 Amenities if the religion if the city matches to the capital's.

I am okay at modding Civ lua, but have never modded Civ 6 lua. So I am a little uncertain. Normally, I would go through others' mods or the game scenarios for clues, but there is a lack of examples to go by.

Am I missing anything?

Also, I have never added a script to a Civ 6 modinfo file. Any hints?
 
I have mapped out a possible lua code to install a dummy building if the capital and city religion are the same... since I am unfamiliar with Civ 6 lua modding, there are likely numerous errors, but I would like some of the experts thoughts on this:

Code:
-- checks to see if city religion is the same as the Capital religion.

function MerciaCityReligionChange(iPlayer, iCity)

local pPlayer = Players[iPlayer]
local pCity = pPlayer:GetID(iCity)
local pCapital = pPlayer:GetCapitalCity()
    
    if pPlayer:IsEverAlive() then
        if    PlayerConfigurations.Leaders.LEADER_PENDA.ID == pPlayer:GetLeaderTypeID() then                 
            if pCity:GetReligion():GetMajorityReligion()== pCapital:GetReligion():GetMajorityReligion() then   
                (lua to install/remove dummy building)
            end   
        end
    end
end   

GameEvents.CityReligionChanged.Add (MerciaCityReligionChange)

I am very uncertain about the GameEvent variables I have... whether they are given by the function or not. I am also uncertain about the way I am looking up a leader as that was not used in Civ 5 modding... I do not know if I should first get the Civilization and then leader, for example. As well, I am not certain about using PlayerConfigurations in that context.

There are a lot of uncertainties. I plan to create and install the building in accord with LeeS's use of that sort of function in his Building depends upon resource code where he installs such a building. Can't go wrong by copying an expert :).

Thanks.
 
Top Bottom