Platy World Builder

Version 4.0

The following items are now saved and loaded for scenario making purposes:

1) Barbarian and Minor Civs Info

2) Player Data:
Golden Age Turns
Anarchy Turns
Combat XP
Coastal Trade Routes
State Religion Unit Production Modifier
State Religion Building Production Modifier
Script Data

3) Team Data:
Team Abilities (Map Centering, Gold Trading etc)
Nuke Interception
Enemy War Weariness Modifier
Extra Domain Moves
Extra Route Moves
Extra Improvement Yield

Naturally, there will be more for plot, city and unit data etc...
 
In my first test of the MNAI WorldBuilder 4.0 merge I ran across this bug:

Code:
Traceback (most recent call last):

  File "CvScreensInterface", line 739, in handleInput

  File "WBReligionScreen", line 172, in handleInput

TypeError: interfaceScreen() takes exactly 2 arguments (1 given)
ERR: Python function handleInput failed, module CvScreensInterface

It is pretty clear where the mistake is:
Code:
		elif inputClass.getFunctionName() == "CurrentPlayer":
			iSelectedPlayer = screen.getPullDownData("CurrentPlayer", screen.getSelectedPullDownID("CurrentPlayer"))
##			self.interfaceScreen()
			self.interfaceScreen([COLOR="Red"]iSelectedPlayer[/COLOR])
You defined the variable, but forgot to pass it along.

There appears to be an equivalent error in line 146 of WBCorporationScreen.py


Later I also found this bug:
Code:
Traceback (most recent call last):

  File "CvScreensInterface", line 739, in handleInput

  File "WBGameDataScreen", line 392, in handleInput

AttributeError: WBGameDataScreen instance has no attribute 'bRepeat'
ERR: Python function handleInput failed, module CvScreensInterface
It appears that in WBGameDataScreen.py under def handleInput(self, inputClass): there are several variable which you forgot to change out of the self.iWhatever format when you switched to global variables instead.
Code:
		elif inputClass.getFunctionName() == "HiddenOptions":
			[COLOR="Red"]self.bHiddenOption[/COLOR] = not [COLOR="Red"]self.bHiddenOption[/COLOR]
			self.placeGameOptions()

		elif inputClass.getFunctionName() == "AllowsRepeat":
			[COLOR="Red"]self.bRepeat[/COLOR] = not [COLOR="Red"]self.bRepeat[/COLOR]
			[COLOR="Red"]self.iNewCiv[/COLOR] = -1
		[COLOR="Red"]	self.iNewLeader[/COLOR] = -1
			self.placeNewPlayer()

		elif inputClass.getFunctionName() == "WBNewCiv":
		[COLOR="Red"]	self.iNewCiv [/COLOR]= inputClass.getData2()
			[COLOR="Red"]self.iNewLeader [/COLOR]= -1
			self.interfaceScreen()

		elif inputClass.getFunctionName() == "WBNewLeader":
			[COLOR="Red"]self.iNewLeader[/COLOR] = inputClass.getData2()
			self.interfaceScreen()

You said before that you intended to add a way to switch between cities through the City Data II screen, but it was too crowded. Well, it is not so crowded now.

I decided to add a city menu on the left, with a mouseover to give details of the selected city. (I have that in the City Data I and Buildings screens too.)

I moved the Change By menu to the right, where the Add/Remove menu was, and moved the Add/Remove Menu down a row. That way seems more intuitive to me.

You are welcome to borrow the code, which I am just about to upload in the MNAI Feature Requests and Discussion thread.
 
Version 4.01

Well, since there are a number of bugs in 4.0, you get a quick update.

1) Fix bug in Religion and Corporation Screen when changing player

2) Added a simple dropdown menu for changing cities in City Data II.
I was thinking more of shifting the current production table from City Data I into City Data II since it is so empty now, and add a map to City Data I. So for now, just a simple dropdown will do.

3) City Data I, II and Buildings
Fix a bug with changing city codes. You will run into error with cities destoryed.


4) Saving and Loading
A) Removed Barbarian Data (It was causing problems for player data, team data is fine)
Lazy to analyze, so removed both.


