Eliminating Eras

Craig_Sutter

Deity
Joined
Aug 13, 2002
Messages
2,773
Location
Calgary, Canada
I'm trying to eliminate all of the Eras after Medieval for my mod.

To begin, I simply used the file from the MedEVO mod.

I attached it as an existing item, added it as an action in the property page (uponmodactivated, updatedatabase) by simply selecting it via the dialogue (there is no browse function to select the file path but the item was available).

I then rebuilt my mod (which is simply a map and this added file)

I start up the game and select my mod and install. However, when I look at the tech tree, all the techs are available.

The xml and database logs show no change from usual errors that seem to be inherent in the game.

The file I am using is as follows:

Spoiler :

<?xml version="1.0" encoding="utf-8"?>
<!-- Created by ModBuddy on 10/4/2010 2:33:58 PM -->
<GameData>
<!-- TODO: Insert table creation example here. -->

<!-- TODO: Insert table data example here.-->

<!-- Enter your Game Data here. -->
<Technologies>
<Update>
<Where Era="ERA_RENAISSANCE"/>
<Set Disable="1"/>
</Update>
<Update>
<Where Era="ERA_INDUSTRIAL"/>
<Set Disable="1"/>
</Update>
<Update>
<Where Era="ERA_MODERN"/>
<Set Disable="1"/>
</Update>
<Update>
<Where Era="ERA_FUTURE"/>
<Set Disable="1"/>
</Update>
<Update>
<Where Type="TECH_FUTURE_TECH"/>
<Set Disable="0" Cost="12000"/>
</Update>
</Technologies>
<Technology_PrereqTechs>
<Delete TechType="TECH_FUTURE_TECH"/>
</Technology_PrereqTechs>
<Defines>
<Update>
<Where Name="NUM_AND_TECH_PREREQS"/>
<Set Value="10"/>
</Update>
</Defines>
</GameData>


I've tried to add other such items affecting game speed and tech costs, but none of them seem to work... what am I doing wrong.

I would appreciate some advice because this really ought to be quite simple... what am I missing. If I install the whole MedEVO mod, it seems to work (although there are many "text_key_..." entries in the tech tree) at least as far a eliminating these techs goes.

Thank-you for your advice.
 
First of all, I cut and pasted your logic into my own mod, and it worked just fine. So whatever your mistake is, it's not in the XML itself. Without seeing your mod's actual files, there's no easy way to tell what you're doing wrong. Maybe you've got the wrong path for the UpdateDatabase command, maybe you're just not clicking the right button in the Mod Browser. Who knows.

Also, if you're going to copy code to this board, use the (CODE) environment, not the (SPOILER) one. That way, it'll preserve the indentations and make it much easier to read. (Brackets instead of parentheses, obviously.)

But beyond that, I have to warn you; doing it this way is just going to be UGLY. Disabled techs aren't hidden; they're simply colored red, instead. So the tech tree will still show those later eras, all in red. You could also mod the UI to hide those eras, of course.
 
I understand your point that it should be handled a different way. I just want to get this simple change to work so I can learn the process... I'm obviously doing something wrong. Later, I'll figure out how to simply eliminate all the unwanted techs.

Could it be a VFS error? I checked the properties in the file, but couldn't find a checkbox, true of false.... I'm using Windows 7 if that helps.

Thank-you for the advice. I'll keep plugging away.
 
Well, I got it to work...

Code:
<?xml version="1.0" encoding="utf-8"?>
<!-- Created by ModBuddy on 6/4/2012 11:18:40 AM -->
<GameData>
	<Technologies>
		<Update>
			<Set Era="ERA_MEDIEVAL"/>
			<Where Type="TECH_ASTRONOMY"/>
		</Update>
		<Update>
			<Set Era="ERA_MEDIEVAL"/>
			<Where Type="TECH_BANKING"/>
		</Update>
	</Technologies>  
</GameData>

and this is a screenshot...

View attachment 322671

As you can see, the remaining renaissance techs in the same column as Banking and Astronomy appear in the Medieval period in the tech view.

I'm currently deleting all the techs later than Medieval. I'm running into some oddities... I am able to delete acoustics and printing press, however if I delete others, the mod stops working... I suspect I'll have to change buildings and units that rely on these techs, but I'll do some experimenting and let you know what happens (in case anyone else is having trouble)
 
