any way to give one civ multiple buildings of the same BuildingClass?

orlanth

Storm God. Yarr!
Joined
Nov 17, 2001
Messages
1,805
(I don't know if it's appropriate to post here asking for help, but being quite stuck with a FfH modmodding issue I figured I'd give it a shot..)

For the Warhammer Fantasy Battles Mod (a modmod that uses FfH2 as a base), we're trying to create a group of five different Temple buildings for deities in the Chaos pantheon; where a civ can choose from any of these to build, but isn't able to build more than one from this group in the same city.

I had implemented this by making the Temples share one BuildingClass; this initially appeared to work, but it turns out that when trying to provide a civ multiple building types of the same class in Civ4CivilizationInfos.xml, only one building type of the class actually gets through to be buildable in-game. I've also tried giving each Temple their own BuildingClass so they all become buildable, and making them obsolete all the other temples, but this seems to cause problems too since ObsoleteBuildingClass apparently is transitive (if A obsoletes B and B obseletes A, then A obsoletes A), actually causing a crash once when building a temple. This is actually a fairly important part of the mod; we'd also hoped to give our variety of Magic College buildings an overall max of 3 per civ using a shared BuildingClass.

So, does anyone know if it is possible to somehow let a civ build 1 per city of a specific group of buildings, either using a Class or an entirely different way? Thanks very much for any advice - and as always we'd welcome any interested developers to get involved with this modmod in any way that strikes your fancy; it's quite a unique/promising one but in real need of greater talents than I!
 
I'd like it if it were possible to let civs build any of a building/unitclass given the proper prereqs, but I don't think it is.


I remember complaining to the moder who made the modcomp about Obsolete Building class being transitive, and him considering changing it but then not doing anything about it.


I was planning on something very similar to this in my (oft postponed) modmod.



Without trying to change the SDK, the only way I know how to handle this is to add a block like this in python\CvGameUtils.py:
Code:
	def cannotConstruct(self,argsList):
		pCity = argsList[0]
		eBuilding = argsList[1]
		bContinue = argsList[2]
		bTestVisible = argsList[3]
		bIgnoreCost = argsList[4]
		pPlayer = gc.getPlayer(pCity.getOwner())
		
		
		
		
		if eBuilding == gc.getInfoTypeForString('BUILDING_TEMPLE_A'):
			if (pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_TEMPLE_B')) > 0 or pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_TEMPLE_C')) > 0 or pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_TEMPLE_D')) > 0):
				return True
		if eBuilding == gc.getInfoTypeForString('BUILDING_TEMPLE_B'):
			if (pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_TEMPLE_A')) > 0 or pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_TEMPLE_C')) > 0 or pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_TEMPLE_D')) > 0):
				return True
		if eBuilding == gc.getInfoTypeForString('BUILDING_TEMPLE_C'):
			if (pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_TEMPLE_A')) > 0 or pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_TEMPLE_B')) > 0 or pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_TEMPLE_D')) > 0):
				return True
		if eBuilding == gc.getInfoTypeForString('BUILDING_TEMPLE_D'):
			if (pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_TEMPLE_A')) > 0 or pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_TEMPLE_B')) > 0 or pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_TEMPLE_C')) > 0):
				return True

Unfortunately, no explanation as to why they are unbuildable will be given, but you could still write that in tool tips, strategy, civilopedia entries, etc.
 
Cleanest way I can think of for doing it would be to add a new XML tag to the BuildingClasses which would be a boolean to identify it as having multiple Buildings available in that BuildingClass. Since you want to limit this to a single faction as well, you'll have to put a prereqCiv tag in BuildingClasses as well.

Then you modify the calls for being able to construct a building to skip the normal "does this building match the Civilization's type for this Class?" call, and instead do a loop over all buildings and check if the Civilization/city has any of a matching Buildingclass.
 
I remember complaining to the moder who made the modcomp about Obsolete Building class being transitive, and him considering changing it but then not doing anything about it.

I'm working on it, but you probably know how postponing stuff works. ;) Actually I made an alpha with some changes to the code some time ago, but I wasn't that happy with the result and decided to think about another way.
 
Back
Top Bottom