Some kind of weird bug BtS Final Frontier! (Modding)

Tengawa

Chieftain
Joined
Sep 21, 2009
Messages
6
Hello! First post here!

I've been steadily modding for a couple day a personal mod and... well... I don't understand why it's happening but... I made some new buildings (with tech and texts too!) and for some unexplainable reason, I can't build value buildings anymore (like the survival dome for exemple). When I do build it, the city interface isn't there anymore and when I double click on the solar system There is no more border and I can't edit anything. I just see a planet standing there with the moon frozen. I can still build other buildings on the same planet without opening the interface. The problem though is that I can't change the planet or ajust anything!

So my question is: Does those buildings have some kind of hidden value that I screwed? I never edited the code from those buildings so they are like vanilla FF.

I just added building in "Habitation Dome" Style (more pop. per planet) and "Mining Facility" style (more production per planet)

Of course I edited the SolarSystem.py though to add new buildings. And since I'm not that good in coding, I used MOO2CIV as a base for what to do to add new building in SolarSystem.py...

Anyway...I'm waiting your reply!

Thanks!

Olivier :D
 
Ok... but when I built only Habitation style it was working... hmmm

I keep that in mind!

Is there any other buildings that cannot be modded? (health style (recycling center), ($ style, happiness style, food style?

Thanks!

Olivier
 
It is probably possible to add buildings that do any of the functions that the ones it comes with do (I haven't added a +food per pop assigned to planet building, but I have added an additional +pop to planet and an additional +hammer per pop). It requires editing the stuff near the end of CvSolarSystem.py carefully. It is a lot easier to add buildings to the end of the CIV4BuildingInfos file than anywhere esle - if you don't, you need to check the position of all the buildings with effects implemented via python and adjust the CvSolarSystem data as the order is what matters.

When the interface disappears or you can't build buildings anymore the three most likely problems I can think of at the moment are:
1) You didn't increase the size of the building arrays in CvSolarSystem to be big enough to hold all your buildings. How many BuildingInfo entries do you have? In the line that says "for iBuildingLoop in range(SOMETHING):", that SOMETHING must be at least as big as the number of BuildingInfos (for the sake of simplicity you should probably make it at least two bigger, since the original value is 2 bigger in plain vanilla FF - because it starts 2 bigger you can add 2 buildings without seeing problems, but add a 3rd and things go bad).

2) You added an ArtDefine for the building that specifies a NIF of something other than Art/Empty.nif. The only buidlings that don't have this value in FF are the very few that actually appear on the map - like the Capital Shipyard or Star Fortress. Adding a building that shows up like that is more complicated (I've never done it).

3) You added a building that has an iConquest value of something other than 100. Then somebody captured a planet that has the building and Civ destroyed it internally but not in the onCityAcquired python. With this set to 100, with only a few exceptions (capitol buildings - you can only have 1 so it automatically destroys one that is captured; it may also do this for any other buidling defined as a national wonder if you already have one) they are destroyed only via the onCityAcquired callback.
 
Thanks people!

It's now working!

The problem was actually the Building range.(Now I can have 23 pop planets :crazyeye: and working +hammer on them!)

Now I got another one :crazyeye: The squadron factory, the squadron defense and the capital shipyard.

The Capital Shipyard doesn't show at all (minor bug it works it's only for the eyes :mischief:)

The Squadron Factory and Squadron Defense are... two big red rotating spot in my screen! Any idea why? :D (a slightly more annoying bug as... in my screen it hurt my eyes! :rolleyes:)

Well... waiting for your reply, I'm coding +food next!

Olivier

By the way, deanej... I think I got the solution for your -1 pop building. The way I did my +1, +2, +3, +5 and +10pop can probably be used with negative numbers.

Here is an extract of my code in the CvSolarSystem:

def getPopulationLimit(self, iOwner):

if (self.isDisabled()):
return 0

if (not self.isPlanetWithinCulturalRange()):
return 0

