Platy World Builder

Platyping,

What an interesting mod! :goodjob: I have a definite need for the capability to edit the game options for OGI from within world builder. So I'd like to experiment/test things a little bit. Lets say I wanted to edit the game options using your World building edit Control window and leave everything else in your mod out. Can you tell me what are the minimum python and or XML changes needed so that I can add only the game options window to world builder?

Also, If I merge your mod into another mod that has additional options will your game options window display those additional game options?

Thanks...
 
1) It will list all game options regardless of originial or new ones.
However, there are certain game options with additional codes written.

Spoiler :
Code:
	def handleEditGameOptionCB ( self, argsList ) :
		iIndex, strName = argsList
		CyGame().setOption(int(strName), int(iIndex))
		if int(strName) == GameOptionTypes.GAMEOPTION_NO_GOODY_HUTS and iIndex:
			for i in xrange(CyMap().numPlots()):
				pPlot = CyMap().plotByIndex(i)
				if pPlot.getImprovementType() == gc.getInfoTypeForString("IMPROVEMENT_GOODY_HUT"):
					pPlot.setImprovementType(-1)
		elif int(strName) == GameOptionTypes.GAMEOPTION_NO_VASSAL_STATES and iIndex:
			for iTeamX in xrange(gc.getMAX_CIV_TEAMS()):
				pTeamX = gc.getTeam(iTeamX)
				for iTeamY in xrange(gc.getMAX_CIV_TEAMS()):
					pTeamX.freeVassal(iTeamY)
		elif int(strName) == GameOptionTypes.GAMEOPTION_ALWAYS_PEACE and iIndex:
			for iTeamX in xrange(gc.getMAX_CIV_TEAMS()):
				pTeamX = gc.getTeam(iTeamX)
				if CyGame().isOption(GameOptionTypes.GAMEOPTION_ALWAYS_WAR) and pTeamX.isHuman(): continue
				for iTeamY in xrange(gc.getMAX_CIV_TEAMS()):
					if CyGame().isOption(GameOptionTypes.GAMEOPTION_ALWAYS_WAR) and gc.getTeam(iTeamY).isHuman(): continue
					pTeamX.makePeace(iTeamY)
		elif int(strName) == GameOptionTypes.GAMEOPTION_ONE_CITY_CHALLENGE and iIndex:
			for iPlayerX in xrange(gc.getMAX_CIV_PLAYERS()):
				pPlayerX = gc.getPlayer(iPlayerX)
				if pPlayerX.isHuman():
					(loopCity, iter) = pPlayerX.firstCity(false)
					while(loopCity):
						if not loopCity.isCapital():
							loopCity.kill()
						(loopCity, iter) = pPlayerX.nextCity(iter, false)
		elif int(strName) == GameOptionTypes.GAMEOPTION_NO_BARBARIANS and iIndex:
			pPlayerBarb = gc.getPlayer(gc.getBARBARIAN_PLAYER ())
			(loopCity, iter) = pPlayerBarb.firstCity(false)
			while(loopCity):
				loopCity.kill()
				(loopCity, iter) = pPlayerBarb.nextCity(iter, false)
			(loopUnit, iter) = pPlayerBarb.firstUnit(false)
			while(loopUnit):
				loopUnit.kill(False, -1)
				(loopUnit, iter) = pPlayerBarb.nextUnit(iter, false)
		return 1

The reason is that activating Game Option in game generally does not affect whatever has already happened.

For instance, No Barbarian option is supposed to prevent the game from having any barbarians.
If it was disabled initially, barbarians would have spawned in the game.
But if it was enabled later, it will only prevent spawning of barbarians from now on, but any existing barbarian units or cities will remain in the game.
Thus, for certain game options, the above additional codes are written so that they remove whatever should not be there, if that game option was activated from start.

Similarly for OCC, it is supposed to restrict human player from having more than one city.
Activating mid game will only prevent him/her from building more cities, but existing ones remain.

