Question: Multiple Tech Trees

Warlord Sam

2500 hours and counting..
Joined
Oct 27, 2001
Messages
379
Would it be possible to A) grant different civs completely unique tech trees or B) have religions grant completely different tech trees (and perhaps make the choice to adopt a religion a one-time-only deal, irreversible?)

I am toying with some ideas I'd enjoy trying to turn into a scenario, but am not sure about the current modability of Civ4. I tried searching but couldn't really find much aside from Civ5 ideas and theoretical stuff, not any direct answers to these two questions.

My thanks in advance!
 
You can create no-trade no-research technologies.

These technologies can be AND or OR requirements for other technologies.

You can grant these technologies via the SDK or the Python scripting based off of events, or simply grant the technology to a player when they reach a certain level of advancement.

Making the tech tree look pretty might take some work.

Ie, you might have:
Faith of the True Flame (base tech for a civ)
leads to:
Truth of the True Flame
Theology of the True Flame
Enlightenment of the True Flame
Understanding of the True Flame

with each of these technologies set in different eras, connected by AND requirements, and having an OR requirement from the main tech tree, and leading via AND or OR to other technologies.

Make sense?
 
There has been alot of discussion on this topic since Civ4 came out and several ways to make it work have been discovered, but I think I have figured out a pretty clean way to do it with python.

First step would be to set up the TechInfo.xml with the multiple tech trees.
TechA1 -> TechA2 -> TechA3
TechB1 -> TechB2 -> TechB3

The next step is to make the different trees unresearchable by specific players. This can be pretty easyly accomplished with the cannotResearch method in the CvGameUtils.py file. The real code would be in a function that checks if a given Player has access to a given Tech, say isTechValid(iPlayer, iTech), that returns True or False.

The last step, and the one that I don't think anyone has come up with a good fix for, is displaying a correct looking tech tree on the Tech Advisor screen. However, I think the answer just hit me and after looking at the Tech Advisor screen code I'm pretty sure it will work.
In the CvTechChosser.py file, in the placeTechs() method.
Code:
	def placeTechs (self):
	
		iMaxX = 0
		iMaxY = 0

		# If we are the Pitboss, we don't want to put up an interface at all
		if ( CyGame().isPitbossHost() ):
			return
			
		# Get the screen
		screen = CyGInterfaceScreen( "TechChooser", CvScreenEnums.TECH_CHOOSER )
	
		# Go through all the techs
		for i in range(gc.getNumTechInfos()):

			# Create and place a tech in its proper location
			iX = 30 + ( (gc.getTechInfo(i).getGridX() - 1) * ( ( BOX_INCREMENT_X_SPACING + BOX_INCREMENT_WIDTH ) * PIXEL_INCREMENT ) )
			iY = ( gc.getTechInfo(i).getGridY() - 1 ) * ( BOX_INCREMENT_Y_SPACING * PIXEL_INCREMENT ) + 5
			szTechRecord = "TechRecord" + str(i)
			
			if ( iMaxX < iX + self.getXStart() ):
				iMaxX = iX + self.getXStart()
			if ( iMaxY < iY + ( BOX_INCREMENT_HEIGHT * PIXEL_INCREMENT ) ):
				iMaxY = iY + ( BOX_INCREMENT_HEIGHT * PIXEL_INCREMENT )

			screen.attachPanelAt( "TechList", szTechRecord, u"", u"", True, False, PanelStyles.PANEL_STYLE_TECH, iX - 6, iY - 6, self.getXStart() + 6, 12 + ( BOX_INCREMENT_HEIGHT * PIXEL_INCREMENT ), WidgetTypes.WIDGET_TECH_TREE, i, -1 )
			screen.setActivation( szTechRecord, ActivationTypes.ACTIVATE_MIMICPARENTFOCUS)
			screen.hide( szTechRecord )
