Question: Building Limit per City

John Marlowe

Chieftain
Joined
Aug 16, 2012
Messages
3
Hello.

I hope this is the right place to ask for help.

1) Does anyone with more modding experience and talent know how I could possibly implement a limit on the number of buildings that can be constructed within a single city? I would like that limit to be based on population (1 building per citizen).

2) And assuming I manage to implement this, how can I make national wonders not count towards this limit?

3) And finally: How can I make it so that all buildings (even those with zero upkeep, and even wonders) can be sold? Once you have a building limit this becomes desirable.

Thank you very much in advance for your advice.
 
Errr #1 and #2 sound like you'll need to use LUA to do that, and it'll probably be a pain in the ass too.

#3 I'm not too sure on either, I don't recall seeing anything in the XML that handles selling buildings...just that any building with a maintenance cost can be sold (therefore you'd have to put maintenace on all buildings, and for those that you don't want to actually cost you anything you'll have to assign a +1 Gold yield to them.
 
It will require some lua but I think it is doable.

First you'll want to add a column to the building table, something like "spaceTaken, int, default 0". Set this to 1 for most buildings and 0 for Wonders, Palace, stuff that you don't want to count. The default should be 0 so that if another mod is using hidden buildings to do stuff the hidden buildings won't mess up your mod by consuming all the space in a city.

Second you'll want to add a function to GameEvents.CityCanConstruct (that may not be the exact name, but it is something like that) that calculates a how much space a city has (population or whatever method you want) and counts the sum of "spaceTaken" by each building the city has. If (spaceTaken >= spaceOpen) return false; else return true;

I'm glossing over some of the details but you're probably better off making Wonders not require space than making them sellable.
 
Back
Top Bottom