TC01
Deity
Final Frontier Worldbuilder v1.2
After a discussion in this thread in the Star Trek Mod forum about how useless Worldbuilder was in Final Frontier, I decided to try to make it work. What do I mean, useless? Well, prior to this utility/modcomp, you couldn't add or remove solar systems properly- they would appear with no sun or planets, and would come back the next turn if you removed them. Buildings would be placed in a solar system- but not on a specific planet. And all sorts of other things were wrong as well.
I've succeeded in making it work, and thus am releasing this version of "Final Frontier Worldbuilder." Now, it doesn't make major changes to Worldbuilder- you can't change the sun or planets in a solar system, for instance- but it makes Worldbuilder useful for making a Final Frontier map. This is not intended to help people cheat. (Although, you could use it that way...) It is intended to allow Final Frontier modders to be able to make scenarios using Worldbuilder, not the .WBS file. It is mostly finished, but there are some bugs and little other things to add.
You can probably also use this with other mods for Final Frontier. First, you should check and see if this is already included in that mod. If it isn't, then there are directions under the "To Install" section on how to install it for a mod based off of Final Frontier.
This utility is included in Final Frontier Plus.
Feature List:
Changes to the in-game Worldbuilder:
-When you place a solar system in Worldbuilder, planets and sun type will be randomly generated.
-When you overwrite a solar system with another feature, it will not come back the next turn.
-When you place a building in a city, it will add that building to the planet where buildings are being built.
-When you add a building using the Edit City menu, every planet in the solar system will get that building.
-When you remove a building using the Edit City menu, every planet in the solar system will loose that building.
-When you remove a solar system in Worldbuilder using the "Remove" button, it will not come back the next turn.
-When you build a city, population will be correctly assigned to that solar system.
-When you place a Black Hole, the Black Hole Gravity Field will automatically appear on the correct plots around it.
-When you place a Supernova, the Damage Zone will automatically appear on the correct plots around it.
-When you remove a Black Hole, the Black Hole Gravity Field will automatically be removed as well.
-When you remove a Supernova, the Damage Zone will automatically be removed as well.
Changes to the Worldbuilder Save file:
-Worldbuilder now saves and loads buildings on different planets
-Worldbuilder now saves and loads the name of each planet
-Worldbuilder now saves and loads the population of each planet
-Worldbuilder now saves and loads the names of units (thanks to deanej)
-Worldbuilder now saves and loads the selected and building planets of a city
-Worldbuilder now saves the name of the mod the WBS was created in
Worldbuilder Save File Changes:
Several changes have been made to the WBS files, used for scenarios. SelectedPlanet and BuildingPlanetRing tags have been added to the city section. A PlanetName tag has been added to the planet data section, a Planet1Population (and Planet2Population, and so on...) tag has been added to the city data section to store population per planet, and a Planet1BuildingType (and Planet2BuildingType, and so on...) tag has been added to the city data section to say that a building should be on a specific planet.
This means that scenarios created using Final Frontier Worldbuilder will not be compatible with versions of Civ not using Final Frontier Worldbuilder- or, rather, they will be, but any tags added by FF Worldbuilder won't be loaded into the game.
See the spoiler tag for more information.
Download Here
Changelog:
To Install:
If you are installing this utility for Final Frontier, all you need to do is unzip the files and copy the Final Frontier folder in the download into your Beyond the Sword\Mods directory.
If you are installing this utility for a modmod of Final Frontier, then you may need to do more work, or you may not, since those mods might be using this utility anyway. FF Worldbuilder contains three files. One, CvWorldBuilderScreen.py, is not in Final Frontier. Another, CvWBDesc.py, is in Final Frontier, but it is sparsely edited by mods, so you should be able to just overwrite it.
The third file is the problem. CvFinalFrontierEvents.py is probably the most-frequently edited python file. Fortunately, the change I made to it was very small, and therefore I have provided a guide to merge my change in. See the spoiler below for instructions.
To Do: (Feel free to suggest problems with Final Frontier's Worldbuilder or WBS file system that could be fixed here. There is nothing I can think of that needs doing, so this is effectively done.).
Credits:
-TC01
-deanej (ideas, help)
-apenpaap (ideas)
-JEELEN (feedback)
-The_J, God-Emperor, Emperor Fool (help)
-Jon Shafer for making Final Frontier
-Firaxis for making Civilization IV
After a discussion in this thread in the Star Trek Mod forum about how useless Worldbuilder was in Final Frontier, I decided to try to make it work. What do I mean, useless? Well, prior to this utility/modcomp, you couldn't add or remove solar systems properly- they would appear with no sun or planets, and would come back the next turn if you removed them. Buildings would be placed in a solar system- but not on a specific planet. And all sorts of other things were wrong as well.
I've succeeded in making it work, and thus am releasing this version of "Final Frontier Worldbuilder." Now, it doesn't make major changes to Worldbuilder- you can't change the sun or planets in a solar system, for instance- but it makes Worldbuilder useful for making a Final Frontier map. This is not intended to help people cheat. (Although, you could use it that way...) It is intended to allow Final Frontier modders to be able to make scenarios using Worldbuilder, not the .WBS file. It is mostly finished, but there are some bugs and little other things to add.
You can probably also use this with other mods for Final Frontier. First, you should check and see if this is already included in that mod. If it isn't, then there are directions under the "To Install" section on how to install it for a mod based off of Final Frontier.
This utility is included in Final Frontier Plus.
Feature List:
Changes to the in-game Worldbuilder:
-When you place a solar system in Worldbuilder, planets and sun type will be randomly generated.
-When you overwrite a solar system with another feature, it will not come back the next turn.
-When you place a building in a city, it will add that building to the planet where buildings are being built.
-When you add a building using the Edit City menu, every planet in the solar system will get that building.
-When you remove a building using the Edit City menu, every planet in the solar system will loose that building.
-When you remove a solar system in Worldbuilder using the "Remove" button, it will not come back the next turn.
-When you build a city, population will be correctly assigned to that solar system.
-When you place a Black Hole, the Black Hole Gravity Field will automatically appear on the correct plots around it.
-When you place a Supernova, the Damage Zone will automatically appear on the correct plots around it.
-When you remove a Black Hole, the Black Hole Gravity Field will automatically be removed as well.
-When you remove a Supernova, the Damage Zone will automatically be removed as well.
Changes to the Worldbuilder Save file:
-Worldbuilder now saves and loads buildings on different planets
-Worldbuilder now saves and loads the name of each planet
-Worldbuilder now saves and loads the population of each planet
-Worldbuilder now saves and loads the names of units (thanks to deanej)
-Worldbuilder now saves and loads the selected and building planets of a city
-Worldbuilder now saves the name of the mod the WBS was created in
Worldbuilder Save File Changes:
Several changes have been made to the WBS files, used for scenarios. SelectedPlanet and BuildingPlanetRing tags have been added to the city section. A PlanetName tag has been added to the planet data section, a Planet1Population (and Planet2Population, and so on...) tag has been added to the city data section to store population per planet, and a Planet1BuildingType (and Planet2BuildingType, and so on...) tag has been added to the city data section to say that a building should be on a specific planet.
This means that scenarios created using Final Frontier Worldbuilder will not be compatible with versions of Civ not using Final Frontier Worldbuilder- or, rather, they will be, but any tags added by FF Worldbuilder won't be loaded into the game.
See the spoiler tag for more information.
Spoiler WBS File Editing Help :
The planets of a solar system were stored under the "FeatureType=FEATURE_SOLAR_SYSTEM" line, as seen below:
Now, an additional tag has been added to the end of this list called "PlanetName=". It specifies what the name of the planet is. See below for an example:
The following lines of code can be added to any city define (below any "BeginCity"). They control the distribution of "CityPopulation=" among various planets in the solar system. The total of all the values of the planet population tags must equal the city population, and it should go under the "CityPopulation=" line.
The following lines of code can be added to any city define (below any "BeginCity"). They store buildings to a specific planet, so "Planet1BuildingType=" means that the listed building is added to Planet 1, and the same for all the others. They should be added under the last "BuildingType=" line)
The following lines of code can be added to any city define (under BeginCity). They specify the selected planet and the building planet ring for each city- the planet that is selected in the city screen and the planet that buildings will be created on.
Code:
PlanetType=ORANGE_PLANET, OrbitRing=4, PlanetSize=1, HasMoon=1, HasRings=0
PlanetType=RED_PLANET, OrbitRing=2, PlanetSize=2, HasMoon=0, HasRings=0
PlanetType=RED_PLANET, OrbitRing=1, PlanetSize=1, HasMoon=0, HasRings=0
PlanetType=BLUE_PLANET, OrbitRing=7, PlanetSize=2, HasMoon=0, HasRings=0
PlanetType=GREEN_PLANET, OrbitRing=3, PlanetSize=1, HasMoon=0, HasRings=0
PlanetType=RED_PLANET, OrbitRing=8, PlanetSize=0, HasMoon=0, HasRings=0
Now, an additional tag has been added to the end of this list called "PlanetName=". It specifies what the name of the planet is. See below for an example:
Code:
PlanetType=ORANGE_PLANET, OrbitRing=4, PlanetSize=1, HasMoon=1, HasRings=0, PlanetName=Xi Horus
PlanetType=RED_PLANET, OrbitRing=2, PlanetSize=2, HasMoon=0, HasRings=0, PlanetName=Zeus Cancer
PlanetType=RED_PLANET, OrbitRing=1, PlanetSize=1, HasMoon=0, HasRings=0, PlanetName=Sigma Libra
PlanetType=BLUE_PLANET, OrbitRing=7, PlanetSize=2, HasMoon=0, HasRings=0, PlanetName=Gamma Hephaestus
PlanetType=GREEN_PLANET, OrbitRing=3, PlanetSize=1, HasMoon=0, HasRings=0, PlanetName=Paradise
PlanetType=RED_PLANET, OrbitRing=8, PlanetSize=0, HasMoon=0, HasRings=0, PlanetName=Pi Hermes
The following lines of code can be added to any city define (below any "BeginCity"). They control the distribution of "CityPopulation=" among various planets in the solar system. The total of all the values of the planet population tags must equal the city population, and it should go under the "CityPopulation=" line.
Code:
Planet1Population=2
Planet2Population=1
Planet3Population=0
Planet4Population=1
Planet5Population=2
Planet6Population=1
Planet7Population=0
Planet8Population=1
The following lines of code can be added to any city define (below any "BeginCity"). They store buildings to a specific planet, so "Planet1BuildingType=" means that the listed building is added to Planet 1, and the same for all the others. They should be added under the last "BuildingType=" line)
Code:
Planet1BuildingType=BUILDING_CAPITOL
Planet2BuildingType=BUILDING_NUTRITION_FACILITY
Planet3BuildingType=BUILDING_MINING_FACILITY
Planet4BuildingType=BUILDING_RECYCLING_CENTER
Planet5BuildingType=BUILDING_NUTRITION_FACILITY
Planet6BuildingType=BUILDING_MINING_FACILITY
Planet7BuildingType=BUILDING_RECYCLING_CENTER
Planet8BuildingType=BUILDING_CAPITOL
The following lines of code can be added to any city define (under BeginCity). They specify the selected planet and the building planet ring for each city- the planet that is selected in the city screen and the planet that buildings will be created on.
Code:
SelectedPlanet= 2
BuildingPlanetRing = 2
Download Here
Changelog:
Code:
v1.2 Changelog:
-Fixed a bug with black hole/supernova removal
-Worldbuilder now saves and loads the selected and building planets of a system
-Worldbuilder once again saves and loads what a city is producing
-Worldbuilder automatically stores the name of the mod to the ModPath tag in the WBS file
v1.1 Changelog:
-Fixed a major bug where Worldbuilder was unable to load WBS save files
-Worldbuilder now saves and loads the name of each planet
-Worldbuilder now saves and loads the population of each planet
-Worldbuilder now saves and loads the names of units (thanks to deanej)
-Worldbuilder no longer stores what a city is producing due to FF issues (thanks to deanej)
v1.0 Changelog:
-Worldbuilder now properly saves (and then loads) buildings on different planets.
-When you place a Black Hole, the Black Hole Gravity Field will automatically appear on the correct plots around it.
-When you place a Supernova, the Damage Zone will automatically appear on the correct plots around it.
-When you remove a Black Hole, the Black Hole Gravity Field will automatically be removed as well.
-When you remove a Supernova, the Damage Zone will automatically be removed as well.
v0.9 Changelog:
-When you remove a solar system in Worldbuilder using the "Remove" button, it will not come back the next turn.
-When you build a city, population will be correctly assigned to that solar system.
-Any other FF specific code triggered when a city is built will now be triggered when a city is Worldbuildered.
To Install:
If you are installing this utility for Final Frontier, all you need to do is unzip the files and copy the Final Frontier folder in the download into your Beyond the Sword\Mods directory.
If you are installing this utility for a modmod of Final Frontier, then you may need to do more work, or you may not, since those mods might be using this utility anyway. FF Worldbuilder contains three files. One, CvWorldBuilderScreen.py, is not in Final Frontier. Another, CvWBDesc.py, is in Final Frontier, but it is sparsely edited by mods, so you should be able to just overwrite it.
The third file is the problem. CvFinalFrontierEvents.py is probably the most-frequently edited python file. Fortunately, the change I made to it was very small, and therefore I have provided a guide to merge my change in. See the spoiler below for instructions.
Spoiler CvFinalFrontierEvents.py Merging Guide :
Open CvFinalFrontierEvents.py and find the "onGameStart" function, shown below with much of its code, at least in normal Final Frontier:
That's a lot of code. Fortunately, much of it can be gotten rid of very easily, since much of it handles building the solar systems on loading of a Worldbuilder save. Since that has now been moved to CvWBDesc.py, the entire section above should now look like the code below. Copy paste the code below over the code above.
If the code in the mod you are editing looks very different, then these are the changes you have to make:
Here is the code you must add:
Code:
def onGameStart(self, argsList):
'Called at the start of the game'
self.parent.onGameStart(self, argsList)
self.iWinningTeam = -1
self.iTimeLeft = 0
self.initValues()
self.initMembers()
CyGame().makeNukesValid(true)
CyGame().setStartYear(2302)
AI.initPlayerAIInfos()
# Give Barbs some techs
iTechHappy0 = CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),'TECH_HAPPY_0')
iTechIndustry0 = CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),'TECH_INDUSTRY_0')
iTechMilitary0 = CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),'TECH_MILITARY_0')
iTechMilitary1 = CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),'TECH_MILITARY_1')
pBarbPlayer = gc.getPlayer(18)
pBarbTeam = gc.getTeam(pBarbPlayer.getTeam())
pBarbTeam.setHasTech(iTechHappy0, true, 18, false, false)
pBarbTeam.setHasTech(iTechIndustry0, true, 18, false, false)
pBarbTeam.setHasTech(iTechMilitary0, true, 18, false, false)
pBarbTeam.setHasTech(iTechMilitary1, false, 18, false, false)
# Is this a scenario file?
if ('.CivBeyondSwordWBSave' in CyMap().getMapScriptName()):
import CvWBInterface
# Search through all plots on the map for Solar Systems to add content for
for pWBPlotLoop in CvWBInterface.WBDesc.plotDesc:
iX = pWBPlotLoop.iX
iY = pWBPlotLoop.iY
pPlot = CyMap().plot(iX, iY)
if (pPlot.getFeatureType() == self.iFeatureIDSolarSystem):
iStarType = getStarIndexFromTag(pWBPlotLoop.szStarType)
pSystem = CvSystem(iX,iY,iStarType)
for iPlanetLoop in range(pWBPlotLoop.iNumPlanets):
iPlanetType = getPlanetIndexFromTag(pWBPlotLoop.aszPlanetType[iPlanetLoop])
iOrbitRing = pWBPlotLoop.aiOrbitRing[iPlanetLoop]
iPlanetSize = pWBPlotLoop.aiPlanetSize[iPlanetLoop]
bMoon = pWBPlotLoop.aiMoon[iPlanetLoop]
bRings = pWBPlotLoop.aiRings[iPlanetLoop]
pSystem.addPlanet(iPlanetType, iPlanetSize, iOrbitRing, bMoon, bRings)
self.addSystem(pSystem)
# Add Buildings in WBS to Home Planet of Star System
for iPlayerLoop in range(gc.getMAX_CIV_PLAYERS()):
pPlayer = gc.getPlayer(iPlayerLoop)
for iCityLoop in range(pPlayer.getNumCities()):
pCity = pPlayer.getCity(iCityLoop)
pSystem = self.getSystemAt(pCity.getX(), pCity.getY())
iBestPlanet = getBestPlanetInSystem(pSystem)
pPlanet = pSystem.getPlanetByIndex(iBestPlanet)
for iBuildingLoop in range(gc.getNumBuildingInfos()):
if (pCity.isHasBuilding(iBuildingLoop)):
pPlanet.setHasBuilding(iBuildingLoop, true)
else:
# Loop through all plots, find the Solar Systems and give them randomized starting junk
for iPlotLoop in range(CyMap().numPlots()):
pPlot = CyMap().plotByIndex(iPlotLoop)
if (pPlot.getFeatureType() == self.iFeatureIDSolarSystem):
iYield = -1 #No preference
pSystem = createRandomSystem(pPlot.getX(), pPlot.getY(), iYield, iPlanetQuantityTypePoor) # Called from CvSolarSystem
self.addSystem(pSystem)
That's a lot of code. Fortunately, much of it can be gotten rid of very easily, since much of it handles building the solar systems on loading of a Worldbuilder save. Since that has now been moved to CvWBDesc.py, the entire section above should now look like the code below. Copy paste the code below over the code above.
Code:
def onGameStart(self, argsList):
'Called at the start of the game'
self.parent.onGameStart(self, argsList)
self.iWinningTeam = -1
self.iTimeLeft = 0
self.initValues()
CyGame().makeNukesValid(true)
CyGame().setStartYear(2302)
AI.initPlayerAIInfos()
# Give Barbs some techs
iTechHappy0 = CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),'TECH_HAPPY_0')
iTechIndustry0 = CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),'TECH_INDUSTRY_0')
iTechMilitary0 = CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),'TECH_MILITARY_0')
iTechMilitary1 = CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),'TECH_MILITARY_1')
pBarbPlayer = gc.getPlayer(18)
pBarbTeam = gc.getTeam(pBarbPlayer.getTeam())
pBarbTeam.setHasTech(iTechHappy0, true, 18, false, false)
pBarbTeam.setHasTech(iTechIndustry0, true, 18, false, false)
pBarbTeam.setHasTech(iTechMilitary0, true, 18, false, false)
pBarbTeam.setHasTech(iTechMilitary1, false, 18, false, false)
# Is this not a scenario file?
if not ('.CivBeyondSwordWBSave' in CyMap().getMapScriptName()):
self.initMembers()
# Loop through all plots, find the Solar Systems and give them randomized starting junk
for iPlotLoop in range(CyMap().numPlots()):
pPlot = CyMap().plotByIndex(iPlotLoop)
if (pPlot.getFeatureType() == self.iFeatureIDSolarSystem):
iYield = -1 #No preference
pSystem = createRandomSystem(pPlot.getX(), pPlot.getY(), iYield, iPlanetQuantityTypePoor) # Called from CvSolarSystem
self.addSystem(pSystem)
If the code in the mod you are editing looks very different, then these are the changes you have to make:
- Remove the line that says "self.initMembers()" at the top of the function
- Add the code below somewhere in the function.
Here is the code you must add:
Code:
if not ('.CivBeyondSwordWBSave' in CyMap().getMapScriptName()):
self.initMembers()
To Do: (Feel free to suggest problems with Final Frontier's Worldbuilder or WBS file system that could be fixed here. There is nothing I can think of that needs doing, so this is effectively done.).
Credits:
-TC01
-deanej (ideas, help)
-apenpaap (ideas)
-JEELEN (feedback)
-The_J, God-Emperor, Emperor Fool (help)
-Jon Shafer for making Final Frontier
-Firaxis for making Civilization IV