This just goes through all the techs in the xml file and places them at the proper x, y coords on the Tech Advisor screen.
If you change it to something like this
Code:
	def placeTechs (self):
	
		iMaxX = 0
		iMaxY = 0

		# If we are the Pitboss, we don't want to put up an interface at all
		if ( CyGame().isPitbossHost() ):
			return
			
		# Get the screen
		screen = CyGInterfaceScreen( "TechChooser", CvScreenEnums.TECH_CHOOSER )
	
		# Go through all the techs
		for i in range(gc.getNumTechInfos()):

                        if(not isTechValid(gc.getGame().getActivePlayer(), i)):
                                continue

			# Create and place a tech in its proper location
			iX = 30 + ( (gc.getTechInfo(i).getGridX() - 1) * ( ( BOX_INCREMENT_X_SPACING + BOX_INCREMENT_WIDTH ) * PIXEL_INCREMENT ) )
			iY = ( gc.getTechInfo(i).getGridY() - 1 ) * ( BOX_INCREMENT_Y_SPACING * PIXEL_INCREMENT ) + 5
			szTechRecord = "TechRecord" + str(i)
then only techs in the proper tech tree will be displayed. You will then be able to set each tech tree up as if the others don't exist.

I have a few free hours, I'm going to look into making an example mod of this, should be able to get it done tonight. :)
 
I added a tag to the tech called TechTreeID. I also set it up so each player was given a TechTreeID through the XML too. That way yo can see if the TechTreeID matches to see which techs will be displayed and coud can also see if the ID match to see if its possible to research them. Takes some SDK work, but my beta of its turned out fine so far (I hope I don't jinx myself!).

Setting it up in the MXL reader is a little more difficult than Jeckel idea but is more flexible as you can just plug in more techtrees with little or no hassle. You could also set iy up for names if you like text better than IDing everything with a number. So you could under the ID tag have EVIL_NATION_TREE, and under the civilization info have EVIL_NATION_TREE also.

Anyways I love adding Tags and the SDK, I've even cut out the Python calls in my mod, so if you can't C++ very well or don't like it Jeckel's the way to go.
 
Hmm, adding some new tags isn't a bad idea. I've got the display part done, but i've been trying to come up with a way to know what tech tree a given tech is in. I can't seem to find a clean way that doesn't involve a new list that techs have to be added to or lots of recursive loops looking through the tree finding whats connected to what.

The good news is that not showing part of the tech info file is pretty easy to do and seems to work fine. I've got a test mod that doesn't show techs more then 1 era ahead of you.

I'm going to eat some dinner and then I'll see about putting a SDK together with the new tags then I'll polish up the python and post it. :)
 
You could also create a second, "all tech", location for a given tech tree node.

That would help during debugging or when you want to look at the entire tech tree. ;)
 
Thats an interesting idea Yakk. I will look into that after i get the basic version working. :cool:

I ran into some problems last night, I couldn't get BtS to compile, but found a thread that fixed the problem.
Also discovered that gettting strings from the xml is different in the SDK then ints or bools, but I think I got that working to after I found an example.
Should have it finished he shortly. :)
 
Ok, here is a alpha version. Give it a try and let me know how it works and what other features you would like to see in the mod. :)
 
Hehe, sorry Zebra 9, you snooze, ya loose. ;) You got any ideas for things to add to this mod?

I'm working on adding member functions to the CvPlayer class that will allow you to get and set a player's TechTree dynamicly from python. I'm not going to get much done today, I have 54,000 zombies to kill in Dead Rising so I can get the Mega Blaster, and that will prob take all day. But I'm going to work on this mod some more tomorrow. :)
 
Can't think of anything just now. Maybe give that ability to disable a tech for a civ from python. :hmm:

Cool, I am only working on this and one other project, so should have a new alpha version out some time this week.


Seeing as noone is complaining about errors, I'm going to assume the current alpha version I posted above is working ok and will post it in the DB sometime in the next couple days. :)
 
Top Bottom