# iMaxPop = iMaxDefaultPopulationPerPlanet # Oh noes!
iMaxPop = aiDefaultPopulationPlanetSizeTypes[self.getPlanetSize()]

iBuildingHabSys = CvUtil.findInfoTypeNum(gc.getBuildingInfo,gc.getNumBuildingInfos(),'BUILDING_HABITATION_SYSTEM')
iBuildingHabCom = CvUtil.findInfoTypeNum(gc.getBuildingInfo,gc.getNumBuildingInfos(),'BUILDING_HABITATION_COMPLEX')
iBuildingHabAlp = CvUtil.findInfoTypeNum(gc.getBuildingInfo,gc.getNumBuildingInfos(),'BUILDING_HABITATION_ALPHA')
iBuildingHabGam = CvUtil.findInfoTypeNum(gc.getBuildingInfo,gc.getNumBuildingInfos(),'BUILDING_HABITATION_GAMMA')
iBuildingHabOme = CvUtil.findInfoTypeNum(gc.getBuildingInfo,gc.getNumBuildingInfos(),'BUILDING_HABITATION_OMEGA')

# for iBuildingLoop in range(gc.getNumBuildingInfos()):
if (self.isHasBuilding(iBuildingHabSys)):
# if (g_aiBuildingPopCapIncrease[iBuildingLoop] > 0):
iMaxPop += 1

if (self.isHasBuilding(iBuildingHabCom)):
# if (g_aiBuildingPopCapIncrease[iBuildingLoop] > 0):
iMaxPop += 2

if (self.isHasBuilding(iBuildingHabAlp)):
# if (g_aiBuildingPopCapIncrease[iBuildingLoop] > 0):
iMaxPop += 3

if (self.isHasBuilding(iBuildingHabGam)):
# if (g_aiBuildingPopCapIncrease[iBuildingLoop] > 0):
iMaxPop += 5

if (self.isHasBuilding(iBuildingHabOme)):
# if (g_aiBuildingPopCapIncrease[iBuildingLoop] > 0):
iMaxPop += 10


I actually used a part of the MOO2CIV for the code but I adapted it and it works!
By the way, I also removed the hard coded value at the very end (for what is done yet as Pop+ and Hammer+). It look like this:

# Hardcoded (This is Bad)
for iBuildingLoop in range(90):
g_aiBuildingYieldIncrease.append([0,0,0])
g_aiBuildingPopCapIncrease.append(0)
g_aszBuildingDummyTags.append("")

g_aiBuildingYieldIncrease[1][0] = 1 # Nutrition Facility
#g_aiBuildingYieldIncrease[2][1] = 1 # Mining Facility (---------- Commented
g_aiBuildingYieldIncrease[3][2] = 1 # Road Network
g_aiBuildingYieldIncrease[4][2] = 2 # Mag Lev Network

#g_aiBuildingPopCapIncrease[5] = 1 # Habitation Center (---------- Commented

g_aszBuildingDummyTags[7] = "FEATURE_MODEL_TAG_CAPITAL_SHIPYARD"
g_aszBuildingDummyTags[8] = "FEATURE_MODEL_TAG_SQUADRON_FACTORY"
g_aszBuildingDummyTags[21] = "FEATURE_MODEL_TAG_SQUADRON_DEFENSE_NETWORK"
g_aszBuildingDummyTags[22] = "FEATURE_MODEL_TAG_STAR_FORTRESS"


Well... I hope that help!
 
Thanks people!

It's now working!

The problem was actually the Building range.(Now I can have 23 pop planets :crazyeye: and working +hammer on them!)

Problematic Thing #1 for FF mods.

Now I got another one :crazyeye: The squadron factory, the squadron defense and the capital shipyard.

The Capital Shipyard doesn't show at all (minor bug it works it's only for the eyes :mischief:)

The Squadron Factory and Squadron Defense are... two big red rotating spot in my screen! Any idea why? :D (a slightly more annoying bug as... in my screen it hurt my eyes! :rolleyes:)