B) Unit Data
Adjusted Base Combat Strength
Adjusted Cargo Space
Immobile Turns

C) City Data
Defense Damage
Occupation Turns
Extra Happiness
Extra Health
Extra Trade Routes
Extra Building Yield
Extra Building Commerce
Free Bonus
No Bonus Access

Plot, City, Unit
Script Data can now save and load "NONE", which was disallowed due to stupid codes.


I didn't bother to save certain data, such as Food amount, Conscript/Hurry Anger, since I doubt anybody need this for scenario making.

@GameData Screen
All the above mentioned bugs are not found in WB 4.0 though.
 
Version 4.01
4) Saving and Loading
A) Removed Barbarian Data (It was causing problems for player data, team data is fine)
Lazy to analyze, so removed both.

Too bad, seemed very interesting and needed.

Thank you for all this, it's a wonderful tool. :king:
 
Version 4.02

A) New layout for City Screens
1) Added full detailed City List to all 3 screens
2) Added City Map to City Data I
3) Shifted Modify Building Section into City Data II
4) Modified Sections now only display modified changes
5) Added inactive codes for Modify Building Happiness and Health
Inactive because neither of them is working correctly for BTS dll
The problem is with the dll, not the python so whoever bothered to fix it can activate the codes.
Spoiler :





B) Team Data
1) Added Master Power, Vassal Power, Espionage Points Ever
Frankly speaking, I have no idea what are these for... EPE however, is saved and loaded data so might as well let you edit.
2) Added Vassals into Member List.
Gold Star: Team Leader
Angry Pop: Team Member
Silver Star: Vassal
3) Modified Sections now only display modified changes
Spoiler :



C) Diplomacy
1) Overhaul of codes
2) Fix some bugs with using Team instead of Player as input
3) Removed Attitude Buttons. Platy WB is now non-modular since the only XML is text.
Spoiler :




D) Save and Load
1) Barbarian Team Data saved and loaded
2) Barbarian Player Data saved and loaded (inactive)
Inactive because when loading a BTSWB save, if there is a missing player entry, the load fails.
Thus, if you want to load a PlatyWB save, you activate the codes to load Barbarian data, else, it will not load Barbarian data.
Only affects reading, not writing.
PlatyWB save can be loaded via mods without PlatyWB. (The extra data simply ignored)
3) Extra Building Happiness and Health saved and loaded

E) Misc
1) Fixed missing Landmark Text in main file.
 
I finished merging this with MNAI and thought I got everything working, until I tried to load some worldbuilder saves.

Loading worldbuilder saves with your modcomp alone works fine, but not in the merge.


I've tried it with both bBarbarian = False and bBarbarian = True, both with scenarios saved from before and with saves made just a few seconds before loading them.

It always resulted either in an immediate crash to desktop, or at best an instant defeat.


The second outcome reminds me of an issue we discovered in MNAI years ago. A couple of the scenarios that Kael made for FfH2 would not work in MNAI. I found that this issue with these way that Kael had skipped a player number, and that either shifting all the player indices down or adding new players to fill the gaps would make the game work fine.

I'm not sure that we ever figured out the exact cause, but it was hypothesized that some code borrowed from the BUG mod really did not like dealing with non-consecutive player numbers.

I suspect that having a barbarian player 50 where there are only 4 other players is troublesome for the same reason.


Do you have any idea how I can get around this?

Will the MNAI version just have to go back to using gc.getMAX_CIV_PLAYERS() instead of gc.getMAX_PLAYERS() and gc.getMAX_CIV_TEAMS() instead of gc.getMAX_TEAMS() ?
 
Version 4.02b
Nothing serious, just to fix a leftover missing text.

A) Fix missing member text in Team Data for Merge Team

B) Save and Load
Redundant data no longer written to save file.
1) Contact with own team and Barb
2) Player Data which are "None"
3) Cut one useless loop for civics in Player Data

-----------------------------------------------------------

@Magister
Well, if bBarbarian is True, it will definitely crash due to insufficient number of player data, which is existing problem with BTS WB.

As for bBarbarian False:
1) In my tests, Team Data is never a problem.
Platy WB can load BTS WB save.
BTS WB can load Platy WB save.
So at the very least, you should be able to keep the gc.getMAX_TEAMS changes, to edit techs which is what most scenario makers would be concerned. Projects as well, since that is a spell system(?) in FFH.

