Mod Idea - Variable Tech Tree

arrataz

Chieftain
Joined
Jan 27, 2012
Messages
3
So, I was a big fan of Civ IV and did some minor tinkering and tried out various mods. Now I'm playing Civ V and doing the same. And through both, I realized that at some point, I was only pursuing the same strategies over and over and over again. And then I thought about the ultimate mod (for me) that would add many multiples of playtime for me. Instead of trying to tinker with the tech tree so that it's more realistic, or etc, and having a different vision of that from everyone else, how about a mod that does the following:

Generate the tech tree semi-randomly at the start of each game, right before/after map generation.

This means that every game would be different and require a different strategy. Personally, I think I'd use this most with the "Hide techs you can't research" option I listed at the bottom.

There are two ways of accomplishing this that I can think of:

* Scramble the prereqs for techs, but leave them in their relative tier positions and have each one do what it currently does. (This would already be more interesting than the current game, but less so than the one below.)

* Generate an entire tech tree from scratch each game. Each tech benefit (units, * benefits like irrigation or bridges, buildings, resource reveals, terrain improvements, wonders, etc) would be assigned to a tech in the appropriate era. The number of techs per era could be variable slightly to accommodate this. Each tech would have at least one benefit (maybe a min of 2?) and a maximum of 4 or 5 benefits. The techs would be semi-randomly assigned prereqs from earlier eras (possibly with the requirement that a tech granting a building or a unit has a prereq (or a chained prereq) of the tech which grants the required prereq building or the units that upgrade into it. For the AI's, each tech would be given the flavors depending on what made it up. The names could be random things like "Haberdashery" and "Civil Discourse". They don't have to have any relation to the things contained within (but they could be coded to as well. A tech with a domestic flavor in the modern age could be "Social Networking" and one in the ancient age could be "Public Debate" etc.)


Optional checkboxes (choose at game setup):
* Hide any techs that you can't currently research. (I think I 'd pick this one by default)
* Remove unique units/buildings
* Generic units (Just create a chain for each category: Warriors, Ranged, Siege, Scout, Light Ships, Heavy Ships, anti-maneuver warriors (pikemen, anti-tank gun, etc).)

Here are the possible complaints:

* The game makes no historical sense. You're not recreating history anymore. To which I say "who cares?" You weren't creating history before. No one has ever made a tech tree & unit set that everyone likes for historical accuracy.

* The game's balance would be.... off. It already is, depending on who you listen to. But each game's balance would be a little different.


Here are what I see as the pros:

* You get the option of not knowing how the game will play out. You get to recover that sense of "Exploration" when researching that you had that first time you played your first Civ game. Choices would be made based on "What do I need right now", like true emergency research and not "Where will I be in a hundred years".

* Every game will have an entirely unique flavor, even if you can look over the full tree at the start and plan a strategy, you won't fall into the rut of "Build X, research Y. After 7 turns, do Z." for each strategy.


I would love to see this mod made by someone with more time and modding skill than I have, either for Civ IV or Civ V (or both). I think it would create endless replayability for both games.

<Crosses Fingers>
 