Well... waiting for your reply, I'm coding +food next!

Olivier

By the way, deanej... I think I got the solution for your -1 pop building. The way I did my +1, +2, +3, +5 and +10pop can probably be used with negative numbers.

Here is an extract of my code in the CvSolarSystem:

Code:
def getPopulationLimit(self, iOwner):
		
		if (self.isDisabled()):
			return 0
		
		if (not self.isPlanetWithinCulturalRange()):
			return 0
		
#		iMaxPop = iMaxDefaultPopulationPerPlanet		# Oh noes!
		iMaxPop = aiDefaultPopulationPlanetSizeTypes[self.getPlanetSize()]
		
		iBuildingHabSys = CvUtil.findInfoTypeNum(gc.getBuildingInfo,gc.getNumBuildingInfos(),'BUILDING_HABITATION_SYSTEM')
		iBuildingHabCom = CvUtil.findInfoTypeNum(gc.getBuildingInfo,gc.getNumBuildingInfos(),'BUILDING_HABITATION_COMPLEX')
		iBuildingHabAlp = CvUtil.findInfoTypeNum(gc.getBuildingInfo,gc.getNumBuildingInfos(),'BUILDING_HABITATION_ALPHA')
		iBuildingHabGam = CvUtil.findInfoTypeNum(gc.getBuildingInfo,gc.getNumBuildingInfos(),'BUILDING_HABITATION_GAMMA')
		iBuildingHabOme = CvUtil.findInfoTypeNum(gc.getBuildingInfo,gc.getNumBuildingInfos(),'BUILDING_HABITATION_OMEGA')
		
		# for iBuildingLoop in range(gc.getNumBuildingInfos()):
		if (self.isHasBuilding(iBuildingHabSys)):
			# if (g_aiBuildingPopCapIncrease[iBuildingLoop] > 0):
			iMaxPop += 1
			
		if (self.isHasBuilding(iBuildingHabCom)):
			# if (g_aiBuildingPopCapIncrease[iBuildingLoop] > 0):
			iMaxPop += 2
			
		if (self.isHasBuilding(iBuildingHabAlp)):
			# if (g_aiBuildingPopCapIncrease[iBuildingLoop] > 0):
			iMaxPop += 3
			
		if (self.isHasBuilding(iBuildingHabGam)):
			# if (g_aiBuildingPopCapIncrease[iBuildingLoop] > 0):
			iMaxPop += 5
			
		if (self.isHasBuilding(iBuildingHabOme)):
			# if (g_aiBuildingPopCapIncrease[iBuildingLoop] > 0):
			iMaxPop += 10

I actually used a part of the MOO2CIV for the code but I adapted it and it works!
By the way, I also removed the hard coded value at the very end (for what is done yet as Pop+ and Hammer+). It look like this:

Code:
# Hardcoded (This is Bad)
for iBuildingLoop in range(90):
	g_aiBuildingYieldIncrease.append([0,0,0])
	g_aiBuildingPopCapIncrease.append(0)
	g_aszBuildingDummyTags.append("")
	
g_aiBuildingYieldIncrease[1][0] = 1		# Nutrition Facility
#g_aiBuildingYieldIncrease[2][1] = 1		# Mining Facility (---------- Commented
g_aiBuildingYieldIncrease[3][2] = 1		# Road Network
g_aiBuildingYieldIncrease[4][2] = 2		# Mag Lev Network

#g_aiBuildingPopCapIncrease[5] = 1		# Habitation Center   (---------- Commented

g_aszBuildingDummyTags[7] = "FEATURE_MODEL_TAG_CAPITAL_SHIPYARD"
g_aszBuildingDummyTags[8] = "FEATURE_MODEL_TAG_SQUADRON_FACTORY"
g_aszBuildingDummyTags[21] = "FEATURE_MODEL_TAG_SQUADRON_DEFENSE_NETWORK"
g_aszBuildingDummyTags[22] = "FEATURE_MODEL_TAG_STAR_FORTRESS"

