Make only one of two buildings buildable

Maniac

Apolyton Sage
Joined
Nov 27, 2004
Messages
5,603
Location
Gent, Belgium
Is there some way to make it so that you can build two buildings, but if you build one of them, the other one becomes unbuildable and disappears off the build list? One building excluding another?
 
The building upgrade tags Lopez was planning could be configured to have this effect.

P.S. I HATE it when games have Building Trees with these kinds of A OR B choices, for example you can build Archery Range and build archer OR a Stable and Build Knights but not both! This makes NO SENSE WHAT-SO-EVER and is a poor substiture for an interesting and Balanced Tree of choices. DO NOT MAKE A MOD LIKE THIS :mad: :mad: :mad:
 
Don't worry what I was trying to achieve was a Post Office building that can only be built in landlocked cities and gives +50% trade yield. I assumed a way to achieve this was to create a choice between either a Harbor or a Post Office. Since harbors can only be built in coastal cities, in landlocked cities the choice would automatically default to post offices. :D

Anyway, this was meant for Fall from Heaven, so if it requires an outside mod it won't be possible. :(
 
I would think you would want to invert the tag on Harbors that makes them coast only to create a landlocked only tag. Also why not call it a "Canal" as that would make more sense then Post Office which exist in all cities.
 
If this is for only a few change , you can do that in python without creating a new tag , by changing the function cannotConstruct(..) in CvGameInterface.py ... you already have an example in FFH2 for settlement ,etc ... I think ( i never deal with this function , so perhaps , this is not as simple )

Tcho !
 
Impaler[WrG] said:
The building upgrade tags Lopez was planning could be configured to have this effect.

P.S. I HATE it when games have Building Trees with these kinds of A OR B choices, for example you can build Archery Range and build archer OR a Stable and Build Knights but not both! This makes NO SENSE WHAT-SO-EVER and is a poor substiture for an interesting and Balanced Tree of choices. DO NOT MAKE A MOD LIKE THIS :mad: :mad: :mad:

In general I agree but there are situations where this could be interesting.

For example, if you are designing a sci-fi mod that begins with your people crash landing into a distant world you could provide some starting materials that could be used to build an armory, a biodome, a workshop or a giant statue of dolly parton. But you wouldn't be able to build the others until later eras where you were able to manufacture new supplies.

As in all things mechanics arent bad, just the implementation of mechanics.
 
M@ni@c said:
Don't worry what I was trying to achieve was a Post Office building that can only be built in landlocked cities and gives +50% trade yield. I assumed a way to achieve this was to create a choice between either a Harbor or a Post Office. Since harbors can only be built in coastal cities, in landlocked cities the choice would automatically default to post offices. :D

Anyway, this was meant for Fall from Heaven, so if it requires an outside mod it won't be possible. :(

The best way to do this is probably a block in cannotConstruct function in CvGameInterface.py. Check it out to see some examples of other buildings we block.
 
Kael said:
The best way to do this is probably a block in cannotConstruct function in CvGameInterface.py. Check it out to see some examples of other buildings we block.

Are you referring to this event, or whatever you have to call it?

Code:
def cannotConstruct(argsList):
	pCity = argsList[0]
	eBuilding = argsList[1]
	bContinue = argsList[2]
	bTestVisible = argsList[3]
	bIgnoreCost = argsList[4]
	pPlayer = gc.getPlayer(pCity.getOwner())

	iSettlement = gc.getInfoTypeForString('BUILDING_SETTLEMENT')

	if pCity.isHasRealBuilding(iSettlement):
		bValid = False
		if (eBuilding == gc.getInfoTypeForString('BUILDING_OBELISK') or eBuilding == gc.getInfoTypeForString('BUILDING_WALLS')):
			bValid = True
		if eBuilding == gc.getInfoTypeForString('BUILDING_CITY'):
			if pPlayer.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_CITY")) < gc.getDefineINT('SPRAWLING_NUMBER_OF_CITIES'):
				bValid = True
		if bValid == False:
			return True

	return False

I'm afraid I don't understand the grammar of that event. :crazyeye:

FfH v13 has this, but I assume this forbids construction of a building in all cities:

Code:
	if eBuilding == gc.getInfoTypeForString('BUILDING_GOLDEN_WOOD'):
		for i in range(pPlayer.getNumCities()):
			pCity2 = pPlayer.getCity(i)
			if pCity2.hasBuilding(gc.getInfoTypeForString('BUILDING_SHADOWED_VALE')):
				return True
 
for an example you can try this if you want that just building A or B buildable in a city : (i don't test the code ) :

Code:
iBuildingA=gc.getInfoTypeForString('BUILDING_A')
iBuildingB=gc.getInfoTypeForString('BUILDING_B')
if eBuilding in (iBuildingA,iBuildingB):
        if pCity.isHasRealBuilding(iBuildingA) or pCity.isHasRealBuilding(iBuildingB):
                return True

edit :

( edit : the following code is not usefull . )

for a cosmetic issue , if you don't want that buildingA or buildingB appear in grey (in the city screen ) when you already have built one : you can edit CvMainInterface.py :

Code:
# Buildings to construct
for i in range ( g_NumBuildingClassInfos ):
        if (not isLimitedWonderClass(i)):
                eLoopBuilding = gc.getCivilizationInfo(pHeadSelectedCity.getCivilizationType()).getCivilizationBuildings(i)

                if (pHeadSelectedCity.canConstruct(eLoopBuilding, False, True, False)):
                        
                        #### added code
                        iBuildingA=gc.getInfoTypeForString('BUILDING_A')
                        iBuildingB=gc.getInfoTypeForString('BUILDING_B')
                        if eLoopBuilding in (iBuildingA,iBuildingB):
                                if pHeadSelectedCity.isHasRealBuilding(iBuildingA) or pHeadSelectedCity.isHasRealBuilding(iBuildingB):
                                        continue
                        #### added code
                                    
                        screen.appendMultiListButton( "BottomButtonContainer", gc.getBuildingInfo(eLoopBuilding).getButton(), iRow, WidgetTypes.WIDGET_CONSTRUCT, i, -1, False )
                        screen.show( "BottomButtonContainer" )
                        
                        if ( not pHeadSelectedCity.canConstruct(eLoopBuilding, False, False, False) ):
                                screen.disableMultiListButton( "BottomButtonContainer", iRow, iCount, gc.getBuildingInfo(eLoopBuilding).getButton() )

                        iCount = iCount + 1
                        bFound = True
 
Thanks for the help!!!

But when I test out this event,the game is dramatically slowed down. I can't even get the city screen to show. Any idea what could be causing this?
 
i've made this because i was boring to see settlement when you don't have the sprawling trait . there is perhaps a better way ... but i think this a bug because i had nothing like that .

So i have two question : do you have enabled the debugger ? and could you post your file if you can't fix your code or your code? ( perhaps i've made a mistake and this come from me ) . i'm interrested in fixing it
 
Tested with the debugger on. First I had problems with indentation. Now I've fixed those, I get reports I don't understand at all. The interface is completely lacking and civilopedia doesn't work.
 
i've tested with herbalist and obelisk and that goes (with your file). i'm sorry , editing CvMainInterface.py was not usefull ... editing CvGameInterface.py is enough .

Sorry again , i was thinking that the building would appear in grey but i was wrong ! as soon as you you build one of the two buildings the other disappear ( but i will search for the bug , since i do not understand why this not goes with the last version of FFH2 )

Tcho !
 
Back
Top Bottom