2) Player Data however, is the big issue, because part of the applying is not handled in that file.
(Civ Type, Leader Type etc which are not exposed to python)
This also means that for Platy WB, even if you go into the Save file and edit the Barbarian leader to Alexander, it will still load as Barbarian Leader.

3) There are 2 instances in getAssignedStartingPlots and applyInitialItems where the range of the loops has changed to len(self.playersDesc) so that I can alter between bBarbarian = True/False freely, you may have missed this in merging.

I know that you have added some new FFH stuff to this file, so perhaps you should try your merged WB with the original PlatyWB CvWBDesc, see if it works with bBarbarian = False, then slowly add in the new FFH stuff and see which function is the culprit.

Currently I am trying to figure out a way such that it will not crash with insufficient number of player data.

-----------------------
Things to do:
A) Figure out how to use CyInterface().isRightMouseDown() in other WB files so that right click can be used to remove without adjusting Add/Remove. Apparently it is working in the main file but not others. CyInterface().shiftKey() is working though...

B) Save and Load, insufficient player data crash

C) Save and Load transport status. Well, transport unit is identified by its ID at best, but all units are recreated when you load a scenario so ID cannot be used. So have to identify with other means.
 
@Magister
Well, if bBarbarian is True, it will definitely crash due to insufficient number of player data, which is existing problem with BTS WB.

As for bBarbarian False:
1) In my tests, Team Data is never a problem.
Platy WB can load BTS WB save.
BTS WB can load Platy WB save.
So at the very least, you should be able to keep the gc.getMAX_TEAMS changes, to edit techs which is what most scenario makers would be concerned. Projects as well, since that is a spell system(?) in FFH.

2) Player Data however, is the big issue, because part of the applying is not handled in that file.
(Civ Type, Leader Type etc which are not exposed to python)
This also means that for Platy WB, even if you go into the Save file and edit the Barbarian leader to Alexander, it will still load as Barbarian Leader.

3) There are 2 instances in getAssignedStartingPlots and applyInitialItems where the range of the loops has changed to len(self.playersDesc) so that I can alter between bBarbarian = True/False freely, you may have missed this in merging.

I know that you have added some new FFH stuff to this file, so perhaps you should try your merged WB with the original PlatyWB CvWBDesc, see if it works with bBarbarian = False, then slowly add in the new FFH stuff and see which function is the culprit.

Currently I am trying to figure out a way such that it will not crash with insufficient number of player data.

As you suggested I tried the original PlatyWB CvWBDesc.

It did not help.

I have exactly the same problem with or without my FfH2 specific changes when I try to use this with MNAI or MagisterModmod.

I had already made the len(self.playersDesc) changes.


I believe that it is Team data that is causing the imcompatibility with MNAI.


When I get a python error report instead of just a crash, it looks like this:
Spoiler :
Code:
Traceback (most recent call last):

  File "CvWBInterface", line 271, in applyInitialItems

  File "CvWBDesc", line 1922, in applyInitialItems

IndexError: list index out of range
ERR: Python function applyInitialItems failed, module CvWBInterface
Traceback (most recent call last):

  File "BugUtil", line 692, in <lambda>

  File "BugEventManager", line 570, in preGameStart

  File "CvAppInterface", line 70, in preGameStart

  File "CvScreensInterface", line 117, in showTechChooser

  File "CvTechChooser", line 231, in interfaceScreen

  File "CvTechChooser", line 243, in ConstructTabs

  File "CvTechChooser", line 280, in DrawTechChooser

  File "CvTechChooser", line 324, in placeTechs

AttributeError: type object 'CvPythonExtensions.WidgetTypes' has no attribute 'WIDGET_TECH_CHOOSER_ERA'
ERR: Python function preGameStart failed, module CvAppInterface

It appears that the BUG modcomp that Tholal incorporated in MNAI is catching a problem related to not finding the era-specific colors to use on the tech tree and determining whether things are obsolete.

I don't know why this happens, or why it should prevent the game from initializing any cities or units.