As you can see, the remaining renaissance techs in the same column as Banking and Astronomy appear in the Medieval period in the tech view.

As we've told you quite a few times now, you can't have techs from two different eras in the same column. The game won't split them up automatically, you have to change the GridX values for the techs you're moving.

I'm currently deleting all the techs later than Medieval.

Deleting things is BAD.

First, a lot of different tables use those deleted entities. Sure, you delete the Combustion tech, but then the game tries to process the Tank unit, whose prerequisite tech is Combustion, and it no longer sees a valid value and crashes. Repeat for every unit, building, promotion, and even policy branch that unlocks at a now-deleted tech. When you're chopping off entire eras, you'll have to delete a tremendous number of table entries to keep this from happening; the game won't do it for you automatically.

Second, many of the game's data tables can't handle non-sequential IDs. You'll notice that the Technologies, Units, Buildings, etc. tables all have an <ID> field, that's set to auto-increment. The first entry in each table says <ID>0</ID>, but there are no later <ID> declarations; what happens is that the second entry is given an ID of 1, the one after that gets 2, and so on down the line, automatically.
But when you delete an entry, it doesn't re-sequence the later IDs. So if you delete the second entry, now it'll go 0, 2, 3... and sometimes this causes crashes. It used to be that it'd ALWAYS cause a crash, but the devs went back and fixed some (but not all) of the tables to work around this. So you can now delete a Unit without it crashing, but you still can't delete a Promotion, because that's a table they never got around to fixing.
There's a mod out there that uses SQL to re-sequence all IDs from deleted entries, but the default game doesn't do that.
 
"As we've told you quite a few times now, you can't have techs from two different eras in the same column. The game won't split them up automatically, you have to change the GridX values for the techs you're moving."

Yes, I understand that. That is why I thought it so interesting that the techs sorted themselves out as I pointed out in the screenshot, with the placing of banking and astronomy in the medieval column causing the other techs in that same column to also appear in the medieval column although they are renaissance techs. Moving everything one over on the grid will certainly change that, but I thought it was an interesting result. That may be my next step as I'm doing this incrementally... if I figure out how to appropriately alter the techs, it may be unneeded.

My next question is, then, how do I go about changing or deleting techs so that doing so does not adversely affect the game mechanics.

I can think a a couple of possibilities, but do not know the ramifications...

1) delete every tech Renaissance and above

If I can delete all of them, perhaps the ID numbering won't matter as re-sequencing is not needed. If the ID numbers, for instance, go from 0-100 and I delete techs numbered 50-100 there ought to be no gaps in the 0-49 range. This still leaves the major problem of all the dependencies you mentioned.

2) delete all Eras after Renaissance - this has all the problems of above.

3) make all the Renaissance and later techs have a prereq tech that cannot be researched. The only problem I see with this is that it leaves these Eras in the game and I don't know the ramifications of this.

4) I can't look at a tech entry here in my office, but perhaps there is a true/false or 0/1 choice to turn off a tech.

All these methods have certain difficulties... if techs are not deleted, that may affect the AI strategies such that it might be confused as to which path to research. Deletions cause problems with dependent entries throughout the game.

My basic goal is to have a game largely set in the Medieval and earlier Eras. There must be a way to delete or alter techs in such a way that they are not in play anymore, and do not have negative effects on the AI.

Hopefully, someone who has handled this problem can give me a solution that is more elegant than the ones I have thought of.

As always, thank you very much for the advice. If it seems I'm ignoring some of it, I am not... I very satisfied that I got the code I supplied earlier in this thread to work. Though it has resulted in an odd tech tree, I can deal with that now... at least I know the original code worked. I appreciate all the help very much and have learned a lot already about the many pitfalls that may arise. I'm going to incrementally get my mod to the state I want.

As I said, any advice about how to get rid or suitably alter Renaissance or older techs would be much appreciated.

Thanks
 
My apologies to Spatz if he take offence to my quote.

No offense taken. I was addressing the "deleting is bad" comment at the new modders, who generally aren't even aware there is an issue with deletion. Kael's guide explains how to delete an entry, but it doesn't discuss the effects of doing so. Experienced modders do know about the problems, and know the multiple ways to deal with them, but those people aren't gaining much from these discussions to begin with.

