Religious Building Query

Lplate

Esus (Allegedly)
Joined
Feb 8, 2011
Messages
578
Location
Ireland
Hi,

I want to have a building which generates positive happiness when the state religion is X, no impact on happiness when the state religion is Y and negative happiness when the state religion is Z.

I haven't been able to work out how to accomplish this during my various trawls through xml and python:confused:. Could someone please tell me how I can achieve this?
 
This ought to be doable with a Python script. You tap into the onPlayerChangeStateReligion call-up in CvEventManager and iterate through all player cities (probably with PyPlayer.getCityList()). Look for the building in question with CyCity.isHasBuilding(), if found you invoke CyCity.getBuildingHappyChange() to see what amount of happiness is currently added by the building. Depending on these return values you assign a new happiness/unhappiness count with CyCity.setBuildingHappyChange() corresponding the new state religion. Repeat with all cities.

You also need to hook-up with the onBuildingBuilt call-up, but then you wanna use CyPlayer.getStateReligion() to detect what the state religion is. Apply happiness value accordingly.

If you post the XML identifier tag for this building class it would be possible to write some sample code for you.
 
Thanks.

Helpful as ever Baldyr. I'll miss the Lena pic.
 
Back
Top Bottom