(Projects, called instead Rituals, don't have a whole lot to do with the spell system. There are projects that use python to trigger effects similar to spells on a larger scale. There are projects which trigger python to create units that have spells. There is a project that restores the player's ability to cast a world spell, by using python to change the status of a Feat which prevents the player from using this spell again. The barbarian state does not have access to any world spells anyway though.)
 
Change
Code:
	def applyInitialItems(self):
		if len(self.teamsDesc) :
			for iTeamLoop in range(gc.getMAX_TEAMS()):
				if (self.teamsDesc[iTeamLoop]):
					
					pTeam = gc.getTeam(iTeamLoop)
					pWBTeam = self.teamsDesc[iTeamLoop]

to

Code:
	def applyInitialItems(self):
		for iTeamLoop in xrange(len(self.teamsDesc)):
			pTeam = gc.getTeam(iTeamLoop)
			pWBTeam = self.teamsDesc[iTeamLoop]

And see if it works.
 
With that change I can load WB saves from before that change just fine, but not those made after the change. It is still writing things about the barbarian team, in particular about whether plots are revealed to the team.

I think the big complication is the line self.abTeamPlotRevealed = [0]*gc.getMAX_TEAMS(), which is before self.teamsDesc is defined so I can't just use the length of that.


I decided to replace all of those repeated calls like gc.getMAX_TEAMS() or len(self.teamsDesc) with variables defined at the top of the file.
Code:
bBarbarian = False

iNumTeams = gc.getMAX_CIV_TEAMS()
iNumPlayers = gc.getMAX_CIV_PLAYERS()
if bBarbarian:
	iNumTeams = gc.getMAX_TEAMS()
	iNumPlayers = gc.getMAX_PLAYERS()

Things seem to be working fine after I switched to that method.


Shouldn't you be able to search through the file to see if the Barbarian state (or at least a player with LEADER_BARBARIAN) is defined, and if so set bBarbarian, iNumTeams, and iNumPlayers appropriately? It seems like doing that would let the same file load saves either with or without the Barbs, even if you would have to adjust the boolean variable defined at the top in order to control whether to write the barbarian info.



p.s. This is not a big issue, but the trailing spaces and tabs at the end of lines (and uneven tabs in lines with nothing but white space) kind of annoys me. I tend to eliminate them in my version, but then when I use WinMerge to update to your new releases most of the differences end up being irrelevant white space. I tend to tell the program to ignore white space, but then I occasionally miss some white space (particularly tabs that are important for nesting loops) that actually is important. Could you try to cut down on white space at the end of lines in future releases?
 
Version 4.03

Featurewise, nothing new.
Changed coding in such a way that for newly created Platy WB saves, it will automatically be loaded with barb info. All BTS WB saves or pre 4.03 saves will be loaded without barb info.

No longer necessary to manually alter bBarbarian.
If you have spent 1000 hours in the past few days creating a scenario and wanna load a old WB save with barb data, just add "Platy" into the first line, Version will become second line.

Rewrote codes for self.abTeamPlotRevealed in a more sensible way too.

P.S.
Generally, I won't bother to add unnecessary "space" at EOL. If you see any, 99% is because it is a whole chunk of C&P codes from Firaxis somewhere.

Platy WB save will look like this:
Code:
Platy Builder 4.03
Version=11
BeginGame
	Era=ERA_ANCIENT
 
A-M-A-Z-I-N-G ! :D

I wonder if the plot culture is correct. I have negative amounts and even a -,112,450 on one (?). This is after a save. I gave legendary culture to my capital city, added the great wall and saved (fine). When I reload WBsave, I have a 2nd level of tiles without culture (or with negative culture), then the 3rd and 4th layers are OK. Graphically, the great wall stops at one tile layer. Weird.

I'm thinking of an option to control the cultural borders in a modern world scenario for instance, but that would imply saving this data in a WB save. Doable?
 
1) Plot Culture is not saved and loaded via WB atm.
What is saved is city culture itself.

2) Negative value is possible when Legendary Culture is set at "too high" resulting in overflow.
But I doubt you will do that...

Some screenshots will be useful.
 
Legendary culture = 150,000, still a reasonable amount.