It is possible to randomize table entries as PawelS does here for city names. However, in the case of tech prereqs you don't want it re-randomized each time the game is re-loaded. There may be some SQL trickery to prevent this, but I can't think of it at the moment. (You'll have to make yourself an SQLite expert to have any chance to implement this.)

I would love to see this mod made by someone with more time and modding skill than I have, either for Civ IV or Civ V (or both).

Won't happen. Sorry. We're all too busy with our own crazy ideas.
 
grate Idea, this would be my ultimat mod to. I love both the added veriety of gamesplay and the realisum of not knowing what the furutre will hold e.g. most medeval leaders were unsure wether the next technological brake though would be in making biger sords, advanced agriculture, turning stone to gold or training fairys.
I started work on a mod like this for civ4 which relyed on each added teck having a prerequisit teck given in global randon events while this sort of worked it was a messy and longwinded solution so I never got very far.
Good luck, and if it gets going I'd be happy to help though I'm limted to basic XML
 
Won't happen. Sorry. We're all too busy with our own crazy ideas.

Repeating this for emphasis.

It's very easy to come up with great ideas for how things should be, and a lot of people post on these boards with their latest brainstorm on how Civ5 could be improved. Figuring out exactly which ideas are possible with the current tools is a time-consuming process, given that we've got a very limited set of Lua hooks and XML schema to work with. Actually DOING those things is even more time-consuming, obviously. Everyone who can mod Civ5 has their own ideas that they're already doing, so no one's going to volunteer to implement your ideas instead.

If you find a mod that's already doing something similar to what you'd thought of, then feel free to make suggestions to that mod's creator. But if the idea is completely impossible (or at least horribly impractical) given the tools we've been given, then don't be surprised if you're basically ignored, and even if the idea IS practical to do, it's still that other person's decision.

The best thing you can do is try to learn how to make mods yourself, read up on the Lua functions we have, and try to come up with a preliminary version yourself. Once you've got something fairly complete, ask for help on these boards and someone might be able to point you in the right direction to help you finish your own mod. It's a lot easier to answer a "how do I use function X?" question than a "hey, wouldn't this be great?" one.
 
In that spirit.....

How would I get my mod to run a function only on initial game start (and not on mod load)?
How would I save arbitrary xml to the save game to make sure the tree remains the same through save/reload of the game?

Writing the code to generate the tree is straightforward (if tedious). I have no problem with the internal algorithm. I have no idea how to trigger it in the required way, since "OnModLoad" would fail utterly to do what is desired.
 
How would I get my mod to run a function only on initial game start (and not on mod load)?

The easiest way is to simply compare the current turn number to the turn number the game started on. Technically you could start a game, save it immediately, and then re-load the save to get it to execute twice, but that sort of abuse is pretty pointless and it's unlikely to come up by accident.

Syntax is
Code:
function MyStartGame()
  if( Game:GetGameTurn() == Game:GetStartTurn() ) then
  end
end
Events.SequenceGameInitComplete.Add( MyStartGame );

As for the saving, there are a few ways to do this. SaveUtils is a bit older but is still used for most mods, but there are a few newer components. Go look in the mod components forum to see the options.
 
Using the turn comparison had occured to me, and it is a useful idea. Unfortunately, it does mean that "Retry my game" is out of the question.

Yeah, it's abusive, but when I realize I've bolloxed up a game, sometimes I start from the initial autosave again just to see if I can do it better. In Civ V, I'm an Immortal Time Lord guiding a single civilization from infancy to ascendancy; We take our advantage where we can get them. :p


In the end, if I can't figure out a different way, I'll go with that and start doing "Restart from 1" when I feel like trying again.

I'll have to check out the SaveUtils.

Thanks for the constructive response!
 
I use something like that in my main lua file :

near the beginning :

Code:
local bWaitBeforeInitialize = true

and at the end, after all the includes, defines, etc...

Code:
if ( bWaitBeforeInitialize ) then
	bWaitBeforeInitialize = false	
	local savedData = Modding.OpenSaveData()
	local iValue = savedData.GetValue("InitDone")
	if (iValue ~= 1) then	
		-- place what you want done only once when starting a new game here...

		savedData.SetValue("InitDone", 1)
	else

		-- place what you want done when loading a save game here...

	end
end
 
I use something like that in my main lua file :

Right. There are a couple ways to add a lock to ensure that something doesn't execute twice, beyond the turn check I'd mentioned above; what Gedemon showed is the "soft" way, which uses the SaveData structures to create a lock variable in the save file's database. It's very flexible, since you have total control over the variables involved, and as long as you're a decent programmer you can get some impressively complex logic to control all possible outcomes. The "hard" way is to create something tangible in the game (a Building, a Project, a Promotion, etc.) and create an instance of it during any initialization to ensure that something doesn't execute twice.

For instance, take unit creation. You want to do something whenever a unit is first created, so you think to use SerialEventUnitCreated. Which is fine, because it DOES trigger whenever a unit is created, even for AIs you've never met. Unfortunately, that particular Event also triggers whenever a unit embarks, disembarks, rebases, etc., so now you need some way to make sure it doesn't trigger twice for the same unit. You could use a SaveData method to add a flag to each unit, but let's say you wanted to try the other way.
So you create PROMOTION_ROOKIE. It might do nothing as a promotion (or, in the case of my mod, has a -10% combat penalty but makes your first combat give twice the normal XP). You have your custom OnUnitCreated function using the aforementioned serial event, but you add another bit of logic: if the unit's creation date (automatically stored by the game in the Units structure) doesn't match the current turn, OR the unit already has the Rookie promotion, then you do nothing. Only if it's the unit's birth turn AND it doesn't have Rookie do you do your custom logic, and in there, you give the unit the Rookie promotion in addition to whatever else you wanted to do when units are spawned. Then, at some later point (like after the unit's first combat, or at the start of the next turn), you simply remove the Rookie promotion.

There, you've created a system where it's impossible for the code to execute twice, using only those things the game already stores perfectly in every savegame file. Methods that rely strictly on the memory structures are a lot less dependable when mods are involved, because a lot of things can cause the memory addresses to become somewhat corrupted, especially when you're altering your own mods on a regular basis and the cache isn't cleared each time. I've seen it happen way too often. So whenever it's practical, I'd say you should stick with the methods involving some in-game element that can be controlled purely through XML and very simple Lua. This is often quite a bit more work, but tends to be much more stable. In my own Mythology mod, for instance, I created a hidden Project for each pantheon, and on the first turn each player is given one copy of the appropriate one; then, if I ever want to find out which pantheon each player is following, it's a very quick check requiring no memory access functions.
 
Back
Top Bottom