Thus, additional codes for the following:
A) No Goody Huts: Remove all existing ones
B) No Vassal States: Cancel all existing ones
C) Always Peace: Stops all wars, unless Always War also activated and player is human
D) One City Challenge: Destroys all cities of human player except capital
E) No Barbarians: Remove all existing ones

2) XML
The only ones included are simply Text files. All those related to game options should be in Side Panel.

3) Python
This is tough...
For CvScreensInterface, quite simple, take those under Game Options, and those common functions defined before all others.

For CvWorldBuilderScreen, because Game Option is accessed from Game Data Screen, you will have to look for both parts, 99% of them should be commented necessarily.

Actually, if your mod does not have any changes to CvWorldBuilderScreen, you might as well just add the whole file in and just use whichever function you need :D
 
3) Python
This is tough...
For CvScreensInterface, quite simple, take those under Game Options, and those common functions defined before all others.

Yes it is tough, as I haven't got it to work yet. When you say, "those common functions defined before all others;" can you be more specific by stating, which common functions?
 
Pretty Clear :D
Code:
## Platy World Builder Start ##

def WorldBuilderHandleEditScriptCB( argsList ):
	worldBuilderScreen.handleEditScriptCB(argsList)

def WorldBuilderHandleEnterNewScreenCB( argsList ):
	worldBuilderScreen.handleEnterNewScreenCB(argsList)

They are really before everything else :D

Actually the previous versions you can actually go to Game Options without going through Game Data Screen, so if you are free, you can edit the CvWorldBuilderScreen to do so again.
 
2) Modify Buildings:
The art of cheating...
Modify such that a granary in this city grants +100 Food, +100 Production and +100 Culture if you like.

Not pretty obvious when you are in WB. I think you will need to write a manual for everybody to fully appreciate all the features available now!
Spoiler :
For example, I can't find plot data! The third top button is inactive, right?

Weekly update of French translations included. :king:
 
Plot data is same as default WB
Assessed via
1) Edit unit or Edit city and right click...
2) Shift Click

Don't ask me why Firaxis designed it that way and I am lazy to change.

The third button was change all plots, but I decided to merge it into map edit.
I intended to use third button to access game data directly, but again... lazy to implement.

For manual, refer to first post. It explains all :D
 
Wow, I don't even remember if I knew about that access to plot data in default WB. Really not easy to figure it out.

For the manual, you're right, sorry. I guess it's a long time I did not pay attention to the first post! :goodjob:
 
Updates

1) Irritated by Super Long Winded Code for Multiple Tiles. Cut it down...
Example 1:

Firaxis:
Spoiler :
Code:
	def setMultipleReveal(self, bReveal):
		print "setMultipleReveal"
		bInsideForLoop = False
		permCurrentPlot = self.m_pCurrentPlot
		for i in range( (self.m_iBrushWidth-1) ):
			for j in range((self.m_iBrushHeight)):
				bInsideForLoop = True
				self.m_pCurrentPlot = CyMap().plot(permCurrentPlot.getX()-(i+1), permCurrentPlot.getY()-(j))
				if (not self.m_pCurrentPlot.isNone()):
					self.RevealCurrentPlot(bReveal)
				self.m_pCurrentPlot = CyMap().plot(permCurrentPlot.getX(), permCurrentPlot.getY()-(j))
				if (not self.m_pCurrentPlot.isNone()):
					self.RevealCurrentPlot(bReveal)
				self.m_pCurrentPlot = CyMap().plot(permCurrentPlot.getX()+(i+1), permCurrentPlot.getY()-(j))
				if (not self.m_pCurrentPlot.isNone()):
					self.RevealCurrentPlot(bReveal)
				self.m_pCurrentPlot = CyMap().plot(permCurrentPlot.getX()-(i+1), permCurrentPlot.getY()+(j))
				if (not self.m_pCurrentPlot.isNone()):
					self.RevealCurrentPlot(bReveal)
				self.m_pCurrentPlot = CyMap().plot(permCurrentPlot.getX(), permCurrentPlot.getY()+(j))
				if (not self.m_pCurrentPlot.isNone()):
					self.RevealCurrentPlot(bReveal)
				self.m_pCurrentPlot = CyMap().plot(permCurrentPlot.getX()+(i+1), permCurrentPlot.getY()+(j))
				if (not self.m_pCurrentPlot.isNone()):
					self.RevealCurrentPlot(bReveal)
		if (not bInsideForLoop):
			self.m_pCurrentPlot = CyMap().plot(permCurrentPlot.getX(), permCurrentPlot.getY())
			if (not self.m_pCurrentPlot.isNone()):
				self.RevealCurrentPlot(bReveal)
			for j in range((self.m_iBrushHeight)):
				self.m_pCurrentPlot = CyMap().plot(permCurrentPlot.getX(), permCurrentPlot.getY()-(j))
				if (not self.m_pCurrentPlot.isNone()):
					self.RevealCurrentPlot(bReveal)
				self.m_pCurrentPlot = CyMap().plot(permCurrentPlot.getX(), permCurrentPlot.getY()-(j))
				if (not self.m_pCurrentPlot.isNone()):
					self.RevealCurrentPlot(bReveal)
		self.m_pCurrentPlot = permCurrentPlot
		self.showMultipleReveal()
		return