In general, even if you're comfortable with re-sequencing, you want to be careful with deletions because of all its secondary effects; making something hidden is nearly always a better solution. For instance, if you want to hide a tech from the tree, just give it a GridY value that falls well outside the normal 0-9 range, to ensure that its box won't fit into the window. Poof, hidden tech! As long as you've also deleted that tech's prerequisites, so that it doesn't try to draw arrows, that is, and obviously you need to Disable the tech as well. (Note that changing the GridX value as well doesn't have the same effect, because the game has a horizontal scroll bar and uses the GridX value to decide how to draw each era and how long to make that scroll bar.)

So if you're using a simple Update to change the Disable flag on every tech in a certain era, just change the GridY to -10 or something on the same command. You'll see a big empty box where that era's techs go, but fixing THAT requires UI modifications that you really don't want to get into. And while you need to delete some prerequisites to keep it from drawing lines, you really only need to do that for the first tier of hidden techs.
Note that deleting an era entirely will ALSO require a UI mod, because in TechTree.lua it explicitly loops from 0 to 6 for the Eras; if you delete eras, or delete all techs within an era, it'll break that UI code.
 
No offense taken. I was addressing the "deleting is bad" comment at the new modders, who generally aren't even aware there is an issue with deletion. Kael's guide explains how to delete an entry, but it doesn't discuss the effects of doing so. Experienced modders do know about the problems, and know the multiple ways to deal with them, but those people aren't gaining much from these discussions to begin with.
It's sometimes hard to figure out a modder's experience level from their posts. For example, I thought this post To make a mod using Microsoft Access was incomprehensibly dim and responded accordingly. Then it turned out that the poster was actually a pretty sophisticated modder, making me feel silly for my initial assumption.
 
Thank-you for the replies, and the tutorial looks great.

Because I'm looking at removing/altering all of the Renaissance and later techs, I think that simply deleting them is not the best thing. The ramifications of a mistake are too great, and it is extremely hard to do incrementally... modding it step by step is easier for me. Also, I really do not want to search out every file for units, buildings, etc. that are dependent on the techs. I'm certain it would be very frustrating to do so as the mod would not work until I got every one right, and it may be hard for me to judge how well the mod is progressing until I find the final dependency... and then I may find I've made a serious error and my mod will not work anyway... far better to do it step by step, and be able to judge my progress along the way with successfully installed versions as my guide.

That makes the method in the tutorial problematic... it is likely of more use for a better and more experienced modder.

I'm interested in the suggestions made by Spatzimaus. I was unaware of these methods and perhaps a guide may be in order for these alternative means of hiding a tech or other item... I may have missed some of them in the following scheme I will try to implement:

- I can make techs nonresearchable by giving them cost of -1. Does the AI realize this? Are there negative effects. Can they still be discovered accidentally, for instance, in Goody Huts?

