Univerasal Building Modification Idea/Descussion

Impaler[WrG]

Civ4:Col UI programmer
Joined
Dec 5, 2005
Messages
1,750
Location
Vallejo, California
I have often heard people ask if its possible for a Civic, Wonder or Tech to change the effect of a building, say for example If you had Monarchy Tech your Castles would produce +1 Happiness, or if you Built NotraDam wonder all your Cathedrals would get +25% additional Culture for a total of +75% bonus.

In addition many people might like to create effects similar to the Virtual World ala SMAC inwhich building A gains the additional effect of and substitues for Building B. So for example all Libraries could act as Observatories and have the combined effects of each, onece the city has a Library its like getting the observatory for free.

Any individual one of these example could easily be done in Python or the SDK layer but it would be specific the the combination desired, I have a plan that may alow moders to alter a buildings effects with any effect that a building can have or might have in the future. Its realy a rather simple system based on technices peple have been using in Python for some time now, create a phantom building in XML which holds the desired changes and set a new tag I will create <bPhantom> to true and its cost to -1 (unbuildable) to designate the building as a phantom. The UI and Pedia will be modified to simply not display building which are Phantoms so they will not clutter things up. Then in the Tech/Wonder/Civic pair up the real building and the Phantom under a <BuildingModifications> element wich will be added. The player object CvPlayer will hold an array of [NumBuildingInfos] that initializes with -1 to all elements which constitutes an empty state. On Processing of Techs/Civis and Wonders the code will detect any BuildingModifications and set the Player Array with the linkage. For example Building number 17 is going to gain an effect which is encapsulated as building 24 we just do a BuildingModifier[17] = 24. This establishes the linkage of building 24 piggybacking on 17. We then call the CvCity::ProcessBuilding function which will be modifed to detect this linkage and call itself recursivly with the piggybacking building as its argument. A simple check function will detect if a dumb moder has created some kind of infinite loop before the recursion begins and if so abort. The Primary building will now carry the new effects and they will apear and disapear with it as if they had always been part of it. The UI will need some modification to display the new effects with the mouse over of the primary building but this should be rather simple as we just append the effects mouse over info to the primary. The same system will handle piggybacking a real non-phantom building as well but this will require some additional checks to make shure effects arn't duplicated and the CvCity::canBuild must return false in an existing building is already acting as the desired building. Even better when more effects are added to buildings (as I have already beed doing) these will get folded in without any additional work (so long as they trigger through ProcessBuildings which anyone with half a brain would do.

So to summarize modifications to buildings that can include any effect that a building has or will have and it should be doable entirely in XML. Sound like a good plan?
 
Clever. As is my current obsession, my only concern is that the AI be able to "use" it right. This should be fine for Techs as the AI, AFAIK, just relies on Flavors to pick a tech, but from what I understand the AI does a real analysis for Civics and Buildings. It would be well beyond your mod parameters to change that, but perhaps modders should be on notice that effects as extreme as what you described would put the AI at a serious disadvantage.
 
Padmewan said:
This should be fine for Techs as the AI, AFAIK, just relies on Flavors to pick a tech
You're ever so slightly (completely) wrong.

The AI does not just rely on Flavours to pick a tech. Instead, it looks at all the techs within it's era, or the next one up to a certain link depth, and picks the best one. The links are then just the fastest way it could get to this tech.

What it should do is check for the best set of links, and go for these, but that's only a minor difference, and is slightly off topic.

As mentioned - AI may be an issue, however I quite like the idea.
 
The Great Apple said:
You're ever so slightly (completely) wrong.
Well, I guess that's a Good Thing! Live and learn :) I haven't gone through that part of the codebase yet (just installed the SDK this past week).
 
Back
Top Bottom