Possible to increase attribute of BuildingClass via Tech?

Xyth

History Rewritten
Joined
Jul 14, 2004
Messages
4,106
Location
Aotearoa
As the title suggests I'm wondering if there's a simple way to increase an attribute of an entire BuildingClass when a tech is discovered. Examples of what I mean:

Communications Exchange
(Requires Electricity)
•-10% City Maintenance
•-10% City Maintenance with Radio
•-10% City Maintenance with Fibre Optics
•-10% City Maintenance with Satellites

Smithy
(Requires Copper Working)
• +2 production
• +2 production with Iron Working
• +2 production with Steel Working

I tried using the Event system but such changes these only apply to buildings already constructed and not future ones. Using Python, I figure I can use onBuildingBuilt for newly built buildings and onTechAcquired to loop through each city and apply the change to each building previously built. However, is there a simpler way to do this that I'm overlooking?

EDIT: Dawned on me that I could use the event system for existing buildings and onBuildingBuilt for new ones which would cut out all the messy loops. Still, do let me know if there is some API function I've missed that does this easier.
 
You're looking to use the CyCity class to manipulate the output/yield of buildings already present? I however bet you only need to use the onTechAquired callup to loop all cities of the responsible player. (Use PyPlayer.getCityList()!) That would make the increase/decrease permanent for that city - no matter if the building is already present or not - or if it is lost later.

What you need to do, instead, is to hack into the onCityBuilt/onCityAquired callups - to ensure that any fututure cities also get this change! And also that any lost city has its privilieges revoked!

In short: This is really a candidate for SDK modding. :p Still sounds like a fun Python outing to me though! :D
 
Back
Top Bottom