Platyping:
Spoiler :
Code:
	def setMultipleReveal(self, bReveal):
		print "setMultipleReveal"
		permCurrentPlot = self.m_pCurrentPlot
		for x in range(permCurrentPlot.getX() - self.m_iBrushSize +1, permCurrentPlot.getX() + self.m_iBrushSize):
			for y in range(permCurrentPlot.getY() - self.m_iBrushSize +1, permCurrentPlot.getY() + self.m_iBrushSize):
				self.m_pCurrentPlot = CyMap().plot(x,y)
				if not self.m_pCurrentPlot.isNone():
					self.RevealCurrentPlot(bReveal)
		self.m_pCurrentPlot = permCurrentPlot
		self.showMultipleReveal()
		return

2) Added 7x7 for Multiple Tile Mode... (Out of Boredom)

3) New Toy:



Allows you to edit visiblity of plot's invisibility.
Under Plot Reveal Section
Reveal/Unreveal All will also work according to reveal mode choice (Normal, Sub, Stealth)

Edit:
Clean up some codes.
Fix one typo error.
 
Updates

1) Clean up some codes, rewrite some Firaxis ones

2) Added River to Plot Data



3) Script Data now displayed directly in respective screen.
Previously, press a button, popup appear



4) Added Kill function to Unit
For your convenience if you do not know setting Damage to 100% == Dead Unit

5) Added Kill function to Player
If you really hate him/her that much...

6) Multiple Tile Function
Added Improvements and Routes, so you can now add Farms in a 5x5 Tile instead of always 1x1.

7) Multiple Tile now checks for sensibility before adding.

Previous:


New:


The new version will only add X if the plot can have X, whether X is a feature, bonus, improvement or route whatever.
So you can add a 7x7 horse without having fear of seeing sea horse.
If you insist on seeing see horse... use single tile mode.

Edit:
Fixed Single Tile Mode, the "sensibility" part should now only apply to Multiple Tile Mode
 
As I compare the two python files CvScreensInterface.py and CvWorldBuilderScreen.py, with the stock BTS files; there a lot of lines that have been removed and a lot of lines that have been added. Many of these changes have no explaination to indicate they were made due to your Platy world builder mod or some other mod. This makes merging the Platy world builder mod very difficult to understand. I know that if I have difficulty with merging this mod, others are likely to have difficulty as well.

May I suggest that you fully document EVERY line of difference, whether added or removed to help others with the merging process. This is most useful when attempting to merge several changes from multiple mods into a single file. It also helps with troubleshooting any problems that may occur. If a potential bug can be isolated to a single line of code that belongs to a specific mod, then bug fixes become much easier.

Respectfully,
 
Well, since it is a standalone mod, it is pretty obvious whatever is added or removed is simply due to this mod.

Regarding CvWorldBuilderScreen.py, since not even BUG has modified that file, I highly doubt there is another mod existing that modified that file.
As such, what is the difficulty to merge it with another mod?

