Edit buildings or wonders in a city

DonQuiche

Emperor
Joined
May 23, 2011
Messages
1,122
Hello everyone.

I would like to know if any of you has an idea about how to forcefully add buildings or wonders to a city.
* I tried to use Game.CityPurchaseBuilding but it only works for purchasable items (no wonders, techs must be discovered, etc). Registering GameEvents.CanConstruct didn't work.
* I tried to use City.Hurry[Production/Gold/] but... Does this feature even work ?
* I tried to use City.SetProduction and SetProductionOveflow and it works but there is still one turn left.

Besides, I would also like to be able to remove buildings. I tried to sell them through Network.SendSellBuilding(cityID, building.ID) but it seems to bug sometimes. Does anyone know the causes please ?
 
Yes, SetNumRealBuildings works just fine for this; it might have problems if you try to break a limit, like setting a Wonder to be true when there's already one of it in the world, but I haven't tested that.

It also has the added advantage that, if a building has the <NoLimit> flag set in its building class, the function can specify how many copies of it will be in a city. The UI unfortunately doesn't reflect the existence of multiple copies of a building, but I used this mechanism in my own mod to add Happiness-generating specialists (at the end of the turn, place one copy of a +1 Happiness building in a city for each specialist of that type) and a head-start bonus for people who begin the game in later eras (a tapering bonus to food, production, etc. to let you get up to speed quickly). It's a very useful bit of code.
 
Back
Top Bottom