- I can make the nonresearchable techs invisible by moving them off the grid and removing prerequisites and thus the lines between them and the visible techs. If I use some sort of command somewhat like set Y=-10 where Era=Era_Renaissance Era=Era_Industrial Era=Era_Modern (I'm not certain about the exact commands being at work now), does it matter if some of the hidden techs are superimposed upon each other with x and y coordinates being the same (remember, they are hidden). Or is it best to hide the techs with a command for each individually changing x and y so they are not on top of each other.

- It was mentioned that at least one tech should be maintained in each Era. Could that be explained a bit. Would removing techs as specified above be okay in this context - hidden and unresearchable, but not removed?

- What should I do with future tech... can it be safely removed or hidden and made unresearchable. What are the consequences of not removing it? I don't want spaceship parts accidentally made available to my medieval civ.

- how are these hidden techs reflected in the civilpedia? Do I have to make an entry to cover them... perhaps altering the pedia text for all techs in those later Eras explicitly stating that they are not usable in my mod?

Again, any advice as to the best course to take would be welcome.
 
Well... Clearly my tutorial was effective. (I always tell my interns that the best thing they might learn is that this line of work is not for them.)
 
Actually very informative and the ensuing discussion as well. I know way more than I did yesterday.

Searching for the dependencies is too daunting at the moment. I'm too unfamiliar with relations between files to readily search them out. If there were a cheat sheet of exactly what files to update when something was deleted, that would be most useful... as it is, for instance, I've no idea where to look... buildings and units seem obvious, but what about resources or policies, etc. It is too easy to miss something.

Of course, the tutorial will be of great use depending on ability and circumstance.
 
- I can make techs nonresearchable by giving them cost of -1.

No, you can't. Technologies is one of the tables that doesn't accept a negative cost; if you type in -1, it'll just have the tech cost 1 (the lowest value it can handle). If you want to disable a tech, then you MUST use the <Disable> flag. On the bright side, this prevents all of the usual ways of gaining techs (research, Great Scientists, etc.).

But there is ONE loophole to watch out for: if you're planning to provide a mechanism where civs CAN gain the Disabled tech, then barbarians and city-states can gain it once at least one major empire has the tech. You see, barbarians and minor civs have a "steal" mechanism that has a chance of giving them any tech known by a major civ; this lets them keep up technologically in spite of having a 1-city empire (city-states) or NO cities (barbarians). Since this isn't a research process, it's not affected by the PlayerCanEverResearch GameEvent, as far as I know.

I'll give you an example. In my Ascension mod, which uses Alpha Centauri content to provide three new eras at the end of the tech tree, the key tech is Centauri Ecology. CE is a disabled tech, but is still visible on the tech tree. Once you complete the spaceship, instead of winning the game, it awards you a bunch of bonuses (with the winner of the space race getting larger bonuses than anyone who finishes later)... and the Centauri Ecology tech. After a certain number of turns, an event occurs and everyone else is given that tech. Since that tech is required for most of the future techs, it's pretty important to get it ASAP.
The problem is that as soon as one person finishes the spaceship and gets that tech, there's a chance that the Barbarians will gain it on following turns. I use that loophole to my advantage, but if you were trying to award a tech that you didn't want the barbarians to have, you won't be able to stop them.

Can they still be discovered accidentally, for instance, in Goody Huts?

Each tech explicitly says whether it can be gained from a goody hut; that's what the <GoodyTech> flag in the Technologies table is for. None of the late-era techs have that flag, so you shouldn't worry about that.

does it matter if some of the hidden techs are superimposed upon each other with x and y coordinates being the same

No, it doesn't matter. If you really wanted to you could stack every tech in the game in one pile; sure, it'd be hard for the player to pick what to research next, but the UI wouldn't care. In my own mod, I hid four disabled techs underneath the final tech in the tech tree; while I could have just moved them off the screen, it added a nice color to that final tech to make it stand out better.

It was mentioned that at least one tech should be maintained in each Era.

When building the tech tree, the game checks all techs within an era, and takes the minimum and maximum GridX values for techs in that era, then places the vertical era separators on the left side of the minimum GridX and the other on the right side of the maximum. So as long as you don't alter the GridX values for your hidden techs, all of those later eras will still be 3 columns wide. If you want to squash those down a bit to where all of the deleted Industrial techs are set to GridX = 9 and GridY = -10, then it'll maintain a 1-column empty box for the Industrial.

What should I do with future tech... can it be safely removed or hidden and made unresearchable.

If you'd asked this a year ago, the answer would have been that you'd need a repeatable tech at the end of your tech tree. But that's been fixed, so you can disable it just like any other tech. If someone runs out of techs, it'll just stop asking them what to research next.

I don't want spaceship parts accidentally made available to my medieval civ.

Since no spaceship parts unlock at Future Tech, that's not a problem. If you disable a tech, everything at that tech is effectively locked as well. Since you'll be disabling Satellites, Robotics, Nanotechnology, and Particle Physics, all four spaceship parts will be forever unavailable.

So if you still want to have Future Tech as a repeatable tech at the end of your tree, you'd just need to make it depend on the techs at the end of your tree. If you do this, then you'll need to lower its cost and move its GridX and Era to something closer to your other techs. Or just add a new tech to fill the same role.

how are these hidden techs reflected in the civilpedia?

As long as the tech is still in the database, it'll be listed under the appropriate era in the Civilopedia. If you want to change that, you'll need to do some modifications to the UI, and I would NOT recommend trying that if you're still trying to get the hang of XML modding, since a mistake there can REALLY break things.

But really, no one who uses your mod will care that the disabled techs are still in the Civilopedia. After all, they wouldn't be using a mod like this unless they already knew what it did...
 
... as it is, for instance, I've no idea where to look...
I agree with your overall assessment. However, this is not a good reason. I don't know where to look either. Download and learn to use a good text search program like Windows Grep. It will be useful in many other areas of modding (not just finding references).
 
Okay... I've finally got a working mod, more or less, that disconnects and hides all techs beyond Medieval except for future tech.

View attachment 322840

The only problem I have is that astronomy and banking fail to show up as prequisite techs for future_tech...

here is the section of code I suspect is causing problems...

Code:
<Technology_PrereqTechs>
		<Delete TechType="TECH_ACOUSTICS"/>
		<Delete TechType="TECH_PRINTING_PRESS"/>
		<Delete TechType="TECH_GUNPOWDER"/>
		<Delete TechType="TECH_NAVIGATION"/>
		<Delete TechType="TECH_ECONOMICS"/>
		<Delete TechType="TECH_FUTURE_TECH"/>
		<Update>
			<Set PrereqTech="TECH_ASTRONOMY"/>
			<Where TechType="TECH_FUTURE_TECH"/>
		</Update>
		<Update>
			<Set PrereqTech="TECH_BANKING"/>
			<Where TechType="TECH_FUTURE_TECH"/>
		</Update>
	</Technology_PrereqTechs>

It deletes FUTURE_TECH_FUTURE than updates it. I thought that the order of the code would allow me to do this, but it doesn't.

I think I need to go back to the guide to see how to add an entry instead of just using update...

but I see the light at the end of the tunnel.
 
It deletes FUTURE_TECH_FUTURE than updates it. I thought that the order of the code would allow me to do this, but it doesn't.

While you've realized your mistake by now (Update only modifies an existing entry, Row adds a new one, and since you deleted all the old entries there's nothing left to update), I should point out that depending on XML to execute in a specific order is, in general, a bad idea. The fact that Civ5 translates it all through SQL means that there's no real guarantee on what order it'll do things in, so you should write your code such that it never HAS to depend on the order. (This is expecially true if you're doing something like my mod, where it's actually a set of 4 separate mods that are intended to work together.)