As for CvScreensInterface.py, all lines added or removed are under the WorldBuilderSection.
Again, unless your mod has modified World Builder, there should be no changes to that section.
Whatever is removed, is because the function no longer exist in CvWorldBuilderScreen.py.

P.S.
Apparently AIAndy has merged it into C2C awhile ago, some others like isenchine and Aloha also tested it out.
Since C2C is pretty much the biggest mod around and he managed to merge it, then it shouldn't be an issue? :D
 
Well, since it is a standalone mod, it is pretty obvious whatever is added or removed is simply due to this mod.

Regarding CvWorldBuilderScreen.py, since not even BUG has modified that file, I highly doubt there is another mod existing that modified that file.
As such, what is the difficulty to merge it with another mod?

As for CvScreensInterface.py, all lines added or removed are under the WorldBuilderSection.
Again, unless your mod has modified World Builder, there should be no changes to that section.
Whatever is removed, is because the function no longer exist in CvWorldBuilderScreen.py.

P.S.
Apparently AIAndy has merged it into C2C awhile ago, some others like isenchine and Aloha also tested it out.
Since C2C is pretty much the biggest mod around and he managed to merge it, then it shouldn't be an issue? :D

I have documented all the changes myself, it took me all day to do it. You are correct about the CvWorldBuilderScreen.py file, as it rarely gets modified by anyone. The reason I wanted to play with the options screen, was to learn something about how you did all this. The amount of work you have put into improving worldbuilder is simply incredible and you have my respect. :hatsoff:
 
Glad you got it working :D
At this moment, almost every part of the CvWorldBuilderScreen.py file has been changed, except for Advanced Start part, so after awhile it is pretty hard to keep track of all changes, so most of them I just add a heading comment and thats all :D

Mini Update

1) Rewrite coding for Move Unit, simpler.

2) Changed the UNITAI_XXX to Upper and Lower Case, easier to read for me.
Didn't bother to sort alphabetically as all the "Sea" and "Air" ones are grouped together.

3) Added Facing Direction just for fun.
 
Regarding CvWorldBuilderScreen.py, since not even BUG has modified that file, I highly doubt there is another mod existing that modified that file.

Well, Final Frontier Plus modified that file. Getting it to work at all with star systems and planets required several changes to that (done by TC01, all I did was tweak how some of the data was accessed since that changed for some things when I merged in BUG).

So now you know of one other mod that has changed that file.
 
Well then it may be challenging if he wishes to mod it in since pretty much every section of that file is already modified in this mod, except for advanced start which I am totally not interested to explore.

But in general, most mods like pie, c2c or ri never bothered with that file, so merging shouldn't be an issue :)
 
Hmm, shouldn't be hard to use after you try for awhile, since all the functions are still accessed via the same method, except for change all plots. It is just that there are quite a lot of new fields which affect things which are unfamiliar to users not exposed to SDK or python, such as the recently added ability to edit plot invisibility visibility.

One day, I may bother to add hover text, but not for now since I still have 2 or 3 more projects ongoing. The recently added enhanced gp mod and the currently on hold natural wonder mod since there are no more nw art to use.

2 other projects still in development, project help tag and adding pages to civilopedia
 


2 New Features

1) Change Unit Type
Change the unit into another type, keeping all reasonable stats like promotions, name, level, experience, script data.

2) Leader Unit Type
Cosmetic Effects. Tired of seeing a Great General leading your troops? How about using Great Artist or a silly Bear?
 
Hi Golden Python! Awesome promotion you got there! :D

Weekly update of French translations.

Thank you for the kill unit button!

Any chance you wanna use the third button to access Plot Data?
 
Maybe but not anytime soon.
Changing the function of that button may require more files I guess.
One thing I would like to figure out is how to add tabs so that each of those data screens will not be that big.

For instance, main unit data like name and owner on first tab, modifiable ones like exp and lvl on next tab, promotions next tab.

Something like bug option page
 
Top Bottom