On Pic4: "La Mecque" strangely surrounded
On Pic5: weird culture number
on Pic7: "La Mecque" plot culture (normal, after some turns)
 
See if the attachment makes a difference.

The GW is understandable since the 2nd layer is missing, thus it only extends as far as possible, which is just 1st layer.

Let me know if you can replicate it in base Platy WB.
 
The new file did not make a difference (but I did not try to re-do the experiment).

And... I could not replicate the problem in base BtS + WB...

So it's my mod which behaves strangely, or should I say it is again a not-so-good change from K-mod. It's not the first time that I see strange things linked to plot culture (but never negative amounts). I will have to take this out and put back in place the BtS system of culture.

Sorry!
 
Version 4.04

1) Fix Add Comma function in CvPlatyBuilderScreen, for signed numbers.
-900 or -900000 will now be displayed as -900 or -900,000 instead of -,900 and -,900,00.


2) Culture in City Screen now displayed with commas

3) Plot Culture now saved and loaded for whoever interested in making scenarios with "Fixed Borders" style.
 
Thank you! :goodjob:

I don't know if it has any importance but the plot culture is shown in the WBsave with an additional indentation:

Spoiler :
Code:
BeginPlot
	x=2,y=11
	RiverNSDirection=0
	isWOfRiver
	RouteType=ROUTE_ROAD
	TerrainType=TERRAIN_GRASS
	PlotType=2
	BeginUnit
		UnitType=UNIT_WARRIOR, UnitOwner=2
		UnitName=Cong
		Level=1, Experience=0
		FacingDirection=4
		UnitAIType=UNITAI_CITY_DEFENSE
	EndUnit
	BeginCity
		CityOwner=2
		CityName=TXT_KEY_CITY_NAME_AMSTERDAM
		CityPopulation=1
		ProductionUnit=UNIT_WARRIOR
		BuildingType=BUILDING_PALACE_NETHERLANDS
		BuildingType=BUILDING_CAPITAL_CITY
		BuildingType=BUILDING_HERMITAGE_NETHERLANDS
		Player2Culture=28
		FreeBonus=BONUS_NETHERLANDS, Amount=1
	EndCity
	TeamReveal=2,
		Player2Culture=262
EndPlot
BeginPlot
	x=2,y=12
	isNOfRiver
	RiverWEDirection=3
	TerrainType=TERRAIN_GRASS
	PlotType=2
	TeamReveal=2,
		Player2Culture=261
EndPlot
BeginPlot
	x=2,y=13
	BonusType=BONUS_PIG
	TerrainType=TERRAIN_GRASS
	PlotType=1
	TeamReveal=2,
		Player2Culture=104
EndPlot
BeginPlot
	x=2,y=14
	RiverNSDirection=0
	isNOfRiver
	RiverWEDirection=1
	isWOfRiver
	TerrainType=TERRAIN_GRASS
	PlotType=1
		Player2Culture=52
EndPlot
BeginPlot
	x=2,y=15
	TerrainType=TERRAIN_PLAINS
	PlotType=2
EndPlot

It is indented at the same level than the City culture and has the same name (PlayerXCulture). Probably doesn't matter as it is working correctly (this city did not receive the "culture bomb").

I also reproduced the "culture bomb" in my mod: still negative numbers (showing properly as negative numbers now) but strangely nothing is saved in the WBsave although they reappear after loading. I suppose that k-mod introduced new checks/codes that are not executed when done in World Builder. Anyway, whatever people do with the WB is always at own risk!

Edit: repeated same test with Platy Builder 3.18: same results!... So I just did the wrong test at the wrong moment...
 
Reuploaded just to fix the indentation.

The indentation here is only for humans to read. It has no value to the computer.

Negative numbers are not saved or loaded for WB, because I told it not to.
In BTS, culture will never be negative. If it is, there is an error somewhere, so there is no point to save or load an error.

But if negative culture is actually used somewhere for k-mod, then I might bother to remove this safety check.
 
But if negative culture is actually used somewhere for k-mod, then I might bother to remove this safety check.

No, doesn't look like it, must have been an overflow as you said.

Reverted back to BtS code, all is fine now.
 
Top Bottom