For instance, instead of using a single Delete command for TECH_FUTURE_TECH's three prerequisites, you could instead delete them individually, a la
Code:
<Delete TechType="TECH_FUTURE_TECH" PrereqTech="TECH_GLOBALIZATION"/>
<Delete TechType="TECH_FUTURE_TECH" PrereqTech="TECH_NUCLEAR_FUSION"/>
<Delete TechType="TECH_FUTURE_TECH" PrereqTech="TECH_NANOTECHNOLOGY"/>
and then add on your two new Rows for Astronomy and Banking. That way, the order the commands are executed in wouldn't matter at all.

Remember, when you put two items in a Where, Set, or Delete command, it treats them as an implicit AND. That is,
<Delete TechType="TECH_FUTURE_TECH" PrereqTech="TECH_GLOBALIZATION"/>
means "Delete all entries that have both TechType equal to "TECH_FUTURE_TECH" and PrereqTech equal to "TECH_GLOBALIZATION"". Only one entry will meet both of those conditions, which lets you delete a single prerequisite for a tech without altering the others.
Likewise, using multiple items in a Where results in a more restrictive condition, letting you target an entry more exactly, so it's a good habit to get into when you're doing something other than these sweeping changes.

But for a Set, that AND effectively means the opposite: it lets you do two things on one Set, expanding instead of restricting. That is,
Code:
<Update>
    <Set GridX="10"/>
    <Where Type="TECHNOLOGY_BANKING"/>
</Update>
<Update>
    <Set GridY="3"/>
    <Where Type="TECHNOLOGY_BANKING"/>
</Update>

can be written in half the space as
Code:
<Update>
    <Set GridX="10" GridY="3"/>
    <Where Type="TECHNOLOGY_BANKING"/>
</Update>
which, besides saving space, is just a lot easier to read most of the time.
 
Back
Top Bottom