Well... I hope that help!

When you added buildings, did you add them all at the end? If not, then the building numbers changed and you need to figure out what they are and make the index values for g_aszBuildingDummyTags match where they are now (don't forget it starts with the first building being 0, not 1). If you don't have this problem, did you do anything involving the art defines?

Moving the yield modifications out of the array into the function obviously works, but it means you are making adjustments in more places which can make it more confusing. You could have just added your new buildings to the g_aiBuildingYieldIncrease list for those that change food, hammers, or commerce or to the g_aiBuildingPopCapIncrease for those that change the population. (By the way, two of the comments as to which building is which are wrong: "Road Network" is really "Mag Lev Network" and "Mag Lev Network" is really "Commercial Satellites".)

To make pop reduction buildings work using the existing arrays, you can change the line in getPopulationLimit that says:
Code:
				if (g_aiBuildingPopCapIncrease[iBuildingLoop] > 0):
You can make the ">0" be "!=0". Alternatively you could just remove that line and modify the max pop by whatever is in the list. The list elements are set to 0 when it is initialized so it isn't a problem. Just adding 0 should even be slightly faster than doing the "if" to skip all the 0s (and negative values, which aren't used in regular FF).
 
Problematic Thing #1 for FF mods.

When you added buildings, did you add them all at the end? If not, then the building numbers changed and you need to figure out what they are and make the index values for g_aszBuildingDummyTags match where they are now (don't forget it starts with the first building being 0, not 1). If you don't have this problem, did you do anything involving the art defines?

Are you talking in CvSystem or in BuildingInfo.xml? If it's in BuildingInfo... that would make sense. I put my modification just after the Habitation center and the Mining Facility. So then.... if I add every new buildings at the end of that file it would solve that problem?

And how to figure the index values? Are they related to the order in BuildingInfo again?

Moving the yield modifications out of the array into the function obviously works, but it means you are making adjustments in more places which can make it more confusing. You could have just added your new buildings to the g_aiBuildingYieldIncrease list for those that change food, hammers, or commerce or to the g_aiBuildingPopCapIncrease for those that change the population. (By the way, two of the comments as to which building is which are wrong: "Road Network" is really "Mag Lev Network" and "Mag Lev Network" is really "Commercial Satellites".)

So then... if I want to only add them to g_aiBuidingYieldIncrease and g_aiBuidingPopCapIncrease how would I do it? I just put the code I already did under those values? (I'm not that good in coding!)

I'm in a course right now (good student!):rolleyes:) so I will check it out (aka moving the building that I created at the very bottom of the file so that the original value are still aligned)

FF really deserve some kind of wiki don't you think? :D

Waiting for your reply,
Olivier
 
Are you talking in CvSystem or in BuildingInfo.xml? If it's in BuildingInfo... that would make sense. I put my modification just after the Habitation center and the Mining Facility. So then.... if I add every new buildings at the end of that file it would solve that problem?

And how to figure the index values? Are they related to the order in BuildingInfo again?
I'm talking about CIV4BuildingInfos.xml.

The index values are exactly the order in that file. The first one is 0.

The index used in the array is the building that will have that effect. If you don't change the arrays but add exactly one building and it is at the start of the file then the capitol gets a free ability (stealing it from the nutrition facility) and none of the rest would have the expected effect either, instead a capitol would add 1 food, the nutrition facitlity would add 1 hammer, the mining facility would add 1 commerce, and so on since they'd all be off by 1.

As to how to figure out what they are now, start at 0 and count... (you might want to add a comment next to the start of each saying what it is, at least every 10 or so if not for every one). Since I only added buildings at the end, I didn't have to worry about it. As I added each building that needed an entry in the solar system related global arrays, I used the Notepad++'s "count" ability (on the find dialog) to determine what the current number was (subtract 1 and that is the index to use).

So then... if I want to only add them to g_aiBuidingYieldIncrease and g_aiBuidingPopCapIncrease how would I do it? I just put the code I already did under those values? (I'm not that good in coding!)

I'm in a course right now (good student!):rolleyes:) so I will check it out (aka moving the building that I created at the very bottom of the file so that the original value are still aligned)

FF really deserve some kind of wiki don't you think? :D

Waiting for your reply,
Olivier

Say you add two buildings at the end of the file. These will be the 31st and 32nd buildings in the file, since it starts with 30. The index for the first is 30 and the second is 31. If you want the first to add +2 hammers per unit of population assigned to the planet and the second to increase the population limit of the planet by 2 then you'd add some entries to the arrays like so (changes in red):
Code:
g_aiBuildingYieldIncrease[1][0] = 1		# Nutrition Facility
g_aiBuildingYieldIncrease[2][1] = 1		# Mining Facility
g_aiBuildingYieldIncrease[3][2] = 1		# [COLOR="Navy"]Mag Lev Network[/COLOR]
g_aiBuildingYieldIncrease[4][2] = 2		# [COLOR="#000080"]Commercial Satellites[/COLOR]
[COLOR="Red"]g_aiBuildingYieldIncrease[30][1] = 2		# New Hammer Thing[/COLOR]

g_aiBuildingPopCapIncrease[5] = 1		# Habitation Center
[COLOR="#ff0000"]g_aiBuildingPopCapIncrease[31] = 2		# New Pop Thing[/COLOR]
They then do what they are supposed to do.

Don't forget to adjust the range used by the loop when you add stuff. You can make it pretty big and not worry about it (aside from that initialization loop, I don't think it ever loops over the whole list again, it loops over the range of the number of buildings as per gc.getNumBuildingInfos(), so it just uses a little extra memory fo unused entries.
Theoretically, it should dynamically set the range of that loop via gc.getNumBuildingInfos() but that means moving code and whatnot (as it is, the Init Python comes before the Init XML; apparently the .py files are actually loaded during the init phase which results in the code sitting naked in the file being run - putting this loop and the assignments after it into a "def initBuildings" function and calling it in the CvSystem class init function ought to do the trick, but I haven't tried it).
 
Allright I did those changes you suggested me. Now they are in the end of the building.xml and the red spot have disappeared and capital shipyard is back!

There is only a slight problem, since I changed the order of the building and since I added the buildings to the addpopcap... It's impossible for me to build the second level of Habitation that I created and thus I can't create the other that are following it!

Any idea why? Is there some kind of order in technology also?

Olivier
 
Allright I did those changes you suggested me. Now they are in the end of the building.xml and the red spot have disappeared and capital shipyard is back!

There is only a slight problem, since I changed the order of the building and since I added the buildings to the addpopcap... It's impossible for me to build the second level of Habitation that I created and thus I can't create the other that are following it!

Any idea why? Is there some kind of order in technology also?

Olivier

There is nothing specific to FF other than that any prerequisite building must be on the same planet, not just in the same system.
 
Hello it's been a while! I must thank all of you!

I made some great progress... been able to code different level of population limit raiser, some ressource buildings etc... now I need help.

Is there a limit on the number of building that you can build?

I'm curious because there is a couple of buildings that are "unbuildable" since I made others. It's kinda like if the new building are taking the space of previous one.

Is there some kind of hard coded limit? I find it quite frustrating as I was able to build the building before adding an entry for another one!

Waiting for your useful advice,

Tengawa!
 
I don't know of any building limit. If there is, it is very large - the number of buildings in regular BtS is much higher than in FF, particularly with all the wonders. Regular BtS
has a total of 159, to be specific. I've played mods with more than that, including one that I just checked that has 254.

Have you duplicated any building classes? If you give a building the same building class as another building then only one of them will be buildable in the game unless you assign the one not mentioned in the "DefaultBuilding" tag of the BuildingClassInfo as some civilization's unique building and even then it will only show up for that civ (and the regular one won't). Implementing a UBs can also require fiddling with the python in various places to get them to work properly.
 
Top Bottom